From f587a0c548d966bd4381236ed726f5ba733b67e2 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Sat, 18 Feb 2023 15:44:36 +0000 Subject: [PATCH] Align sequencer keycodes (#19875) --- .../keycodes/keycodes_0.0.2_sequencer.hjson | 69 +++++++++++++++++++ docs/feature_sequencer.md | 28 ++++---- quantum/keycodes.h | 29 +++++--- quantum/process_keycode/process_sequencer.c | 24 +++---- quantum/quantum_keycodes_legacy.h | 1 + tests/test_common/keycode_table.cpp | 18 ++--- 6 files changed, 124 insertions(+), 45 deletions(-) create mode 100644 data/constants/keycodes/keycodes_0.0.2_sequencer.hjson diff --git a/data/constants/keycodes/keycodes_0.0.2_sequencer.hjson b/data/constants/keycodes/keycodes_0.0.2_sequencer.hjson new file mode 100644 index 0000000000..eedaed166c --- /dev/null +++ b/data/constants/keycodes/keycodes_0.0.2_sequencer.hjson @@ -0,0 +1,69 @@ +{ + "keycodes": { + "!reset!":0, + + "0x7200": { + "group": "sequencer", + "key": "QK_SEQUENCER_ON", + "aliases": [ + "SQ_ON" + ] + }, + "0x7201": { + "group": "sequencer", + "key": "QK_SEQUENCER_OFF", + "aliases": [ + "SQ_OFF" + ] + }, + "0x7202": { + "group": "sequencer", + "key": "QK_SEQUENCER_TOGGLE", + "aliases": [ + "SQ_TOGG" + ] + }, + "0x7203": { + "group": "sequencer", + "key": "QK_SEQUENCER_TEMPO_DOWN", + "aliases": [ + "SQ_TMPD" + ] + }, + "0x7204": { + "group": "sequencer", + "key": "QK_SEQUENCER_TEMPO_UP", + "aliases": [ + "SQ_TMPU" + ] + }, + "0x7205": { + "group": "sequencer", + "key": "QK_SEQUENCER_RESOLUTION_DOWN", + "aliases": [ + "SQ_RESD" + ] + }, + "0x7206": { + "group": "sequencer", + "key": "QK_SEQUENCER_RESOLUTION_UP", + "aliases": [ + "SQ_RESU" + ] + }, + "0x7207": { + "group": "sequencer", + "key": "QK_SEQUENCER_STEPS_ALL", + "aliases": [ + "SQ_SALL" + ] + }, + "0x7208": { + "group": "sequencer", + "key": "QK_SEQUENCER_STEPS_CLEAR", + "aliases": [ + "SQ_SCLR" + ] + } + } +} \ No newline at end of file diff --git a/docs/feature_sequencer.md b/docs/feature_sequencer.md index 76b4db5cf6..87a277400a 100644 --- a/docs/feature_sequencer.md +++ b/docs/feature_sequencer.md @@ -40,20 +40,20 @@ While the tempo defines the absolute speed at which the sequencer goes through t ## Keycodes -|Keycode |Description | -|------- |----------- | -|`SQ_ON` |Start the step sequencer | -|`SQ_OFF` |Stop the step sequencer | -|`SQ_TOG` |Toggle the step sequencer playback | -|`SQ_SALL`|Enable all the steps | -|`SQ_SCLR`|Disable all the steps | -|`SQ_S(n)`|Toggle the step `n` | -|`SQ_TMPD`|Decrease the tempo | -|`SQ_TMPU`|Increase the tempo | -|`SQ_R(n)`|Set the resolution to n | -|`SQ_RESD`|Change to the slower resolution | -|`SQ_RESU`|Change to the faster resolution | -|`SQ_T(n)`|Set `n` as the only active track or deactivate all | +|Key |Aliases |Description | +|-------------------------------|---------|---------------------------------------------------| +|`QK_SEQUENCER_ON` |`SQ_ON` |Start the step sequencer | +|`QK_SEQUENCER_OFF` |`SQ_OFF` |Stop the step sequencer | +|`QK_SEQUENCER_TOGGLE` |`SQ_TOG` |Toggle the step sequencer playback | +|`QK_SEQUENCER_STEPS_ALL` |`SQ_SALL`|Enable all the steps | +|`QK_SEQUENCER_STEPS_CLEAR` |`SQ_SCLR`|Disable all the steps | +|`QK_SEQUENCER_TEMPO_DOWN` |`SQ_TMPD`|Decrease the tempo | +|`QK_SEQUENCER_TEMPO_UP` |`SQ_TMPU`|Increase the tempo | +|`QK_SEQUENCER_RESOLUTION_DOWN` |`SQ_RESD`|Change to the slower resolution | +|`QK_SEQUENCER_RESOLUTION_UP` |`SQ_RESU`|Change to the faster resolution | +|`SQ_S(n)` | |Toggle the step `n` | +|`SQ_R(n)` | |Set the resolution to n | +|`SQ_T(n)` | |Set `n` as the only active track or deactivate all | ## Functions diff --git a/quantum/keycodes.h b/quantum/keycodes.h index 73b86ce9b9..36cec4eab8 100644 --- a/quantum/keycodes.h +++ b/quantum/keycodes.h @@ -494,15 +494,15 @@ enum qk_keycode_defines { QK_MIDI_MODULATION_SPEED_UP = 0x718D, QK_MIDI_PITCH_BEND_DOWN = 0x718E, QK_MIDI_PITCH_BEND_UP = 0x718F, - SQ_ON = 0x7200, - SQ_OFF = 0x7201, - SQ_TOG = 0x7202, - SQ_TMPD = 0x7203, - SQ_TMPU = 0x7204, - SQ_RESD = 0x7205, - SQ_RESU = 0x7206, - SQ_SALL = 0x7207, - SQ_SCLR = 0x7208, + QK_SEQUENCER_ON = 0x7200, + QK_SEQUENCER_OFF = 0x7201, + QK_SEQUENCER_TOGGLE = 0x7202, + QK_SEQUENCER_TEMPO_DOWN = 0x7203, + QK_SEQUENCER_TEMPO_UP = 0x7204, + QK_SEQUENCER_RESOLUTION_DOWN = 0x7205, + QK_SEQUENCER_RESOLUTION_UP = 0x7206, + QK_SEQUENCER_STEPS_ALL = 0x7207, + QK_SEQUENCER_STEPS_CLEAR = 0x7208, QK_JOYSTICK_BUTTON_0 = 0x7400, QK_JOYSTICK_BUTTON_1 = 0x7401, QK_JOYSTICK_BUTTON_2 = 0x7402, @@ -1085,6 +1085,15 @@ enum qk_keycode_defines { MI_MODU = QK_MIDI_MODULATION_SPEED_UP, MI_BNDD = QK_MIDI_PITCH_BEND_DOWN, MI_BNDU = QK_MIDI_PITCH_BEND_UP, + SQ_ON = QK_SEQUENCER_ON, + SQ_OFF = QK_SEQUENCER_OFF, + SQ_TOGG = QK_SEQUENCER_TOGGLE, + SQ_TMPD = QK_SEQUENCER_TEMPO_DOWN, + SQ_TMPU = QK_SEQUENCER_TEMPO_UP, + SQ_RESD = QK_SEQUENCER_RESOLUTION_DOWN, + SQ_RESU = QK_SEQUENCER_RESOLUTION_UP, + SQ_SALL = QK_SEQUENCER_STEPS_ALL, + SQ_SCLR = QK_SEQUENCER_STEPS_CLEAR, JS_0 = QK_JOYSTICK_BUTTON_0, JS_1 = QK_JOYSTICK_BUTTON_1, JS_2 = QK_JOYSTICK_BUTTON_2, @@ -1329,7 +1338,7 @@ enum qk_keycode_defines { #define IS_SWAP_HANDS_KEYCODE(code) ((code) >= QK_SWAP_HANDS_TOGGLE && (code) <= QK_SWAP_HANDS_ONE_SHOT) #define IS_MAGIC_KEYCODE(code) ((code) >= MAGIC_SWAP_CONTROL_CAPSLOCK && (code) <= MAGIC_TOGGLE_ESCAPE_CAPSLOCK) #define IS_MIDI_KEYCODE(code) ((code) >= QK_MIDI_ON && (code) <= QK_MIDI_PITCH_BEND_UP) -#define IS_SEQUENCER_KEYCODE(code) ((code) >= SQ_ON && (code) <= SQ_SCLR) +#define IS_SEQUENCER_KEYCODE(code) ((code) >= QK_SEQUENCER_ON && (code) <= QK_SEQUENCER_STEPS_CLEAR) #define IS_JOYSTICK_KEYCODE(code) ((code) >= QK_JOYSTICK_BUTTON_0 && (code) <= QK_JOYSTICK_BUTTON_31) #define IS_PROGRAMMABLE_BUTTON_KEYCODE(code) ((code) >= QK_PROGRAMMABLE_BUTTON_1 && (code) <= QK_PROGRAMMABLE_BUTTON_32) #define IS_AUDIO_KEYCODE(code) ((code) >= QK_AUDIO_ON && (code) <= QK_AUDIO_VOICE_PREVIOUS) diff --git a/quantum/process_keycode/process_sequencer.c b/quantum/process_keycode/process_sequencer.c index 334b4c0092..6391d1ba9d 100644 --- a/quantum/process_keycode/process_sequencer.c +++ b/quantum/process_keycode/process_sequencer.c @@ -19,39 +19,39 @@ bool process_sequencer(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { switch (keycode) { - case SQ_ON: + case QK_SEQUENCER_ON: sequencer_on(); return false; - case SQ_OFF: + case QK_SEQUENCER_OFF: sequencer_off(); return false; - case SQ_TOG: + case QK_SEQUENCER_TOGGLE: sequencer_toggle(); return false; - case SQ_TMPD: + case QK_SEQUENCER_TEMPO_DOWN: sequencer_decrease_tempo(); return false; - case SQ_TMPU: + case QK_SEQUENCER_TEMPO_UP: sequencer_increase_tempo(); return false; - case SEQUENCER_RESOLUTION_MIN ... SEQUENCER_RESOLUTION_MAX: - sequencer_set_resolution(keycode - SEQUENCER_RESOLUTION_MIN); - return false; - case SQ_RESD: + case QK_SEQUENCER_RESOLUTION_DOWN: sequencer_decrease_resolution(); return false; - case SQ_RESU: + case QK_SEQUENCER_RESOLUTION_UP: sequencer_increase_resolution(); return false; - case SQ_SALL: + case QK_SEQUENCER_STEPS_ALL: sequencer_set_all_steps_on(); return false; - case SQ_SCLR: + case QK_SEQUENCER_STEPS_CLEAR: sequencer_set_all_steps_off(); return false; case SEQUENCER_STEP_MIN ... SEQUENCER_STEP_MAX: sequencer_toggle_step(keycode - SEQUENCER_STEP_MIN); return false; + case SEQUENCER_RESOLUTION_MIN ... SEQUENCER_RESOLUTION_MAX: + sequencer_set_resolution(keycode - SEQUENCER_RESOLUTION_MIN); + return false; case SEQUENCER_TRACK_MIN ... SEQUENCER_TRACK_MAX: sequencer_toggle_single_active_track(keycode - SEQUENCER_TRACK_MIN); return false; diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index 28634d00f7..b23ed00e98 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -4,3 +4,4 @@ // Deprecated Quantum keycodes #define SH_TG QK_SWAP_HANDS_TOGGLE +#define SQ_TOG QK_SEQUENCER_TOGGLE diff --git a/tests/test_common/keycode_table.cpp b/tests/test_common/keycode_table.cpp index 337bc8fb5f..8947659411 100644 --- a/tests/test_common/keycode_table.cpp +++ b/tests/test_common/keycode_table.cpp @@ -436,15 +436,15 @@ std::map KEYCODE_ID_TABLE = { {QK_MIDI_MODULATION_SPEED_UP, "QK_MIDI_MODULATION_SPEED_UP"}, {QK_MIDI_PITCH_BEND_DOWN, "QK_MIDI_PITCH_BEND_DOWN"}, {QK_MIDI_PITCH_BEND_UP, "QK_MIDI_PITCH_BEND_UP"}, - {SQ_ON, "SQ_ON"}, - {SQ_OFF, "SQ_OFF"}, - {SQ_TOG, "SQ_TOG"}, - {SQ_TMPD, "SQ_TMPD"}, - {SQ_TMPU, "SQ_TMPU"}, - {SQ_RESD, "SQ_RESD"}, - {SQ_RESU, "SQ_RESU"}, - {SQ_SALL, "SQ_SALL"}, - {SQ_SCLR, "SQ_SCLR"}, + {QK_SEQUENCER_ON, "QK_SEQUENCER_ON"}, + {QK_SEQUENCER_OFF, "QK_SEQUENCER_OFF"}, + {QK_SEQUENCER_TOGGLE, "QK_SEQUENCER_TOGGLE"}, + {QK_SEQUENCER_TEMPO_DOWN, "QK_SEQUENCER_TEMPO_DOWN"}, + {QK_SEQUENCER_TEMPO_UP, "QK_SEQUENCER_TEMPO_UP"}, + {QK_SEQUENCER_RESOLUTION_DOWN, "QK_SEQUENCER_RESOLUTION_DOWN"}, + {QK_SEQUENCER_RESOLUTION_UP, "QK_SEQUENCER_RESOLUTION_UP"}, + {QK_SEQUENCER_STEPS_ALL, "QK_SEQUENCER_STEPS_ALL"}, + {QK_SEQUENCER_STEPS_CLEAR, "QK_SEQUENCER_STEPS_CLEAR"}, {QK_JOYSTICK_BUTTON_0, "QK_JOYSTICK_BUTTON_0"}, {QK_JOYSTICK_BUTTON_1, "QK_JOYSTICK_BUTTON_1"}, {QK_JOYSTICK_BUTTON_2, "QK_JOYSTICK_BUTTON_2"},