Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PS2_MOUSE_ROTATE to compensate for device orientation #8650

Merged
merged 3 commits into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/feature_ps2_mouse.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,15 @@ To reverse the scroll axes you can put:

into config.h.

### Rotate Mouse Axes :id=rotate-mouse-axes

Rotate the X and Y axes by 90, 180, or 270 degrees to compensate for device
orientation:

```c
#define PS2_MOUSE_ROTATE 270 /* trackpoint module rotated clockwise 90 degrees */
```

### Debug Settings :id=debug-settings

To debug the mouse, add `debug_mouse = true` or enable via bootmagic.
Expand Down
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
manna-harbour marked this conversation as resolved.
Show resolved Hide resolved
#endif
}

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