aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/feature_ps2_mouse.md20
-rw-r--r--tmk_core/protocol/ps2_mouse.c12
2 files changed, 32 insertions, 0 deletions
diff --git a/docs/feature_ps2_mouse.md b/docs/feature_ps2_mouse.md
index 8629b28cf..dac3a5b36 100644
--- a/docs/feature_ps2_mouse.md
+++ b/docs/feature_ps2_mouse.md
@@ -227,6 +227,26 @@ Fine control over the scrolling is supported with the following defines:
227#define PS2_MOUSE_SCROLL_DIVISOR_V 2 227#define PS2_MOUSE_SCROLL_DIVISOR_V 2
228``` 228```
229 229
230#### Invert mouse and scroll axes
231
232To invert the X and Y axes you can put:
233
234```
235#define PS2_MOUSE_INVERT_X
236#define PS2_MOUSE_INVERT_Y
237```
238
239into config.h.
240
241To reverse the scroll axes you can put:
242
243```
244#define PS2_MOUSE_INVERT_H
245#define PS2_MOUSE_INVERT_V
246```
247
248into config.h.
249
230#### Debug settings 250#### Debug settings
231 251
232To debug the mouse, add `debug_mouse = true` or enable via bootmagic. 252To debug the mouse, add `debug_mouse = true` or enable via bootmagic.
diff --git a/tmk_core/protocol/ps2_mouse.c b/tmk_core/protocol/ps2_mouse.c
index 4ed3cae1f..cf1055eb8 100644
--- a/tmk_core/protocol/ps2_mouse.c
+++ b/tmk_core/protocol/ps2_mouse.c
@@ -169,8 +169,14 @@ static inline void ps2_mouse_convert_report_to_hid(report_mouse_t *mouse_report)
169 // remove sign and overflow flags 169 // remove sign and overflow flags
170 mouse_report->buttons &= PS2_MOUSE_BTN_MASK; 170 mouse_report->buttons &= PS2_MOUSE_BTN_MASK;
171 171
172#ifdef PS2_MOUSE_INVERT_X
173 mouse_report->x = -mouse_report->x;
174#endif
175#ifndef PS2_MOUSE_INVERT_Y // NOTE if not!
172 // invert coordinate of y to conform to USB HID mouse 176 // invert coordinate of y to conform to USB HID mouse
173 mouse_report->y = -mouse_report->y; 177 mouse_report->y = -mouse_report->y;
178#endif
179
174} 180}
175 181
176static inline void ps2_mouse_clear_report(report_mouse_t *mouse_report) { 182static inline void ps2_mouse_clear_report(report_mouse_t *mouse_report) {
@@ -227,6 +233,12 @@ static inline void ps2_mouse_scroll_button_task(report_mouse_t *mouse_report) {
227 mouse_report->h = mouse_report->x/(PS2_MOUSE_SCROLL_DIVISOR_H); 233 mouse_report->h = mouse_report->x/(PS2_MOUSE_SCROLL_DIVISOR_H);
228 mouse_report->x = 0; 234 mouse_report->x = 0;
229 mouse_report->y = 0; 235 mouse_report->y = 0;
236#ifdef PS2_MOUSE_INVERT_H
237 mouse_report->h = -mouse_report->h;
238#endif
239#ifdef PS2_MOUSE_INVERT_V
240 mouse_report->v = -mouse_report->v;
241#endif
230 } 242 }
231 } else if (0 == (PS2_MOUSE_SCROLL_BTN_MASK & mouse_report->buttons)) { 243 } else if (0 == (PS2_MOUSE_SCROLL_BTN_MASK & mouse_report->buttons)) {
232 // None of the scroll buttons are pressed 244 // None of the scroll buttons are pressed