diff options
author | Joel Challis <git@zvecr.com> | 2022-11-05 10:30:09 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-05 10:30:09 +0000 |
commit | a69ab05dd687cb9aa38e0c125e4f64956c7da6c7 (patch) | |
tree | 3733805ea012b5bc6ae7dc78dfed9f0f4d942d33 /quantum/process_keycode | |
parent | a070c4c50134cf274a674ee73227289fde81b8ed (diff) |
Initial DD keycode migration (#18643)
* Initial DD keycode migration
* Sort magic keycodes
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r-- | quantum/process_keycode/process_joystick.c | 6 | ||||
-rw-r--r-- | quantum/process_keycode/process_magic.c | 270 | ||||
-rw-r--r-- | quantum/process_keycode/process_programmable_button.c | 4 |
3 files changed, 137 insertions, 143 deletions
diff --git a/quantum/process_keycode/process_joystick.c b/quantum/process_keycode/process_joystick.c index c4c6fb59a8..43067b81db 100644 --- a/quantum/process_keycode/process_joystick.c +++ b/quantum/process_keycode/process_joystick.c @@ -19,11 +19,11 @@ bool process_joystick(uint16_t keycode, keyrecord_t *record) { switch (keycode) { - case QK_JOYSTICK_BUTTON_MIN ... QK_JOYSTICK_BUTTON_MAX: + case QK_JOYSTICK ... QK_JOYSTICK_MAX: if (record->event.pressed) { - register_joystick_button(keycode - QK_JOYSTICK_BUTTON_MIN); + register_joystick_button(keycode - QK_JOYSTICK); } else { - unregister_joystick_button(keycode - QK_JOYSTICK_BUTTON_MIN); + unregister_joystick_button(keycode - QK_JOYSTICK); } return false; } diff --git a/quantum/process_keycode/process_magic.c b/quantum/process_keycode/process_magic.c index 50816c5261..72332b20d7 100644 --- a/quantum/process_keycode/process_magic.c +++ b/quantum/process_keycode/process_magic.c @@ -40,158 +40,152 @@ float cg_swap_song[][2] = CG_SWAP_SONG; bool process_magic(uint16_t keycode, keyrecord_t *record) { // skip anything that isn't a keyup if (record->event.pressed) { - switch (keycode) { - case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_ALT_GUI: - case MAGIC_SWAP_LCTL_LGUI ... MAGIC_EE_HANDS_RIGHT: - case MAGIC_TOGGLE_GUI: - case MAGIC_TOGGLE_CONTROL_CAPSLOCK: - case MAGIC_TOGGLE_BACKSLASH_BACKSPACE: - case MAGIC_SWAP_ESCAPE_CAPSLOCK ... MAGIC_TOGGLE_ESCAPE_CAPSLOCK: - /* keymap config */ - keymap_config.raw = eeconfig_read_keymap(); - switch (keycode) { - case MAGIC_SWAP_CONTROL_CAPSLOCK: - keymap_config.swap_control_capslock = true; - break; - case MAGIC_SWAP_ESCAPE_CAPSLOCK: - keymap_config.swap_escape_capslock = true; - break; - case MAGIC_CAPSLOCK_TO_CONTROL: - keymap_config.capslock_to_control = true; - break; - case MAGIC_SWAP_LALT_LGUI: - keymap_config.swap_lalt_lgui = true; - break; - case MAGIC_SWAP_RALT_RGUI: - keymap_config.swap_ralt_rgui = true; - break; - case MAGIC_SWAP_LCTL_LGUI: - keymap_config.swap_lctl_lgui = true; - break; - case MAGIC_SWAP_RCTL_RGUI: - keymap_config.swap_rctl_rgui = true; - break; - case MAGIC_NO_GUI: - keymap_config.no_gui = true; - break; - case MAGIC_SWAP_GRAVE_ESC: - keymap_config.swap_grave_esc = true; - break; - case MAGIC_SWAP_BACKSLASH_BACKSPACE: - keymap_config.swap_backslash_backspace = true; - break; - case MAGIC_HOST_NKRO: - clear_keyboard(); // clear first buffer to prevent stuck keys - keymap_config.nkro = true; - break; - case MAGIC_SWAP_ALT_GUI: - keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = true; + if (IS_MAGIC_KEYCODE(keycode)) { + /* keymap config */ + keymap_config.raw = eeconfig_read_keymap(); + switch (keycode) { + case MAGIC_SWAP_CONTROL_CAPSLOCK: + keymap_config.swap_control_capslock = true; + break; + case MAGIC_SWAP_ESCAPE_CAPSLOCK: + keymap_config.swap_escape_capslock = true; + break; + case MAGIC_CAPSLOCK_TO_CONTROL: + keymap_config.capslock_to_control = true; + break; + case MAGIC_SWAP_LALT_LGUI: + keymap_config.swap_lalt_lgui = true; + break; + case MAGIC_SWAP_RALT_RGUI: + keymap_config.swap_ralt_rgui = true; + break; + case MAGIC_SWAP_LCTL_LGUI: + keymap_config.swap_lctl_lgui = true; + break; + case MAGIC_SWAP_RCTL_RGUI: + keymap_config.swap_rctl_rgui = true; + break; + case MAGIC_NO_GUI: + keymap_config.no_gui = true; + break; + case MAGIC_SWAP_GRAVE_ESC: + keymap_config.swap_grave_esc = true; + break; + case MAGIC_SWAP_BACKSLASH_BACKSPACE: + keymap_config.swap_backslash_backspace = true; + break; + case MAGIC_HOST_NKRO: + clear_keyboard(); // clear first buffer to prevent stuck keys + keymap_config.nkro = true; + break; + case MAGIC_SWAP_ALT_GUI: + keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = true; #ifdef AUDIO_ENABLE - PLAY_SONG(ag_swap_song); + PLAY_SONG(ag_swap_song); #endif - break; - case MAGIC_SWAP_CTL_GUI: - keymap_config.swap_lctl_lgui = keymap_config.swap_rctl_rgui = true; + break; + case MAGIC_SWAP_CTL_GUI: + keymap_config.swap_lctl_lgui = keymap_config.swap_rctl_rgui = true; #ifdef AUDIO_ENABLE - PLAY_SONG(cg_swap_song); + PLAY_SONG(cg_swap_song); #endif - break; - case MAGIC_UNSWAP_CONTROL_CAPSLOCK: - keymap_config.swap_control_capslock = false; - break; - case MAGIC_UNSWAP_ESCAPE_CAPSLOCK: - keymap_config.swap_escape_capslock = false; - break; - case MAGIC_UNCAPSLOCK_TO_CONTROL: - keymap_config.capslock_to_control = false; - break; - case MAGIC_UNSWAP_LALT_LGUI: - keymap_config.swap_lalt_lgui = false; - break; - case MAGIC_UNSWAP_RALT_RGUI: - keymap_config.swap_ralt_rgui = false; - break; - case MAGIC_UNSWAP_LCTL_LGUI: - keymap_config.swap_lctl_lgui = false; - break; - case MAGIC_UNSWAP_RCTL_RGUI: - keymap_config.swap_rctl_rgui = false; - break; - case MAGIC_UNNO_GUI: - keymap_config.no_gui = false; - break; - case MAGIC_UNSWAP_GRAVE_ESC: - keymap_config.swap_grave_esc = false; - break; - case MAGIC_UNSWAP_BACKSLASH_BACKSPACE: - keymap_config.swap_backslash_backspace = false; - break; - case MAGIC_UNHOST_NKRO: - clear_keyboard(); // clear first buffer to prevent stuck keys - keymap_config.nkro = false; - break; - case MAGIC_UNSWAP_ALT_GUI: - keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = false; + break; + case MAGIC_UNSWAP_CONTROL_CAPSLOCK: + keymap_config.swap_control_capslock = false; + break; + case MAGIC_UNSWAP_ESCAPE_CAPSLOCK: + keymap_config.swap_escape_capslock = false; + break; + case MAGIC_UNCAPSLOCK_TO_CONTROL: + keymap_config.capslock_to_control = false; + break; + case MAGIC_UNSWAP_LALT_LGUI: + keymap_config.swap_lalt_lgui = false; + break; + case MAGIC_UNSWAP_RALT_RGUI: + keymap_config.swap_ralt_rgui = false; + break; + case MAGIC_UNSWAP_LCTL_LGUI: + keymap_config.swap_lctl_lgui = false; + break; + case MAGIC_UNSWAP_RCTL_RGUI: + keymap_config.swap_rctl_rgui = false; + break; + case MAGIC_UNNO_GUI: + keymap_config.no_gui = false; + break; + case MAGIC_UNSWAP_GRAVE_ESC: + keymap_config.swap_grave_esc = false; + break; + case MAGIC_UNSWAP_BACKSLASH_BACKSPACE: + keymap_config.swap_backslash_backspace = false; + break; + case MAGIC_UNHOST_NKRO: + clear_keyboard(); // clear first buffer to prevent stuck keys + keymap_config.nkro = false; + break; + case MAGIC_UNSWAP_ALT_GUI: + keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = false; #ifdef AUDIO_ENABLE - PLAY_SONG(ag_norm_song); + PLAY_SONG(ag_norm_song); #endif - break; - case MAGIC_UNSWAP_CTL_GUI: - keymap_config.swap_lctl_lgui = keymap_config.swap_rctl_rgui = false; + break; + case MAGIC_UNSWAP_CTL_GUI: + keymap_config.swap_lctl_lgui = keymap_config.swap_rctl_rgui = false; #ifdef AUDIO_ENABLE - PLAY_SONG(cg_norm_song); + PLAY_SONG(cg_norm_song); #endif - break; - case MAGIC_TOGGLE_ALT_GUI: - keymap_config.swap_lalt_lgui = !keymap_config.swap_lalt_lgui; - keymap_config.swap_ralt_rgui = keymap_config.swap_lalt_lgui; + break; + case MAGIC_TOGGLE_ALT_GUI: + keymap_config.swap_lalt_lgui = !keymap_config.swap_lalt_lgui; + keymap_config.swap_ralt_rgui = keymap_config.swap_lalt_lgui; #ifdef AUDIO_ENABLE - if (keymap_config.swap_ralt_rgui) { - PLAY_SONG(ag_swap_song); - } else { - PLAY_SONG(ag_norm_song); - } + if (keymap_config.swap_ralt_rgui) { + PLAY_SONG(ag_swap_song); + } else { + PLAY_SONG(ag_norm_song); + } #endif - break; - case MAGIC_TOGGLE_CTL_GUI: - keymap_config.swap_lctl_lgui = !keymap_config.swap_lctl_lgui; - keymap_config.swap_rctl_rgui = keymap_config.swap_lctl_lgui; + break; + case MAGIC_TOGGLE_CTL_GUI: + keymap_config.swap_lctl_lgui = !keymap_config.swap_lctl_lgui; + keymap_config.swap_rctl_rgui = keymap_config.swap_lctl_lgui; #ifdef AUDIO_ENABLE - if (keymap_config.swap_rctl_rgui) { - PLAY_SONG(cg_swap_song); - } else { - PLAY_SONG(cg_norm_song); - } + if (keymap_config.swap_rctl_rgui) { + PLAY_SONG(cg_swap_song); + } else { + PLAY_SONG(cg_norm_song); + } #endif - break; - case MAGIC_TOGGLE_BACKSLASH_BACKSPACE: - keymap_config.swap_backslash_backspace = !keymap_config.swap_backslash_backspace; - break; - case MAGIC_TOGGLE_NKRO: - clear_keyboard(); // clear first buffer to prevent stuck keys - keymap_config.nkro = !keymap_config.nkro; - break; - case MAGIC_EE_HANDS_LEFT: - eeconfig_update_handedness(true); - break; - case MAGIC_EE_HANDS_RIGHT: - eeconfig_update_handedness(false); - break; - case MAGIC_TOGGLE_GUI: - keymap_config.no_gui = !keymap_config.no_gui; - break; - case MAGIC_TOGGLE_CONTROL_CAPSLOCK: - keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock; - break; - case MAGIC_TOGGLE_ESCAPE_CAPSLOCK: - keymap_config.swap_escape_capslock = !keymap_config.swap_escape_capslock; - break; - } + break; + case MAGIC_TOGGLE_BACKSLASH_BACKSPACE: + keymap_config.swap_backslash_backspace = !keymap_config.swap_backslash_backspace; + break; + case MAGIC_TOGGLE_NKRO: + clear_keyboard(); // clear first buffer to prevent stuck keys + keymap_config.nkro = !keymap_config.nkro; + break; + case MAGIC_EE_HANDS_LEFT: + eeconfig_update_handedness(true); + break; + case MAGIC_EE_HANDS_RIGHT: + eeconfig_update_handedness(false); + break; + case MAGIC_TOGGLE_GUI: + keymap_config.no_gui = !keymap_config.no_gui; + break; + case MAGIC_TOGGLE_CONTROL_CAPSLOCK: + keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock; + break; + case MAGIC_TOGGLE_ESCAPE_CAPSLOCK: + keymap_config.swap_escape_capslock = !keymap_config.swap_escape_capslock; + break; + } - eeconfig_update_keymap(keymap_config.raw); - clear_keyboard(); // clear to prevent stuck keys + eeconfig_update_keymap(keymap_config.raw); + clear_keyboard(); // clear to prevent stuck keys - return false; + return false; } } diff --git a/quantum/process_keycode/process_programmable_button.c b/quantum/process_keycode/process_programmable_button.c index d6a14e120c..03034edb61 100644 --- a/quantum/process_keycode/process_programmable_button.c +++ b/quantum/process_keycode/process_programmable_button.c @@ -19,8 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "programmable_button.h" bool process_programmable_button(uint16_t keycode, keyrecord_t *record) { - if (keycode >= QK_PROGRAMMABLE_BUTTON_MIN && keycode <= QK_PROGRAMMABLE_BUTTON_MAX) { - uint8_t button = keycode - QK_PROGRAMMABLE_BUTTON_MIN + 1; + if (IS_QK_PROGRAMMABLE_BUTTON(keycode)) { + uint8_t button = keycode - QK_PROGRAMMABLE_BUTTON + 1; if (record->event.pressed) { programmable_button_register(button); } else { |