2018.07.26
Dependencies: FATFileSystem2 mbed-rtos
Fork of USBHost by
Diff: USBHostHID/USBHostMouse.h
- Revision:
- 5:e48791a1ef18
- Parent:
- 4:b320d68e98e7
- Child:
- 8:93da8ea2708b
--- a/USBHostHID/USBHostMouse.h Tue Mar 12 17:23:37 2013 +0000 +++ b/USBHostHID/USBHostMouse.h Wed Mar 13 10:23:01 2013 +0000 @@ -55,11 +55,55 @@ * * @param ptr function pointer */ - inline void attach(void (*ptr)(uint8_t buttons, int8_t x, int8_t y, int8_t z)) { + inline void attachEvent(void (*ptr)(uint8_t buttons, int8_t x, int8_t y, int8_t z)) { if (ptr != NULL) { onUpdate = ptr; } } + + /** + * Attach a callback called when the button state changes + * + * @param ptr function pointer + */ + inline void attachButtonEvent(void (*ptr)(uint8_t buttons)) { + if (ptr != NULL) { + onButtonUpdate = ptr; + } + } + + /** + * Attach a callback called when the X axis value changes + * + * @param ptr function pointer + */ + inline void attachXEvent(void (*ptr)(int8_t x)) { + if (ptr != NULL) { + onXUpdate = ptr; + } + } + + /** + * Attach a callback called when the Y axis value changes + * + * @param ptr function pointer + */ + inline void attachYEvent(void (*ptr)(int8_t y)) { + if (ptr != NULL) { + onYUpdate = ptr; + } + } + + /** + * Attach a callback called when the Z axis value changes (scrolling) + * + * @param ptr function pointer + */ + inline void attachZEvent(void (*ptr)(int8_t z)) { + if (ptr != NULL) { + onZUpdate = ptr; + } + } protected: //From IUSBEnumerator @@ -77,8 +121,17 @@ bool mouse_device_found; int mouse_intf; + uint8_t buttons; + int8_t x; + int8_t y; + int8_t z; + void rxHandler(); void (*onUpdate)(uint8_t buttons, int8_t x, int8_t y, int8_t z); + void (*onButtonUpdate)(uint8_t buttons); + void (*onXUpdate)(int8_t x); + void (*onYUpdate)(int8_t y); + void (*onZUpdate)(int8_t z); int report_id; void init(); };