Skip to content

Commit a0309db

Browse files
drashnaskullydazed
authored andcommitted
Add On/Off keycodes
1 parent cfb1b35 commit a0309db

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

docs/feature_audio.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,16 @@ You can completely disable Music Mode as well. This is useful, if you're pressed
119119

120120
#define NO_MUSIC_MODE
121121

122-
## Faux Click
122+
## Audio Click
123123

124124
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.
125125

126126
* `CK_TOGG` - Toggles the status (will play sound if enabled)
127-
* `CK_RST` - Resets the frequency to the default state
128-
* `CK_UP` - Increases the frequency of the clicks
129-
* `CK_DOWN` - Decreases the frequency of the clicks
127+
* `CK_ON` - Turns on Audio Click (plays sound)
128+
* `CK_OFF` - Turns off Audio Click (doesn't play sound)
129+
* `CK_RST` - Resets the frequency to the default state (plays sound at default frequency)
130+
* `CK_UP` - Increases the frequency of the clicks (plays sound at new frequency)
131+
* `CK_DOWN` - Decreases the frequency of the clicks (plays sound at new frequency)
130132

131133

132134
The feature is disabled by default, to save space. To enable it, add this to your `config.h`:
@@ -142,7 +144,7 @@ You can configure the default, min and max frequencies, the stepping and built i
142144
| `AUDIO_CLICKY_FREQ_MIN` | 65.0f | Sets the lowest frequency (under 60f are a bit buggy). |
143145
| `AUDIO_CLICKY_FREQ_MAX` | 1500.0f | Sets the the highest frequency. Too high may result in coworkers attacking you. |
144146
| `AUDIO_CLICKY_FREQ_FACTOR` | 1.18921f| Sets the stepping of UP/DOWN key codes. |
145-
| `AUDIO_CLICKY_FREQ_RANDOMNESS` | 0.05f | Sets a factor of randomness for the clicks, Setting this to `0f` will make each click identical. |
147+
| `AUDIO_CLICKY_FREQ_RANDOMNESS` | 0.05f | Sets a factor of randomness for the clicks, Setting this to `0f` will make each click identical, and `1.0f` will make this sound much like the 90's computer screen scrolling/typing effect. |
146148

147149

148150

quantum/process_keycode/process_clicky.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@ void clicky_freq_reset(void) {
5656
clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT;
5757
}
5858

59-
void clicky_freq_toggle(void) {
59+
void clicky_toggle(void) {
6060
audio_config.clicky_enable ^= 1;
6161
eeconfig_update_audio(audio_config.raw);
6262
}
6363

64-
void clicky_freq_on(void) {
64+
void clicky_on(void) {
6565
audio_config.clicky_enable = 1;
6666
eeconfig_update_audio(audio_config.raw);
6767
}
6868

69-
void clicky_freq_off(void) {
69+
void clicky_off(void) {
7070
audio_config.clicky_enable = 0;
7171
eeconfig_update_audio(audio_config.raw);
7272
}
@@ -76,7 +76,10 @@ bool is_clicky_on(void) {
7676
}
7777

7878
bool process_clicky(uint16_t keycode, keyrecord_t *record) {
79-
if (keycode == CLICKY_TOGGLE && record->event.pressed) { clicky_freq_toggle(); }
79+
if (keycode == CLICKY_TOGGLE && record->event.pressed) { clicky_toggle(); }
80+
81+
if (keycode == CLICKY_ENABLE && record->event.pressed) { clicky_on(); }
82+
if (keycode == CLICKY_DISABLE && record->event.pressed) { clicky_off(); }
8083

8184
if (keycode == CLICKY_RESET && record->event.pressed) { clicky_freq_reset(); }
8285

quantum/process_keycode/process_clicky.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ bool process_clicky(uint16_t keycode, keyrecord_t *record);
77
void clicky_freq_up(void);
88
void clicky_freq_down(void);
99
void clicky_freq_reset(void);
10-
void clicky_freq_toggle(void);
11-
void clicky_freq_on(void);
12-
void clicky_freq_off(void);
10+
11+
void clicky_toggle(void);
12+
void clicky_on(void);
13+
void clicky_off(void);
1314

1415
bool is_clicky_on(void);
1516

quantum/quantum_keycodes.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,13 @@ enum quantum_keycodes {
139139

140140
// Faux clicky as part of main audio feature
141141
CLICKY_TOGGLE,
142+
CLICKY_ENABLE,
143+
CLICKY_DISABLE,
142144
CLICKY_UP,
143145
CLICKY_DOWN,
144146
CLICKY_RESET,
145147

148+
146149
#ifdef FAUXCLICKY_ENABLE
147150
// Faux clicky
148151
FC_ON,
@@ -571,6 +574,8 @@ enum quantum_keycodes {
571574
#define CK_RST CLICKY_RESET
572575
#define CK_UP CLICKY_UP
573576
#define CK_DOWN CLICKY_DOWN
577+
#define CK_ON CLICKY_ENABLE
578+
#define CK_OFF CLICKY_DISABLE
574579

575580
#define RGB_MOD RGB_MODE_FORWARD
576581
#define RGB_SMOD RGB_MODE_FORWARD

0 commit comments

Comments
 (0)