| 1 | #include "libusb.h" |
|---|
| 2 | #include <stdio.h> |
|---|
| 3 | |
|---|
| 4 | #define RNBO_USB_VENDOR_ID 0x04b9 |
|---|
| 5 | #define USB_SPRO_PROD_ID 0x300 |
|---|
| 6 | #define MAX_USB_PROD_ID 0x3ff |
|---|
| 7 | |
|---|
| 8 | #define SHK_PROD_ID 0x8000 //Sentinel Hardware Key |
|---|
| 9 | #define SHK_T_PROD_ID 0x8001 //Sentinel Hardware Key/T |
|---|
| 10 | #define SHK_M_PROD_ID 0x8002 //Sentinel Hardware Key/M |
|---|
| 11 | #define SHK_MT_PROD_ID 0x8003 //Sentinel Hardware Key/MT |
|---|
| 12 | #define SDHK_M_PROD_ID 0x8004 //Sentinel Dual Hardware Key |
|---|
| 13 | #define SDHK_MT_PROD_ID 0x8005 //Sentinel Dual Hardware Key/T |
|---|
| 14 | |
|---|
| 15 | /*****************************************************************************/ |
|---|
| 16 | int probe_devices() |
|---|
| 17 | { |
|---|
| 18 | |
|---|
| 19 | libusb_device **devs; |
|---|
| 20 | int iRetVal; |
|---|
| 21 | ssize_t cnt; |
|---|
| 22 | |
|---|
| 23 | int count = 0; |
|---|
| 24 | int i = 0 ; |
|---|
| 25 | |
|---|
| 26 | iRetVal = libusb_init(NULL); |
|---|
| 27 | if (iRetVal != 0) |
|---|
| 28 | { |
|---|
| 29 | return iRetVal; |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | cnt = libusb_get_device_list(NULL, &devs); |
|---|
| 33 | if (cnt < 0) |
|---|
| 34 | { |
|---|
| 35 | return (int) cnt; // return -1 incase of any error |
|---|
| 36 | } |
|---|
| 37 | else |
|---|
| 38 | { |
|---|
| 39 | libusb_device *dev; |
|---|
| 40 | while ((dev = devs[i++]) != NULL) |
|---|
| 41 | { |
|---|
| 42 | struct libusb_device_descriptor desc; |
|---|
| 43 | int r = libusb_get_device_descriptor(dev, &desc); |
|---|
| 44 | if (r < 0) |
|---|
| 45 | { |
|---|
| 46 | printf("failed to get device descriptor"); |
|---|
| 47 | libusb_free_device_list(devs, 0); |
|---|
| 48 | return r; |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | #if !defined(_SHK_LINUX_) |
|---|
| 52 | if((desc.idVendor== RNBO_USB_VENDOR_ID ) && |
|---|
| 53 | (desc.idProduct== USB_SPRO_PROD_ID)) |
|---|
| 54 | #else |
|---|
| 55 | |
|---|
| 56 | if((desc.idVendor== RNBO_USB_VENDOR_ID) && |
|---|
| 57 | ((desc.idProduct == USB_SPRO_PROD_ID) || |
|---|
| 58 | (desc.idProduct == SHK_PROD_ID) || |
|---|
| 59 | (desc.idProduct == SHK_T_PROD_ID) || |
|---|
| 60 | (desc.idProduct == SHK_M_PROD_ID) || |
|---|
| 61 | (desc.idProduct == SHK_MT_PROD_ID) || |
|---|
| 62 | (desc.idProduct == SDHK_M_PROD_ID) || |
|---|
| 63 | (desc.idProduct == SDHK_MT_PROD_ID))) |
|---|
| 64 | #endif |
|---|
| 65 | |
|---|
| 66 | { |
|---|
| 67 | //arr[count] = libusb_ref_device(dev); |
|---|
| 68 | count ++; |
|---|
| 69 | } |
|---|
| 70 | printf("\n%04x:%04x (bus %d, device %d) BY NAVDEEP \n", |
|---|
| 71 | desc.idVendor, desc.idProduct, |
|---|
| 72 | libusb_get_bus_number(dev), libusb_get_device_address(dev)); |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | libusb_free_device_list(devs, 0); |
|---|
| 76 | } /*end of else */ |
|---|
| 77 | return count; |
|---|
| 78 | |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | int main() |
|---|
| 82 | { |
|---|
| 83 | probe_devices(); |
|---|
| 84 | |
|---|
| 85 | return 0; |
|---|
| 86 | } |
|---|