diff options
-rw-r--r-- | docs/feature_ps2_mouse.md | 19 | ||||
-rw-r--r-- | tmk_core/protocol/ps2_mouse.c | 15 |
2 files changed, 34 insertions, 0 deletions
diff --git a/docs/feature_ps2_mouse.md b/docs/feature_ps2_mouse.md index ce072fbe9..c1bd8bff5 100644 --- a/docs/feature_ps2_mouse.md +++ b/docs/feature_ps2_mouse.md | |||
@@ -266,6 +266,25 @@ To reverse the scroll axes you can put: | |||
266 | 266 | ||
267 | into config.h. | 267 | into config.h. |
268 | 268 | ||
269 | ### Rotate Mouse Axes :id=rotate-mouse-axes | ||
270 | |||
271 | Transform the output of the device with a clockwise rotation of 90, 180, or 270 | ||
272 | degrees. | ||
273 | |||
274 | When compensating for device orientation, rotate the output the same amount in | ||
275 | the opposite direction. E.g. if the normal device orientation is considered to | ||
276 | be North-facing, compensate as follows: | ||
277 | |||
278 | ```c | ||
279 | #define PS2_MOUSE_ROTATE 270 /* Compensate for East-facing device orientation. */ | ||
280 | ``` | ||
281 | ```c | ||
282 | #define PS2_MOUSE_ROTATE 180 /* Compensate for South-facing device orientation. */ | ||
283 | ``` | ||
284 | ```c | ||
285 | #define PS2_MOUSE_ROTATE 90 /* Compensate for West-facing device orientation. */ | ||
286 | ``` | ||
287 | |||
269 | ### Debug Settings :id=debug-settings | 288 | ### Debug Settings :id=debug-settings |
270 | 289 | ||
271 | To debug the mouse, add `debug_mouse = true` or enable via bootmagic. | 290 | To 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 aa3a307eb..a0e52bc7c 100644 --- a/tmk_core/protocol/ps2_mouse.c +++ b/tmk_core/protocol/ps2_mouse.c | |||
@@ -157,6 +157,21 @@ static inline void ps2_mouse_convert_report_to_hid(report_mouse_t *mouse_report) | |||
157 | // invert coordinate of y to conform to USB HID mouse | 157 | // invert coordinate of y to conform to USB HID mouse |
158 | mouse_report->y = -mouse_report->y; | 158 | mouse_report->y = -mouse_report->y; |
159 | #endif | 159 | #endif |
160 | |||
161 | #ifdef PS2_MOUSE_ROTATE | ||
162 | int8_t x = mouse_report->x; | ||
163 | int8_t y = mouse_report->y; | ||
164 | # if PS2_MOUSE_ROTATE == 90 | ||
165 | mouse_report->x = y; | ||
166 | mouse_report->y = -x; | ||
167 | # elif PS2_MOUSE_ROTATE == 180 | ||
168 | mouse_report->x = -x; | ||
169 | mouse_report->y = -y; | ||
170 | # elif PS2_MOUSE_ROTATE == 270 | ||
171 | mouse_report->x = -y; | ||
172 | mouse_report->y = x; | ||
173 | # endif | ||
174 | #endif | ||
160 | } | 175 | } |
161 | 176 | ||
162 | static inline void ps2_mouse_clear_report(report_mouse_t *mouse_report) { | 177 | static inline void ps2_mouse_clear_report(report_mouse_t *mouse_report) { |