Skip to content

Commit

Permalink
Add PS2_MOUSE_ROTATE to compensate for device orientation (qmk#8650)
Browse files Browse the repository at this point in the history
* Add PS2_MOUSE_ROTATE to compensate for device orientation

* fixup! Add PS2_MOUSE_ROTATE to compensate for device orientation

* Reformat with IndentPPDirectives: AfterHash as per qmk#6316
  • Loading branch information
manna-harbour authored and drashna committed May 24, 2020
1 parent 9c0bfc9 commit a001fe7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tmk_core/protocol/ps2_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,21 @@ static inline void ps2_mouse_convert_report_to_hid(report_mouse_t *mouse_report)
// invert coordinate of y to conform to USB HID mouse
mouse_report->y = -mouse_report->y;
#endif

#ifdef PS2_MOUSE_ROTATE
int8_t x = mouse_report->x;
int8_t y = mouse_report->y;
# if PS2_MOUSE_ROTATE == 90
mouse_report->x = y;
mouse_report->y = -x;
# elif PS2_MOUSE_ROTATE == 180
mouse_report->x = -x;
mouse_report->y = -y;
# elif PS2_MOUSE_ROTATE == 270
mouse_report->x = -y;
mouse_report->y = x;
# endif
#endif
}

static inline void ps2_mouse_clear_report(report_mouse_t *mouse_report) {
Expand Down

0 comments on commit a001fe7

Please sign in to comment.