Add non blocking connect support for hiddevice
Fork of USBDevice by
Revision 57:73cb8326e149, committed 2015-06-12
- Comitter:
- jaerts
- Date:
- Fri Jun 12 20:52:45 2015 +0000
- Parent:
- 56:151ba33713ff
- Commit message:
- Add support for non-blocking connect on HID device
Changed in this revision
USBHID/USBMouseKeyboard.cpp | Show annotated file Show diff for this revision Revisions of this file |
USBHID/USBMouseKeyboard.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/USBHID/USBMouseKeyboard.cpp Mon Jun 08 08:15:25 2015 +0100 +++ b/USBHID/USBMouseKeyboard.cpp Fri Jun 12 20:52:45 2015 +0000 @@ -566,6 +566,15 @@ return lock_status; } +bool USBMouseKeyboard::connect(MOUSE_TYPE mouse_type, bool blocking) { + this->mouse_type = mouse_type; + this->lock_status = 0; + this->button = 0; + USBHID::connect(blocking); + return true; +} + + bool USBMouseKeyboard::update(int16_t x, int16_t y, uint8_t button, int8_t z) { switch (mouse_type) { case REL_MOUSE:
--- a/USBHID/USBMouseKeyboard.h Mon Jun 08 08:15:25 2015 +0100 +++ b/USBHID/USBMouseKeyboard.h Fri Jun 12 20:52:45 2015 +0000 @@ -87,9 +87,17 @@ lock_status = 0; button = 0; this->mouse_type = mouse_type; - connect(); + //connect(); }; + /* + * Connect a device + * + * @param blocking: block if not configured + * @param mouse_type Mouse type: ABS_MOUSE (absolute mouse) or REL_MOUSE (relative mouse) (default: REL_MOUSE) + */ + bool connect(MOUSE_TYPE mouse_type = REL_MOUSE, bool blocking = true); + /** * Write a state of the mouse *