parent
b5d79ed77a
commit
10d037819e
@ -0,0 +1,28 @@ |
||||
#include <libusb.h> |
||||
#include <stdio.h> |
||||
#include <stdlib.h> |
||||
|
||||
void usb_init() |
||||
{ |
||||
// List all usb devices obtaining 'vendor:product'
|
||||
// Call corresponding driver if it exists, so
|
||||
// that we get a peripheral handle
|
||||
if(libusb_init(NULL)) |
||||
{ |
||||
fprintf(stderr, "Error: Could not initialize libusb\n"); |
||||
return; |
||||
} |
||||
|
||||
libusb_device** list; |
||||
ssize_t device_count = libusb_get_device_list(NULL, &list); |
||||
if(device_count <= 0) return; |
||||
|
||||
for(ssize_t i = 0; i < device_count; i++) |
||||
{ |
||||
libusb_device* current = list[i]; |
||||
struct libusb_device_descriptor desc; |
||||
libusb_get_device_descriptor(current, &desc); |
||||
|
||||
printf("Found usb device %04x:%04x\n", desc.idVendor, desc.idProduct); |
||||
} |
||||
} |
@ -0,0 +1,6 @@ |
||||
#ifndef USB_H |
||||
#define USB_H |
||||
|
||||
void usb_init(); |
||||
|
||||
#endif |
@ -1,7 +1,10 @@ |
||||
#include "ui/ginput-application.h" |
||||
#include "device/usb/usb.h" |
||||
|
||||
int main(gint argc, gchar** argv) |
||||
{ |
||||
usb_init(); |
||||
|
||||
AdwApplication* application = ginput_application_new(); |
||||
return g_application_run(G_APPLICATION(application), argc, argv); |
||||
} |
||||
|
Loading…
Reference in new issue