Skip to content

Commit

Permalink
Fix PS2_MOUSE_INVERT_BUTTONS (qmk#20646)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkao authored and csolje committed Oct 21, 2023
1 parent 64f1eda commit 0a2774c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions drivers/ps2/ps2_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0a2774c

Please sign in to comment.