]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Add option to reverse PS2 mouse axes and scrolling
authorJesper Brix Rosenkilde <jbr@nordu.net>
Fri, 22 Sep 2017 11:58:49 +0000 (13:58 +0200)
committerJack Humbert <jack.humb@gmail.com>
Tue, 10 Oct 2017 17:20:17 +0000 (07:20 -1000)
docs/feature_ps2_mouse.md
tmk_core/protocol/ps2_mouse.c

index 8629b28cffaf8a8680f0bda9a382f9e260ec19d2..dac3a5b361765a06bab91d3407948ae242eb38af 100644 (file)
@@ -227,6 +227,26 @@ Fine control over the scrolling is supported with the following defines:
 #define PS2_MOUSE_SCROLL_DIVISOR_V 2
 ```
 
+#### Invert mouse and scroll axes
+
+To invert the X and Y axes you can put:
+
+```
+#define PS2_MOUSE_INVERT_X
+#define PS2_MOUSE_INVERT_Y
+```
+
+into config.h.
+
+To reverse the scroll axes you can put:
+
+```
+#define PS2_MOUSE_INVERT_H
+#define PS2_MOUSE_INVERT_V
+```
+
+into config.h.
+
 #### Debug settings
 
 To debug the mouse, add `debug_mouse = true` or enable via bootmagic.
index 4ed3cae1fd0d859fa48f05513eaf3fc867596c5a..cf1055eb802c30f3f434df6ba55aeb50c8c466b2 100644 (file)
@@ -169,8 +169,14 @@ static inline void ps2_mouse_convert_report_to_hid(report_mouse_t *mouse_report)
     // remove sign and overflow flags
     mouse_report->buttons &= PS2_MOUSE_BTN_MASK;
 
+#ifdef PS2_MOUSE_INVERT_X
+    mouse_report->x = -mouse_report->x;
+#endif
+#ifndef PS2_MOUSE_INVERT_Y // NOTE if not!
     // invert coordinate of y to conform to USB HID mouse
     mouse_report->y = -mouse_report->y;
+#endif
+
 }
 
 static 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) {
             mouse_report->h =  mouse_report->x/(PS2_MOUSE_SCROLL_DIVISOR_H);
             mouse_report->x = 0;
             mouse_report->y = 0;
+#ifdef PS2_MOUSE_INVERT_H
+            mouse_report->h = -mouse_report->h;
+#endif
+#ifdef PS2_MOUSE_INVERT_V
+            mouse_report->v = -mouse_report->v;
+#endif
         }
     } else if (0 == (PS2_MOUSE_SCROLL_BTN_MASK & mouse_report->buttons)) {
         // None of the scroll buttons are pressed