diff options
author | Devaev Maxim <[email protected]> | 2020-08-18 10:45:15 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-08-18 10:45:15 +0300 |
commit | 28cc3fe99a3e90213f1f01286b5ec55f4f06224c (patch) | |
tree | be3751fb65bc53f2bcf9158e155eebe27208abe6 /hid | |
parent | 6840c514dc4b1996719787878bbf9d60b402f760 (diff) |
mouse buttons 4 and 5
Diffstat (limited to 'hid')
-rw-r--r-- | hid/src/main.cpp | 18 | ||||
-rw-r--r-- | hid/src/usb/hid.h | 6 |
2 files changed, 18 insertions, 6 deletions
diff --git a/hid/src/main.cpp b/hid/src/main.cpp index 08ec3f65..cd3c245a 100644 --- a/hid/src/main.cpp +++ b/hid/src/main.cpp @@ -66,6 +66,11 @@ #define PROTO_CMD_MOUSE_BUTTON_MIDDLE_SELECT 0b00100000 #define PROTO_CMD_MOUSE_BUTTON_MIDDLE_STATE 0b00000010 +#define PROTO_CMD_MOUSE_BUTTON_EXTRA_UP_SELECT 0b10000000 +#define PROTO_CMD_MOUSE_BUTTON_EXTRA_UP_STATE 0b00001000 +#define PROTO_CMD_MOUSE_BUTTON_EXTRA_DOWN_SELECT 0b01000000 +#define PROTO_CMD_MOUSE_BUTTON_EXTRA_DOWN_STATE 0b00000100 + // ----------------------------------------------------------------------------- #ifdef HID_USB_KBD @@ -94,14 +99,17 @@ INLINE uint8_t cmdKeyEvent(const uint8_t *buffer) { // 2 bytes return PROTO_RESP_OK; } -INLINE uint8_t cmdMouseButtonEvent(const uint8_t *buffer) { // 1 byte +INLINE uint8_t cmdMouseButtonEvent(const uint8_t *buffer) { // 2 bytes # ifdef HID_USB_MOUSE - uint8_t state = buffer[0]; + uint8_t main_state = buffer[0]; + uint8_t extra_state = buffer[1]; hid_mouse.sendMouseButtons( - state & PROTO_CMD_MOUSE_BUTTON_LEFT_SELECT, state & PROTO_CMD_MOUSE_BUTTON_LEFT_STATE, - state & PROTO_CMD_MOUSE_BUTTON_RIGHT_SELECT, state & PROTO_CMD_MOUSE_BUTTON_RIGHT_STATE, - state & PROTO_CMD_MOUSE_BUTTON_MIDDLE_SELECT, state & PROTO_CMD_MOUSE_BUTTON_MIDDLE_STATE + main_state & PROTO_CMD_MOUSE_BUTTON_LEFT_SELECT, main_state & PROTO_CMD_MOUSE_BUTTON_LEFT_STATE, + main_state & PROTO_CMD_MOUSE_BUTTON_RIGHT_SELECT, main_state & PROTO_CMD_MOUSE_BUTTON_RIGHT_STATE, + main_state & PROTO_CMD_MOUSE_BUTTON_MIDDLE_SELECT, main_state & PROTO_CMD_MOUSE_BUTTON_MIDDLE_STATE, + extra_state & PROTO_CMD_MOUSE_BUTTON_EXTRA_UP_SELECT, extra_state & PROTO_CMD_MOUSE_BUTTON_EXTRA_UP_STATE, + extra_state & PROTO_CMD_MOUSE_BUTTON_EXTRA_DOWN_SELECT, extra_state & PROTO_CMD_MOUSE_BUTTON_EXTRA_DOWN_STATE ); # endif return PROTO_RESP_OK; diff --git a/hid/src/usb/hid.h b/hid/src/usb/hid.h index 48e99d28..b4523a6b 100644 --- a/hid/src/usb/hid.h +++ b/hid/src/usb/hid.h @@ -76,11 +76,15 @@ class UsbHidMouse { INLINE void sendMouseButtons( bool left_select, bool left_state, bool right_select, bool right_state, - bool middle_select, bool middle_state + bool middle_select, bool middle_state, + bool up_select, bool up_state, + bool down_select, bool down_state ) { if (left_select) _sendMouseButton(MOUSE_LEFT, left_state); if (right_select) _sendMouseButton(MOUSE_RIGHT, right_state); if (middle_select) _sendMouseButton(MOUSE_MIDDLE, middle_state); + if (up_select) _sendMouseButton(MOUSE_PREV, up_state); + if (down_select) _sendMouseButton(MOUSE_NEXT, down_state); } INLINE void sendMouseMove(int x, int y) { |