aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/feature_ps2_mouse.md10
-rw-r--r--tmk_core/protocol/ps2_mouse.c7
2 files changed, 17 insertions, 0 deletions
diff --git a/docs/feature_ps2_mouse.md b/docs/feature_ps2_mouse.md
index 00c7ee72e..776a33150 100644
--- a/docs/feature_ps2_mouse.md
+++ b/docs/feature_ps2_mouse.md
@@ -270,6 +270,16 @@ Fine control over the scrolling is supported with the following defines:
270#define PS2_MOUSE_SCROLL_DIVISOR_V 2 270#define PS2_MOUSE_SCROLL_DIVISOR_V 2
271``` 271```
272 272
273### Invert Mouse buttons :id=invert-buttons
274
275To invert the left & right buttons you can put:
276
277```c
278#define PS2_MOUSE_INVERT_BUTTONS
279```
280
281into config.h.
282
273### Invert Mouse and Scroll Axes :id=invert-mouse-and-scroll-axes 283### Invert Mouse and Scroll Axes :id=invert-mouse-and-scroll-axes
274 284
275To invert the X and Y axes you can put: 285To invert the X and Y axes you can put:
diff --git a/tmk_core/protocol/ps2_mouse.c b/tmk_core/protocol/ps2_mouse.c
index 525aeb45a..39251a643 100644
--- a/tmk_core/protocol/ps2_mouse.c
+++ b/tmk_core/protocol/ps2_mouse.c
@@ -156,8 +156,15 @@ static inline void ps2_mouse_convert_report_to_hid(report_mouse_t *mouse_report)
156 mouse_report->x = X_IS_NEG ? ((!X_IS_OVF && -127 <= mouse_report->x && mouse_report->x <= -1) ? mouse_report->x : -127) : ((!X_IS_OVF && 0 <= mouse_report->x && mouse_report->x <= 127) ? mouse_report->x : 127); 156 mouse_report->x = X_IS_NEG ? ((!X_IS_OVF && -127 <= mouse_report->x && mouse_report->x <= -1) ? mouse_report->x : -127) : ((!X_IS_OVF && 0 <= mouse_report->x && mouse_report->x <= 127) ? mouse_report->x : 127);
157 mouse_report->y = Y_IS_NEG ? ((!Y_IS_OVF && -127 <= mouse_report->y && mouse_report->y <= -1) ? mouse_report->y : -127) : ((!Y_IS_OVF && 0 <= mouse_report->y && mouse_report->y <= 127) ? mouse_report->y : 127); 157 mouse_report->y = Y_IS_NEG ? ((!Y_IS_OVF && -127 <= mouse_report->y && mouse_report->y <= -1) ? mouse_report->y : -127) : ((!Y_IS_OVF && 0 <= mouse_report->y && mouse_report->y <= 127) ? mouse_report->y : 127);
158 158
159#ifdef PS2_MOUSE_INVERT_BUTTONS
160 // swap left & right buttons
161 uint8_t needs_left = mouse_report->buttons & PS2_MOUSE_BTN_RIGHT;
162 uint8_t needs_right = mouse_report->buttons & PS2_MOUSE_BTN_LEFT;
163 mouse_report->buttons = (mouse_report->buttons & ~(PS2_MOUSE_BTN_MASK)) | (needs_left ? PS2_MOUSE_BTN_LEFT : 0) | (needs_right ? PS2_MOUSE_BTN_RIGHT : 0);
164#else
159 // remove sign and overflow flags 165 // remove sign and overflow flags
160 mouse_report->buttons &= PS2_MOUSE_BTN_MASK; 166 mouse_report->buttons &= PS2_MOUSE_BTN_MASK;
167#endif
161 168
162#ifdef PS2_MOUSE_INVERT_X 169#ifdef PS2_MOUSE_INVERT_X
163 mouse_report->x = -mouse_report->x; 170 mouse_report->x = -mouse_report->x;