diff options
| author | Drashna Jaelre <drashna@live.com> | 2018-05-31 12:24:10 -0700 |
|---|---|---|
| committer | skullydazed <skullydazed@users.noreply.github.com> | 2018-09-25 13:28:36 -0700 |
| commit | cfb1b353eef290ea4eddd7cfcb4617ca25d440d2 (patch) | |
| tree | 403f968d510db001e9a81f022415a3bfdfb6bdae /quantum/process_keycode/process_clicky.c | |
| parent | e72e4b6920299176a322a2862f930b7ee5f73dff (diff) | |
| download | qmk_firmware-cfb1b353eef290ea4eddd7cfcb4617ca25d440d2.tar.gz qmk_firmware-cfb1b353eef290ea4eddd7cfcb4617ca25d440d2.zip | |
Add functions so you can configure programatically
Diffstat (limited to 'quantum/process_keycode/process_clicky.c')
| -rw-r--r-- | quantum/process_keycode/process_clicky.c | 60 |
1 files changed, 42 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) { | |||
| 38 | PLAY_SONG(clicky_song); | 38 | PLAY_SONG(clicky_song); |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | void clicky_freq_up(void) { | ||
| 42 | float new_freq = clicky_freq * AUDIO_CLICKY_FREQ_FACTOR; | ||
| 43 | if (new_freq < AUDIO_CLICKY_FREQ_MAX) { | ||
| 44 | clicky_freq = new_freq; | ||
| 45 | } | ||
| 46 | } | ||
| 47 | |||
| 48 | void clicky_freq_down(void) { | ||
| 49 | float new_freq = clicky_freq / AUDIO_CLICKY_FREQ_FACTOR; | ||
| 50 | if (new_freq > AUDIO_CLICKY_FREQ_MIN) { | ||
| 51 | clicky_freq = new_freq; | ||
| 52 | } | ||
| 53 | } | ||
| 54 | |||
| 55 | void clicky_freq_reset(void) { | ||
| 56 | clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT; | ||
| 57 | } | ||
| 58 | |||
| 59 | void clicky_freq_toggle(void) { | ||
| 60 | audio_config.clicky_enable ^= 1; | ||
| 61 | eeconfig_update_audio(audio_config.raw); | ||
| 62 | } | ||
| 63 | |||
| 64 | void clicky_freq_on(void) { | ||
| 65 | audio_config.clicky_enable = 1; | ||
| 66 | eeconfig_update_audio(audio_config.raw); | ||
| 67 | } | ||
| 68 | |||
| 69 | void clicky_freq_off(void) { | ||
| 70 | audio_config.clicky_enable = 0; | ||
| 71 | eeconfig_update_audio(audio_config.raw); | ||
| 72 | } | ||
| 73 | |||
| 74 | bool is_clicky_on(void) { | ||
| 75 | return (audio_config.clicky_enable != 0); | ||
| 76 | } | ||
| 77 | |||
| 41 | bool process_clicky(uint16_t keycode, keyrecord_t *record) { | 78 | bool process_clicky(uint16_t keycode, keyrecord_t *record) { |
| 42 | if (keycode == CLICKY_TOGGLE && record->event.pressed) { | 79 | if (keycode == CLICKY_TOGGLE && record->event.pressed) { clicky_freq_toggle(); } |
| 43 | audio_config.clicky ^= 1; | ||
| 44 | eeconfig_update_audio(audio_config.raw); | ||
| 45 | } | ||
| 46 | 80 | ||
| 47 | if (keycode == CLICKY_RESET && record->event.pressed) { clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT; } | 81 | if (keycode == CLICKY_RESET && record->event.pressed) { clicky_freq_reset(); } |
| 48 | 82 | ||
| 49 | if (keycode == CLICKY_UP && record->event.pressed) { | 83 | if (keycode == CLICKY_UP && record->event.pressed) { clicky_freq_up(); } |
| 50 | float new_freq = clicky_freq * AUDIO_CLICKY_FREQ_FACTOR; | 84 | if (keycode == CLICKY_DOWN && record->event.pressed) { clicky_freq_down(); } |
| 51 | if (new_freq < AUDIO_CLICKY_FREQ_MAX) { | ||
| 52 | clicky_freq = new_freq; | ||
| 53 | } | ||
| 54 | } | ||
| 55 | if (keycode == CLICKY_DOWN && record->event.pressed) { | ||
| 56 | float new_freq = clicky_freq / AUDIO_CLICKY_FREQ_FACTOR; | ||
| 57 | if (new_freq > AUDIO_CLICKY_FREQ_MIN) { | ||
| 58 | clicky_freq = new_freq; | ||
| 59 | } | ||
| 60 | } | ||
| 61 | 85 | ||
| 62 | 86 | ||
| 63 | if ( audio_config.clicky ) { | 87 | if ( audio_config.clicky_enable ) { |
| 64 | if (record->event.pressed) { | 88 | if (record->event.pressed) { |
| 65 | clicky_play();; | 89 | clicky_play();; |
| 66 | } | 90 | } |
