From: Drew Fisher Date: Tue, 25 Oct 2011 05:42:01 +0000 (-0700) Subject: Make OSX actually find the mouse. X-Git-Url: https://git.zarvox.org/shortlog/month?a=commitdiff_plain;h=7dfb575e690c4e77a88320b13b62ab98b7d3019b;p=libtouchmouse.git Make OSX actually find the mouse. 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 --- diff --git a/touchmouse.c b/touchmouse.c index 9b22851..081ccc8 100644 --- a/touchmouse.c +++ b/touchmouse.c @@ -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; }