diff options
-rw-r--r-- | build_keyboard.mk | 5 | ||||
-rw-r--r-- | keyboards/gonnerd/keymaps/default/keymap.c | 22 | ||||
-rw-r--r-- | keyboards/gonnerd/keymaps/mauin/keymap.c | 50 | ||||
-rw-r--r-- | keyboards/gonnerd/readme.md | 4 | ||||
-rw-r--r-- | keyboards/planck/keymaps/priyadi/Makefile | 3 | ||||
-rw-r--r-- | keyboards/planck/keymaps/priyadi/keymap.c | 4 | ||||
-rw-r--r-- | quantum/fauxclicky.c | 68 | ||||
-rw-r--r-- | quantum/fauxclicky.h | 99 | ||||
-rw-r--r-- | quantum/quantum.c | 24 | ||||
-rw-r--r-- | quantum/quantum_keycodes.h | 7 | ||||
-rw-r--r-- | quantum/template/rules.mk | 1 | ||||
-rw-r--r-- | tmk_core/common/action.c | 13 | ||||
-rw-r--r-- | tmk_core/common/keyboard.c | 6 |
13 files changed, 287 insertions, 19 deletions
diff --git a/build_keyboard.mk b/build_keyboard.mk index 2c64e93a2..c8e82cf0e 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk | |||
@@ -161,6 +161,11 @@ ifeq ($(strip $(AUDIO_ENABLE)), yes) | |||
161 | SRC += $(QUANTUM_DIR)/audio/luts.c | 161 | SRC += $(QUANTUM_DIR)/audio/luts.c |
162 | endif | 162 | endif |
163 | 163 | ||
164 | ifeq ($(strip $(FAUXCLICKY_ENABLE)), yes) | ||
165 | OPT_DEFS += -DFAUXCLICKY_ENABLE | ||
166 | SRC += $(QUANTUM_DIR)/fauxclicky.c | ||
167 | endif | ||
168 | |||
164 | ifeq ($(strip $(UCIS_ENABLE)), yes) | 169 | ifeq ($(strip $(UCIS_ENABLE)), yes) |
165 | OPT_DEFS += -DUCIS_ENABLE | 170 | OPT_DEFS += -DUCIS_ENABLE |
166 | UNICODE_ENABLE = yes | 171 | UNICODE_ENABLE = yes |
diff --git a/keyboards/gonnerd/keymaps/default/keymap.c b/keyboards/gonnerd/keymaps/default/keymap.c index a37005939..d74f949dc 100644 --- a/keyboards/gonnerd/keymaps/default/keymap.c +++ b/keyboards/gonnerd/keymaps/default/keymap.c | |||
@@ -1,14 +1,24 @@ | |||
1 | #include "gonnerd.h" | 1 | #include "gonnerd.h" |
2 | 2 | ||
3 | // Keymap layers | 3 | #define __x__ KC_NO |
4 | 4 | ||
5 | // Keymap layers | ||
5 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | 6 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { |
6 | [0] = KEYMAP_60( /* Base */ | 7 | [0] = KEYMAP_60( /* Base */ |
7 | KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,KC_EQL, KC_BSPC,\ | 8 | KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, \ |
8 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC,KC_RBRC,KC_BSLS,\ | 9 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, \ |
9 | KC_LCTL,KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT,KC_NO, KC_ENT, \ | 10 | KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, __x__, KC_ENT, \ |
10 | KC_LSFT,KC_NO, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH,KC_RSFT,KC_NO, \ | 11 | KC_LSFT, __x__, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, __x__, \ |
11 | KC_LCTL,KC_LGUI,KC_LALT, KC_SPC, KC_RALT,KC_RGUI,MO(1), KC_RCTL), | 12 | KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, MO(1), KC_RCTL \ |
13 | ), | ||
14 | |||
15 | [1] = KEYMAP_60( /* System layer to have access to RESET button */ | ||
16 | RESET, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, \ | ||
17 | __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, \ | ||
18 | __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, \ | ||
19 | __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, \ | ||
20 | __x__, __x__, __x__, __x__, __x__, __x__, KC_TRNS, __x__ \ | ||
21 | ), | ||
12 | }; | 22 | }; |
13 | 23 | ||
14 | const uint16_t PROGMEM fn_actions[] = { | 24 | const uint16_t PROGMEM fn_actions[] = { |
diff --git a/keyboards/gonnerd/keymaps/mauin/keymap.c b/keyboards/gonnerd/keymaps/mauin/keymap.c index 1a1d515a9..5979a7ca4 100644 --- a/keyboards/gonnerd/keymaps/mauin/keymap.c +++ b/keyboards/gonnerd/keymaps/mauin/keymap.c | |||
@@ -23,11 +23,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
23 | * `-----------------------------------------------------------' | 23 | * `-----------------------------------------------------------' |
24 | */ | 24 | */ |
25 | [BASE_LAYER] = KEYMAP_60( | 25 | [BASE_LAYER] = KEYMAP_60( |
26 | KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, \ | 26 | F(0), KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, \ |
27 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, \ | 27 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, \ |
28 | MO(1), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, __x__, KC_ENT, \ | 28 | MO(1), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, __x__, KC_ENT, \ |
29 | KC_LSFT, __x__, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, __x__, \ | 29 | KC_LSFT, __x__, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, __x__, \ |
30 | KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, KC_RALT, MO(3), KC_RCTL \ | 30 | KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, KC_RALT, MO(2), KC_RCTL \ |
31 | ), | 31 | ), |
32 | 32 | ||
33 | /* Layer 1: Function Layer | 33 | /* Layer 1: Function Layer |
@@ -45,10 +45,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
45 | */ | 45 | */ |
46 | [FUNCTION_LAYER] = KEYMAP_60( | 46 | [FUNCTION_LAYER] = KEYMAP_60( |
47 | KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, \ | 47 | KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, \ |
48 | __x__, KC_MPRV, KC_MPLY, KC_MNXT, __x__, __x__, KC_PGUP, KC_HOME, KC_UP, KC_END, __x__, KC_SLCK, KC_PAUS, __x__, \ | 48 | __x__, KC_MPRV, KC_MPLY, KC_MNXT, __x__, __x__, KC_PGUP, KC_HOME, KC_UP, KC_END, __x__, KC_SLCK, KC_PAUS, __x__, \ |
49 | KC_TRNS, KC_MUTE, KC_VOLD, KC_VOLU, __x__, __x__, KC_PGDN, KC_LEFT, KC_DOWN, KC_RGHT, __x__, __x__, __x__, __x__, \ | 49 | KC_TRNS, KC_MUTE, KC_VOLD, KC_VOLU, __x__, __x__, KC_PGDN, KC_LEFT, KC_DOWN, KC_RGHT, __x__, __x__, __x__, __x__, \ |
50 | KC_LSFT, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, \ | 50 | KC_LSFT, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, \ |
51 | KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, __x__, __x__, __x__, __x__ \ | 51 | KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, __x__, __x__, __x__, __x__ \ |
52 | ), | 52 | ), |
53 | 53 | ||
54 | /* Layer 2: System Layer | 54 | /* Layer 2: System Layer |
@@ -69,10 +69,40 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
69 | __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, \ | 69 | __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, \ |
70 | __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, \ | 70 | __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, \ |
71 | __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, \ | 71 | __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, __x__, \ |
72 | __x__, __x__, __x__, __x__, __x__, __x__, KC_TRNS, __x__ \ | 72 | __x__, __x__, __x__, __x__, __x__, __x__, KC_TRNS, __x__ \ |
73 | ), | 73 | ), |
74 | }; | 74 | }; |
75 | 75 | ||
76 | const uint16_t PROGMEM fn_actions[] = { | 76 | enum function_id { |
77 | ESC_GRV, // Makes Esc behave like `~ when pressed with the left GUI modifier. This is the "switch between windows of the same application" key combination in macOS | ||
78 | }; | ||
77 | 79 | ||
80 | const uint16_t PROGMEM fn_actions[] = { | ||
81 | [0] = ACTION_FUNCTION(ESC_GRV), | ||
78 | }; | 82 | }; |
83 | |||
84 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) { | ||
85 | static uint8_t esc_grv_mask; | ||
86 | switch (id) { | ||
87 | case ESC_GRV: | ||
88 | esc_grv_mask = get_mods() & MOD_BIT(KC_LGUI); | ||
89 | if (record->event.pressed) { | ||
90 | if (esc_grv_mask) { | ||
91 | add_key(KC_GRV); | ||
92 | send_keyboard_report(); | ||
93 | } else { | ||
94 | add_key(KC_ESC); | ||
95 | send_keyboard_report(); | ||
96 | } | ||
97 | } else { | ||
98 | if (esc_grv_mask) { | ||
99 | del_key(KC_GRV); | ||
100 | send_keyboard_report(); | ||
101 | } else { | ||
102 | del_key(KC_ESC); | ||
103 | send_keyboard_report(); | ||
104 | } | ||
105 | } | ||
106 | break; | ||
107 | } | ||
108 | } | ||
diff --git a/keyboards/gonnerd/readme.md b/keyboards/gonnerd/readme.md index 1224ff6b0..807df308a 100644 --- a/keyboards/gonnerd/readme.md +++ b/keyboards/gonnerd/readme.md | |||
@@ -11,6 +11,10 @@ It is possible to change the bootloader of the GON NerD with an ISP programmer. | |||
11 | _After changing the bootloader on your GON NerD PCB you will not be able to go back to the original firmware and the official configuration software will | 11 | _After changing the bootloader on your GON NerD PCB you will not be able to go back to the original firmware and the official configuration software will |
12 | not work anymore. You will lose your warranty and official support from GON!_ | 12 | not work anymore. You will lose your warranty and official support from GON!_ |
13 | 13 | ||
14 | ## Reset button | ||
15 | |||
16 | To run the `make dfu` command to flash keymaps onto the board, you need to put the board into DFU mode. As the GON NerD PCBs do not have a reset button on the board to put it into DFU mode, be sure to include a `RESET` button on your keymap. Otherwise you'll have to unscrew your keyboard from the case and short the GND and RST pins. | ||
17 | |||
14 | ## Building | 18 | ## Building |
15 | 19 | ||
16 | Download or clone the whole firmware and navigate to the keyboards/gonnerd folder. Once your dev env is setup, you'll be able to type `make` to generate your .hex - you can then use the Teensy Loader to program your .hex file. | 20 | Download or clone the whole firmware and navigate to the keyboards/gonnerd folder. Once your dev env is setup, you'll be able to type `make` to generate your .hex - you can then use the Teensy Loader to program your .hex file. |
diff --git a/keyboards/planck/keymaps/priyadi/Makefile b/keyboards/planck/keymaps/priyadi/Makefile index 336608b8c..27c2638e2 100644 --- a/keyboards/planck/keymaps/priyadi/Makefile +++ b/keyboards/planck/keymaps/priyadi/Makefile | |||
@@ -10,12 +10,13 @@ COMMAND_ENABLE = no # Commands for debug and configuration | |||
10 | NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | 10 | NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work |
11 | BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality | 11 | BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality |
12 | MIDI_ENABLE = no # MIDI controls | 12 | MIDI_ENABLE = no # MIDI controls |
13 | AUDIO_ENABLE = yes # Audio output on port C6 | 13 | AUDIO_ENABLE = no # Audio output on port C6 |
14 | UNICODE_ENABLE = no # Unicode | 14 | UNICODE_ENABLE = no # Unicode |
15 | UNICODEMAP_ENABLE = yes # Unicode map | 15 | UNICODEMAP_ENABLE = yes # Unicode map |
16 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | 16 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID |
17 | RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. | 17 | RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. |
18 | API_SYSEX_ENABLE = no | 18 | API_SYSEX_ENABLE = no |
19 | FAUXCLICKY_ENABLE = yes | ||
19 | 20 | ||
20 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | 21 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE |
21 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | 22 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
diff --git a/keyboards/planck/keymaps/priyadi/keymap.c b/keyboards/planck/keymaps/priyadi/keymap.c index 2e979221a..13668fd10 100644 --- a/keyboards/planck/keymaps/priyadi/keymap.c +++ b/keyboards/planck/keymaps/priyadi/keymap.c | |||
@@ -268,8 +268,8 @@ const uint32_t PROGMEM unicode_map[] = { | |||
268 | 268 | ||
269 | 269 | ||
270 | // hybrid right-gui & scroll lock (mapped to Compose in OS) | 270 | // hybrid right-gui & scroll lock (mapped to Compose in OS) |
271 | #undef KC_RCTL | 271 | #undef KC_RALT |
272 | #define KC_RCTL MT(MOD_LCTL, KC_SLCK) | 272 | #define KC_RALT MT(MOD_RALT, KC_SLCK) |
273 | 273 | ||
274 | // keymaps | 274 | // keymaps |
275 | 275 | ||
diff --git a/quantum/fauxclicky.c b/quantum/fauxclicky.c new file mode 100644 index 000000000..13273e705 --- /dev/null +++ b/quantum/fauxclicky.c | |||
@@ -0,0 +1,68 @@ | |||
1 | /* | ||
2 | Copyright 2017 Priyadi Iman Nurcahyo | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation, either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | This program is distributed in the hope that it will be useful, | ||
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | GNU General Public License for more details. | ||
12 | You should have received a copy of the GNU General Public License | ||
13 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
14 | */ | ||
15 | |||
16 | #include <avr/interrupt.h> | ||
17 | #include <avr/io.h> | ||
18 | #include <timer.h> | ||
19 | #include <fauxclicky.h> | ||
20 | #include <stdbool.h> | ||
21 | #include <musical_notes.h> | ||
22 | |||
23 | __attribute__ ((weak)) | ||
24 | float fauxclicky_pressed_note[2] = MUSICAL_NOTE(_F3, 2); | ||
25 | __attribute__ ((weak)) | ||
26 | float fauxclicky_released_note[2] = MUSICAL_NOTE(_A3, 2); | ||
27 | __attribute__ ((weak)) | ||
28 | float fauxclicky_beep_note[2] = MUSICAL_NOTE(_C3, 2); | ||
29 | |||
30 | bool fauxclicky_enabled = true; | ||
31 | uint16_t note_start = 0; | ||
32 | bool note_playing = false; | ||
33 | uint16_t note_period = 0; | ||
34 | |||
35 | void fauxclicky_init() | ||
36 | { | ||
37 | // Set port PC6 (OC3A and /OC4A) as output | ||
38 | DDRC |= _BV(PORTC6); | ||
39 | |||
40 | // TCCR3A / TCCR3B: Timer/Counter #3 Control Registers | ||
41 | TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30); | ||
42 | TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30); | ||
43 | } | ||
44 | |||
45 | void fauxclicky_stop() | ||
46 | { | ||
47 | FAUXCLICKY_DISABLE_OUTPUT; | ||
48 | note_playing = false; | ||
49 | } | ||
50 | |||
51 | void fauxclicky_play(float note[2]) { | ||
52 | if (!fauxclicky_enabled) return; | ||
53 | if (note_playing) fauxclicky_stop(); | ||
54 | FAUXCLICKY_TIMER_PERIOD = (uint16_t)(((float)F_CPU) / (note[0] * FAUXCLICKY_CPU_PRESCALER)); | ||
55 | FAUXCLICKY_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (note[0] * FAUXCLICKY_CPU_PRESCALER)) / 2); | ||
56 | note_playing = true; | ||
57 | note_period = (note[1] / 16) * (60 / (float)FAUXCLICKY_TEMPO) * 100; // check this | ||
58 | note_start = timer_read(); | ||
59 | FAUXCLICKY_ENABLE_OUTPUT; | ||
60 | } | ||
61 | |||
62 | void fauxclicky_check() { | ||
63 | if (!note_playing) return; | ||
64 | |||
65 | if (timer_elapsed(note_start) > note_period) { | ||
66 | fauxclicky_stop(); | ||
67 | } | ||
68 | } | ||
diff --git a/quantum/fauxclicky.h b/quantum/fauxclicky.h new file mode 100644 index 000000000..109bd0d83 --- /dev/null +++ b/quantum/fauxclicky.h | |||
@@ -0,0 +1,99 @@ | |||
1 | /* | ||
2 | Copyright 2017 Priyadi Iman Nurcahyo | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation, either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | This program is distributed in the hope that it will be useful, | ||
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | GNU General Public License for more details. | ||
12 | You should have received a copy of the GNU General Public License | ||
13 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
14 | */ | ||
15 | |||
16 | #ifdef AUDIO_ENABLE | ||
17 | #error "AUDIO_ENABLE and FAUXCLICKY_ENABLE cannot be both enabled" | ||
18 | #endif | ||
19 | |||
20 | #include "musical_notes.h" | ||
21 | #include "stdbool.h" | ||
22 | |||
23 | __attribute__ ((weak)) | ||
24 | float fauxclicky_pressed_note[2]; | ||
25 | __attribute__ ((weak)) | ||
26 | float fauxclicky_released_note[2]; | ||
27 | __attribute__ ((weak)) | ||
28 | float fauxclicky_beep_note[2]; | ||
29 | |||
30 | bool fauxclicky_enabled; | ||
31 | |||
32 | // | ||
33 | // tempo in BPM | ||
34 | // | ||
35 | |||
36 | #ifndef FAUXCLICKY_TEMPO | ||
37 | #define FAUXCLICKY_TEMPO TEMPO_DEFAULT | ||
38 | #endif | ||
39 | |||
40 | // beep on press | ||
41 | #define FAUXCLICKY_ACTION_PRESS fauxclicky_play(fauxclicky_pressed_note) | ||
42 | |||
43 | // beep on release | ||
44 | #define FAUXCLICKY_ACTION_RELEASE fauxclicky_play(fauxclicky_released_note) | ||
45 | |||
46 | // general purpose beep | ||
47 | #define FAUXCLICKY_BEEP fauxclicky_play(fauxclicky_beep_note) | ||
48 | |||
49 | // enable | ||
50 | #define FAUXCLICKY_ON fauxclicky_enabled = true | ||
51 | |||
52 | // disable | ||
53 | #define FAUXCLICKY_OFF do { \ | ||
54 | fauxclicky_enabled = false; \ | ||
55 | fauxclicky_stop(); \ | ||
56 | } while (0) | ||
57 | |||
58 | // toggle | ||
59 | #define FAUXCLICKY_TOGGLE do { \ | ||
60 | if (fauxclicky_enabled) { \ | ||
61 | FAUXCLICKY_OFF; \ | ||
62 | } else { \ | ||
63 | FAUXCLICKY_ON; \ | ||
64 | } \ | ||
65 | } while (0) | ||
66 | |||
67 | // | ||
68 | // pin configuration | ||
69 | // | ||
70 | |||
71 | #ifndef FAUXCLICKY_CPU_PRESCALER | ||
72 | #define FAUXCLICKY_CPU_PRESCALER 8 | ||
73 | #endif | ||
74 | |||
75 | #ifndef FAUXCLICKY_ENABLE_OUTPUT | ||
76 | #define FAUXCLICKY_ENABLE_OUTPUT TCCR3A |= _BV(COM3A1); | ||
77 | #endif | ||
78 | |||
79 | #ifndef FAUXCLICKY_DISABLE_OUTPUT | ||
80 | #define FAUXCLICKY_DISABLE_OUTPUT TCCR3A &= ~(_BV(COM3A1) | _BV(COM3A0)); | ||
81 | #endif | ||
82 | |||
83 | #ifndef FAUXCLICKY_TIMER_PERIOD | ||
84 | #define FAUXCLICKY_TIMER_PERIOD ICR3 | ||
85 | #endif | ||
86 | |||
87 | #ifndef FAUXCLICKY_DUTY_CYCLE | ||
88 | #define FAUXCLICKY_DUTY_CYCLE OCR3A | ||
89 | #endif | ||
90 | |||
91 | // | ||
92 | // definitions | ||
93 | // | ||
94 | |||
95 | void fauxclicky_init(void); | ||
96 | void fauxclicky_stop(void); | ||
97 | void fauxclicky_play(float note[2]); | ||
98 | void fauxclicky_check(void); | ||
99 | |||
diff --git a/quantum/quantum.c b/quantum/quantum.c index 45ea8cb73..2088c10c9 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
@@ -7,6 +7,10 @@ | |||
7 | #define TAPPING_TERM 200 | 7 | #define TAPPING_TERM 200 |
8 | #endif | 8 | #endif |
9 | 9 | ||
10 | #ifdef FAUXCLICKY_ENABLE | ||
11 | #include "fauxclicky.h" | ||
12 | #endif | ||
13 | |||
10 | static void do_code16 (uint16_t code, void (*f) (uint8_t)) { | 14 | static void do_code16 (uint16_t code, void (*f) (uint8_t)) { |
11 | switch (code) { | 15 | switch (code) { |
12 | case QK_MODS ... QK_MODS_MAX: | 16 | case QK_MODS ... QK_MODS_MAX: |
@@ -196,6 +200,26 @@ bool process_record_quantum(keyrecord_t *record) { | |||
196 | } | 200 | } |
197 | return false; | 201 | return false; |
198 | break; | 202 | break; |
203 | #ifdef FAUXCLICKY_ENABLE | ||
204 | case FC_TOG: | ||
205 | if (record->event.pressed) { | ||
206 | FAUXCLICKY_TOGGLE; | ||
207 | } | ||
208 | return false; | ||
209 | break; | ||
210 | case FC_ON: | ||
211 | if (record->event.pressed) { | ||
212 | FAUXCLICKY_ON; | ||
213 | } | ||
214 | return false; | ||
215 | break; | ||
216 | case FC_OFF: | ||
217 | if (record->event.pressed) { | ||
218 | FAUXCLICKY_OFF; | ||
219 | } | ||
220 | return false; | ||
221 | break; | ||
222 | #endif | ||
199 | #ifdef RGBLIGHT_ENABLE | 223 | #ifdef RGBLIGHT_ENABLE |
200 | case RGB_TOG: | 224 | case RGB_TOG: |
201 | if (record->event.pressed) { | 225 | if (record->event.pressed) { |
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index ab2e79026..cc7a5013f 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h | |||
@@ -86,6 +86,13 @@ enum quantum_keycodes { | |||
86 | AU_OFF, | 86 | AU_OFF, |
87 | AU_TOG, | 87 | AU_TOG, |
88 | 88 | ||
89 | #ifdef FAUXCLICKY_ENABLE | ||
90 | // Faux clicky | ||
91 | FC_ON, | ||
92 | FC_OFF, | ||
93 | FC_TOG, | ||
94 | #endif | ||
95 | |||
89 | // Music mode on/off/toggle | 96 | // Music mode on/off/toggle |
90 | MU_ON, | 97 | MU_ON, |
91 | MU_OFF, | 98 | MU_OFF, |
diff --git a/quantum/template/rules.mk b/quantum/template/rules.mk index 55898147d..bad3387bf 100644 --- a/quantum/template/rules.mk +++ b/quantum/template/rules.mk | |||
@@ -65,3 +65,4 @@ MIDI_ENABLE ?= no # MIDI controls | |||
65 | UNICODE_ENABLE ?= no # Unicode | 65 | UNICODE_ENABLE ?= no # Unicode |
66 | BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID | 66 | BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID |
67 | AUDIO_ENABLE ?= no # Audio output on port C6 | 67 | AUDIO_ENABLE ?= no # Audio output on port C6 |
68 | FAUXCLICKY_ENABLE ?= no # Use buzzer to emulate clicky switches | ||
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index f03670a7f..94de36918 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c | |||
@@ -33,6 +33,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
33 | #include "nodebug.h" | 33 | #include "nodebug.h" |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #ifdef FAUXCLICKY_ENABLE | ||
37 | #include <fauxclicky.h> | ||
38 | #endif | ||
36 | 39 | ||
37 | void action_exec(keyevent_t event) | 40 | void action_exec(keyevent_t event) |
38 | { | 41 | { |
@@ -41,6 +44,16 @@ void action_exec(keyevent_t event) | |||
41 | dprint("EVENT: "); debug_event(event); dprintln(); | 44 | dprint("EVENT: "); debug_event(event); dprintln(); |
42 | } | 45 | } |
43 | 46 | ||
47 | #ifdef FAUXCLICKY_ENABLE | ||
48 | if (IS_PRESSED(event)) { | ||
49 | FAUXCLICKY_ACTION_PRESS; | ||
50 | } | ||
51 | if (IS_RELEASED(event)) { | ||
52 | FAUXCLICKY_ACTION_RELEASE; | ||
53 | } | ||
54 | fauxclicky_check(); | ||
55 | #endif | ||
56 | |||
44 | #ifdef ONEHAND_ENABLE | 57 | #ifdef ONEHAND_ENABLE |
45 | if (!IS_NOEVENT(event)) { | 58 | if (!IS_NOEVENT(event)) { |
46 | process_hand_swap(&event); | 59 | process_hand_swap(&event); |
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 3aa82231b..eac1f1dd8 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c | |||
@@ -51,6 +51,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
51 | #ifdef RGBLIGHT_ENABLE | 51 | #ifdef RGBLIGHT_ENABLE |
52 | # include "rgblight.h" | 52 | # include "rgblight.h" |
53 | #endif | 53 | #endif |
54 | #ifdef FAUXCLICKY_ENABLE | ||
55 | # include "fauxclicky.h" | ||
56 | #endif | ||
54 | #ifdef SERIAL_LINK_ENABLE | 57 | #ifdef SERIAL_LINK_ENABLE |
55 | # include "serial_link/system/serial_link.h" | 58 | # include "serial_link/system/serial_link.h" |
56 | #endif | 59 | #endif |
@@ -108,6 +111,9 @@ void keyboard_init(void) { | |||
108 | #ifdef RGBLIGHT_ENABLE | 111 | #ifdef RGBLIGHT_ENABLE |
109 | rgblight_init(); | 112 | rgblight_init(); |
110 | #endif | 113 | #endif |
114 | #ifdef FAUXCLICKY_ENABLE | ||
115 | fauxclicky_init(); | ||
116 | #endif | ||
111 | #if defined(NKRO_ENABLE) && defined(FORCE_NKRO) | 117 | #if defined(NKRO_ENABLE) && defined(FORCE_NKRO) |
112 | keymap_config.nkro = 1; | 118 | keymap_config.nkro = 1; |
113 | #endif | 119 | #endif |