summaryrefslogtreecommitdiffstats
path: root/quantum/process_keycode
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2018-05-31 21:24:10 +0200
committerskullydazed <skullydazed@users.noreply.github.com>2018-09-25 22:28:36 +0200
commitcfb1b353eef290ea4eddd7cfcb4617ca25d440d2 (patch)
tree403f968d510db001e9a81f022415a3bfdfb6bdae /quantum/process_keycode
parente72e4b6920299176a322a2862f930b7ee5f73dff (diff)
downloadqmk_firmware-cfb1b353eef290ea4eddd7cfcb4617ca25d440d2.tar.gz
qmk_firmware-cfb1b353eef290ea4eddd7cfcb4617ca25d440d2.tar.xz
Add functions so you can configure programatically
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r--quantum/process_keycode/process_clicky.c60
-rw-r--r--quantum/process_keycode/process_clicky.h9
2 files changed, 51 insertions, 18 deletions
diff --git a/quantum/process_keycode/process_clicky.c b/quantum/process_keycode/process_clicky.c
index bd2f1b3b3..b3c8d890e 100644
--- a/quantum/process_keycode/process_clicky.c
+++ b/quantum/process_keycode/process_clicky.c
@@ -38,29 +38,53 @@ void clicky_play(void) {
PLAY_SONG(clicky_song);
}
+void clicky_freq_up(void) {
+ float new_freq = clicky_freq * AUDIO_CLICKY_FREQ_FACTOR;
+ if (new_freq < AUDIO_CLICKY_FREQ_MAX) {
+ clicky_freq = new_freq;
+ }
+}
+
+void clicky_freq_down(void) {
+ float new_freq = clicky_freq / AUDIO_CLICKY_FREQ_FACTOR;
+ if (new_freq > AUDIO_CLICKY_FREQ_MIN) {
+ clicky_freq = new_freq;
+ }
+}
+
+void clicky_freq_reset(void) {
+ clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT;
+}
+
+void clicky_freq_toggle(void) {
+ audio_config.clicky_enable ^= 1;
+ eeconfig_update_audio(audio_config.raw);
+}
+
+void clicky_freq_on(void) {
+ audio_config.clicky_enable = 1;
+ eeconfig_update_audio(audio_config.raw);
+}
+
+void clicky_freq_off(void) {
+ audio_config.clicky_enable = 0;
+ eeconfig_update_audio(audio_config.raw);
+}
+
+bool is_clicky_on(void) {
+ return (audio_config.clicky_enable != 0);
+}
+
bool process_clicky(uint16_t keycode, keyrecord_t *record) {
- if (keycode == CLICKY_TOGGLE && record->event.pressed) {
- audio_config.clicky ^= 1;
- eeconfig_update_audio(audio_config.raw);
- }
+ if (keycode == CLICKY_TOGGLE && record->event.pressed) { clicky_freq_toggle(); }
- if (keycode == CLICKY_RESET && record->event.pressed) { clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT; }
+ if (keycode == CLICKY_RESET && record->event.pressed) { clicky_freq_reset(); }
- if (keycode == CLICKY_UP && record->event.pressed) {
- float new_freq = clicky_freq * AUDIO_CLICKY_FREQ_FACTOR;
- if (new_freq < AUDIO_CLICKY_FREQ_MAX) {
- clicky_freq = new_freq;
- }
- }
- if (keycode == CLICKY_DOWN && record->event.pressed) {
- float new_freq = clicky_freq / AUDIO_CLICKY_FREQ_FACTOR;
- if (new_freq > AUDIO_CLICKY_FREQ_MIN) {
- clicky_freq = new_freq;
- }
- }
+ if (keycode == CLICKY_UP && record->event.pressed) { clicky_freq_up(); }
+ if (keycode == CLICKY_DOWN && record->event.pressed) { clicky_freq_down(); }
- if ( audio_config.clicky ) {
+ if ( audio_config.clicky_enable ) {
if (record->event.pressed) {
clicky_play();;
}
diff --git a/quantum/process_keycode/process_clicky.h b/quantum/process_keycode/process_clicky.h
index e274af56f..6ee3cc5d9 100644
--- a/quantum/process_keycode/process_clicky.h
+++ b/quantum/process_keycode/process_clicky.h
@@ -4,4 +4,13 @@
void clicky_play(void);
bool process_clicky(uint16_t keycode, keyrecord_t *record);
+void clicky_freq_up(void);
+void clicky_freq_down(void);
+void clicky_freq_reset(void);
+void clicky_freq_toggle(void);
+void clicky_freq_on(void);
+void clicky_freq_off(void);
+
+bool is_clicky_on(void);
+
#endif