From 002537b8eacd391350927fd3c6aab2a494191f3e Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 8 Jul 2023 11:11:17 +0900 Subject: [PATCH] core: Add mousekey support to ACTION_KEY() #675 ACT_MOUSEKEY can be removed but kept for backward compatibility. Mousekeys work with ACTION_KEY(), ACTION_MODS_KEY(), ACTION_MODS_TAP_KEY() now. But not completely with ACTION_LAYER_TAP_KEY(), layer_param_bit_op { OP_TAP_TOGGLE, OP_ON_OFF, OP_OFF_ON, OP_SET_CLEAR } overlaps with mousekeys KC_MS_* paritally(F0-F3). --- tmk_core/common/action.c | 12 +++++++ tmk_core/common/action_code.h | 1 - tmk_core/common/actionmap.h | 64 +++++++++++++++++------------------ tmk_core/common/keymap.c | 2 +- 4 files changed, 45 insertions(+), 34 deletions(-) diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index 82c87b52..0a2b785d 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c @@ -454,6 +454,12 @@ void register_code(uint8_t code) wait_ms(50); bootloader_jump(); } +#ifdef MOUSEKEY_ENABLE + else if IS_MOUSEKEY(code) { + mousekey_on(code); + mousekey_send(); + } +#endif } void unregister_code(uint8_t code) @@ -503,6 +509,12 @@ void unregister_code(uint8_t code) else if IS_CONSUMER(code) { host_consumer_send(0); } +#ifdef MOUSEKEY_ENABLE + else if IS_MOUSEKEY(code) { + mousekey_off(code); + mousekey_send(); + } +#endif } void type_code(uint8_t code) diff --git a/tmk_core/common/action_code.h b/tmk_core/common/action_code.h index 89cee76f..7b39cba0 100644 --- a/tmk_core/common/action_code.h +++ b/tmk_core/common/action_code.h @@ -229,7 +229,6 @@ enum usage_pages { }; #define ACTION_USAGE_SYSTEM(id) ACTION(ACT_USAGE, PAGE_SYSTEM<<10 | (id)) #define ACTION_USAGE_CONSUMER(id) ACTION(ACT_USAGE, PAGE_CONSUMER<<10 | (id)) -#define ACTION_MOUSEKEY(key) ACTION(ACT_MOUSEKEY, key) diff --git a/tmk_core/common/actionmap.h b/tmk_core/common/actionmap.h index 6fe2614e..0b57ee74 100644 --- a/tmk_core/common/actionmap.h +++ b/tmk_core/common/actionmap.h @@ -287,22 +287,22 @@ along with this program. If not, see . #define AC_BRIGHTNESS_DEC ACTION_USAGE_CONSUMER(BRIGHTNESS_DECREMENT) /* Mousekey */ -#define AC_MS_UP ACTION_MOUSEKEY(KC_MS_UP) -#define AC_MS_DOWN ACTION_MOUSEKEY(KC_MS_DOWN) -#define AC_MS_LEFT ACTION_MOUSEKEY(KC_MS_LEFT) -#define AC_MS_RIGHT ACTION_MOUSEKEY(KC_MS_RIGHT) -#define AC_MS_BTN1 ACTION_MOUSEKEY(KC_MS_BTN1) -#define AC_MS_BTN2 ACTION_MOUSEKEY(KC_MS_BTN2) -#define AC_MS_BTN3 ACTION_MOUSEKEY(KC_MS_BTN3) -#define AC_MS_BTN4 ACTION_MOUSEKEY(KC_MS_BTN4) -#define AC_MS_BTN5 ACTION_MOUSEKEY(KC_MS_BTN5) -#define AC_MS_WH_UP ACTION_MOUSEKEY(KC_MS_WH_UP) -#define AC_MS_WH_DOWN ACTION_MOUSEKEY(KC_MS_WH_DOWN) -#define AC_MS_WH_LEFT ACTION_MOUSEKEY(KC_MS_WH_LEFT) -#define AC_MS_WH_RIGHT ACTION_MOUSEKEY(KC_MS_WH_RIGHT) -#define AC_MS_ACCEL0 ACTION_MOUSEKEY(KC_MS_ACCEL0) -#define AC_MS_ACCEL1 ACTION_MOUSEKEY(KC_MS_ACCEL1) -#define AC_MS_ACCEL2 ACTION_MOUSEKEY(KC_MS_ACCEL2) +#define AC_MS_UP ACTION_KEY(KC_MS_UP) +#define AC_MS_DOWN ACTION_KEY(KC_MS_DOWN) +#define AC_MS_LEFT ACTION_KEY(KC_MS_LEFT) +#define AC_MS_RIGHT ACTION_KEY(KC_MS_RIGHT) +#define AC_MS_BTN1 ACTION_KEY(KC_MS_BTN1) +#define AC_MS_BTN2 ACTION_KEY(KC_MS_BTN2) +#define AC_MS_BTN3 ACTION_KEY(KC_MS_BTN3) +#define AC_MS_BTN4 ACTION_KEY(KC_MS_BTN4) +#define AC_MS_BTN5 ACTION_KEY(KC_MS_BTN5) +#define AC_MS_WH_UP ACTION_KEY(KC_MS_WH_UP) +#define AC_MS_WH_DOWN ACTION_KEY(KC_MS_WH_DOWN) +#define AC_MS_WH_LEFT ACTION_KEY(KC_MS_WH_LEFT) +#define AC_MS_WH_RIGHT ACTION_KEY(KC_MS_WH_RIGHT) +#define AC_MS_ACCEL0 ACTION_KEY(KC_MS_ACCEL0) +#define AC_MS_ACCEL1 ACTION_KEY(KC_MS_ACCEL1) +#define AC_MS_ACCEL2 ACTION_KEY(KC_MS_ACCEL2) /* Command */ #define AC_BOOTLOADER ACTION_COMMAND(COMMAND_BOOTLOADER, 0) @@ -388,22 +388,22 @@ along with this program. If not, see . #define AC_AGIN ACTION_KEY(KC_AGAIN) #define AC_PSTE ACTION_KEY(KC_PASTE) /* Mousekey */ -#define AC_MS_U ACTION_MOUSEKEY(KC_MS_UP) -#define AC_MS_D ACTION_MOUSEKEY(KC_MS_DOWN) -#define AC_MS_L ACTION_MOUSEKEY(KC_MS_LEFT) -#define AC_MS_R ACTION_MOUSEKEY(KC_MS_RIGHT) -#define AC_BTN1 ACTION_MOUSEKEY(KC_MS_BTN1) -#define AC_BTN2 ACTION_MOUSEKEY(KC_MS_BTN2) -#define AC_BTN3 ACTION_MOUSEKEY(KC_MS_BTN3) -#define AC_BTN4 ACTION_MOUSEKEY(KC_MS_BTN4) -#define AC_BTN5 ACTION_MOUSEKEY(KC_MS_BTN5) -#define AC_WH_U ACTION_MOUSEKEY(KC_MS_WH_UP) -#define AC_WH_D ACTION_MOUSEKEY(KC_MS_WH_DOWN) -#define AC_WH_L ACTION_MOUSEKEY(KC_MS_WH_LEFT) -#define AC_WH_R ACTION_MOUSEKEY(KC_MS_WH_RIGHT) -#define AC_ACL0 ACTION_MOUSEKEY(KC_MS_ACCEL0) -#define AC_ACL1 ACTION_MOUSEKEY(KC_MS_ACCEL1) -#define AC_ACL2 ACTION_MOUSEKEY(KC_MS_ACCEL2) +#define AC_MS_U ACTION_KEY(KC_MS_UP) +#define AC_MS_D ACTION_KEY(KC_MS_DOWN) +#define AC_MS_L ACTION_KEY(KC_MS_LEFT) +#define AC_MS_R ACTION_KEY(KC_MS_RIGHT) +#define AC_BTN1 ACTION_KEY(KC_MS_BTN1) +#define AC_BTN2 ACTION_KEY(KC_MS_BTN2) +#define AC_BTN3 ACTION_KEY(KC_MS_BTN3) +#define AC_BTN4 ACTION_KEY(KC_MS_BTN4) +#define AC_BTN5 ACTION_KEY(KC_MS_BTN5) +#define AC_WH_U ACTION_KEY(KC_MS_WH_UP) +#define AC_WH_D ACTION_KEY(KC_MS_WH_DOWN) +#define AC_WH_L ACTION_KEY(KC_MS_WH_LEFT) +#define AC_WH_R ACTION_KEY(KC_MS_WH_RIGHT) +#define AC_ACL0 ACTION_KEY(KC_MS_ACCEL0) +#define AC_ACL1 ACTION_KEY(KC_MS_ACCEL1) +#define AC_ACL2 ACTION_KEY(KC_MS_ACCEL2) /* Sytem Control */ #define AC_PWR ACTION_USAGE_SYSTEM(SYSTEM_POWER_DOWN) #define AC_SLEP ACTION_USAGE_SYSTEM(SYSTEM_SLEEP) diff --git a/tmk_core/common/keymap.c b/tmk_core/common/keymap.c index f9b8ca12..2bd4a253 100644 --- a/tmk_core/common/keymap.c +++ b/tmk_core/common/keymap.c @@ -149,7 +149,7 @@ static action_t keycode_to_action(uint8_t keycode) return (action_t)ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode)); break; case KC_MS_UP ... KC_MS_ACCEL2: - return (action_t)ACTION_MOUSEKEY(keycode); + return (action_t)ACTION_KEY(keycode); break; case KC_TRNS: return (action_t)ACTION_TRANSPARENT;