diff options
25 files changed, 759 insertions, 608 deletions
diff --git a/.travis.yml b/.travis.yml index f5ae78c89..955f69679 100644 --- a/.travis.yml +++ b/.travis.yml | |||
@@ -10,7 +10,7 @@ env: | |||
10 | global: | 10 | global: |
11 | - secure: vBTSL34BDPxDilKUuTXqU4CJ26Pv5hogD2nghatkxSQkI1/jbdnLj/DQdPUrMJFDIY6TK3AltsBx72MaMsLQ1JO/Ou24IeHINHXzUC1FlS9yQa48cpxnhX5kzXNyGs3oa0qaFbvnr7RgYRWtmD52n4bIZuSuW+xpBv05x2OCizdT2ZonH33nATaHGFasxROm4qYZ241VfzcUv766V6RVHgL4x9V08warugs+RENVkfzxxwhk3NmkrISabze0gSVJLHBPHxroZC6EUcf/ocobcuDrCwFqtEt90i7pNIAFUE7gZsN2uE75LmpzAWin21G7lLPcPL2k4FJVd8an1HiP2WmscJU6U89fOfMb2viObnKcCzebozBCmKGtHEuXZo9FcReOx49AnQSpmESJGs+q2dL/FApkTjQiyT4J6O5dJpoww0/r57Wx0cmmqjETKBb5rSgXM51Etk3wO09mvcPHsEwrT7qH8r9XWdyCDoEn7FCLX3/LYnf/D4SmZ633YPl5gv3v9XEwxR5+04akjgnvWDSNIaDbWBdxHNb7l4pMc+WR1bwCyMyA7KXj0RrftEGOrm9ZRLe6BkbT4cycA+j77nbPOMcyZChliV9pPQos+4TOJoTzcK2L8yWVoY409aDNVuAjdP6Yum0R2maBGl/etLmIMpJC35C5/lZ+dUNjJAM= | 11 | - secure: vBTSL34BDPxDilKUuTXqU4CJ26Pv5hogD2nghatkxSQkI1/jbdnLj/DQdPUrMJFDIY6TK3AltsBx72MaMsLQ1JO/Ou24IeHINHXzUC1FlS9yQa48cpxnhX5kzXNyGs3oa0qaFbvnr7RgYRWtmD52n4bIZuSuW+xpBv05x2OCizdT2ZonH33nATaHGFasxROm4qYZ241VfzcUv766V6RVHgL4x9V08warugs+RENVkfzxxwhk3NmkrISabze0gSVJLHBPHxroZC6EUcf/ocobcuDrCwFqtEt90i7pNIAFUE7gZsN2uE75LmpzAWin21G7lLPcPL2k4FJVd8an1HiP2WmscJU6U89fOfMb2viObnKcCzebozBCmKGtHEuXZo9FcReOx49AnQSpmESJGs+q2dL/FApkTjQiyT4J6O5dJpoww0/r57Wx0cmmqjETKBb5rSgXM51Etk3wO09mvcPHsEwrT7qH8r9XWdyCDoEn7FCLX3/LYnf/D4SmZ633YPl5gv3v9XEwxR5+04akjgnvWDSNIaDbWBdxHNb7l4pMc+WR1bwCyMyA7KXj0RrftEGOrm9ZRLe6BkbT4cycA+j77nbPOMcyZChliV9pPQos+4TOJoTzcK2L8yWVoY409aDNVuAjdP6Yum0R2maBGl/etLmIMpJC35C5/lZ+dUNjJAM= |
12 | script: | 12 | script: |
13 | - make all-keyboards quick AUTOGEN=true | 13 | - make all-keyboards-quick AUTOGEN=true |
14 | addons: | 14 | addons: |
15 | apt: | 15 | apt: |
16 | packages: | 16 | packages: |
@@ -120,11 +120,15 @@ else | |||
120 | endif | 120 | endif |
121 | 121 | ||
122 | 122 | ||
123 | |||
124 | ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","") | 123 | ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","") |
125 | CONFIG_H = $(KEYMAP_PATH)/config.h | 124 | CONFIG_H = $(KEYMAP_PATH)/config.h |
126 | else | 125 | else |
127 | CONFIG_H = $(KEYBOARD_PATH)/config.h | 126 | CONFIG_H = $(KEYBOARD_PATH)/config.h |
127 | ifdef SUBPROJECT | ||
128 | ifneq ("$(wildcard $(SUBPROJECT_PATH)/$(SUBPROJECT).c)","") | ||
129 | CONFIG_H = $(SUBPROJECT_PATH)/config.h | ||
130 | endif | ||
131 | endif | ||
128 | endif | 132 | endif |
129 | 133 | ||
130 | # # project specific files | 134 | # # project specific files |
@@ -132,7 +136,16 @@ SRC += $(KEYBOARD_FILE) \ | |||
132 | $(KEYMAP_FILE) \ | 136 | $(KEYMAP_FILE) \ |
133 | $(QUANTUM_DIR)/quantum.c \ | 137 | $(QUANTUM_DIR)/quantum.c \ |
134 | $(QUANTUM_DIR)/keymap.c \ | 138 | $(QUANTUM_DIR)/keymap.c \ |
135 | $(QUANTUM_DIR)/keycode_config.c | 139 | $(QUANTUM_DIR)/keycode_config.c \ |
140 | $(QUANTUM_DIR)/process_keycode/process_leader.c | ||
141 | |||
142 | ifdef SUBPROJECT | ||
143 | SRC += $(SUBPROJECT_FILE) | ||
144 | endif | ||
145 | |||
146 | ifdef SUBPROJECT | ||
147 | SRC += $(SUBPROJECT_FILE) | ||
148 | endif | ||
136 | 149 | ||
137 | ifdef SUBPROJECT | 150 | ifdef SUBPROJECT |
138 | SRC += $(SUBPROJECT_FILE) | 151 | SRC += $(SUBPROJECT_FILE) |
@@ -142,16 +155,33 @@ ifndef CUSTOM_MATRIX | |||
142 | SRC += $(QUANTUM_DIR)/matrix.c | 155 | SRC += $(QUANTUM_DIR)/matrix.c |
143 | endif | 156 | endif |
144 | 157 | ||
158 | ifeq ($(strip $(MIDI_ENABLE)), yes) | ||
159 | OPT_DEFS += -DMIDI_ENABLE | ||
160 | SRC += $(QUANTUM_DIR)/process_keycode/process_audio.c | ||
161 | endif | ||
162 | |||
145 | ifeq ($(strip $(AUDIO_ENABLE)), yes) | 163 | ifeq ($(strip $(AUDIO_ENABLE)), yes) |
164 | OPT_DEFS += -DAUDIO_ENABLE | ||
165 | SRC += $(QUANTUM_DIR)/process_keycode/process_music.c | ||
146 | SRC += $(QUANTUM_DIR)/audio/audio.c | 166 | SRC += $(QUANTUM_DIR)/audio/audio.c |
147 | SRC += $(QUANTUM_DIR)/audio/voices.c | 167 | SRC += $(QUANTUM_DIR)/audio/voices.c |
148 | SRC += $(QUANTUM_DIR)/audio/luts.c | 168 | SRC += $(QUANTUM_DIR)/audio/luts.c |
149 | endif | 169 | endif |
150 | 170 | ||
171 | ifeq ($(strip $(UNICODE_ENABLE)), yes) | ||
172 | OPT_DEFS += -DUNICODE_ENABLE | ||
173 | SRC += $(QUANTUM_DIR)/process_keycode/process_unicode.c | ||
174 | endif | ||
175 | |||
151 | ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) | 176 | ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) |
177 | OPT_DEFS += -DRGBLIGHT_ENABLE | ||
152 | SRC += $(QUANTUM_DIR)/light_ws2812.c | 178 | SRC += $(QUANTUM_DIR)/light_ws2812.c |
153 | SRC += $(QUANTUM_DIR)/rgblight.c | 179 | SRC += $(QUANTUM_DIR)/rgblight.c |
154 | OPT_DEFS += -DRGBLIGHT_ENABLE | 180 | endif |
181 | |||
182 | ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) | ||
183 | OPT_DEFS += -DTAP_DANCE_ENABLE | ||
184 | SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c | ||
155 | endif | 185 | endif |
156 | 186 | ||
157 | # Optimize size but this may cause error "relocation truncated to fit" | 187 | # Optimize size but this may cause error "relocation truncated to fit" |
@@ -168,6 +198,7 @@ VPATH += $(TMK_PATH) | |||
168 | VPATH += $(QUANTUM_PATH) | 198 | VPATH += $(QUANTUM_PATH) |
169 | VPATH += $(QUANTUM_PATH)/keymap_extras | 199 | VPATH += $(QUANTUM_PATH)/keymap_extras |
170 | VPATH += $(QUANTUM_PATH)/audio | 200 | VPATH += $(QUANTUM_PATH)/audio |
201 | VPATH += $(QUANTUM_PATH)/process_keycode | ||
171 | 202 | ||
172 | include $(TMK_PATH)/protocol/lufa.mk | 203 | include $(TMK_PATH)/protocol/lufa.mk |
173 | include $(TMK_PATH)/common.mk | 204 | include $(TMK_PATH)/common.mk |
diff --git a/keyboards/alps64/matrix.c b/keyboards/alps64/matrix.c index 805999d4a..b3508850d 100644 --- a/keyboards/alps64/matrix.c +++ b/keyboards/alps64/matrix.c | |||
@@ -100,6 +100,8 @@ uint8_t matrix_scan(void) | |||
100 | } | 100 | } |
101 | } | 101 | } |
102 | 102 | ||
103 | matrix_scan_quantum(); | ||
104 | |||
103 | return 1; | 105 | return 1; |
104 | } | 106 | } |
105 | 107 | ||
diff --git a/keyboards/clueboard/Makefile b/keyboards/clueboard/Makefile index d6f4bfcae..ccc01ea9a 100644 --- a/keyboards/clueboard/Makefile +++ b/keyboards/clueboard/Makefile | |||
@@ -1,3 +1,42 @@ | |||
1 | #---------------------------------------------------------------------------- | ||
2 | # On command line: | ||
3 | # | ||
4 | # make all = Make software. | ||
5 | # | ||
6 | # make clean = Clean out built project files. | ||
7 | # | ||
8 | # make coff = Convert ELF to AVR COFF. | ||
9 | # | ||
10 | # make extcoff = Convert ELF to AVR Extended COFF. | ||
11 | # | ||
12 | # make program = Download the hex file to the device. | ||
13 | # Please customize your programmer settings(PROGRAM_CMD) | ||
14 | # | ||
15 | # make teensy = Download the hex file to the device, using teensy_loader_cli. | ||
16 | # (must have teensy_loader_cli installed). | ||
17 | # | ||
18 | # make dfu = Download the hex file to the device, using dfu-programmer (must | ||
19 | # have dfu-programmer installed). | ||
20 | # | ||
21 | # make flip = Download the hex file to the device, using Atmel FLIP (must | ||
22 | # have Atmel FLIP installed). | ||
23 | # | ||
24 | # make dfu-ee = Download the eeprom file to the device, using dfu-programmer | ||
25 | # (must have dfu-programmer installed). | ||
26 | # | ||
27 | # make flip-ee = Download the eeprom file to the device, using Atmel FLIP | ||
28 | # (must have Atmel FLIP installed). | ||
29 | # | ||
30 | # make debug = Start either simulavr or avarice as specified for debugging, | ||
31 | # with avr-gdb or avr-insight as the front end for debugging. | ||
32 | # | ||
33 | # make filename.s = Just compile filename.c into the assembler code only. | ||
34 | # | ||
35 | # make filename.i = Create a preprocessed source file for use in submitting | ||
36 | # bug reports to the GCC project. | ||
37 | # | ||
38 | # To rebuild project do "make clean" then "make all". | ||
39 | #---------------------------------------------------------------------------- | ||
1 | 40 | ||
2 | SUBPROJECT_DEFAULT = rev2 | 41 | SUBPROJECT_DEFAULT = rev2 |
3 | 42 | ||
diff --git a/keyboards/ergodox_ez/matrix.c b/keyboards/ergodox_ez/matrix.c index e0de06c34..b87fddbad 100644 --- a/keyboards/ergodox_ez/matrix.c +++ b/keyboards/ergodox_ez/matrix.c | |||
@@ -187,8 +187,7 @@ uint8_t matrix_scan(void) | |||
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
190 | 190 | matrix_scan_quantum(); | |
191 | matrix_scan_kb(); | ||
192 | 191 | ||
193 | return 1; | 192 | return 1; |
194 | } | 193 | } |
diff --git a/keyboards/hhkb/matrix.c b/keyboards/hhkb/matrix.c index 2dfb2f5e1..666b6f595 100644 --- a/keyboards/hhkb/matrix.c +++ b/keyboards/hhkb/matrix.c | |||
@@ -71,6 +71,14 @@ void matrix_init(void) | |||
71 | matrix_prev = _matrix1; | 71 | matrix_prev = _matrix1; |
72 | } | 72 | } |
73 | 73 | ||
74 | __attribute__ ((weak)) | ||
75 | void matrix_scan_user(void) { | ||
76 | } | ||
77 | |||
78 | void matrix_scan_kb(void) { | ||
79 | matrix_scan_user(); | ||
80 | } | ||
81 | |||
74 | uint8_t matrix_scan(void) | 82 | uint8_t matrix_scan(void) |
75 | { | 83 | { |
76 | uint8_t *tmp; | 84 | uint8_t *tmp; |
@@ -150,6 +158,9 @@ uint8_t matrix_scan(void) | |||
150 | KEY_POWER_OFF(); | 158 | KEY_POWER_OFF(); |
151 | suspend_power_down(); | 159 | suspend_power_down(); |
152 | } | 160 | } |
161 | |||
162 | matrix_scan_quantum(); | ||
163 | |||
153 | return 1; | 164 | return 1; |
154 | } | 165 | } |
155 | 166 | ||
diff --git a/keyboards/planck/rev3/config.h b/keyboards/planck/rev3/config.h index fa50a5622..cc37874e8 100644 --- a/keyboards/planck/rev3/config.h +++ b/keyboards/planck/rev3/config.h | |||
@@ -5,4 +5,4 @@ | |||
5 | 5 | ||
6 | #define DEVICE_VER 0x0003 | 6 | #define DEVICE_VER 0x0003 |
7 | 7 | ||
8 | #endif \ No newline at end of file | 8 | #endif |
diff --git a/keyboards/sixkeyboard/matrix.c b/keyboards/sixkeyboard/matrix.c index c27998648..ed1b70e28 100644 --- a/keyboards/sixkeyboard/matrix.c +++ b/keyboards/sixkeyboard/matrix.c | |||
@@ -87,7 +87,7 @@ uint8_t matrix_scan(void) | |||
87 | matrix[0] = (PINC&(1<<7) ? 0 : (1<<0)) | (PINB&(1<<7) ? 0 : (1<<1)) | (PINB&(1<<5) ? 0 : (1<<2)); | 87 | matrix[0] = (PINC&(1<<7) ? 0 : (1<<0)) | (PINB&(1<<7) ? 0 : (1<<1)) | (PINB&(1<<5) ? 0 : (1<<2)); |
88 | matrix[1] = (PIND&(1<<6) ? 0 : (1<<0)) | (PIND&(1<<1) ? 0 : (1<<1)) | (PIND&(1<<4) ? 0 : (1<<2)); | 88 | matrix[1] = (PIND&(1<<6) ? 0 : (1<<0)) | (PIND&(1<<1) ? 0 : (1<<1)) | (PIND&(1<<4) ? 0 : (1<<2)); |
89 | 89 | ||
90 | matrix_scan_kb(); | 90 | matrix_scan_quantum(); |
91 | 91 | ||
92 | return 1; | 92 | return 1; |
93 | } | 93 | } |
diff --git a/quantum/keymap.h b/quantum/keymap.h index 41fa394ab..a994f4f2e 100644 --- a/quantum/keymap.h +++ b/quantum/keymap.h | |||
@@ -77,6 +77,8 @@ enum quantum_keycodes { | |||
77 | #endif | 77 | #endif |
78 | QK_MOD_TAP = 0x6000, | 78 | QK_MOD_TAP = 0x6000, |
79 | QK_MOD_TAP_MAX = 0x6FFF, | 79 | QK_MOD_TAP_MAX = 0x6FFF, |
80 | QK_TAP_DANCE = 0x7100, | ||
81 | QK_TAP_DANCE_MAX = 0x71FF, | ||
80 | #ifdef UNICODE_ENABLE | 82 | #ifdef UNICODE_ENABLE |
81 | QK_UNICODE = 0x8000, | 83 | QK_UNICODE = 0x8000, |
82 | QK_UNICODE_MAX = 0xFFFF, | 84 | QK_UNICODE_MAX = 0xFFFF, |
diff --git a/quantum/keymap_midi.c b/quantum/keymap_midi.c deleted file mode 100644 index 46049b987..000000000 --- a/quantum/keymap_midi.c +++ /dev/null | |||
@@ -1,109 +0,0 @@ | |||
1 | /* | ||
2 | Copyright 2015 Jack Humbert <jack.humb@gmail.com> | ||
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 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #include "keymap.h" | ||
19 | #include "keymap_midi.h" | ||
20 | |||
21 | uint8_t starting_note = 0x0C; | ||
22 | int offset = 7; | ||
23 | |||
24 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) | ||
25 | { | ||
26 | if (id != 0) { | ||
27 | if (record->event.pressed) { | ||
28 | midi_send_noteon(&midi_device, opt, (id & 0xFF), 127); | ||
29 | } else { | ||
30 | midi_send_noteoff(&midi_device, opt, (id & 0xFF), 127); | ||
31 | } | ||
32 | } | ||
33 | |||
34 | if (record->event.key.col == (MATRIX_COLS - 1) && record->event.key.row == (MATRIX_ROWS - 1)) { | ||
35 | if (record->event.pressed) { | ||
36 | starting_note++; | ||
37 | play_note(((double)261.626)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1)), 0xC); | ||
38 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
39 | midi_send_cc(&midi_device, 1, 0x7B, 0); | ||
40 | midi_send_cc(&midi_device, 2, 0x7B, 0); | ||
41 | midi_send_cc(&midi_device, 3, 0x7B, 0); | ||
42 | midi_send_cc(&midi_device, 4, 0x7B, 0); | ||
43 | return; | ||
44 | } else { | ||
45 | stop_note(((double)261.626)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1))); | ||
46 | stop_all_notes(); | ||
47 | return; | ||
48 | } | ||
49 | } | ||
50 | if (record->event.key.col == (MATRIX_COLS - 2) && record->event.key.row == (MATRIX_ROWS - 1)) { | ||
51 | if (record->event.pressed) { | ||
52 | starting_note--; | ||
53 | play_note(((double)261.626)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1)), 0xC); | ||
54 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
55 | midi_send_cc(&midi_device, 1, 0x7B, 0); | ||
56 | midi_send_cc(&midi_device, 2, 0x7B, 0); | ||
57 | midi_send_cc(&midi_device, 3, 0x7B, 0); | ||
58 | midi_send_cc(&midi_device, 4, 0x7B, 0); | ||
59 | return; | ||
60 | } else { | ||
61 | stop_note(((double)261.626)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1))); | ||
62 | stop_all_notes(); | ||
63 | return; | ||
64 | } | ||
65 | } | ||
66 | |||
67 | if (record->event.key.col == (MATRIX_COLS - 3) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { | ||
68 | offset++; | ||
69 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
70 | midi_send_cc(&midi_device, 1, 0x7B, 0); | ||
71 | midi_send_cc(&midi_device, 2, 0x7B, 0); | ||
72 | midi_send_cc(&midi_device, 3, 0x7B, 0); | ||
73 | midi_send_cc(&midi_device, 4, 0x7B, 0); | ||
74 | stop_all_notes(); | ||
75 | for (int i = 0; i <= 7; i++) { | ||
76 | play_note(((double)261.626)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1)), 0xC); | ||
77 | _delay_us(80000); | ||
78 | stop_note(((double)261.626)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1))); | ||
79 | _delay_us(8000); | ||
80 | } | ||
81 | return; | ||
82 | } | ||
83 | if (record->event.key.col == (MATRIX_COLS - 4) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { | ||
84 | offset--; | ||
85 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
86 | midi_send_cc(&midi_device, 1, 0x7B, 0); | ||
87 | midi_send_cc(&midi_device, 2, 0x7B, 0); | ||
88 | midi_send_cc(&midi_device, 3, 0x7B, 0); | ||
89 | midi_send_cc(&midi_device, 4, 0x7B, 0); | ||
90 | stop_all_notes(); | ||
91 | for (int i = 0; i <= 7; i++) { | ||
92 | play_note(((double)261.626)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1)), 0xC); | ||
93 | _delay_us(80000); | ||
94 | stop_note(((double)261.626)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1))); | ||
95 | _delay_us(8000); | ||
96 | } | ||
97 | return; | ||
98 | } | ||
99 | |||
100 | if (record->event.pressed) { | ||
101 | // midi_send_noteon(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127); | ||
102 | // midi_send_noteon(&midi_device, 0, (starting_note + SCALE[record->event.key.col + offset])+12*(MATRIX_ROWS - record->event.key.row), 127); | ||
103 | play_note(((double)261.626)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)), 0xF); | ||
104 | } else { | ||
105 | // midi_send_noteoff(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127); | ||
106 | // midi_send_noteoff(&midi_device, 0, (starting_note + SCALE[record->event.key.col + offset])+12*(MATRIX_ROWS - record->event.key.row), 127); | ||
107 | stop_note(((double)261.626)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row))); | ||
108 | } | ||
109 | } \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_chording.c b/quantum/process_keycode/process_chording.c new file mode 100644 index 000000000..d7814629f --- /dev/null +++ b/quantum/process_keycode/process_chording.c | |||
@@ -0,0 +1,60 @@ | |||
1 | #include "process_chording.h" | ||
2 | |||
3 | bool keys_chord(uint8_t keys[]) { | ||
4 | uint8_t keys_size = sizeof(keys)/sizeof(keys[0]); | ||
5 | bool pass = true; | ||
6 | uint8_t in = 0; | ||
7 | for (uint8_t i = 0; i < chord_key_count; i++) { | ||
8 | bool found = false; | ||
9 | for (uint8_t j = 0; j < keys_size; j++) { | ||
10 | if (chord_keys[i] == (keys[j] & 0xFF)) { | ||
11 | in++; // detects key in chord | ||
12 | found = true; | ||
13 | break; | ||
14 | } | ||
15 | } | ||
16 | if (found) | ||
17 | continue; | ||
18 | if (chord_keys[i] != 0) { | ||
19 | pass = false; // makes sure rest are blank | ||
20 | } | ||
21 | } | ||
22 | return (pass && (in == keys_size)); | ||
23 | } | ||
24 | |||
25 | bool process_chording(uint16_t keycode, keyrecord_t *record) { | ||
26 | if (keycode >= QK_CHORDING && keycode <= QK_CHORDING_MAX) { | ||
27 | if (record->event.pressed) { | ||
28 | if (!chording) { | ||
29 | chording = true; | ||
30 | for (uint8_t i = 0; i < CHORDING_MAX; i++) | ||
31 | chord_keys[i] = 0; | ||
32 | chord_key_count = 0; | ||
33 | chord_key_down = 0; | ||
34 | } | ||
35 | chord_keys[chord_key_count] = (keycode & 0xFF); | ||
36 | chord_key_count++; | ||
37 | chord_key_down++; | ||
38 | return false; | ||
39 | } else { | ||
40 | if (chording) { | ||
41 | chord_key_down--; | ||
42 | if (chord_key_down == 0) { | ||
43 | chording = false; | ||
44 | // Chord Dictionary | ||
45 | if (keys_chord((uint8_t[]){KC_ENTER, KC_SPACE})) { | ||
46 | register_code(KC_A); | ||
47 | unregister_code(KC_A); | ||
48 | return false; | ||
49 | } | ||
50 | for (uint8_t i = 0; i < chord_key_count; i++) { | ||
51 | register_code(chord_keys[i]); | ||
52 | unregister_code(chord_keys[i]); | ||
53 | return false; | ||
54 | } | ||
55 | } | ||
56 | } | ||
57 | } | ||
58 | } | ||
59 | return true; | ||
60 | } \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_chording.h b/quantum/process_keycode/process_chording.h new file mode 100644 index 000000000..49c97db3b --- /dev/null +++ b/quantum/process_keycode/process_chording.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #ifndef PROCESS_CHORDING_H | ||
2 | #define PROCESS_CHORDING_H | ||
3 | |||
4 | #include "quantum.h" | ||
5 | |||
6 | // Chording stuff | ||
7 | #define CHORDING_MAX 4 | ||
8 | bool chording = false; | ||
9 | |||
10 | uint8_t chord_keys[CHORDING_MAX] = {0}; | ||
11 | uint8_t chord_key_count = 0; | ||
12 | uint8_t chord_key_down = 0; | ||
13 | |||
14 | bool process_chording(uint16_t keycode, keyrecord_t *record); | ||
15 | |||
16 | #endif \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c new file mode 100644 index 000000000..e53d221e7 --- /dev/null +++ b/quantum/process_keycode/process_leader.c | |||
@@ -0,0 +1,38 @@ | |||
1 | #include "process_leader.h" | ||
2 | |||
3 | __attribute__ ((weak)) | ||
4 | void leader_start(void) {} | ||
5 | |||
6 | __attribute__ ((weak)) | ||
7 | void leader_end(void) {} | ||
8 | |||
9 | // Leader key stuff | ||
10 | bool leading = false; | ||
11 | uint16_t leader_time = 0; | ||
12 | |||
13 | uint16_t leader_sequence[5] = {0, 0, 0, 0, 0}; | ||
14 | uint8_t leader_sequence_size = 0; | ||
15 | |||
16 | bool process_leader(uint16_t keycode, keyrecord_t *record) { | ||
17 | // Leader key set-up | ||
18 | if (record->event.pressed) { | ||
19 | if (!leading && keycode == KC_LEAD) { | ||
20 | leader_start(); | ||
21 | leading = true; | ||
22 | leader_time = timer_read(); | ||
23 | leader_sequence_size = 0; | ||
24 | leader_sequence[0] = 0; | ||
25 | leader_sequence[1] = 0; | ||
26 | leader_sequence[2] = 0; | ||
27 | leader_sequence[3] = 0; | ||
28 | leader_sequence[4] = 0; | ||
29 | return false; | ||
30 | } | ||
31 | if (leading && timer_elapsed(leader_time) < LEADER_TIMEOUT) { | ||
32 | leader_sequence[leader_sequence_size] = keycode; | ||
33 | leader_sequence_size++; | ||
34 | return false; | ||
35 | } | ||
36 | } | ||
37 | return true; | ||
38 | } \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_leader.h b/quantum/process_keycode/process_leader.h new file mode 100644 index 000000000..c83db8abb --- /dev/null +++ b/quantum/process_keycode/process_leader.h | |||
@@ -0,0 +1,23 @@ | |||
1 | #ifndef PROCESS_LEADER_H | ||
2 | #define PROCESS_LEADER_H | ||
3 | |||
4 | #include "quantum.h" | ||
5 | |||
6 | bool process_leader(uint16_t keycode, keyrecord_t *record); | ||
7 | |||
8 | void leader_start(void); | ||
9 | void leader_end(void); | ||
10 | |||
11 | #ifndef LEADER_TIMEOUT | ||
12 | #define LEADER_TIMEOUT 200 | ||
13 | #endif | ||
14 | #define SEQ_ONE_KEY(key) if (leader_sequence[0] == (key) && leader_sequence[1] == 0 && leader_sequence[2] == 0 && leader_sequence[3] == 0 && leader_sequence[4] == 0) | ||
15 | #define SEQ_TWO_KEYS(key1, key2) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == 0 && leader_sequence[3] == 0 && leader_sequence[4] == 0) | ||
16 | #define SEQ_THREE_KEYS(key1, key2, key3) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == (key3) && leader_sequence[3] == 0 && leader_sequence[4] == 0) | ||
17 | #define SEQ_FOUR_KEYS(key1, key2, key3, key4) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == (key3) && leader_sequence[3] == (key4) && leader_sequence[4] == 0) | ||
18 | #define SEQ_FIVE_KEYS(key1, key2, key3, key4, key5) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == (key3) && leader_sequence[3] == (key4) && leader_sequence[4] == (key5)) | ||
19 | |||
20 | #define LEADER_EXTERNS() extern bool leading; extern uint16_t leader_time; extern uint16_t leader_sequence[5]; extern uint8_t leader_sequence_size | ||
21 | #define LEADER_DICTIONARY() if (leading && timer_elapsed(leader_time) > LEADER_TIMEOUT) | ||
22 | |||
23 | #endif \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_midi.c b/quantum/process_keycode/process_midi.c new file mode 100644 index 000000000..d6ab9c626 --- /dev/null +++ b/quantum/process_keycode/process_midi.c | |||
@@ -0,0 +1,66 @@ | |||
1 | #include "process_midi.h" | ||
2 | |||
3 | bool midi_activated = false; | ||
4 | uint8_t starting_note = 0x0C; | ||
5 | int offset = 7; | ||
6 | |||
7 | bool process_midi(uint16_t keycode, keyrecord_t *record) { | ||
8 | if (keycode == MI_ON && record->event.pressed) { | ||
9 | midi_activated = true; | ||
10 | music_scale_user(); | ||
11 | return false; | ||
12 | } | ||
13 | |||
14 | if (keycode == MI_OFF && record->event.pressed) { | ||
15 | midi_activated = false; | ||
16 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
17 | return false; | ||
18 | } | ||
19 | |||
20 | if (midi_activated) { | ||
21 | if (record->event.key.col == (MATRIX_COLS - 1) && record->event.key.row == (MATRIX_ROWS - 1)) { | ||
22 | if (record->event.pressed) { | ||
23 | starting_note++; // Change key | ||
24 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
25 | } | ||
26 | return false; | ||
27 | } | ||
28 | if (record->event.key.col == (MATRIX_COLS - 2) && record->event.key.row == (MATRIX_ROWS - 1)) { | ||
29 | if (record->event.pressed) { | ||
30 | starting_note--; // Change key | ||
31 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
32 | } | ||
33 | return false; | ||
34 | } | ||
35 | if (record->event.key.col == (MATRIX_COLS - 3) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { | ||
36 | offset++; // Change scale | ||
37 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
38 | return false; | ||
39 | } | ||
40 | if (record->event.key.col == (MATRIX_COLS - 4) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { | ||
41 | offset--; // Change scale | ||
42 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
43 | return false; | ||
44 | } | ||
45 | // basic | ||
46 | // uint8_t note = (starting_note + SCALE[record->event.key.col + offset])+12*(MATRIX_ROWS - record->event.key.row); | ||
47 | // advanced | ||
48 | // uint8_t note = (starting_note + record->event.key.col + offset)+12*(MATRIX_ROWS - record->event.key.row); | ||
49 | // guitar | ||
50 | uint8_t note = (starting_note + record->event.key.col + offset)+5*(MATRIX_ROWS - record->event.key.row); | ||
51 | // violin | ||
52 | // uint8_t note = (starting_note + record->event.key.col + offset)+7*(MATRIX_ROWS - record->event.key.row); | ||
53 | |||
54 | if (record->event.pressed) { | ||
55 | // midi_send_noteon(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127); | ||
56 | midi_send_noteon(&midi_device, 0, note, 127); | ||
57 | } else { | ||
58 | // midi_send_noteoff(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127); | ||
59 | midi_send_noteoff(&midi_device, 0, note, 127); | ||
60 | } | ||
61 | |||
62 | if (keycode < 0xFF) // ignores all normal keycodes, but lets RAISE, LOWER, etc through | ||
63 | return false; | ||
64 | } | ||
65 | return true; | ||
66 | } \ No newline at end of file | ||
diff --git a/quantum/keymap_midi.h b/quantum/process_keycode/process_midi.h index 3a2bf3aff..acd4fc1b1 100644 --- a/quantum/keymap_midi.h +++ b/quantum/process_keycode/process_midi.h | |||
@@ -1,24 +1,9 @@ | |||
1 | /* | 1 | #ifndef PROCESS_MIDI_H |
2 | Copyright 2015 Jack Humbert <jack.humb@gmail.com> | 2 | #define PROCESS_MIDI_H |
3 | 3 | ||
4 | This program is free software: you can redistribute it and/or modify | 4 | #include "quantum.h" |
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 | 5 | ||
9 | This program is distributed in the hope that it will be useful, | 6 | bool process_midi(uint16_t keycode, keyrecord_t *record); |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #ifndef KEYMAP_MIDI_H | ||
19 | #define KEYMAP_MIDI_H | ||
20 | |||
21 | #include <lufa.h> | ||
22 | 7 | ||
23 | #define MIDI(n) ((n) | 0x6000) | 8 | #define MIDI(n) ((n) | 0x6000) |
24 | #define MIDI12 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000 | 9 | #define MIDI12 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000 |
diff --git a/quantum/process_keycode/process_music.c b/quantum/process_keycode/process_music.c new file mode 100644 index 000000000..c8f3ddb90 --- /dev/null +++ b/quantum/process_keycode/process_music.c | |||
@@ -0,0 +1,171 @@ | |||
1 | #include "process_music.h" | ||
2 | |||
3 | bool music_activated = false; | ||
4 | uint8_t starting_note = 0x0C; | ||
5 | int offset = 7; | ||
6 | |||
7 | // music sequencer | ||
8 | static bool music_sequence_recording = false; | ||
9 | static bool music_sequence_playing = false; | ||
10 | static float music_sequence[16] = {0}; | ||
11 | static uint8_t music_sequence_count = 0; | ||
12 | static uint8_t music_sequence_position = 0; | ||
13 | |||
14 | static uint16_t music_sequence_timer = 0; | ||
15 | static uint16_t music_sequence_interval = 100; | ||
16 | |||
17 | bool process_music(uint16_t keycode, keyrecord_t *record) { | ||
18 | |||
19 | if (keycode == AU_ON && record->event.pressed) { | ||
20 | audio_on(); | ||
21 | return false; | ||
22 | } | ||
23 | |||
24 | if (keycode == AU_OFF && record->event.pressed) { | ||
25 | audio_off(); | ||
26 | return false; | ||
27 | } | ||
28 | |||
29 | if (keycode == AU_TOG && record->event.pressed) { | ||
30 | if (is_audio_on()) | ||
31 | { | ||
32 | audio_off(); | ||
33 | } | ||
34 | else | ||
35 | { | ||
36 | audio_on(); | ||
37 | } | ||
38 | return false; | ||
39 | } | ||
40 | |||
41 | if (keycode == MU_ON && record->event.pressed) { | ||
42 | music_on(); | ||
43 | return false; | ||
44 | } | ||
45 | |||
46 | if (keycode == MU_OFF && record->event.pressed) { | ||
47 | music_off(); | ||
48 | return false; | ||
49 | } | ||
50 | |||
51 | if (keycode == MU_TOG && record->event.pressed) { | ||
52 | if (music_activated) | ||
53 | { | ||
54 | music_off(); | ||
55 | } | ||
56 | else | ||
57 | { | ||
58 | music_on(); | ||
59 | } | ||
60 | return false; | ||
61 | } | ||
62 | |||
63 | if (keycode == MUV_IN && record->event.pressed) { | ||
64 | voice_iterate(); | ||
65 | music_scale_user(); | ||
66 | return false; | ||
67 | } | ||
68 | |||
69 | if (keycode == MUV_DE && record->event.pressed) { | ||
70 | voice_deiterate(); | ||
71 | music_scale_user(); | ||
72 | return false; | ||
73 | } | ||
74 | |||
75 | if (music_activated) { | ||
76 | |||
77 | if (keycode == KC_LCTL && record->event.pressed) { // Start recording | ||
78 | stop_all_notes(); | ||
79 | music_sequence_recording = true; | ||
80 | music_sequence_playing = false; | ||
81 | music_sequence_count = 0; | ||
82 | return false; | ||
83 | } | ||
84 | |||
85 | if (keycode == KC_LALT && record->event.pressed) { // Stop recording/playing | ||
86 | stop_all_notes(); | ||
87 | music_sequence_recording = false; | ||
88 | music_sequence_playing = false; | ||
89 | return false; | ||
90 | } | ||
91 | |||
92 | if (keycode == KC_LGUI && record->event.pressed) { // Start playing | ||
93 | stop_all_notes(); | ||
94 | music_sequence_recording = false; | ||
95 | music_sequence_playing = true; | ||
96 | music_sequence_position = 0; | ||
97 | music_sequence_timer = 0; | ||
98 | return false; | ||
99 | } | ||
100 | |||
101 | if (keycode == KC_UP) { | ||
102 | if (record->event.pressed) | ||
103 | music_sequence_interval-=10; | ||
104 | return false; | ||
105 | } | ||
106 | |||
107 | if (keycode == KC_DOWN) { | ||
108 | if (record->event.pressed) | ||
109 | music_sequence_interval+=10; | ||
110 | return false; | ||
111 | } | ||
112 | |||
113 | float freq = ((float)220.0)*pow(2.0, -5.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)); | ||
114 | if (record->event.pressed) { | ||
115 | play_note(freq, 0xF); | ||
116 | if (music_sequence_recording) { | ||
117 | music_sequence[music_sequence_count] = freq; | ||
118 | music_sequence_count++; | ||
119 | } | ||
120 | } else { | ||
121 | stop_note(freq); | ||
122 | } | ||
123 | |||
124 | if (keycode < 0xFF) // ignores all normal keycodes, but lets RAISE, LOWER, etc through | ||
125 | return false; | ||
126 | } | ||
127 | return true; | ||
128 | } | ||
129 | |||
130 | bool is_music_on(void) { | ||
131 | return (music_activated != 0); | ||
132 | } | ||
133 | |||
134 | void music_toggle(void) { | ||
135 | if (!music_activated) { | ||
136 | music_on(); | ||
137 | } else { | ||
138 | music_off(); | ||
139 | } | ||
140 | } | ||
141 | |||
142 | void music_on(void) { | ||
143 | music_activated = 1; | ||
144 | music_on_user(); | ||
145 | } | ||
146 | |||
147 | void music_off(void) { | ||
148 | music_activated = 0; | ||
149 | stop_all_notes(); | ||
150 | } | ||
151 | |||
152 | |||
153 | __attribute__ ((weak)) | ||
154 | void music_on_user() {} | ||
155 | |||
156 | __attribute__ ((weak)) | ||
157 | void audio_on_user() {} | ||
158 | |||
159 | __attribute__ ((weak)) | ||
160 | void music_scale_user() {} | ||
161 | |||
162 | void matrix_scan_music(void) { | ||
163 | if (music_sequence_playing) { | ||
164 | if ((music_sequence_timer == 0) || (timer_elapsed(music_sequence_timer) > music_sequence_interval)) { | ||
165 | music_sequence_timer = timer_read(); | ||
166 | stop_note(music_sequence[(music_sequence_position - 1 < 0)?(music_sequence_position - 1 + music_sequence_count):(music_sequence_position - 1)]); | ||
167 | play_note(music_sequence[music_sequence_position], 0xF); | ||
168 | music_sequence_position = (music_sequence_position + 1) % music_sequence_count; | ||
169 | } | ||
170 | } | ||
171 | } | ||
diff --git a/quantum/process_keycode/process_music.h b/quantum/process_keycode/process_music.h new file mode 100644 index 000000000..318b3e387 --- /dev/null +++ b/quantum/process_keycode/process_music.h | |||
@@ -0,0 +1,27 @@ | |||
1 | #ifndef PROCESS_MUSIC_H | ||
2 | #define PROCESS_MUSIC_H | ||
3 | |||
4 | #include "quantum.h" | ||
5 | |||
6 | bool process_music(uint16_t keycode, keyrecord_t *record); | ||
7 | |||
8 | bool is_music_on(void); | ||
9 | void music_toggle(void); | ||
10 | void music_on(void); | ||
11 | void music_off(void); | ||
12 | |||
13 | void audio_on_user(void); | ||
14 | void music_on_user(void); | ||
15 | void music_scale_user(void); | ||
16 | |||
17 | void matrix_scan_music(void); | ||
18 | |||
19 | #ifndef SCALE | ||
20 | #define SCALE (int8_t []){ 0 + (12*0), 2 + (12*0), 4 + (12*0), 5 + (12*0), 7 + (12*0), 9 + (12*0), 11 + (12*0), \ | ||
21 | 0 + (12*1), 2 + (12*1), 4 + (12*1), 5 + (12*1), 7 + (12*1), 9 + (12*1), 11 + (12*1), \ | ||
22 | 0 + (12*2), 2 + (12*2), 4 + (12*2), 5 + (12*2), 7 + (12*2), 9 + (12*2), 11 + (12*2), \ | ||
23 | 0 + (12*3), 2 + (12*3), 4 + (12*3), 5 + (12*3), 7 + (12*3), 9 + (12*3), 11 + (12*3), \ | ||
24 | 0 + (12*4), 2 + (12*4), 4 + (12*4), 5 + (12*4), 7 + (12*4), 9 + (12*4), 11 + (12*4), } | ||
25 | #endif | ||
26 | |||
27 | #endif \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c new file mode 100644 index 000000000..9b172e1b6 --- /dev/null +++ b/quantum/process_keycode/process_tap_dance.c | |||
@@ -0,0 +1,90 @@ | |||
1 | #include "quantum.h" | ||
2 | |||
3 | static qk_tap_dance_state_t qk_tap_dance_state; | ||
4 | |||
5 | static void _process_tap_dance_action_pair (qk_tap_dance_state_t *state, | ||
6 | uint16_t kc1, uint16_t kc2) { | ||
7 | uint16_t kc; | ||
8 | |||
9 | if (state->count == 0) | ||
10 | return; | ||
11 | |||
12 | kc = (state->count == 1) ? kc1 : kc2; | ||
13 | |||
14 | register_code (kc); | ||
15 | unregister_code (kc); | ||
16 | |||
17 | if (state->count >= 2) { | ||
18 | reset_tap_dance (state); | ||
19 | } | ||
20 | } | ||
21 | |||
22 | static void _process_tap_dance_action_fn (qk_tap_dance_state_t *state, | ||
23 | qk_tap_dance_user_fn_t fn) | ||
24 | { | ||
25 | fn(state); | ||
26 | } | ||
27 | |||
28 | void process_tap_dance_action (uint16_t keycode) | ||
29 | { | ||
30 | uint16_t idx = keycode - QK_TAP_DANCE; | ||
31 | qk_tap_dance_action_t action; | ||
32 | |||
33 | action = tap_dance_actions[idx]; | ||
34 | |||
35 | switch (action.type) { | ||
36 | case QK_TAP_DANCE_TYPE_PAIR: | ||
37 | _process_tap_dance_action_pair (&qk_tap_dance_state, | ||
38 | action.pair.kc1, action.pair.kc2); | ||
39 | break; | ||
40 | case QK_TAP_DANCE_TYPE_FN: | ||
41 | _process_tap_dance_action_fn (&qk_tap_dance_state, action.fn); | ||
42 | break; | ||
43 | |||
44 | default: | ||
45 | break; | ||
46 | } | ||
47 | } | ||
48 | |||
49 | bool process_tap_dance(uint16_t keycode, keyrecord_t *record) { | ||
50 | bool r = true; | ||
51 | |||
52 | switch(keycode) { | ||
53 | case QK_TAP_DANCE ... QK_TAP_DANCE_MAX: | ||
54 | if (qk_tap_dance_state.keycode && qk_tap_dance_state.keycode != keycode) { | ||
55 | process_tap_dance_action (qk_tap_dance_state.keycode); | ||
56 | } else { | ||
57 | r = false; | ||
58 | } | ||
59 | |||
60 | if (record->event.pressed) { | ||
61 | qk_tap_dance_state.keycode = keycode; | ||
62 | qk_tap_dance_state.timer = timer_read (); | ||
63 | qk_tap_dance_state.count++; | ||
64 | } | ||
65 | break; | ||
66 | |||
67 | default: | ||
68 | if (qk_tap_dance_state.keycode) { | ||
69 | process_tap_dance_action (qk_tap_dance_state.keycode); | ||
70 | |||
71 | reset_tap_dance (&qk_tap_dance_state); | ||
72 | } | ||
73 | break; | ||
74 | } | ||
75 | |||
76 | return r; | ||
77 | } | ||
78 | |||
79 | void matrix_scan_tap_dance () { | ||
80 | if (qk_tap_dance_state.keycode && timer_elapsed (qk_tap_dance_state.timer) > TAPPING_TERM) { | ||
81 | process_tap_dance_action (qk_tap_dance_state.keycode); | ||
82 | |||
83 | reset_tap_dance (&qk_tap_dance_state); | ||
84 | } | ||
85 | } | ||
86 | |||
87 | void reset_tap_dance (qk_tap_dance_state_t *state) { | ||
88 | state->keycode = 0; | ||
89 | state->count = 0; | ||
90 | } | ||
diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h new file mode 100644 index 000000000..b9d7c7fcf --- /dev/null +++ b/quantum/process_keycode/process_tap_dance.h | |||
@@ -0,0 +1,62 @@ | |||
1 | #ifndef PROCESS_TAP_DANCE_H | ||
2 | #define PROCESS_TAP_DANCE_H | ||
3 | |||
4 | #ifdef TAP_DANCE_ENABLE | ||
5 | |||
6 | #include <stdbool.h> | ||
7 | #include <inttypes.h> | ||
8 | |||
9 | typedef struct | ||
10 | { | ||
11 | uint8_t count; | ||
12 | uint16_t keycode; | ||
13 | uint16_t timer; | ||
14 | } qk_tap_dance_state_t; | ||
15 | |||
16 | #define TD(n) (QK_TAP_DANCE + n) | ||
17 | |||
18 | typedef enum | ||
19 | { | ||
20 | QK_TAP_DANCE_TYPE_PAIR, | ||
21 | QK_TAP_DANCE_TYPE_FN, | ||
22 | } qk_tap_dance_type_t; | ||
23 | |||
24 | typedef void (*qk_tap_dance_user_fn_t) (qk_tap_dance_state_t *state); | ||
25 | |||
26 | typedef struct | ||
27 | { | ||
28 | qk_tap_dance_type_t type; | ||
29 | union { | ||
30 | struct { | ||
31 | uint16_t kc1; | ||
32 | uint16_t kc2; | ||
33 | } pair; | ||
34 | qk_tap_dance_user_fn_t fn; | ||
35 | }; | ||
36 | } qk_tap_dance_action_t; | ||
37 | |||
38 | #define ACTION_TAP_DANCE_DOUBLE(kc1, kc2) { \ | ||
39 | .type = QK_TAP_DANCE_TYPE_PAIR, \ | ||
40 | .pair = { kc1, kc2 } \ | ||
41 | } | ||
42 | |||
43 | #define ACTION_TAP_DANCE_FN(user_fn) { \ | ||
44 | .type = QK_TAP_DANCE_TYPE_FN, \ | ||
45 | .fn = user_fn \ | ||
46 | } | ||
47 | |||
48 | extern const qk_tap_dance_action_t tap_dance_actions[]; | ||
49 | |||
50 | /* To be used internally */ | ||
51 | |||
52 | bool process_tap_dance(uint16_t keycode, keyrecord_t *record); | ||
53 | void matrix_scan_tap_dance (void); | ||
54 | void reset_tap_dance (qk_tap_dance_state_t *state); | ||
55 | |||
56 | #else | ||
57 | |||
58 | #define TD(n) KC_NO | ||
59 | |||
60 | #endif | ||
61 | |||
62 | #endif | ||
diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c new file mode 100644 index 000000000..ad5d7f86b --- /dev/null +++ b/quantum/process_keycode/process_unicode.c | |||
@@ -0,0 +1,57 @@ | |||
1 | #include "process_unicode.h" | ||
2 | |||
3 | static uint8_t input_mode; | ||
4 | |||
5 | uint16_t hex_to_keycode(uint8_t hex) | ||
6 | { | ||
7 | if (hex == 0x0) { | ||
8 | return KC_0; | ||
9 | } else if (hex < 0xA) { | ||
10 | return KC_1 + (hex - 0x1); | ||
11 | } else { | ||
12 | return KC_A + (hex - 0xA); | ||
13 | } | ||
14 | } | ||
15 | |||
16 | void set_unicode_mode(uint8_t os_target) | ||
17 | { | ||
18 | input_mode = os_target; | ||
19 | } | ||
20 | |||
21 | bool process_unicode(uint16_t keycode, keyrecord_t *record) { | ||
22 | if (keycode > QK_UNICODE && record->event.pressed) { | ||
23 | uint16_t unicode = keycode & 0x7FFF; | ||
24 | switch(input_mode) { | ||
25 | case UC_OSX: | ||
26 | register_code(KC_LALT); | ||
27 | break; | ||
28 | case UC_LNX: | ||
29 | register_code(KC_LCTL); | ||
30 | register_code(KC_LSFT); | ||
31 | register_code(KC_U); | ||
32 | unregister_code(KC_U); | ||
33 | break; | ||
34 | case UC_WIN: | ||
35 | register_code(KC_LALT); | ||
36 | register_code(KC_PPLS); | ||
37 | unregister_code(KC_PPLS); | ||
38 | break; | ||
39 | } | ||
40 | for(int i = 3; i >= 0; i--) { | ||
41 | uint8_t digit = ((unicode >> (i*4)) & 0xF); | ||
42 | register_code(hex_to_keycode(digit)); | ||
43 | unregister_code(hex_to_keycode(digit)); | ||
44 | } | ||
45 | switch(input_mode) { | ||
46 | case UC_OSX: | ||
47 | case UC_WIN: | ||
48 | unregister_code(KC_LALT); | ||
49 | break; | ||
50 | case UC_LNX: | ||
51 | unregister_code(KC_LCTL); | ||
52 | unregister_code(KC_LSFT); | ||
53 | break; | ||
54 | } | ||
55 | } | ||
56 | return true; | ||
57 | } \ No newline at end of file | ||
diff --git a/quantum/unicode.h b/quantum/process_keycode/process_unicode.h index 756ec8bc3..ca17f8f66 100644 --- a/quantum/unicode.h +++ b/quantum/process_keycode/process_unicode.h | |||
@@ -1,22 +1,16 @@ | |||
1 | /* | 1 | #ifndef PROCESS_UNICODE_H |
2 | Copyright 2016 Jack Humbert <jack.humb@gmail.com> | 2 | #define PROCESS_UNICODE_H |
3 | This program is free software: you can redistribute it and/or modify | ||
4 | it under the terms of the GNU General Public License as published by | ||
5 | the Free Software Foundation, either version 2 of the License, or | ||
6 | (at your option) any later version. | ||
7 | This program is distributed in the hope that it will be useful, | ||
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
10 | GNU General Public License for more details. | ||
11 | You should have received a copy of the GNU General Public License | ||
12 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
13 | */ | ||
14 | |||
15 | #ifndef UNICODE_H | ||
16 | #define UNICODE_H | ||
17 | 3 | ||
18 | #include "quantum.h" | 4 | #include "quantum.h" |
19 | #include <math.h> | 5 | |
6 | #define UC_OSX 0 | ||
7 | #define UC_LNX 1 | ||
8 | #define UC_WIN 2 | ||
9 | #define UC_BSD 3 | ||
10 | |||
11 | void set_unicode_input_mode(uint8_t os_target); | ||
12 | |||
13 | bool process_unicode(uint16_t keycode, keyrecord_t *record); | ||
20 | 14 | ||
21 | #define UC_BSPC UC(0x0008) | 15 | #define UC_BSPC UC(0x0008) |
22 | 16 | ||
diff --git a/quantum/quantum.c b/quantum/quantum.c index 9c0f9691f..c0580e0aa 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
@@ -15,54 +15,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
15 | return true; | 15 | return true; |
16 | } | 16 | } |
17 | 17 | ||
18 | __attribute__ ((weak)) | ||
19 | void leader_start(void) {} | ||
20 | |||
21 | __attribute__ ((weak)) | ||
22 | void leader_end(void) {} | ||
23 | |||
24 | uint8_t starting_note = 0x0C; | ||
25 | int offset = 7; | ||
26 | |||
27 | |||
28 | #ifdef AUDIO_ENABLE | ||
29 | bool music_activated = false; | ||
30 | |||
31 | // music sequencer | ||
32 | static bool music_sequence_recording = false; | ||
33 | static bool music_sequence_playing = false; | ||
34 | static float music_sequence[16] = {0}; | ||
35 | static uint8_t music_sequence_count = 0; | ||
36 | static uint8_t music_sequence_position = 0; | ||
37 | |||
38 | static uint16_t music_sequence_timer = 0; | ||
39 | static uint16_t music_sequence_interval = 100; | ||
40 | |||
41 | #endif | ||
42 | |||
43 | #ifdef MIDI_ENABLE | ||
44 | bool midi_activated = false; | ||
45 | #endif | ||
46 | |||
47 | // Leader key stuff | ||
48 | bool leading = false; | ||
49 | uint16_t leader_time = 0; | ||
50 | |||
51 | uint16_t leader_sequence[5] = {0, 0, 0, 0, 0}; | ||
52 | uint8_t leader_sequence_size = 0; | ||
53 | |||
54 | // Chording stuff | ||
55 | #define CHORDING_MAX 4 | ||
56 | bool chording = false; | ||
57 | |||
58 | uint8_t chord_keys[CHORDING_MAX] = {0}; | ||
59 | uint8_t chord_key_count = 0; | ||
60 | uint8_t chord_key_down = 0; | ||
61 | |||
62 | #ifdef UNICODE_ENABLE | ||
63 | static uint8_t input_mode; | ||
64 | #endif | ||
65 | |||
66 | // Shift / paren setup | 18 | // Shift / paren setup |
67 | 19 | ||
68 | #ifndef LSPO_KEY | 20 | #ifndef LSPO_KEY |
@@ -74,48 +26,6 @@ uint8_t chord_key_down = 0; | |||
74 | 26 | ||
75 | static bool shift_interrupted[2] = {0, 0}; | 27 | static bool shift_interrupted[2] = {0, 0}; |
76 | 28 | ||
77 | bool keys_chord(uint8_t keys[]) { | ||
78 | uint8_t keys_size = sizeof(keys)/sizeof(keys[0]); | ||
79 | bool pass = true; | ||
80 | uint8_t in = 0; | ||
81 | for (uint8_t i = 0; i < chord_key_count; i++) { | ||
82 | bool found = false; | ||
83 | for (uint8_t j = 0; j < keys_size; j++) { | ||
84 | if (chord_keys[i] == (keys[j] & 0xFF)) { | ||
85 | in++; // detects key in chord | ||
86 | found = true; | ||
87 | break; | ||
88 | } | ||
89 | } | ||
90 | if (found) | ||
91 | continue; | ||
92 | if (chord_keys[i] != 0) { | ||
93 | pass = false; // makes sure rest are blank | ||
94 | } | ||
95 | } | ||
96 | return (pass && (in == keys_size)); | ||
97 | } | ||
98 | |||
99 | #ifdef UNICODE_ENABLE | ||
100 | |||
101 | uint16_t hex_to_keycode(uint8_t hex) | ||
102 | { | ||
103 | if (hex == 0x0) { | ||
104 | return KC_0; | ||
105 | } else if (hex < 0xA) { | ||
106 | return KC_1 + (hex - 0x1); | ||
107 | } else { | ||
108 | return KC_A + (hex - 0xA); | ||
109 | } | ||
110 | } | ||
111 | |||
112 | void set_unicode_mode(uint8_t os_target) | ||
113 | { | ||
114 | input_mode = os_target; | ||
115 | } | ||
116 | |||
117 | #endif | ||
118 | |||
119 | bool process_record_quantum(keyrecord_t *record) { | 29 | bool process_record_quantum(keyrecord_t *record) { |
120 | 30 | ||
121 | /* This gets the keycode from the key pressed */ | 31 | /* This gets the keycode from the key pressed */ |
@@ -136,9 +46,6 @@ bool process_record_quantum(keyrecord_t *record) { | |||
136 | keycode = keymap_key_to_keycode(layer_switch_get_layer(key), key); | 46 | keycode = keymap_key_to_keycode(layer_switch_get_layer(key), key); |
137 | #endif | 47 | #endif |
138 | 48 | ||
139 | if (!process_record_kb(keycode, record)) | ||
140 | return false; | ||
141 | |||
142 | // This is how you use actions here | 49 | // This is how you use actions here |
143 | // if (keycode == KC_LEAD) { | 50 | // if (keycode == KC_LEAD) { |
144 | // action_t action; | 51 | // action_t action; |
@@ -147,278 +54,30 @@ bool process_record_quantum(keyrecord_t *record) { | |||
147 | // return false; | 54 | // return false; |
148 | // } | 55 | // } |
149 | 56 | ||
57 | if (!( | ||
58 | process_record_kb(keycode, record) && | ||
150 | #ifdef MIDI_ENABLE | 59 | #ifdef MIDI_ENABLE |
151 | if (keycode == MI_ON && record->event.pressed) { | 60 | process_midi(keycode, record) && |
152 | midi_activated = true; | ||
153 | music_scale_user(); | ||
154 | return false; | ||
155 | } | ||
156 | |||
157 | if (keycode == MI_OFF && record->event.pressed) { | ||
158 | midi_activated = false; | ||
159 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
160 | return false; | ||
161 | } | ||
162 | |||
163 | if (midi_activated) { | ||
164 | if (record->event.key.col == (MATRIX_COLS - 1) && record->event.key.row == (MATRIX_ROWS - 1)) { | ||
165 | if (record->event.pressed) { | ||
166 | starting_note++; // Change key | ||
167 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
168 | } | ||
169 | return false; | ||
170 | } | ||
171 | if (record->event.key.col == (MATRIX_COLS - 2) && record->event.key.row == (MATRIX_ROWS - 1)) { | ||
172 | if (record->event.pressed) { | ||
173 | starting_note--; // Change key | ||
174 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
175 | } | ||
176 | return false; | ||
177 | } | ||
178 | if (record->event.key.col == (MATRIX_COLS - 3) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { | ||
179 | offset++; // Change scale | ||
180 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
181 | return false; | ||
182 | } | ||
183 | if (record->event.key.col == (MATRIX_COLS - 4) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { | ||
184 | offset--; // Change scale | ||
185 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
186 | return false; | ||
187 | } | ||
188 | // basic | ||
189 | // uint8_t note = (starting_note + SCALE[record->event.key.col + offset])+12*(MATRIX_ROWS - record->event.key.row); | ||
190 | // advanced | ||
191 | // uint8_t note = (starting_note + record->event.key.col + offset)+12*(MATRIX_ROWS - record->event.key.row); | ||
192 | // guitar | ||
193 | uint8_t note = (starting_note + record->event.key.col + offset)+5*(MATRIX_ROWS - record->event.key.row); | ||
194 | // violin | ||
195 | // uint8_t note = (starting_note + record->event.key.col + offset)+7*(MATRIX_ROWS - record->event.key.row); | ||
196 | |||
197 | if (record->event.pressed) { | ||
198 | // midi_send_noteon(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127); | ||
199 | midi_send_noteon(&midi_device, 0, note, 127); | ||
200 | } else { | ||
201 | // midi_send_noteoff(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127); | ||
202 | midi_send_noteoff(&midi_device, 0, note, 127); | ||
203 | } | ||
204 | |||
205 | if (keycode < 0xFF) // ignores all normal keycodes, but lets RAISE, LOWER, etc through | ||
206 | return false; | ||
207 | } | ||
208 | #endif | 61 | #endif |
209 | |||
210 | #ifdef AUDIO_ENABLE | 62 | #ifdef AUDIO_ENABLE |
211 | if (keycode == AU_ON && record->event.pressed) { | 63 | process_music(keycode, record) && |
212 | audio_on(); | ||
213 | return false; | ||
214 | } | ||
215 | |||
216 | if (keycode == AU_OFF && record->event.pressed) { | ||
217 | audio_off(); | ||
218 | return false; | ||
219 | } | ||
220 | |||
221 | if (keycode == AU_TOG && record->event.pressed) { | ||
222 | if (is_audio_on()) | ||
223 | { | ||
224 | audio_off(); | ||
225 | } | ||
226 | else | ||
227 | { | ||
228 | audio_on(); | ||
229 | } | ||
230 | return false; | ||
231 | } | ||
232 | |||
233 | if (keycode == MU_ON && record->event.pressed) { | ||
234 | music_on(); | ||
235 | return false; | ||
236 | } | ||
237 | |||
238 | if (keycode == MU_OFF && record->event.pressed) { | ||
239 | music_off(); | ||
240 | return false; | ||
241 | } | ||
242 | |||
243 | if (keycode == MU_TOG && record->event.pressed) { | ||
244 | if (music_activated) | ||
245 | { | ||
246 | music_off(); | ||
247 | } | ||
248 | else | ||
249 | { | ||
250 | music_on(); | ||
251 | } | ||
252 | return false; | ||
253 | } | ||
254 | |||
255 | if (keycode == MUV_IN && record->event.pressed) { | ||
256 | voice_iterate(); | ||
257 | music_scale_user(); | ||
258 | return false; | ||
259 | } | ||
260 | |||
261 | if (keycode == MUV_DE && record->event.pressed) { | ||
262 | voice_deiterate(); | ||
263 | music_scale_user(); | ||
264 | return false; | ||
265 | } | ||
266 | |||
267 | if (music_activated) { | ||
268 | |||
269 | if (keycode == KC_LCTL && record->event.pressed) { // Start recording | ||
270 | stop_all_notes(); | ||
271 | music_sequence_recording = true; | ||
272 | music_sequence_playing = false; | ||
273 | music_sequence_count = 0; | ||
274 | return false; | ||
275 | } | ||
276 | |||
277 | if (keycode == KC_LALT && record->event.pressed) { // Stop recording/playing | ||
278 | stop_all_notes(); | ||
279 | music_sequence_recording = false; | ||
280 | music_sequence_playing = false; | ||
281 | return false; | ||
282 | } | ||
283 | |||
284 | if (keycode == KC_LGUI && record->event.pressed) { // Start playing | ||
285 | stop_all_notes(); | ||
286 | music_sequence_recording = false; | ||
287 | music_sequence_playing = true; | ||
288 | music_sequence_position = 0; | ||
289 | music_sequence_timer = 0; | ||
290 | return false; | ||
291 | } | ||
292 | |||
293 | if (keycode == KC_UP) { | ||
294 | if (record->event.pressed) | ||
295 | music_sequence_interval-=10; | ||
296 | return false; | ||
297 | } | ||
298 | |||
299 | if (keycode == KC_DOWN) { | ||
300 | if (record->event.pressed) | ||
301 | music_sequence_interval+=10; | ||
302 | return false; | ||
303 | } | ||
304 | |||
305 | float freq = ((float)220.0)*pow(2.0, -5.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)); | ||
306 | if (record->event.pressed) { | ||
307 | play_note(freq, 0xF); | ||
308 | if (music_sequence_recording) { | ||
309 | music_sequence[music_sequence_count] = freq; | ||
310 | music_sequence_count++; | ||
311 | } | ||
312 | } else { | ||
313 | stop_note(freq); | ||
314 | } | ||
315 | |||
316 | if (keycode < 0xFF) // ignores all normal keycodes, but lets RAISE, LOWER, etc through | ||
317 | return false; | ||
318 | } | ||
319 | #endif | 64 | #endif |
320 | 65 | #ifdef TAP_DANCE_ENABLE | |
321 | #ifndef DISABLE_LEADER | 66 | process_tap_dance(keycode, record) && |
322 | // Leader key set-up | 67 | #endif |
323 | if (record->event.pressed) { | 68 | #ifndef DISABLE_LEADER |
324 | if (!leading && keycode == KC_LEAD) { | 69 | process_leader(keycode, record) && |
325 | leader_start(); | 70 | #endif |
326 | leading = true; | 71 | #ifndef DISABLE_CHORDING |
327 | leader_time = timer_read(); | 72 | process_chording(keycode, record) && |
328 | leader_sequence_size = 0; | 73 | #endif |
329 | leader_sequence[0] = 0; | 74 | #ifdef UNICODE_ENABLE |
330 | leader_sequence[1] = 0; | 75 | process_unicode(keycode, record) && |
331 | leader_sequence[2] = 0; | 76 | #endif |
332 | leader_sequence[3] = 0; | 77 | true)) { |
333 | leader_sequence[4] = 0; | 78 | return false; |
334 | return false; | ||
335 | } | ||
336 | if (leading && timer_elapsed(leader_time) < LEADER_TIMEOUT) { | ||
337 | leader_sequence[leader_sequence_size] = keycode; | ||
338 | leader_sequence_size++; | ||
339 | return false; | ||
340 | } | ||
341 | } | ||
342 | #endif | ||
343 | |||
344 | #define DISABLE_CHORDING | ||
345 | #ifndef DISABLE_CHORDING | ||
346 | |||
347 | if (keycode >= QK_CHORDING && keycode <= QK_CHORDING_MAX) { | ||
348 | if (record->event.pressed) { | ||
349 | if (!chording) { | ||
350 | chording = true; | ||
351 | for (uint8_t i = 0; i < CHORDING_MAX; i++) | ||
352 | chord_keys[i] = 0; | ||
353 | chord_key_count = 0; | ||
354 | chord_key_down = 0; | ||
355 | } | ||
356 | chord_keys[chord_key_count] = (keycode & 0xFF); | ||
357 | chord_key_count++; | ||
358 | chord_key_down++; | ||
359 | return false; | ||
360 | } else { | ||
361 | if (chording) { | ||
362 | chord_key_down--; | ||
363 | if (chord_key_down == 0) { | ||
364 | chording = false; | ||
365 | // Chord Dictionary | ||
366 | if (keys_chord((uint8_t[]){KC_ENTER, KC_SPACE})) { | ||
367 | register_code(KC_A); | ||
368 | unregister_code(KC_A); | ||
369 | return false; | ||
370 | } | ||
371 | for (uint8_t i = 0; i < chord_key_count; i++) { | ||
372 | register_code(chord_keys[i]); | ||
373 | unregister_code(chord_keys[i]); | ||
374 | return false; | ||
375 | } | ||
376 | } | ||
377 | } | ||
378 | } | ||
379 | } | ||
380 | |||
381 | #endif | ||
382 | |||
383 | #ifdef UNICODE_ENABLE | ||
384 | |||
385 | if (keycode > QK_UNICODE && record->event.pressed) { | ||
386 | uint16_t unicode = keycode & 0x7FFF; | ||
387 | switch(input_mode) { | ||
388 | case UC_OSX: | ||
389 | register_code(KC_LALT); | ||
390 | break; | ||
391 | case UC_LNX: | ||
392 | register_code(KC_LCTL); | ||
393 | register_code(KC_LSFT); | ||
394 | register_code(KC_U); | ||
395 | unregister_code(KC_U); | ||
396 | break; | ||
397 | case UC_WIN: | ||
398 | register_code(KC_LALT); | ||
399 | register_code(KC_PPLS); | ||
400 | unregister_code(KC_PPLS); | ||
401 | break; | ||
402 | } | ||
403 | for(int i = 3; i >= 0; i--) { | ||
404 | uint8_t digit = ((unicode >> (i*4)) & 0xF); | ||
405 | register_code(hex_to_keycode(digit)); | ||
406 | unregister_code(hex_to_keycode(digit)); | ||
407 | } | ||
408 | switch(input_mode) { | ||
409 | case UC_OSX: | ||
410 | case UC_WIN: | ||
411 | unregister_code(KC_LALT); | ||
412 | break; | ||
413 | case UC_LNX: | ||
414 | unregister_code(KC_LCTL); | ||
415 | unregister_code(KC_LSFT); | ||
416 | break; | ||
417 | } | ||
418 | } | 79 | } |
419 | 80 | ||
420 | #endif | ||
421 | |||
422 | // Shift / paren setup | 81 | // Shift / paren setup |
423 | 82 | ||
424 | switch(keycode) { | 83 | switch(keycode) { |
@@ -657,46 +316,15 @@ void matrix_init_quantum() { | |||
657 | 316 | ||
658 | void matrix_scan_quantum() { | 317 | void matrix_scan_quantum() { |
659 | #ifdef AUDIO_ENABLE | 318 | #ifdef AUDIO_ENABLE |
660 | if (music_sequence_playing) { | 319 | matrix_scan_music(); |
661 | if ((music_sequence_timer == 0) || (timer_elapsed(music_sequence_timer) > music_sequence_interval)) { | ||
662 | music_sequence_timer = timer_read(); | ||
663 | stop_note(music_sequence[(music_sequence_position - 1 < 0)?(music_sequence_position - 1 + music_sequence_count):(music_sequence_position - 1)]); | ||
664 | play_note(music_sequence[music_sequence_position], 0xF); | ||
665 | music_sequence_position = (music_sequence_position + 1) % music_sequence_count; | ||
666 | } | ||
667 | } | ||
668 | |||
669 | #endif | 320 | #endif |
670 | 321 | ||
322 | #ifdef TAP_DANCE_ENABLE | ||
323 | matrix_scan_tap_dance(); | ||
324 | #endif | ||
671 | matrix_scan_kb(); | 325 | matrix_scan_kb(); |
672 | } | 326 | } |
673 | 327 | ||
674 | #ifdef AUDIO_ENABLE | ||
675 | bool is_music_on(void) { | ||
676 | return (music_activated != 0); | ||
677 | } | ||
678 | |||
679 | void music_toggle(void) { | ||
680 | if (!music_activated) { | ||
681 | music_on(); | ||
682 | } else { | ||
683 | music_off(); | ||
684 | } | ||
685 | } | ||
686 | |||
687 | void music_on(void) { | ||
688 | music_activated = 1; | ||
689 | music_on_user(); | ||
690 | } | ||
691 | |||
692 | void music_off(void) { | ||
693 | music_activated = 0; | ||
694 | stop_all_notes(); | ||
695 | } | ||
696 | |||
697 | #endif | ||
698 | |||
699 | |||
700 | #if defined(BACKLIGHT_ENABLE) && defined(BACKLIGHT_PIN) | 328 | #if defined(BACKLIGHT_ENABLE) && defined(BACKLIGHT_PIN) |
701 | 329 | ||
702 | static const uint8_t backlight_pin = BACKLIGHT_PIN; | 330 | static const uint8_t backlight_pin = BACKLIGHT_PIN; |
@@ -1048,13 +676,4 @@ void startup_user() {} | |||
1048 | __attribute__ ((weak)) | 676 | __attribute__ ((weak)) |
1049 | void shutdown_user() {} | 677 | void shutdown_user() {} |
1050 | 678 | ||
1051 | __attribute__ ((weak)) | ||
1052 | void music_on_user() {} | ||
1053 | |||
1054 | __attribute__ ((weak)) | ||
1055 | void audio_on_user() {} | ||
1056 | |||
1057 | __attribute__ ((weak)) | ||
1058 | void music_scale_user() {} | ||
1059 | |||
1060 | //------------------------------------------------------------------------------ | 679 | //------------------------------------------------------------------------------ |
diff --git a/quantum/quantum.h b/quantum/quantum.h index 7795294d5..ad180c71f 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
@@ -10,15 +10,6 @@ | |||
10 | #ifdef RGBLIGHT_ENABLE | 10 | #ifdef RGBLIGHT_ENABLE |
11 | #include "rgblight.h" | 11 | #include "rgblight.h" |
12 | #endif | 12 | #endif |
13 | #ifdef AUDIO_ENABLE | ||
14 | #include "audio.h" | ||
15 | #endif | ||
16 | #ifdef MIDI_ENABLE | ||
17 | #include <lufa.h> | ||
18 | #endif | ||
19 | #ifdef UNICODE_ENABLE | ||
20 | #include "unicode.h" | ||
21 | #endif | ||
22 | 13 | ||
23 | #include "action_layer.h" | 14 | #include "action_layer.h" |
24 | #include "eeconfig.h" | 15 | #include "eeconfig.h" |
@@ -32,42 +23,38 @@ | |||
32 | #include "led.h" | 23 | #include "led.h" |
33 | #include "action_util.h" | 24 | #include "action_util.h" |
34 | 25 | ||
26 | |||
35 | extern uint32_t default_layer_state; | 27 | extern uint32_t default_layer_state; |
36 | 28 | ||
37 | #ifndef NO_ACTION_LAYER | 29 | #ifndef NO_ACTION_LAYER |
38 | extern uint32_t layer_state; | 30 | extern uint32_t layer_state; |
39 | #endif | 31 | #endif |
40 | 32 | ||
33 | #ifdef MIDI_ENABLE | ||
34 | #include <lufa.h> | ||
35 | #include "process_midi.h" | ||
36 | #endif | ||
37 | |||
41 | #ifdef AUDIO_ENABLE | 38 | #ifdef AUDIO_ENABLE |
42 | bool music_activated; | 39 | #include "audio.h" |
40 | #include "process_music.h" | ||
43 | #endif | 41 | #endif |
44 | 42 | ||
45 | #ifdef UNICODE_ENABLE | 43 | #ifndef DISABLE_LEADER |
46 | #define UC_OSX 0 | 44 | #include "process_leader.h" |
47 | #define UC_LNX 1 | 45 | #endif |
48 | #define UC_WIN 2 | ||
49 | #define UC_BSD 3 | ||
50 | 46 | ||
51 | void set_unicode_input_mode(uint8_t os_target); | 47 | #define DISABLE_CHORDING |
48 | #ifndef DISABLE_CHORDING | ||
49 | #include "process_chording.h" | ||
52 | #endif | 50 | #endif |
53 | 51 | ||
54 | #ifndef DISABLE_LEADER | 52 | #ifdef UNICODE_ENABLE |
55 | void leader_start(void); | 53 | #include "process_unicode.h" |
56 | void leader_end(void); | ||
57 | |||
58 | #ifndef LEADER_TIMEOUT | ||
59 | #define LEADER_TIMEOUT 200 | ||
60 | #endif | ||
61 | #define SEQ_ONE_KEY(key) if (leader_sequence[0] == (key) && leader_sequence[1] == 0 && leader_sequence[2] == 0 && leader_sequence[3] == 0 && leader_sequence[4] == 0) | ||
62 | #define SEQ_TWO_KEYS(key1, key2) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == 0 && leader_sequence[3] == 0 && leader_sequence[4] == 0) | ||
63 | #define SEQ_THREE_KEYS(key1, key2, key3) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == (key3) && leader_sequence[3] == 0 && leader_sequence[4] == 0) | ||
64 | #define SEQ_FOUR_KEYS(key1, key2, key3, key4) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == (key3) && leader_sequence[3] == (key4) && leader_sequence[4] == 0) | ||
65 | #define SEQ_FIVE_KEYS(key1, key2, key3, key4, key5) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == (key3) && leader_sequence[3] == (key4) && leader_sequence[4] == (key5)) | ||
66 | |||
67 | #define LEADER_EXTERNS() extern bool leading; extern uint16_t leader_time; extern uint16_t leader_sequence[5]; extern uint8_t leader_sequence_size | ||
68 | #define LEADER_DICTIONARY() if (leading && timer_elapsed(leader_time) > LEADER_TIMEOUT) | ||
69 | #endif | 54 | #endif |
70 | 55 | ||
56 | #include "process_tap_dance.h" | ||
57 | |||
71 | #define SEND_STRING(str) send_string(PSTR(str)) | 58 | #define SEND_STRING(str) send_string(PSTR(str)) |
72 | void send_string(const char *str); | 59 | void send_string(const char *str); |
73 | 60 | ||
@@ -84,16 +71,8 @@ bool process_action_kb(keyrecord_t *record); | |||
84 | bool process_record_kb(uint16_t keycode, keyrecord_t *record); | 71 | bool process_record_kb(uint16_t keycode, keyrecord_t *record); |
85 | bool process_record_user(uint16_t keycode, keyrecord_t *record); | 72 | bool process_record_user(uint16_t keycode, keyrecord_t *record); |
86 | 73 | ||
87 | bool is_music_on(void); | ||
88 | void music_toggle(void); | ||
89 | void music_on(void); | ||
90 | void music_off(void); | ||
91 | |||
92 | void startup_user(void); | 74 | void startup_user(void); |
93 | void shutdown_user(void); | 75 | void shutdown_user(void); |
94 | void audio_on_user(void); | ||
95 | void music_on_user(void); | ||
96 | void music_scale_user(void); | ||
97 | 76 | ||
98 | #ifdef BACKLIGHT_ENABLE | 77 | #ifdef BACKLIGHT_ENABLE |
99 | void backlight_init_ports(void); | 78 | void backlight_init_ports(void); |
diff --git a/tmk_core/common.mk b/tmk_core/common.mk index a1eb38c9c..f2a22e4f8 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk | |||
@@ -17,10 +17,11 @@ SRC += $(COMMON_DIR)/host.c \ | |||
17 | 17 | ||
18 | # Option modules | 18 | # Option modules |
19 | ifeq ($(strip $(BOOTMAGIC_ENABLE)), yes) | 19 | ifeq ($(strip $(BOOTMAGIC_ENABLE)), yes) |
20 | OPT_DEFS += -DBOOTMAGIC_ENABLE | ||
20 | SRC += $(COMMON_DIR)/bootmagic.c | 21 | SRC += $(COMMON_DIR)/bootmagic.c |
21 | SRC += $(COMMON_DIR)/avr/eeconfig.c | 22 | SRC += $(COMMON_DIR)/avr/eeconfig.c |
22 | OPT_DEFS += -DBOOTMAGIC_ENABLE | ||
23 | else | 23 | else |
24 | OPT_DEFS += -DMAGIC_ENABLE | ||
24 | SRC += $(COMMON_DIR)/magic.c | 25 | SRC += $(COMMON_DIR)/magic.c |
25 | SRC += $(COMMON_DIR)/avr/eeconfig.c | 26 | SRC += $(COMMON_DIR)/avr/eeconfig.c |
26 | endif | 27 | endif |
@@ -51,18 +52,6 @@ ifeq ($(strip $(NKRO_ENABLE)), yes) | |||
51 | OPT_DEFS += -DNKRO_ENABLE | 52 | OPT_DEFS += -DNKRO_ENABLE |
52 | endif | 53 | endif |
53 | 54 | ||
54 | ifeq ($(strip $(MIDI_ENABLE)), yes) | ||
55 | OPT_DEFS += -DMIDI_ENABLE | ||
56 | endif | ||
57 | |||
58 | ifeq ($(strip $(AUDIO_ENABLE)), yes) | ||
59 | OPT_DEFS += -DAUDIO_ENABLE | ||
60 | endif | ||
61 | |||
62 | ifeq ($(strip $(UNICODE_ENABLE)), yes) | ||
63 | OPT_DEFS += -DUNICODE_ENABLE | ||
64 | endif | ||
65 | |||
66 | ifeq ($(strip $(USB_6KRO_ENABLE)), yes) | 55 | ifeq ($(strip $(USB_6KRO_ENABLE)), yes) |
67 | OPT_DEFS += -DUSB_6KRO_ENABLE | 56 | OPT_DEFS += -DUSB_6KRO_ENABLE |
68 | endif | 57 | endif |