Skip to content

Commit

Permalink
Align audio keycode names (qmk#18962)
Browse files Browse the repository at this point in the history
* Align audio keycode names

* Update docs

* Update quantum
  • Loading branch information
zvecr authored Nov 5, 2022
1 parent fd4c3f4 commit 69fa02c
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 93 deletions.
58 changes: 43 additions & 15 deletions data/constants/keycodes/keycodes_0.0.1_audio.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -2,83 +2,111 @@
"keycodes": {
"0x7480": {
"group": "audio",
"key": "AU_ON"
"key": "QK_AUDIO_ON",
"aliases": [
"AU_ON"
]
},
"0x7481": {
"group": "audio",
"key": "AU_OFF"
"key": "QK_AUDIO_OFF",
"aliases": [
"AU_OFF"
]
},
"0x7482": {
"group": "audio",
"key": "AU_TOG"
"key": "QK_AUDIO_TOGGLE",
"aliases": [
"AU_TOGG"
]
},

"0x748A": {
"group": "audio",
"key": "CLICKY_TOGGLE",
"key": "QK_AUDIO_CLICKY_TOGGLE",
"aliases": [
"CK_TOGG"
]
},
"0x748B": {
"group": "audio",
"key": "CLICKY_ENABLE",
"key": "QK_AUDIO_CLICKY_ON",
"aliases": [
"CK_ON"
]
},
"0x748C": {
"group": "audio",
"key": "CLICKY_DISABLE",
"key": "QK_AUDIO_CLICKY_OFF",
"aliases": [
"CK_OFF"
]
},
"0x748D": {
"group": "audio",
"key": "CLICKY_UP",
"key": "QK_AUDIO_CLICKY_UP",
"aliases": [
"CK_UP"
]
},
"0x748E": {
"group": "audio",
"key": "CLICKY_DOWN",
"key": "QK_AUDIO_CLICKY_DOWN",
"aliases": [
"CK_DOWN"
]
},
"0x748F": {
"group": "audio",
"key": "CLICKY_RESET",
"key": "QK_AUDIO_CLICKY_RESET",
"aliases": [
"CK_RST"
]
},

"0x7490": {
"group": "audio",
"key": "MU_ON"
"key": "QK_MUSIC_ON",
"aliases": [
"MU_ON"
]
},
"0x7491": {
"group": "audio",
"key": "MU_OFF"
"key": "QK_MUSIC_OFF",
"aliases": [
"MU_OFF"
]
},
"0x7492": {
"group": "audio",
"key": "MU_TOG"
"key": "QK_MUSIC_TOGGLE",
"aliases": [
"MU_TOGG"
]
},
"0x7493": {
"group": "audio",
"key": "MU_MOD"
"key": "QK_MUSIC_MODE_NEXT",
"aliases": [
"MU_NEXT"
]
},

"0x7494": {
"group": "audio",
"key": "MUV_IN"
"key": "QK_AUDIO_VOICE_NEXT",
"aliases": [
"AU_NEXT"
]
},
"0x7495": {
"group": "audio",
"key": "MUV_DE"
"key": "QK_AUDIO_VOICE_PREVIOUS",
"aliases": [
"AU_PREV"
]
}
}
}
71 changes: 45 additions & 26 deletions docs/feature_audio.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,11 @@ It's advised that you wrap all audio features in `#ifdef AUDIO_ENABLE` / `#endif
The available keycodes for audio are:
* `AU_ON` - Turn Audio Feature on
* `AU_OFF` - Turn Audio Feature off
* `AU_TOG` - Toggle Audio Feature state
|Key |Aliases |Description |
|-------------------------|---------|-------------------------------------------|
|`QK_AUDIO_ON` |`AU_ON` |Turns on Audio Feature |
|`QK_AUDIO_OFF` |`AU_OFF` |Turns off Audio Feature |
|`QK_AUDIO_TOGGLE` |`AU_TOGG`|Toggles Audio state |
!> These keycodes turn all of the audio functionality on and off. Turning it off means that audio feedback, audio clicky, music mode, etc. are disabled, completely.
Expand Down Expand Up @@ -219,6 +221,12 @@ Aka "audio effects", different ones can be enabled by setting in `config.h` thes
`#define AUDIO_VOICES` to enable the feature, and `#define AUDIO_VOICE_DEFAULT something` to select a specific effect
for details see quantum/audio/voices.h and .c
Keycodes available:
|Key |Aliases |Description |
|-------------------------|---------|-------------------------------------------|
|`QK_AUDIO_VOICE_NEXT` |`AU_NEXT`|Cycles through the audio voices |
|`QK_AUDIO_VOICE_PREVIOUS`|`AU_PREV`|Cycles through the audio voices in reverse |
## Music Mode
Expand All @@ -228,10 +236,14 @@ Recording is experimental due to some memory issues - if you experience some wei

