diff options
author | Drashna Jaelre <drashna@live.com> | 2021-01-27 09:38:34 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-28 04:38:34 +1100 |
commit | 99f3df28939d89b7fc2d2e7c0ee21b0879c7813f (patch) | |
tree | 2d399785f60ddc0bae95c11e7d6f1462a5511ca1 /tmk_core/common/mousekey.c | |
parent | bab9849a8bc799f43e4dc18674c07625630cab0d (diff) | |
download | qmk_firmware-99f3df28939d89b7fc2d2e7c0ee21b0879c7813f.tar.gz qmk_firmware-99f3df28939d89b7fc2d2e7c0ee21b0879c7813f.zip |
Add support for 8 buttons to mouse report (#10807)
* Add support for 8 buttons to mouse report
This includes support for 8 buttons in mousekeys. However, this does move the keys around due to the fact that the last mousekey keycode is already 0xFF, so any past that would not work with register_code and the like, breaking them for tap hold keys, encoders, and other features.
* Update mouse key docs
* Add changes based on feedback
* Fix VUSB report size comment
Because drashna red gud
* Fix typo in action.c
* Fix IS_MOUSE_BUTTON check
* Change start range for mousekeys so that the end is 0xFF properly
* condense mousekeys check
Diffstat (limited to 'tmk_core/common/mousekey.c')
-rw-r--r-- | tmk_core/common/mousekey.c | 48 |
1 files changed, 8 insertions, 40 deletions
diff --git a/tmk_core/common/mousekey.c b/tmk_core/common/mousekey.c index 6c9df67236..d8cf63f771 100644 --- a/tmk_core/common/mousekey.c +++ b/tmk_core/common/mousekey.c @@ -278,16 +278,8 @@ void mousekey_on(uint8_t code) { mouse_report.h = wheel_unit() * -1; else if (code == KC_MS_WH_RIGHT) mouse_report.h = wheel_unit(); - else if (code == KC_MS_BTN1) - mouse_report.buttons |= MOUSE_BTN1; - else if (code == KC_MS_BTN2) - mouse_report.buttons |= MOUSE_BTN2; - else if (code == KC_MS_BTN3) - mouse_report.buttons |= MOUSE_BTN3; - else if (code == KC_MS_BTN4) - mouse_report.buttons |= MOUSE_BTN4; - else if (code == KC_MS_BTN5) - mouse_report.buttons |= MOUSE_BTN5; + else if (IS_MOUSEKEY_BUTTON(code)) + mouse_report.buttons |= 1 << (code - KC_MS_BTN1); else if (code == KC_MS_ACCEL0) mousekey_accel |= (1 << 0); else if (code == KC_MS_ACCEL1) @@ -313,16 +305,8 @@ void mousekey_off(uint8_t code) { mouse_report.h = 0; else if (code == KC_MS_WH_RIGHT && mouse_report.h > 0) mouse_report.h = 0; - else if (code == KC_MS_BTN1) - mouse_report.buttons &= ~MOUSE_BTN1; - else if (code == KC_MS_BTN2) - mouse_report.buttons &= ~MOUSE_BTN2; - else if (code == KC_MS_BTN3) - mouse_report.buttons &= ~MOUSE_BTN3; - else if (code == KC_MS_BTN4) - mouse_report.buttons &= ~MOUSE_BTN4; - else if (code == KC_MS_BTN5) - mouse_report.buttons &= ~MOUSE_BTN5; + else if (IS_MOUSEKEY_BUTTON(code)) + mouse_report.buttons &= ~(1 << (code - KC_MS_BTN1)); else if (code == KC_MS_ACCEL0) mousekey_accel &= ~(1 << 0); else if (code == KC_MS_ACCEL1) @@ -423,16 +407,8 @@ void mousekey_on(uint8_t code) { mouse_report.h = w_offset * -1; else if (code == KC_MS_WH_RIGHT) mouse_report.h = w_offset; - else if (code == KC_MS_BTN1) - mouse_report.buttons |= MOUSE_BTN1; - else if (code == KC_MS_BTN2) - mouse_report.buttons |= MOUSE_BTN2; - else if (code == KC_MS_BTN3) - mouse_report.buttons |= MOUSE_BTN3; - else if (code == KC_MS_BTN4) - mouse_report.buttons |= MOUSE_BTN4; - else if (code == KC_MS_BTN5) - mouse_report.buttons |= MOUSE_BTN5; + else if (IS_MOUSEKEY_BUTTON(code)) + mouse_report.buttons |= 1 << (code - KC_MS_BTN1); else if (code == KC_MS_ACCEL0) mk_speed = mkspd_0; else if (code == KC_MS_ACCEL1) @@ -462,16 +438,8 @@ void mousekey_off(uint8_t code) { mouse_report.h = 0; else if (code == KC_MS_WH_RIGHT && mouse_report.h > 0) mouse_report.h = 0; - else if (code == KC_MS_BTN1) - mouse_report.buttons &= ~MOUSE_BTN1; - else if (code == KC_MS_BTN2) - mouse_report.buttons &= ~MOUSE_BTN2; - else if (code == KC_MS_BTN3) - mouse_report.buttons &= ~MOUSE_BTN3; - else if (code == KC_MS_BTN4) - mouse_report.buttons &= ~MOUSE_BTN4; - else if (code == KC_MS_BTN5) - mouse_report.buttons &= ~MOUSE_BTN5; + else if (IS_MOUSEKEY_BUTTON(code)) + mouse_report.buttons &= ~(1 << (code - KC_MS_BTN1)); # ifdef MK_MOMENTARY_ACCEL else if (code == KC_MS_ACCEL0) mk_speed = mkspd_DEFAULT; |