]> git.zarvox.org Git - libtouchmouse.git/commitdiff
Make OSX actually find the mouse.
authorDrew Fisher <drew.m.fisher@gmail.com>
Tue, 25 Oct 2011 05:42:01 +0000 (22:42 -0700)
committerDrew Fisher <drew.m.fisher@gmail.com>
Tue, 25 Oct 2011 05:42:01 +0000 (22:42 -0700)
HIDAPI on OSX always returns -1 as the interface_number for all devices,
so we use usage_page and usage to pick the right device.

Signed-off-by: Drew Fisher <drew.m.fisher@gmail.com>
touchmouse.c

index 9b2285108432d76c87027f6168e752e79557db38..081ccc8d119740c22314959c833e604f1c6e557e 100644 (file)
@@ -250,7 +250,26 @@ int main(void) {
        devs = hid_enumerate(0x045e, 0x0773); // 0x045e = Microsoft, 0x0773 = TouchMouse
        cur_dev = devs;
        while(cur_dev) {
-               if (cur_dev->vendor_id == 0x045e && cur_dev->product_id == 0x0773 && cur_dev->interface_number == 2) {
+               printf("Examining device: %s\n", cur_dev->path);
+               printf("\tVendor  ID: %04x\n", cur_dev->vendor_id);
+               printf("\tProduct ID: %04x\n", cur_dev->product_id);
+               printf("\tSerial num: %ls\n", cur_dev->serial_number);
+               printf("\tRelease #:  %d\n", cur_dev->release_number);
+               printf("\tManuf. Str: %ls\n", cur_dev->manufacturer_string);
+               printf("\tProd.  Str: %ls\n", cur_dev->product_string);
+               printf("\tUsage Page: %02x\n", cur_dev->usage_page);
+               printf("\tUsage     : %02x\n", cur_dev->usage);
+               printf("\tInterface:  %d\n", cur_dev->interface_number);
+#ifdef __APPLE__
+               // This method of detection should work on both OSX and Windows.
+               if (cur_dev->usage_page == 0x0c && cur_dev->usage == 0x01)
+#else
+               // This method of detection should work on Linux and Windows.
+               // Pity there's no single way to uniquely ID the device.
+               if (cur_dev->interface_number == 2)
+#endif
+               {
+                       printf("Found TouchMouse: %s\n", cur_dev->path);
                        path = cur_dev->path;
                        break;
                }