summaryrefslogtreecommitdiff
path: root/quantum/pointing_device
diff options
context:
space:
mode:
authorSergey Vlasov <sigprof@gmail.com>2022-11-07 00:39:05 +0300
committerGitHub <noreply@github.com>2022-11-06 21:39:05 +0000
commita7b2f4233ca2062037303e783ced30d9376c9443 (patch)
treecdfbb9a82f695376c41a211b186f51552b3fcb73 /quantum/pointing_device
parent5f9b7c035bdbbbfccfcf2bbfed7d153f5043fdce (diff)
Fix keycode parameter extraction to match the new DD keycodes (#18977)
* Add macros to extract parameters from keycode values Implement both encoding and decoding for keycodes like TO(layer) or LM(layer, mod) in one place, so that the decoding won't get out of sync with the encoding. While at it, fix some macros for creating keycode values that did not apply the appropriate masks to parameters (and therefore could allow the result to be out of range if a wrong parameter was passed). * keymap_common: Use extraction macros for keycodes * pointing_device_auto_mouse: Use extraction macros for keycodes Fixes #18970. * process_autocorrect: Use extraction macros for keycodes * process_caps_word: Use extraction macros for keycodes (Also fix a minor bug - SH_TG was not handled properly) * process_leader: Use extraction macros for keycodes (Technically the code is not 100% correct, because it always assumes that the LT() or MT() action was a tap, but it's a separate issue that already existed before the keycode changes.) * process_unicode: Use extraction macros for keycodes * process_unicodemap: Use extraction macros for keycodes
Diffstat (limited to 'quantum/pointing_device')
-rw-r--r--quantum/pointing_device/pointing_device_auto_mouse.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/quantum/pointing_device/pointing_device_auto_mouse.c b/quantum/pointing_device/pointing_device_auto_mouse.c
index edffd44787..5e78817c7c 100644
--- a/quantum/pointing_device/pointing_device_auto_mouse.c
+++ b/quantum/pointing_device/pointing_device_auto_mouse.c
@@ -266,16 +266,20 @@ bool process_auto_mouse(uint16_t keycode, keyrecord_t* record) {
case QK_MODS ... QK_MODS_MAX:
break;
// TO((AUTO_MOUSE_TARGET_LAYER))-------------------------------------------------------------------------------
- case QK_TO ... QK_TO_MAX: // same proccessing as next
+ case QK_TO ... QK_TO_MAX:
+ if (QK_TO_GET_LAYER(keycode) == (AUTO_MOUSE_TARGET_LAYER)) {
+ if (!(record->event.pressed)) auto_mouse_toggle();
+ }
+ break;
// TG((AUTO_MOUSE_TARGET_LAYER))-------------------------------------------------------------------------------
case QK_TOGGLE_LAYER ... QK_TOGGLE_LAYER_MAX:
- if ((keycode & 0xff) == (AUTO_MOUSE_TARGET_LAYER)) {
+ if (QK_TOGGLE_LAYER_GET_LAYER(keycode) == (AUTO_MOUSE_TARGET_LAYER)) {
if (!(record->event.pressed)) auto_mouse_toggle();
}
break;
// MO((AUTO_MOUSE_TARGET_LAYER))-------------------------------------------------------------------------------
case QK_MOMENTARY ... QK_MOMENTARY_MAX:
- if ((keycode & 0xff) == (AUTO_MOUSE_TARGET_LAYER)) {
+ if (QK_MOMENTARY_GET_LAYER(keycode) == (AUTO_MOUSE_TARGET_LAYER)) {
auto_mouse_keyevent(record->event.pressed);
}
// DF ---------------------------------------------------------------------------------------------------------
@@ -288,14 +292,14 @@ bool process_auto_mouse(uint16_t keycode, keyrecord_t* record) {
break;
// LM((AUTO_MOUSE_TARGET_LAYER), mod)--------------------------------------------------------------------------
case QK_LAYER_MOD ... QK_LAYER_MOD_MAX:
- if (((keycode >> 8) & 0x0f) == (AUTO_MOUSE_TARGET_LAYER)) {
+ if (QK_LAYER_MOD_GET_LAYER(keycode) == (AUTO_MOUSE_TARGET_LAYER)) {
auto_mouse_keyevent(record->event.pressed);
}
break;
// TT((AUTO_MOUSE_TARGET_LAYER))---------------------------------------------------------------------------
# ifndef NO_ACTION_TAPPING
case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX:
- if ((keycode & 0xff) == (AUTO_MOUSE_TARGET_LAYER)) {
+ if (QK_LAYER_TAP_TOGGLE_GET_LAYER(keycode) == (AUTO_MOUSE_TARGET_LAYER)) {
auto_mouse_keyevent(record->event.pressed);
# if TAPPING_TOGGLE != 0
if (record->tap.count == TAPPING_TOGGLE) {
@@ -312,7 +316,7 @@ bool process_auto_mouse(uint16_t keycode, keyrecord_t* record) {
// LT((AUTO_MOUSE_TARGET_LAYER), kc)---------------------------------------------------------------------------
case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:
if (!record->tap.count) {
- if (((keycode >> 8) & 0x0f) == (AUTO_MOUSE_TARGET_LAYER)) {
+ if (QK_LAYER_TAP_GET_LAYER(keycode) == (AUTO_MOUSE_TARGET_LAYER)) {
auto_mouse_keyevent(record->event.pressed);
}
break;