summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDaniel Kao <daniel.m.kao@gmail.com>2023-07-07 04:34:44 -0700
committerGitHub <noreply@github.com>2023-07-07 21:34:44 +1000
commite43080788ea707e53a96e5300d4766749302b364 (patch)
tree4d6ac3262200730cbc4e5734e532587a8fba5ad8 /drivers
parent30de598650f368e215ad5f82c7b9de52eceb539e (diff)
Fix PS2_MOUSE_INVERT_BUTTONS (#20646)
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ps2/ps2_mouse.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/ps2/ps2_mouse.c b/drivers/ps2/ps2_mouse.c
index d6911d66f2..ae594c94bc 100644
--- a/drivers/ps2/ps2_mouse.c
+++ b/drivers/ps2/ps2_mouse.c
@@ -191,13 +191,12 @@ static inline void ps2_mouse_convert_report_to_hid(report_mouse_t *mouse_report)
#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
+ bool needs_left = mouse_report->buttons & (1 << PS2_MOUSE_BTN_RIGHT);
+ bool needs_right = mouse_report->buttons & (1 << PS2_MOUSE_BTN_LEFT);
+ mouse_report->buttons = (mouse_report->buttons & ~((1 << PS2_MOUSE_BTN_LEFT) | (1 << PS2_MOUSE_BTN_RIGHT))) | (needs_left << PS2_MOUSE_BTN_LEFT) | (needs_right << PS2_MOUSE_BTN_RIGHT);
+#endif
// remove sign and overflow flags
mouse_report->buttons &= PS2_MOUSE_BTN_MASK;
-#endif
#ifdef PS2_MOUSE_INVERT_X
mouse_report->x = -mouse_report->x;