diff options
author | Devaev Maxim <[email protected]> | 2020-10-30 15:07:36 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-11-11 22:24:25 +0300 |
commit | a3707d047fddd5f0c923422468be29ddb345f989 (patch) | |
tree | 6462faafb0308704af4df5788bca4a3bd3b7f304 /hid | |
parent | 578a290cc2b1c22718f56e5e4d3dc8885677b445 (diff) |
refactoring
Diffstat (limited to 'hid')
-rw-r--r-- | hid/src/main.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/hid/src/main.cpp b/hid/src/main.cpp index 29982c8d..b4960cb5 100644 --- a/hid/src/main.cpp +++ b/hid/src/main.cpp @@ -104,13 +104,17 @@ INLINE uint8_t cmdMouseButtonEvent(const uint8_t *buffer) { // 2 bytes uint8_t main_state = buffer[0]; uint8_t extra_state = buffer[1]; +# define MOUSE_PAIR(_state, _button) \ + _state & PROTO_CMD_MOUSE_BUTTON_##_button##_SELECT, \ + _state & PROTO_CMD_MOUSE_BUTTON_##_button##_STATE hid_mouse.sendMouseButtons( - 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 + MOUSE_PAIR(main_state, LEFT), + MOUSE_PAIR(main_state, RIGHT), + MOUSE_PAIR(main_state, MIDDLE), + MOUSE_PAIR(extra_state, EXTRA_UP), + MOUSE_PAIR(extra_state, EXTRA_DOWN) ); +# undef MOUSE_PAIR # endif return PROTO_RESP_OK; } |