Keycodes available:

* `MU_ON` - Turn music mode on
* `MU_OFF` - Turn music mode off
* `MU_TOG` - Toggle music mode
* `MU_MOD` - Cycle through the music modes:
|Key |Aliases |Description |
|-------------------------|---------|-------------------------------------------|
|`QK_MUSIC_ON` |`MU_ON` |Turns on Music Mode |
|`QK_MUSIC_OFF` |`MU_OFF` |Turns off Music Mode |
|`QK_MUSIC_TOGGLE` |`MU_TOGG`|Toggles Music Mode |
|`QK_MUSIC_MODE_NEXT` |`MU_NEXT`|Cycles through the music modes |

Available Modes:
* `CHROMATIC_MODE` - Chromatic scale, row changes the octave
* `GUITAR_MODE` - Chromatic scale, but the row changes the string (+5 st)
* `VIOLIN_MODE` - Chromatic scale, but the row changes the string (+7 st)
Expand Down Expand Up @@ -300,13 +312,16 @@ You can look at the [Planck Keyboard](https://github.com/qmk/qmk_firmware/blob/e

This adds a click sound each time you hit a button, to simulate click sounds from the keyboard. And the sounds are slightly different for each keypress, so it doesn't sound like a single long note, if you type rapidly.

* `CK_TOGG` - Toggles the status (will play sound if enabled)
* `CK_ON` - Turns on Audio Click (plays sound)
* `CK_OFF` - Turns off Audio Click (doesn't play sound)
* `CK_RST` - Resets the frequency to the default state (plays sound at default frequency)
* `CK_UP` - Increases the frequency of the clicks (plays sound at new frequency)
* `CK_DOWN` - Decreases the frequency of the clicks (plays sound at new frequency)
Keycodes available:

|Key |Aliases |Description |
|-------------------------|---------|-------------------------------------------|
|`QK_AUDIO_CLICKY_TOGGLE` |`CK_TOGG`|Toggles Audio clicky mode |
|`QK_AUDIO_CLICKY_ON` |`CK_ON` |Turns on Audio clicky mode |
|`QK_AUDIO_CLICKY_OFF` |`CK_OFF` |Turns on Audio clicky mode |
|`QK_AUDIO_CLICKY_UP` |`CK_UP` |Increases frequency of the clicks |
|`QK_AUDIO_CLICKY_DOWN` |`CK_DOWN`|Decreases frequency of the clicks |
|`QK_AUDIO_CLICKY_RESET` |`CK_RST` |Resets frequency to default |

The feature is disabled by default, to save space. To enable it, add this to your `config.h`:

Expand All @@ -333,16 +348,20 @@ See [MIDI](feature_midi.md)

## Audio Keycodes

|Key |Aliases |Description |
|----------------|---------|----------------------------------|
|`AU_ON` | |Audio mode on |
|`AU_OFF` | |Audio mode off |
|`AU_TOG` | |Toggles Audio mode |
|`CLICKY_TOGGLE` |`CK_TOGG`|Toggles Audio clicky mode |
|`CLICKY_UP` |`CK_UP` |Increases frequency of the clicks |
|`CLICKY_DOWN` |`CK_DOWN`|Decreases frequency of the clicks |
|`CLICKY_RESET` |`CK_RST` |Resets frequency to default |
|`MU_ON` | |Turns on Music Mode |
|`MU_OFF` | |Turns off Music Mode |
|`MU_TOG` | |Toggles Music Mode |
|`MU_MOD` | |Cycles through the music modes |
|Key |Aliases |Description |
|-------------------------|---------|-------------------------------------------|
|`QK_AUDIO_ON` |`AU_ON` |Turns on Audio Feature |
|`QK_AUDIO_OFF` |`AU_OFF` |Turns off Audio Feature |
|`QK_AUDIO_TOGGLE` |`AU_TOGG`|Toggles Audio state |
|`QK_AUDIO_CLICKY_TOGGLE` |`CK_TOGG`|Toggles Audio clicky mode |
|`QK_AUDIO_CLICKY_ON` |`CK_ON` |Turns on Audio clicky mode |
|`QK_AUDIO_CLICKY_OFF` |`CK_OFF` |Turns on Audio clicky mode |
|`QK_AUDIO_CLICKY_UP` |`CK_UP` |Increases frequency of the clicks |
|`QK_AUDIO_CLICKY_DOWN` |`CK_DOWN`|Decreases frequency of the clicks |
|`QK_AUDIO_CLICKY_RESET` |`CK_RST` |Resets frequency to default |
|`QK_MUSIC_ON` |`MU_ON` |Turns on Music Mode |
|`QK_MUSIC_OFF` |`MU_OFF` |Turns off Music Mode |
|`QK_MUSIC_TOGGLE` |`MU_TOGG`|Toggles Music Mode |
|`QK_MUSIC_MODE_NEXT` |`MU_NEXT`|Cycles through the music modes |
|`QK_AUDIO_VOICE_NEXT` |`AU_NEXT`|Cycles through the audio voices |
|`QK_AUDIO_VOICE_PREVIOUS`|`AU_PREV`|Cycles through the audio voices in reverse |
30 changes: 17 additions & 13 deletions docs/keycodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,23 @@ See also: [Quantum Keycodes](quantum_keycodes.md#qmk-keycodes)

See also: [Audio](feature_audio.md)

|Key |Aliases |Description |
|----------------|---------|----------------------------------|
|`AU_ON` | |Turns on Audio Feature |
|`AU_OFF` | |Turns off Audio Feature |
|`AU_TOG` | |Toggles Audio state |
|`CLICKY_TOGGLE` |`CK_TOGG`|Toggles Audio clicky mode |
|`CLICKY_UP` |`CK_UP` |Increases frequency of the clicks |
|`CLICKY_DOWN` |`CK_DOWN`|Decreases frequency of the clicks |
|`CLICKY_RESET` |`CK_RST` |Resets frequency to default |
|`MU_ON` | |Turns on Music Mode |
|`MU_OFF` | |Turns off Music Mode |
|`MU_TOG` | |Toggles Music Mode |
|`MU_MOD` | |Cycles through the music modes |
|Key |Aliases |Description |
|-------------------------|---------|-------------------------------------------|
|`QK_AUDIO_ON` |`AU_ON` |Turns on Audio Feature |
|`QK_AUDIO_OFF` |`AU_OFF` |Turns off Audio Feature |
|`QK_AUDIO_TOGGLE` |`AU_TOGG`|Toggles Audio state |
|`QK_AUDIO_CLICKY_TOGGLE` |`CK_TOGG`|Toggles Audio clicky mode |
|`QK_AUDIO_CLICKY_ON` |`CK_ON` |Turns on Audio clicky mode |
|`QK_AUDIO_CLICKY_OFF` |`CK_OFF` |Turns on Audio clicky mode |
|`QK_AUDIO_CLICKY_UP` |`CK_UP` |Increases frequency of the clicks |
|`QK_AUDIO_CLICKY_DOWN` |`CK_DOWN`|Decreases frequency of the clicks |
|`QK_AUDIO_CLICKY_RESET` |`CK_RST` |Resets frequency to default |
|`QK_MUSIC_ON` |`MU_ON` |Turns on Music Mode |
|`QK_MUSIC_OFF` |`MU_OFF` |Turns off Music Mode |
|`QK_MUSIC_TOGGLE` |`MU_TOGG`|Toggles Music Mode |
|`QK_MUSIC_MODE_NEXT` |`MU_NEXT`|Cycles through the music modes |
|`QK_AUDIO_VOICE_NEXT` |`AU_NEXT`|Cycles through the audio voices |
|`QK_AUDIO_VOICE_PREVIOUS`|`AU_PREV`|Cycles through the audio voices in reverse |

## Auto Shift :id=auto-shift

Expand Down
53 changes: 31 additions & 22 deletions quantum/keycodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -563,21 +563,21 @@ enum qk_keycode_defines {
QK_PROGRAMMABLE_BUTTON_30 = 0x745D,
QK_PROGRAMMABLE_BUTTON_31 = 0x745E,
QK_PROGRAMMABLE_BUTTON_32 = 0x745F,
AU_ON = 0x7480,
AU_OFF = 0x7481,
AU_TOG = 0x7482,
CLICKY_TOGGLE = 0x748A,
CLICKY_ENABLE = 0x748B,
CLICKY_DISABLE = 0x748C,
CLICKY_UP = 0x748D,
CLICKY_DOWN = 0x748E,
CLICKY_RESET = 0x748F,
MU_ON = 0x7490,
MU_OFF = 0x7491,
MU_TOG = 0x7492,
MU_MOD = 0x7493,
MUV_IN = 0x7494,
MUV_DE = 0x7495,
QK_AUDIO_ON = 0x7480,
QK_AUDIO_OFF = 0x7481,
QK_AUDIO_TOGGLE = 0x7482,
QK_AUDIO_CLICKY_TOGGLE = 0x748A,
QK_AUDIO_CLICKY_ON = 0x748B,
QK_AUDIO_CLICKY_OFF = 0x748C,
QK_AUDIO_CLICKY_UP = 0x748D,
QK_AUDIO_CLICKY_DOWN = 0x748E,
QK_AUDIO_CLICKY_RESET = 0x748F,
QK_MUSIC_ON = 0x7490,
QK_MUSIC_OFF = 0x7491,
QK_MUSIC_TOGGLE = 0x7492,
QK_MUSIC_MODE_NEXT = 0x7493,
QK_AUDIO_VOICE_NEXT = 0x7494,
QK_AUDIO_VOICE_PREVIOUS = 0x7495,
QK_STENO_BOLT = 0x74F0,
QK_STENO_GEMINI = 0x74F1,
QK_STENO_COMB = 0x74F2,
Expand Down Expand Up @@ -992,12 +992,21 @@ enum qk_keycode_defines {
PB_30 = QK_PROGRAMMABLE_BUTTON_30,
PB_31 = QK_PROGRAMMABLE_BUTTON_31,
PB_32 = QK_PROGRAMMABLE_BUTTON_32,
CK_TOGG = CLICKY_TOGGLE,
CK_ON = CLICKY_ENABLE,
CK_OFF = CLICKY_DISABLE,
CK_UP = CLICKY_UP,
CK_DOWN = CLICKY_DOWN,
CK_RST = CLICKY_RESET,
AU_ON = QK_AUDIO_ON,
AU_OFF = QK_AUDIO_OFF,
AU_TOGG = QK_AUDIO_TOGGLE,
CK_TOGG = QK_AUDIO_CLICKY_TOGGLE,
CK_ON = QK_AUDIO_CLICKY_ON,
CK_OFF = QK_AUDIO_CLICKY_OFF,
CK_UP = QK_AUDIO_CLICKY_UP,
CK_DOWN = QK_AUDIO_CLICKY_DOWN,
CK_RST = QK_AUDIO_CLICKY_RESET,
MU_ON = QK_MUSIC_ON,
MU_OFF = QK_MUSIC_OFF,
MU_TOGG = QK_MUSIC_TOGGLE,
MU_NEXT = QK_MUSIC_MODE_NEXT,
AU_NEXT = QK_AUDIO_VOICE_NEXT,
AU_PREV = QK_AUDIO_VOICE_PREVIOUS,
MC_0 = QK_MACRO_0,
MC_1 = QK_MACRO_1,
MC_2 = QK_MACRO_2,
Expand Down Expand Up @@ -1139,7 +1148,7 @@ enum qk_keycode_defines {
#define IS_SEQUENCER_KEYCODE(code) ((code) >= SQ_ON && (code) <= SQ_SCLR)
#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) >= AU_ON && (code) <= MUV_DE)
#define IS_AUDIO_KEYCODE(code) ((code) >= QK_AUDIO_ON && (code) <= QK_AUDIO_VOICE_PREVIOUS)
#define IS_STENO_KEYCODE(code) ((code) >= QK_STENO_BOLT && (code) <= QK_STENO_COMB_MAX)
#define IS_MACRO_KEYCODE(code) ((code) >= QK_MACRO_0 && (code) <= QK_MACRO_31)
#define IS_BACKLIGHT_KEYCODE(code) ((code) >= BL_ON && (code) <= BL_BRTG)
Expand Down
10 changes: 5 additions & 5 deletions quantum/process_keycode/process_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ float compute_freq_for_midi_note(uint8_t note) {
}

bool process_audio(uint16_t keycode, keyrecord_t *record) {
if (keycode == AU_ON && record->event.pressed) {
if (keycode == QK_AUDIO_ON && record->event.pressed) {
audio_on();
return false;
}

if (keycode == AU_OFF && record->event.pressed) {
if (keycode == QK_AUDIO_OFF && record->event.pressed) {
audio_off();
return false;
}

if (keycode == AU_TOG && record->event.pressed) {
if (keycode == QK_AUDIO_TOGGLE && record->event.pressed) {
if (is_audio_on()) {
audio_off();
} else {
Expand All @@ -35,13 +35,13 @@ bool process_audio(uint16_t keycode, keyrecord_t *record) {
return false;
}

if (keycode == MUV_IN && record->event.pressed) {
if (keycode == QK_AUDIO_VOICE_NEXT && record->event.pressed) {
voice_iterate();
PLAY_SONG(voice_change_song);
return false;
}

if (keycode == MUV_DE && record->event.pressed) {
if (keycode == QK_AUDIO_VOICE_PREVIOUS && record->event.pressed) {
voice_deiterate();
PLAY_SONG(voice_change_song);
return false;
Expand Down
Loading

0 comments on commit 69fa02c

Please sign in to comment.