Fork to support Mouse boot protocol and steam controllers.
Fork of USBHOST by
Diff: USBHostHID/USBHostMouse.cpp
- Revision:
- 8:e57ccb876952
- Parent:
- 7:cc595e523032
- Child:
- 11:ba29414a455e
--- a/USBHostHID/USBHostMouse.cpp Thu Aug 17 22:08:04 2017 +0000 +++ b/USBHostHID/USBHostMouse.cpp Sat Aug 19 19:47:53 2017 +0000 @@ -96,7 +96,7 @@ void USBHostMouse::rxHandler() { int len_listen = int_in->getLengthTransferred(); int buttons_t, x_t, y_t, z_t; -/* { + /*{ int index; for (index=0;index < len_listen; index++) { @@ -111,9 +111,13 @@ if (dev->getVid() == 0x62a && dev->getPid() == 0x4101) { buttons_t = report[1] & 0x07; - x_t = report[2]; - y_t = report[3] >> 4; - z_t = report[4]; + x_t = (((int)report[3] & 0xf) << 8) + (report[2]); + y_t = (report[3] >> 4) + ((int)report[4] << 4); + + if (y_t & 0x800) y_t |= 0xf000; // Fix 4 highest bits of negative nos. + if (x_t & 0x800) x_t |= 0xf000; + + z_t = report[5]; } else { @@ -125,22 +129,22 @@ if (len_listen !=0) { if (onUpdate) { - (*onUpdate)(buttons_t & 0x07, x_t, y_t, z_t); + (*onUpdate)(buttons_t, x_t, y_t, z_t); } - if (onButtonUpdate && (buttons != (report[0] & 0x07))) { - (*onButtonUpdate)(report[0] & 0x07); + if (onButtonUpdate && (buttons != (buttons_t))) { + (*onButtonUpdate)(buttons_t); } - if (onXUpdate && (x != report[1])) { + if (onXUpdate && (x != x_t)) { (*onXUpdate)(x_t); } - if (onYUpdate && (y != report[2])) { + if (onYUpdate && (y != y_t)) { (*onYUpdate)(y_t); } - if (onZUpdate && (z != report[3])) { + if (onZUpdate && (z != z_t)) { (*onZUpdate)(z_t); }