summaryrefslogtreecommitdiffstats
path: root/tmk_core/common
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2021-01-27 09:38:34 -0800
committerGitHub <noreply@github.com>2021-01-28 04:38:34 +1100
commit99f3df28939d89b7fc2d2e7c0ee21b0879c7813f (patch)
tree2d399785f60ddc0bae95c11e7d6f1462a5511ca1 /tmk_core/common
parentbab9849a8bc799f43e4dc18674c07625630cab0d (diff)
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')
-rw-r--r--tmk_core/common/action.c18
-rw-r--r--tmk_core/common/keycode.h14
-rw-r--r--tmk_core/common/mousekey.c48
-rw-r--r--tmk_core/common/report.h5
4 files changed, 40 insertions, 45 deletions
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index a7432bae59..a3830abbff 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -443,6 +443,15 @@ void process_action(keyrecord_t *record, action_t action) {
case KC_MS_BTN5:
register_button(true, MOUSE_BTN5);
break;
+ case KC_MS_BTN6:
+ register_button(true, MOUSE_BTN6);
+ break;
+ case KC_MS_BTN7:
+ register_button(true, MOUSE_BTN7);
+ break;
+ case KC_MS_BTN8:
+ register_button(true, MOUSE_BTN8);
+ break;
# endif
default:
mousekey_send();
@@ -469,6 +478,15 @@ void process_action(keyrecord_t *record, action_t action) {
case KC_MS_BTN5:
register_button(false, MOUSE_BTN5);
break;
+ case KC_MS_BTN6:
+ register_button(false, MOUSE_BTN6);
+ break;
+ case KC_MS_BTN7:
+ register_button(false, MOUSE_BTN7);
+ break;
+ case KC_MS_BTN8:
+ register_button(false, MOUSE_BTN8);
+ break;
# endif
default:
mousekey_send();
diff --git a/tmk_core/common/keycode.h b/tmk_core/common/keycode.h
index d35e44d8dc..efad92b235 100644
--- a/tmk_core/common/keycode.h
+++ b/tmk_core/common/keycode.h
@@ -39,7 +39,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define IS_MOUSEKEY(code) (KC_MS_UP <= (code) && (code) <= KC_MS_ACCEL2)
#define IS_MOUSEKEY_MOVE(code) (KC_MS_UP <= (code) && (code) <= KC_MS_RIGHT)
-#define IS_MOUSEKEY_BUTTON(code) (KC_MS_BTN1 <= (code) && (code) <= KC_MS_BTN5)
+#define IS_MOUSEKEY_BUTTON(code) (KC_MS_BTN1 <= (code) && (code) <= KC_MS_BTN8)
#define IS_MOUSEKEY_WHEEL(code) (KC_MS_WH_UP <= (code) && (code) <= KC_MS_WH_RIGHT)
#define IS_MOUSEKEY_ACCEL(code) (KC_MS_ACCEL0 <= (code) && (code) <= KC_MS_ACCEL2)
@@ -205,6 +205,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define KC_BTN3 KC_MS_BTN3
#define KC_BTN4 KC_MS_BTN4
#define KC_BTN5 KC_MS_BTN5
+#define KC_BTN6 KC_MS_BTN6
+#define KC_BTN7 KC_MS_BTN7
+#define KC_BTN8 KC_MS_BTN8
#define KC_WH_U KC_MS_WH_UP
#define KC_WH_D KC_MS_WH_DOWN
#define KC_WH_L KC_MS_WH_LEFT
@@ -521,15 +524,18 @@ enum internal_special_keycodes {
enum mouse_keys {
/* Mouse Buttons */
- KC_MS_UP = 0xF0,
+ KC_MS_UP = 0xED,
KC_MS_DOWN,
KC_MS_LEFT,
- KC_MS_RIGHT,
+ KC_MS_RIGHT, // 0xF0
KC_MS_BTN1,
KC_MS_BTN2,
KC_MS_BTN3,
KC_MS_BTN4,
KC_MS_BTN5,
+ KC_MS_BTN6,
+ KC_MS_BTN7,
+ KC_MS_BTN8,
/* Mouse Wheel */
KC_MS_WH_UP,
@@ -540,5 +546,5 @@ enum mouse_keys {
/* Acceleration */
KC_MS_ACCEL0,
KC_MS_ACCEL1,
- KC_MS_ACCEL2
+ KC_MS_ACCEL2 // 0xFF
};
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;
diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h
index 5d7c5b3b28..bcf5cab388 100644
--- a/tmk_core/common/report.h
+++ b/tmk_core/common/report.h
@@ -39,7 +39,10 @@ enum mouse_buttons {
MOUSE_BTN2 = (1 << 1),
MOUSE_BTN3 = (1 << 2),
MOUSE_BTN4 = (1 << 3),
- MOUSE_BTN5 = (1 << 4)
+ MOUSE_BTN5 = (1 << 4),
+ MOUSE_BTN6 = (1 << 5),
+ MOUSE_BTN7 = (1 << 6),
+ MOUSE_BTN8 = (1 << 7)
};
/* Consumer Page (0x0C)