diff options
author | Juan Pablo Kutianski <jkutianski@gmail.com> | 2021-08-05 16:09:58 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-06 09:09:58 +1000 |
commit | 07553b41f0a03ca6549c09cecf9cd3dec7332346 (patch) | |
tree | be0ca6ca56fa83e8c97fa7fb0d367e8694be22f9 /tmk_core/protocol | |
parent | 339675693bd92ba4977d89d1aa3fd9750783327e (diff) |
[Feature] Swap buttons on PS2 Mouse/Trackball (#9205)
* [Feature Request] Swap buttons on PS2 Mouse/Trackball
* [Feature Request] Swap buttons on PS2 Mouse/Trackball
* Added id: to the doc
* Missing space
* Solve comment
https://github.com/qmk/qmk_firmware/pull/9205#discussion_r430783182
* Solve comments https://github.com/qmk/qmk_firmware/pull/9205#discussion_r430783182 & https://github.com/qmk/qmk_firmware/pull/9205#discussion_r430783884
* Format code more according to https://docs.qmk.fm/#/coding_conventions_c
* change logic to LUT
* WIP: Clean up
* WIP: Solution with xor operators to mask the change
* delete #endif & added the missed xor operator (ahhh)
* Variable (mouse_report->buttons): avoid setting twice https://github.com/qmk/qmk_firmware/pull/9205#discussion_r430783884
* Update tmk_core/protocol/ps2_mouse.c
Co-authored-by: Nick Brassel <nick@tzarc.org>
Co-authored-by: juank <juank@fktech.net>
Co-authored-by: Nick Brassel <nick@tzarc.org>
Diffstat (limited to 'tmk_core/protocol')
-rw-r--r-- | tmk_core/protocol/ps2_mouse.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tmk_core/protocol/ps2_mouse.c b/tmk_core/protocol/ps2_mouse.c index 525aeb45a0..39251a6434 100644 --- a/tmk_core/protocol/ps2_mouse.c +++ b/tmk_core/protocol/ps2_mouse.c @@ -156,8 +156,15 @@ static inline void ps2_mouse_convert_report_to_hid(report_mouse_t *mouse_report) mouse_report->x = X_IS_NEG ? ((!X_IS_OVF && -127 <= mouse_report->x && mouse_report->x <= -1) ? mouse_report->x : -127) : ((!X_IS_OVF && 0 <= mouse_report->x && mouse_report->x <= 127) ? mouse_report->x : 127); mouse_report->y = Y_IS_NEG ? ((!Y_IS_OVF && -127 <= mouse_report->y && mouse_report->y <= -1) ? mouse_report->y : -127) : ((!Y_IS_OVF && 0 <= mouse_report->y && mouse_report->y <= 127) ? mouse_report->y : 127); +#ifdef PS2_MOUSE_INVERT_BUTTONS + // swap left & right buttons + uint8_t needs_left = mouse_report->buttons & PS2_MOUSE_BTN_RIGHT; + uint8_t needs_right = mouse_report->buttons & PS2_MOUSE_BTN_LEFT; + mouse_report->buttons = (mouse_report->buttons & ~(PS2_MOUSE_BTN_MASK)) | (needs_left ? PS2_MOUSE_BTN_LEFT : 0) | (needs_right ? PS2_MOUSE_BTN_RIGHT : 0); +#else // remove sign and overflow flags mouse_report->buttons &= PS2_MOUSE_BTN_MASK; +#endif #ifdef PS2_MOUSE_INVERT_X mouse_report->x = -mouse_report->x; |