diff options
Diffstat (limited to 'quantum')
92 files changed, 3324 insertions, 1269 deletions
diff --git a/quantum/analog.c b/quantum/analog.c index 49b84ee0e..1ec38df75 100644 --- a/quantum/analog.c +++ b/quantum/analog.c | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2015 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | // Simple analog to digitial conversion | 17 | // Simple analog to digitial conversion |
| 2 | 18 | ||
| 3 | #include <avr/io.h> | 19 | #include <avr/io.h> |
diff --git a/quantum/analog.h b/quantum/analog.h index 9b95a93be..8d93de7dc 100644 --- a/quantum/analog.h +++ b/quantum/analog.h | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2015 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #ifndef _analog_h_included__ | 17 | #ifndef _analog_h_included__ |
| 2 | #define _analog_h_included__ | 18 | #define _analog_h_included__ |
| 3 | 19 | ||
diff --git a/quantum/api.c b/quantum/api.c index 6a7c0a433..52dfe23e1 100644 --- a/quantum/api.c +++ b/quantum/api.c | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #include "api.h" | 17 | #include "api.h" |
| 2 | #include "quantum.h" | 18 | #include "quantum.h" |
| 3 | 19 | ||
| @@ -176,4 +192,4 @@ void process_api(uint16_t length, uint8_t * data) { | |||
| 176 | // #endif | 192 | // #endif |
| 177 | } | 193 | } |
| 178 | 194 | ||
| 179 | } \ No newline at end of file | 195 | } |
diff --git a/quantum/api.h b/quantum/api.h index 00dcdb895..efc0ddca1 100644 --- a/quantum/api.h +++ b/quantum/api.h | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #ifndef _API_H_ | 17 | #ifndef _API_H_ |
| 2 | #define _API_H_ | 18 | #define _API_H_ |
| 3 | 19 | ||
| @@ -56,4 +72,4 @@ bool process_api_keyboard(uint8_t length, uint8_t * data); | |||
| 56 | __attribute__ ((weak)) | 72 | __attribute__ ((weak)) |
| 57 | bool process_api_user(uint8_t length, uint8_t * data); | 73 | bool process_api_user(uint8_t length, uint8_t * data); |
| 58 | 74 | ||
| 59 | #endif \ No newline at end of file | 75 | #endif |
diff --git a/quantum/api/api_sysex.c b/quantum/api/api_sysex.c index 868f854b9..6a2ee9012 100644 --- a/quantum/api/api_sysex.c +++ b/quantum/api/api_sysex.c | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert, Fred Sundvik | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #include "api_sysex.h" | 16 | #include "api_sysex.h" |
| 2 | #include "sysex_tools.h" | 17 | #include "sysex_tools.h" |
| 3 | #include "print.h" | 18 | #include "print.h" |
diff --git a/quantum/api/api_sysex.h b/quantum/api/api_sysex.h index b947b60e5..a23f00f57 100644 --- a/quantum/api/api_sysex.h +++ b/quantum/api/api_sysex.h | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #ifndef _API_SYSEX_H_ | 17 | #ifndef _API_SYSEX_H_ |
| 2 | #define _API_SYSEX_H_ | 18 | #define _API_SYSEX_H_ |
| 3 | 19 | ||
| @@ -7,4 +23,4 @@ void send_bytes_sysex(uint8_t message_type, uint8_t data_type, uint8_t * bytes, | |||
| 7 | 23 | ||
| 8 | #define SEND_BYTES(mt, dt, b, l) send_bytes_sysex(mt, dt, b, l) | 24 | #define SEND_BYTES(mt, dt, b, l) send_bytes_sysex(mt, dt, b, l) |
| 9 | 25 | ||
| 10 | #endif \ No newline at end of file | 26 | #endif |
diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index 2a315fd16..597073611 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #include <stdio.h> | 16 | #include <stdio.h> |
| 2 | #include <string.h> | 17 | #include <string.h> |
| 3 | //#include <math.h> | 18 | //#include <math.h> |
| @@ -89,15 +104,15 @@ void audio_init() | |||
| 89 | } | 104 | } |
| 90 | audio_config.raw = eeconfig_read_audio(); | 105 | audio_config.raw = eeconfig_read_audio(); |
| 91 | 106 | ||
| 92 | // Set port PC6 (OC3A and /OC4A) as output | 107 | // Set port PC6 (OC3A and /OC4A) as output |
| 93 | DDRC |= _BV(PORTC6); | 108 | DDRC |= _BV(PORTC6); |
| 94 | 109 | ||
| 95 | DISABLE_AUDIO_COUNTER_3_ISR; | 110 | DISABLE_AUDIO_COUNTER_3_ISR; |
| 96 | 111 | ||
| 97 | // TCCR3A / TCCR3B: Timer/Counter #3 Control Registers | 112 | // TCCR3A / TCCR3B: Timer/Counter #3 Control Registers |
| 98 | // Compare Output Mode (COM3An) = 0b00 = Normal port operation, OC3A disconnected from PC6 | 113 | // Compare Output Mode (COM3An) = 0b00 = Normal port operation, OC3A disconnected from PC6 |
| 99 | // Waveform Generation Mode (WGM3n) = 0b1110 = Fast PWM Mode 14 (Period = ICR3, Duty Cycle = OCR3A) | 114 | // Waveform Generation Mode (WGM3n) = 0b1110 = Fast PWM Mode 14 (Period = ICR3, Duty Cycle = OCR3A) |
| 100 | // Clock Select (CS3n) = 0b010 = Clock / 8 | 115 | // Clock Select (CS3n) = 0b010 = Clock / 8 |
| 101 | TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30); | 116 | TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30); |
| 102 | TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30); | 117 | TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30); |
| 103 | 118 | ||
| @@ -106,6 +121,8 @@ void audio_init() | |||
| 106 | 121 | ||
| 107 | void stop_all_notes() | 122 | void stop_all_notes() |
| 108 | { | 123 | { |
| 124 | dprintf("audio stop all notes"); | ||
| 125 | |||
| 109 | if (!audio_initialized) { | 126 | if (!audio_initialized) { |
| 110 | audio_init(); | 127 | audio_init(); |
| 111 | } | 128 | } |
| @@ -128,6 +145,8 @@ void stop_all_notes() | |||
| 128 | 145 | ||
| 129 | void stop_note(float freq) | 146 | void stop_note(float freq) |
| 130 | { | 147 | { |
| 148 | dprintf("audio stop note freq=%d", (int)freq); | ||
| 149 | |||
| 131 | if (playing_note) { | 150 | if (playing_note) { |
| 132 | if (!audio_initialized) { | 151 | if (!audio_initialized) { |
| 133 | audio_init(); | 152 | audio_init(); |
| @@ -183,159 +202,161 @@ float vibrato(float average_freq) { | |||
| 183 | 202 | ||
| 184 | ISR(TIMER3_COMPA_vect) | 203 | ISR(TIMER3_COMPA_vect) |
| 185 | { | 204 | { |
| 186 | float freq; | 205 | float freq; |
| 187 | 206 | ||
| 188 | if (playing_note) { | 207 | if (playing_note) { |
| 189 | if (voices > 0) { | 208 | if (voices > 0) { |
| 190 | if (polyphony_rate > 0) { | 209 | if (polyphony_rate > 0) { |
| 191 | if (voices > 1) { | 210 | if (voices > 1) { |
| 192 | voice_place %= voices; | 211 | voice_place %= voices; |
| 193 | if (place++ > (frequencies[voice_place] / polyphony_rate / CPU_PRESCALER)) { | 212 | if (place++ > (frequencies[voice_place] / polyphony_rate / CPU_PRESCALER)) { |
| 194 | voice_place = (voice_place + 1) % voices; | 213 | voice_place = (voice_place + 1) % voices; |
| 195 | place = 0.0; | 214 | place = 0.0; |
| 196 | } | 215 | } |
| 197 | } | 216 | } |
| 198 | 217 | ||
| 199 | #ifdef VIBRATO_ENABLE | 218 | #ifdef VIBRATO_ENABLE |
| 200 | if (vibrato_strength > 0) { | 219 | if (vibrato_strength > 0) { |
| 201 | freq = vibrato(frequencies[voice_place]); | 220 | freq = vibrato(frequencies[voice_place]); |
| 202 | } else { | 221 | } else { |
| 203 | freq = frequencies[voice_place]; | 222 | freq = frequencies[voice_place]; |
| 204 | } | 223 | } |
| 205 | #else | 224 | #else |
| 206 | freq = frequencies[voice_place]; | 225 | freq = frequencies[voice_place]; |
| 207 | #endif | 226 | #endif |
| 208 | } else { | 227 | } else { |
| 209 | if (glissando) { | 228 | if (glissando) { |
| 210 | if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440/frequencies[voices - 1]/12/2)) { | 229 | if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440/frequencies[voices - 1]/12/2)) { |
| 211 | frequency = frequency * pow(2, 440/frequency/12/2); | 230 | frequency = frequency * pow(2, 440/frequency/12/2); |
| 212 | } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440/frequencies[voices - 1]/12/2)) { | 231 | } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440/frequencies[voices - 1]/12/2)) { |
| 213 | frequency = frequency * pow(2, -440/frequency/12/2); | 232 | frequency = frequency * pow(2, -440/frequency/12/2); |
| 214 | } else { | 233 | } else { |
| 215 | frequency = frequencies[voices - 1]; | 234 | frequency = frequencies[voices - 1]; |
| 216 | } | 235 | } |
| 217 | } else { | 236 | } else { |
| 218 | frequency = frequencies[voices - 1]; | 237 | frequency = frequencies[voices - 1]; |
| 219 | } | 238 | } |
| 220 | 239 | ||
| 221 | #ifdef VIBRATO_ENABLE | 240 | #ifdef VIBRATO_ENABLE |
| 222 | if (vibrato_strength > 0) { | 241 | if (vibrato_strength > 0) { |
| 223 | freq = vibrato(frequency); | 242 | freq = vibrato(frequency); |
| 224 | } else { | 243 | } else { |
| 225 | freq = frequency; | 244 | freq = frequency; |
| 226 | } | 245 | } |
| 227 | #else | 246 | #else |
| 228 | freq = frequency; | 247 | freq = frequency; |
| 229 | #endif | 248 | #endif |
| 230 | } | 249 | } |
| 231 | 250 | ||
| 232 | if (envelope_index < 65535) { | 251 | if (envelope_index < 65535) { |
| 233 | envelope_index++; | 252 | envelope_index++; |
| 234 | } | 253 | } |
| 235 | 254 | ||
| 236 | freq = voice_envelope(freq); | 255 | freq = voice_envelope(freq); |
| 237 | 256 | ||
| 238 | if (freq < 30.517578125) { | 257 | if (freq < 30.517578125) { |
| 239 | freq = 30.52; | 258 | freq = 30.52; |
| 240 | } | 259 | } |
| 241 | 260 | ||
| 242 | TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER)); | 261 | TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER)); |
| 243 | TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); | 262 | TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); |
| 244 | } | 263 | } |
| 245 | } | 264 | } |
| 246 | 265 | ||
| 247 | if (playing_notes) { | 266 | if (playing_notes) { |
| 248 | if (note_frequency > 0) { | 267 | if (note_frequency > 0) { |
| 249 | #ifdef VIBRATO_ENABLE | 268 | #ifdef VIBRATO_ENABLE |
| 250 | if (vibrato_strength > 0) { | 269 | if (vibrato_strength > 0) { |
| 251 | freq = vibrato(note_frequency); | 270 | freq = vibrato(note_frequency); |
| 252 | } else { | 271 | } else { |
| 253 | freq = note_frequency; | 272 | freq = note_frequency; |
| 254 | } | 273 | } |
| 255 | #else | 274 | #else |
| 256 | freq = note_frequency; | 275 | freq = note_frequency; |
| 257 | #endif | 276 | #endif |
| 258 | 277 | ||
| 259 | if (envelope_index < 65535) { | 278 | if (envelope_index < 65535) { |
| 260 | envelope_index++; | 279 | envelope_index++; |
| 261 | } | 280 | } |
| 262 | freq = voice_envelope(freq); | 281 | freq = voice_envelope(freq); |
| 263 | 282 | ||
| 264 | TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER)); | 283 | TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER)); |
| 265 | TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); | 284 | TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); |
| 266 | } else { | 285 | } else { |
| 267 | TIMER_3_PERIOD = 0; | 286 | TIMER_3_PERIOD = 0; |
| 268 | TIMER_3_DUTY_CYCLE = 0; | 287 | TIMER_3_DUTY_CYCLE = 0; |
| 269 | } | 288 | } |
| 270 | 289 | ||
| 271 | note_position++; | 290 | note_position++; |
| 272 | bool end_of_note = false; | 291 | bool end_of_note = false; |
| 273 | if (TIMER_3_PERIOD > 0) { | 292 | if (TIMER_3_PERIOD > 0) { |
| 274 | end_of_note = (note_position >= (note_length / TIMER_3_PERIOD * 0xFFFF)); | 293 | end_of_note = (note_position >= (note_length / TIMER_3_PERIOD * 0xFFFF)); |
| 275 | } else { | 294 | } else { |
| 276 | end_of_note = (note_position >= (note_length * 0x7FF)); | 295 | end_of_note = (note_position >= (note_length * 0x7FF)); |
| 277 | } | 296 | } |
| 278 | 297 | ||
| 279 | if (end_of_note) { | 298 | if (end_of_note) { |
| 280 | current_note++; | 299 | current_note++; |
| 281 | if (current_note >= notes_count) { | 300 | if (current_note >= notes_count) { |
| 282 | if (notes_repeat) { | 301 | if (notes_repeat) { |
| 283 | current_note = 0; | 302 | current_note = 0; |
| 284 | } else { | 303 | } else { |
| 285 | DISABLE_AUDIO_COUNTER_3_ISR; | 304 | DISABLE_AUDIO_COUNTER_3_ISR; |
| 286 | DISABLE_AUDIO_COUNTER_3_OUTPUT; | 305 | DISABLE_AUDIO_COUNTER_3_OUTPUT; |
| 287 | playing_notes = false; | 306 | playing_notes = false; |
| 288 | return; | 307 | return; |
| 289 | } | 308 | } |
| 290 | } | 309 | } |
| 291 | if (!note_resting && (notes_rest > 0)) { | 310 | if (!note_resting && (notes_rest > 0)) { |
| 292 | note_resting = true; | 311 | note_resting = true; |
| 293 | note_frequency = 0; | 312 | note_frequency = 0; |
| 294 | note_length = notes_rest; | 313 | note_length = notes_rest; |
| 295 | current_note--; | 314 | current_note--; |
| 296 | } else { | 315 | } else { |
| 297 | note_resting = false; | 316 | note_resting = false; |
| 298 | envelope_index = 0; | 317 | envelope_index = 0; |
| 299 | note_frequency = (*notes_pointer)[current_note][0]; | 318 | note_frequency = (*notes_pointer)[current_note][0]; |
| 300 | note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); | 319 | note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); |
| 301 | } | 320 | } |
| 302 | 321 | ||
| 303 | note_position = 0; | 322 | note_position = 0; |
| 304 | } | 323 | } |
| 305 | } | 324 | } |
| 306 | 325 | ||
| 307 | if (!audio_config.enable) { | 326 | if (!audio_config.enable) { |
| 308 | playing_notes = false; | 327 | playing_notes = false; |
| 309 | playing_note = false; | 328 | playing_note = false; |
| 310 | } | 329 | } |
| 311 | } | 330 | } |
| 312 | 331 | ||
| 313 | void play_note(float freq, int vol) { | 332 | void play_note(float freq, int vol) { |
| 314 | 333 | ||
| 334 | dprintf("audio play note freq=%d vol=%d", (int)freq, vol); | ||
| 335 | |||
| 315 | if (!audio_initialized) { | 336 | if (!audio_initialized) { |
| 316 | audio_init(); | 337 | audio_init(); |
| 317 | } | 338 | } |
| 318 | 339 | ||
| 319 | if (audio_config.enable && voices < 8) { | 340 | if (audio_config.enable && voices < 8) { |
| 320 | DISABLE_AUDIO_COUNTER_3_ISR; | 341 | DISABLE_AUDIO_COUNTER_3_ISR; |
| 321 | 342 | ||
| 322 | // Cancel notes if notes are playing | 343 | // Cancel notes if notes are playing |
| 323 | if (playing_notes) | 344 | if (playing_notes) |
| 324 | stop_all_notes(); | 345 | stop_all_notes(); |
| 325 | 346 | ||
| 326 | playing_note = true; | 347 | playing_note = true; |
| 327 | 348 | ||
| 328 | envelope_index = 0; | 349 | envelope_index = 0; |
| 329 | 350 | ||
| 330 | if (freq > 0) { | 351 | if (freq > 0) { |
| 331 | frequencies[voices] = freq; | 352 | frequencies[voices] = freq; |
| 332 | volumes[voices] = vol; | 353 | volumes[voices] = vol; |
| 333 | voices++; | 354 | voices++; |
| 334 | } | 355 | } |
| 335 | 356 | ||
| 336 | ENABLE_AUDIO_COUNTER_3_ISR; | 357 | ENABLE_AUDIO_COUNTER_3_ISR; |
| 337 | ENABLE_AUDIO_COUNTER_3_OUTPUT; | 358 | ENABLE_AUDIO_COUNTER_3_OUTPUT; |
| 338 | } | 359 | } |
| 339 | 360 | ||
| 340 | } | 361 | } |
| 341 | 362 | ||
| @@ -346,37 +367,37 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) | |||
| 346 | audio_init(); | 367 | audio_init(); |
| 347 | } | 368 | } |
| 348 | 369 | ||
| 349 | if (audio_config.enable) { | 370 | if (audio_config.enable) { |
| 350 | 371 | ||
| 351 | DISABLE_AUDIO_COUNTER_3_ISR; | 372 | DISABLE_AUDIO_COUNTER_3_ISR; |
| 352 | 373 | ||
| 353 | // Cancel note if a note is playing | 374 | // Cancel note if a note is playing |
| 354 | if (playing_note) | 375 | if (playing_note) |
| 355 | stop_all_notes(); | 376 | stop_all_notes(); |
| 356 | 377 | ||
| 357 | playing_notes = true; | 378 | playing_notes = true; |
| 358 | 379 | ||
| 359 | notes_pointer = np; | 380 | notes_pointer = np; |
| 360 | notes_count = n_count; | 381 | notes_count = n_count; |
| 361 | notes_repeat = n_repeat; | 382 | notes_repeat = n_repeat; |
| 362 | notes_rest = n_rest; | 383 | notes_rest = n_rest; |
| 363 | 384 | ||
| 364 | place = 0; | 385 | place = 0; |
| 365 | current_note = 0; | 386 | current_note = 0; |
| 366 | 387 | ||
| 367 | note_frequency = (*notes_pointer)[current_note][0]; | 388 | note_frequency = (*notes_pointer)[current_note][0]; |
| 368 | note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); | 389 | note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); |
| 369 | note_position = 0; | 390 | note_position = 0; |
| 370 | 391 | ||
| 371 | 392 | ||
| 372 | ENABLE_AUDIO_COUNTER_3_ISR; | 393 | ENABLE_AUDIO_COUNTER_3_ISR; |
| 373 | ENABLE_AUDIO_COUNTER_3_OUTPUT; | 394 | ENABLE_AUDIO_COUNTER_3_OUTPUT; |
| 374 | } | 395 | } |
| 375 | 396 | ||
| 376 | } | 397 | } |
| 377 | 398 | ||
| 378 | bool is_playing_notes(void) { | 399 | bool is_playing_notes(void) { |
| 379 | return playing_notes; | 400 | return playing_notes; |
| 380 | } | 401 | } |
| 381 | 402 | ||
| 382 | bool is_audio_on(void) { | 403 | bool is_audio_on(void) { |
diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index 47f326ea0..27fdc2ab6 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #ifndef AUDIO_H | 16 | #ifndef AUDIO_H |
| 2 | #define AUDIO_H | 17 | #define AUDIO_H |
| 3 | 18 | ||
| @@ -88,4 +103,4 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) | |||
| 88 | 103 | ||
| 89 | bool is_playing_notes(void); | 104 | bool is_playing_notes(void); |
| 90 | 105 | ||
| 91 | #endif \ No newline at end of file | 106 | #endif |
diff --git a/quantum/audio/audio_pwm.c b/quantum/audio/audio_pwm.c index f820eec1b..ded86edee 100644 --- a/quantum/audio/audio_pwm.c +++ b/quantum/audio/audio_pwm.c | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #include <stdio.h> | 16 | #include <stdio.h> |
| 2 | #include <string.h> | 17 | #include <string.h> |
| 3 | //#include <math.h> | 18 | //#include <math.h> |
diff --git a/quantum/audio/luts.c b/quantum/audio/luts.c index 9f3de9a05..57f2d5924 100644 --- a/quantum/audio/luts.c +++ b/quantum/audio/luts.c | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2016 IBNobody | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #include <avr/io.h> | 17 | #include <avr/io.h> |
| 2 | #include <avr/interrupt.h> | 18 | #include <avr/interrupt.h> |
| 3 | #include <avr/pgmspace.h> | 19 | #include <avr/pgmspace.h> |
diff --git a/quantum/audio/luts.h b/quantum/audio/luts.h index 7df3078a7..155e34e88 100644 --- a/quantum/audio/luts.h +++ b/quantum/audio/luts.h | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2016 IBNobody | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #include <avr/io.h> | 17 | #include <avr/io.h> |
| 2 | #include <avr/interrupt.h> | 18 | #include <avr/interrupt.h> |
| 3 | #include <avr/pgmspace.h> | 19 | #include <avr/pgmspace.h> |
| @@ -12,4 +28,4 @@ | |||
| 12 | extern const float vibrato_lut[VIBRATO_LUT_LENGTH]; | 28 | extern const float vibrato_lut[VIBRATO_LUT_LENGTH]; |
| 13 | extern const uint16_t frequency_lut[FREQUENCY_LUT_LENGTH]; | 29 | extern const uint16_t frequency_lut[FREQUENCY_LUT_LENGTH]; |
| 14 | 30 | ||
| 15 | #endif /* LUTS_H */ \ No newline at end of file | 31 | #endif /* LUTS_H */ |
diff --git a/quantum/audio/musical_notes.h b/quantum/audio/musical_notes.h index b08d16a6f..a3aaa2f19 100644 --- a/quantum/audio/musical_notes.h +++ b/quantum/audio/musical_notes.h | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #ifndef MUSICAL_NOTES_H | 17 | #ifndef MUSICAL_NOTES_H |
| 2 | #define MUSICAL_NOTES_H | 18 | #define MUSICAL_NOTES_H |
| 3 | 19 | ||
| @@ -214,4 +230,4 @@ | |||
| 214 | #define NOTE_BF8 NOTE_AS8 | 230 | #define NOTE_BF8 NOTE_AS8 |
| 215 | 231 | ||
| 216 | 232 | ||
| 217 | #endif \ No newline at end of file | 233 | #endif |
diff --git a/quantum/audio/song_list.h b/quantum/audio/song_list.h index 8022ca672..db2d1a94c 100644 --- a/quantum/audio/song_list.h +++ b/quantum/audio/song_list.h | |||
| @@ -1,8 +1,27 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #include "musical_notes.h" | 16 | #include "musical_notes.h" |
| 2 | 17 | ||
| 3 | #ifndef SONG_LIST_H | 18 | #ifndef SONG_LIST_H |
| 4 | #define SONG_LIST_H | 19 | #define SONG_LIST_H |
| 5 | 20 | ||
| 21 | #define COIN_SOUND \ | ||
| 22 | E__NOTE(_A5 ),\ | ||
| 23 | HD_NOTE(_E6 ), | ||
| 24 | |||
| 6 | #define ODE_TO_JOY \ | 25 | #define ODE_TO_JOY \ |
| 7 | Q__NOTE(_E4), Q__NOTE(_E4), Q__NOTE(_F4), Q__NOTE(_G4), \ | 26 | Q__NOTE(_E4), Q__NOTE(_E4), Q__NOTE(_F4), Q__NOTE(_G4), \ |
| 8 | Q__NOTE(_G4), Q__NOTE(_F4), Q__NOTE(_E4), Q__NOTE(_D4), \ | 27 | Q__NOTE(_G4), Q__NOTE(_F4), Q__NOTE(_E4), Q__NOTE(_D4), \ |
| @@ -122,4 +141,39 @@ | |||
| 122 | E__NOTE(_E5), \ | 141 | E__NOTE(_E5), \ |
| 123 | E__NOTE(_D5), | 142 | E__NOTE(_D5), |
| 124 | 143 | ||
| 144 | #define UNICODE_WINDOWS \ | ||
| 145 | E__NOTE(_B5), \ | ||
| 146 | S__NOTE(_E6), | ||
| 147 | |||
| 148 | #define UNICODE_LINUX \ | ||
| 149 | E__NOTE(_E6), \ | ||
| 150 | S__NOTE(_B5), | ||
| 151 | |||
| 152 | #define COIN_SOUND \ | ||
| 153 | E__NOTE(_A5 ), \ | ||
| 154 | HD_NOTE(_E6 ), | ||
| 155 | |||
| 156 | #define ONE_UP_SOUND \ | ||
| 157 | Q__NOTE(_E6 ), \ | ||
| 158 | Q__NOTE(_G6 ), \ | ||
| 159 | Q__NOTE(_E7 ), \ | ||
| 160 | Q__NOTE(_C7 ), \ | ||
| 161 | Q__NOTE(_D7 ), \ | ||
| 162 | Q__NOTE(_G7 ), | ||
| 163 | |||
| 164 | #define SONIC_RING \ | ||
| 165 | E__NOTE(_E6), \ | ||
| 166 | E__NOTE(_G6), \ | ||
| 167 | HD_NOTE(_C7), | ||
| 168 | |||
| 169 | #define ZELDA_PUZZLE \ | ||
| 170 | Q__NOTE(_G5), \ | ||
| 171 | Q__NOTE(_FS5), \ | ||
| 172 | Q__NOTE(_DS5), \ | ||
| 173 | Q__NOTE(_A4), \ | ||
| 174 | Q__NOTE(_GS4), \ | ||
| 175 | Q__NOTE(_E5), \ | ||
| 176 | Q__NOTE(_GS5), \ | ||
| 177 | HD_NOTE(_C6), | ||
| 178 | |||
| 125 | #endif | 179 | #endif |
diff --git a/quantum/audio/voices.c b/quantum/audio/voices.c index 8326e91ea..54ebd423b 100644 --- a/quantum/audio/voices.c +++ b/quantum/audio/voices.c | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #include "voices.h" | 16 | #include "voices.h" |
| 2 | #include "audio.h" | 17 | #include "audio.h" |
| 3 | #include "stdlib.h" | 18 | #include "stdlib.h" |
| @@ -24,6 +39,7 @@ void voice_deiterate() { | |||
| 24 | 39 | ||
| 25 | float voice_envelope(float frequency) { | 40 | float voice_envelope(float frequency) { |
| 26 | // envelope_index ranges from 0 to 0xFFFF, which is preserved at 880.0 Hz | 41 | // envelope_index ranges from 0 to 0xFFFF, which is preserved at 880.0 Hz |
| 42 | __attribute__ ((unused)) | ||
| 27 | uint16_t compensated_index = (uint16_t)((float)envelope_index * (880.0 / frequency)); | 43 | uint16_t compensated_index = (uint16_t)((float)envelope_index * (880.0 / frequency)); |
| 28 | 44 | ||
| 29 | switch (voice) { | 45 | switch (voice) { |
diff --git a/quantum/audio/voices.h b/quantum/audio/voices.h index 52f7e006d..9403a6b5e 100644 --- a/quantum/audio/voices.h +++ b/quantum/audio/voices.h | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #include <stdint.h> | 16 | #include <stdint.h> |
| 2 | #include <stdbool.h> | 17 | #include <stdbool.h> |
| 3 | #include <avr/io.h> | 18 | #include <avr/io.h> |
| @@ -32,4 +47,4 @@ void set_voice(voice_type v); | |||
| 32 | void voice_iterate(void); | 47 | void voice_iterate(void); |
| 33 | void voice_deiterate(void); | 48 | void voice_deiterate(void); |
| 34 | 49 | ||
| 35 | #endif \ No newline at end of file | 50 | #endif |
diff --git a/quantum/audio/wave.h b/quantum/audio/wave.h index 6ebc34851..f15615dd1 100644 --- a/quantum/audio/wave.h +++ b/quantum/audio/wave.h | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #include <avr/io.h> | 17 | #include <avr/io.h> |
| 2 | #include <avr/interrupt.h> | 18 | #include <avr/interrupt.h> |
| 3 | #include <avr/pgmspace.h> | 19 | #include <avr/pgmspace.h> |
| @@ -262,4 +278,4 @@ const uint8_t sinewave[] PROGMEM= //2048 values | |||
| 262 | 0x76,0x77,0x77,0x77,0x78,0x78,0x78,0x79, | 278 | 0x76,0x77,0x77,0x77,0x78,0x78,0x78,0x79, |
| 263 | 0x79,0x7a,0x7a,0x7a,0x7b,0x7b,0x7c,0x7c, | 279 | 0x79,0x7a,0x7a,0x7a,0x7b,0x7b,0x7c,0x7c, |
| 264 | 0x7c,0x7d,0x7d,0x7e,0x7e,0x7e,0x7f,0x7f | 280 | 0x7c,0x7d,0x7d,0x7e,0x7e,0x7e,0x7f,0x7f |
| 265 | }; \ No newline at end of file | 281 | }; |
diff --git a/quantum/config_common.h b/quantum/config_common.h index 4bdb2065d..c88e02d91 100644 --- a/quantum/config_common.h +++ b/quantum/config_common.h | |||
| @@ -1,9 +1,27 @@ | |||
| 1 | /* Copyright 2015-2017 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #ifndef CONFIG_DEFINITIONS_H | 17 | #ifndef CONFIG_DEFINITIONS_H |
| 2 | #define CONFIG_DEFINITIONS_H | 18 | #define CONFIG_DEFINITIONS_H |
| 3 | 19 | ||
| 4 | /* diode directions */ | 20 | /* diode directions */ |
| 5 | #define COL2ROW 0 | 21 | #define COL2ROW 0 |
| 6 | #define ROW2COL 1 | 22 | #define ROW2COL 1 |
| 23 | #define CUSTOM_MATRIX 2 /* Disables built-in matrix scanning code */ | ||
| 24 | |||
| 7 | /* I/O pins */ | 25 | /* I/O pins */ |
| 8 | #ifndef F0 | 26 | #ifndef F0 |
| 9 | #define B0 0x30 | 27 | #define B0 0x30 |
diff --git a/quantum/dynamic_macro.h b/quantum/dynamic_macro.h index e6dbc5b9c..64093f293 100644 --- a/quantum/dynamic_macro.h +++ b/quantum/dynamic_macro.h | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | /* Author: Wojciech Siewierski < wojciech dot siewierski at onet dot pl > */ | 17 | /* Author: Wojciech Siewierski < wojciech dot siewierski at onet dot pl > */ |
| 2 | #ifndef DYNAMIC_MACROS_H | 18 | #ifndef DYNAMIC_MACROS_H |
| 3 | #define DYNAMIC_MACROS_H | 19 | #define DYNAMIC_MACROS_H |
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/keycode_config.c b/quantum/keycode_config.c index 6d90781a1..4f7bc525e 100644 --- a/quantum/keycode_config.c +++ b/quantum/keycode_config.c | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #include "keycode_config.h" | 17 | #include "keycode_config.h" |
| 2 | 18 | ||
| 3 | extern keymap_config_t keymap_config; | 19 | extern keymap_config_t keymap_config; |
| @@ -71,4 +87,4 @@ uint16_t keycode_config(uint16_t keycode) { | |||
| 71 | default: | 87 | default: |
| 72 | return keycode; | 88 | return keycode; |
| 73 | } | 89 | } |
| 74 | } \ No newline at end of file | 90 | } |
diff --git a/quantum/keycode_config.h b/quantum/keycode_config.h index c15b0d32f..293fefecf 100644 --- a/quantum/keycode_config.h +++ b/quantum/keycode_config.h | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #include "eeconfig.h" | 17 | #include "eeconfig.h" |
| 2 | #include "keycode.h" | 18 | #include "keycode.h" |
| 3 | 19 | ||
diff --git a/quantum/keymap.h b/quantum/keymap.h index c000d2da8..5d64be19c 100644 --- a/quantum/keymap.h +++ b/quantum/keymap.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | Copyright 2012,2013 Jun Wako <wakojun@gmail.com> | 2 | Copyright 2012-2016 Jun Wako <wakojun@gmail.com> |
| 3 | 3 | ||
| 4 | This program is free software: you can redistribute it and/or modify | 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 | 5 | it under the terms of the GNU General Public License as published by |
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index eced3d2bb..6cf4f031f 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | Copyright 2012,2013 Jun Wako <wakojun@gmail.com> | 2 | Copyright 2012-2017 Jun Wako <wakojun@gmail.com> |
| 3 | 3 | ||
| 4 | This program is free software: you can redistribute it and/or modify | 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 | 5 | it under the terms of the GNU General Public License as published by |
| @@ -80,7 +80,10 @@ action_t action_for_key(uint8_t layer, keypos_t key) | |||
| 80 | action.code = keymap_function_id_to_action( (int)keycode & 0xFFF ); | 80 | action.code = keymap_function_id_to_action( (int)keycode & 0xFFF ); |
| 81 | break; | 81 | break; |
| 82 | case QK_MACRO ... QK_MACRO_MAX: | 82 | case QK_MACRO ... QK_MACRO_MAX: |
| 83 | action.code = ACTION_MACRO(keycode & 0xFF); | 83 | if (keycode & 0x800) // tap macros have upper bit set |
| 84 | action.code = ACTION_MACRO_TAP(keycode & 0xFF); | ||
| 85 | else | ||
| 86 | action.code = ACTION_MACRO(keycode & 0xFF); | ||
| 84 | break; | 87 | break; |
| 85 | case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: | 88 | case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: |
| 86 | action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); | 89 | action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); |
| @@ -116,8 +119,11 @@ action_t action_for_key(uint8_t layer, keypos_t key) | |||
| 116 | mod = keycode & 0xFF; | 119 | mod = keycode & 0xFF; |
| 117 | action.code = ACTION_MODS_ONESHOT(mod); | 120 | action.code = ACTION_MODS_ONESHOT(mod); |
| 118 | break; | 121 | break; |
| 122 | case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX: | ||
| 123 | action.code = ACTION_LAYER_TAP_TOGGLE(keycode & 0xFF); | ||
| 124 | break; | ||
| 119 | case QK_MOD_TAP ... QK_MOD_TAP_MAX: | 125 | case QK_MOD_TAP ... QK_MOD_TAP_MAX: |
| 120 | action.code = ACTION_MODS_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); | 126 | action.code = ACTION_MODS_TAP_KEY((keycode >> 0x8) & 0x1F, keycode & 0xFF); |
| 121 | break; | 127 | break; |
| 122 | #ifdef BACKLIGHT_ENABLE | 128 | #ifdef BACKLIGHT_ENABLE |
| 123 | case BL_0 ... BL_15: | 129 | case BL_0 ... BL_15: |
diff --git a/quantum/keymap_extras/keymap_bepo.h b/quantum/keymap_extras/keymap_bepo.h index e5ef39552..013559e96 100644 --- a/quantum/keymap_extras/keymap_bepo.h +++ b/quantum/keymap_extras/keymap_bepo.h | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2016 Didier Loiseau | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | /* Keymap macros for the French BÉPO layout - http://bepo.fr */ | 16 | /* Keymap macros for the French BÉPO layout - http://bepo.fr */ |
| 2 | #ifndef KEYMAP_BEPO_H | 17 | #ifndef KEYMAP_BEPO_H |
| 3 | #define KEYMAP_BEPO_H | 18 | #define KEYMAP_BEPO_H |
diff --git a/quantum/keymap_extras/keymap_br_abnt2.h b/quantum/keymap_extras/keymap_br_abnt2.h index 0df177721..b001139dd 100644 --- a/quantum/keymap_extras/keymap_br_abnt2.h +++ b/quantum/keymap_extras/keymap_br_abnt2.h | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2017 Potiguar Faga | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #ifndef KEYMAP_BR_ABNT2_H | 17 | #ifndef KEYMAP_BR_ABNT2_H |
| 2 | #define KEYMAP_BR_ABNT2_H | 18 | #define KEYMAP_BR_ABNT2_H |
| 3 | 19 | ||
diff --git a/quantum/keymap_extras/keymap_canadian_multilingual.h b/quantum/keymap_extras/keymap_canadian_multilingual.h index 0bc20c7b9..1d45bee32 100644 --- a/quantum/keymap_extras/keymap_canadian_multilingual.h +++ b/quantum/keymap_extras/keymap_canadian_multilingual.h | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2016 Didier Loiseau | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #ifndef KEYMAP_CANADIAN_MULTILINGUAG_H | 16 | #ifndef KEYMAP_CANADIAN_MULTILINGUAG_H |
| 2 | #define KEYMAP_CANADIAN_MULTILINGUAG_H | 17 | #define KEYMAP_CANADIAN_MULTILINGUAG_H |
| 3 | 18 | ||
diff --git a/quantum/keymap_extras/keymap_colemak.h b/quantum/keymap_extras/keymap_colemak.h index b8d615748..2d3f9c06a 100644 --- a/quantum/keymap_extras/keymap_colemak.h +++ b/quantum/keymap_extras/keymap_colemak.h | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2015-2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #ifndef KEYMAP_COLEMAK_H | 16 | #ifndef KEYMAP_COLEMAK_H |
| 2 | #define KEYMAP_COLEMAK_H | 17 | #define KEYMAP_COLEMAK_H |
| 3 | 18 | ||
diff --git a/quantum/keymap_extras/keymap_dvorak.h b/quantum/keymap_extras/keymap_dvorak.h index a0feed850..b1d5604ba 100644 --- a/quantum/keymap_extras/keymap_dvorak.h +++ b/quantum/keymap_extras/keymap_dvorak.h | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2015-2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #ifndef KEYMAP_DVORAK_H | 16 | #ifndef KEYMAP_DVORAK_H |
| 2 | #define KEYMAP_DVORAK_H | 17 | #define KEYMAP_DVORAK_H |
| 3 | 18 | ||
diff --git a/quantum/keymap_extras/keymap_dvp.h b/quantum/keymap_extras/keymap_dvp.h index 83f49a52b..50e2d1f46 100644 --- a/quantum/keymap_extras/keymap_dvp.h +++ b/quantum/keymap_extras/keymap_dvp.h | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2016 Artyom Mironov | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #ifndef KEYMAP_DVP_H | 17 | #ifndef KEYMAP_DVP_H |
| 2 | #define KEYMAP_DVP_H | 18 | #define KEYMAP_DVP_H |
| 3 | 19 | ||
diff --git a/quantum/keymap_extras/keymap_fr_ch.h b/quantum/keymap_extras/keymap_fr_ch.h index 87d4bb24c..c0ca832a6 100644 --- a/quantum/keymap_extras/keymap_fr_ch.h +++ b/quantum/keymap_extras/keymap_fr_ch.h | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2016 Vincent Pochet | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #ifndef KEYMAP_FR_CH | 16 | #ifndef KEYMAP_FR_CH |
| 2 | #define KEYMAP_FR_CH | 17 | #define KEYMAP_FR_CH |
| 3 | 18 | ||
diff --git a/quantum/keymap_extras/keymap_french.h b/quantum/keymap_extras/keymap_french.h index 834c69650..3308dc5f7 100644 --- a/quantum/keymap_extras/keymap_french.h +++ b/quantum/keymap_extras/keymap_french.h | |||
| @@ -1,10 +1,27 @@ | |||
| 1 | /* Copyright 2015-2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #ifndef KEYMAP_FRENCH_H | 16 | #ifndef KEYMAP_FRENCH_H |
| 2 | #define KEYMAP_FRENCH_H | 17 | #define KEYMAP_FRENCH_H |
| 3 | 18 | ||
| 4 | #include "keymap.h" | 19 | #include "keymap.h" |
| 5 | 20 | ||
| 6 | // Alt gr | 21 | // Alt gr |
| 22 | #ifndef ALGR | ||
| 7 | #define ALGR(kc) RALT(kc) | 23 | #define ALGR(kc) RALT(kc) |
| 24 | #endif | ||
| 8 | #define NO_ALGR KC_RALT | 25 | #define NO_ALGR KC_RALT |
| 9 | 26 | ||
| 10 | // Normal characters | 27 | // Normal characters |
| @@ -72,7 +89,7 @@ | |||
| 72 | #define FR_PIPE ALGR(KC_6) | 89 | #define FR_PIPE ALGR(KC_6) |
| 73 | #define FR_GRV ALGR(KC_7) | 90 | #define FR_GRV ALGR(KC_7) |
| 74 | #define FR_BSLS ALGR(KC_8) | 91 | #define FR_BSLS ALGR(KC_8) |
| 75 | #define FR_CIRC ALGR(KC_9) | 92 | #define FR_CCIRC ALGR(KC_9) |
| 76 | #define FR_AT ALGR(KC_0) | 93 | #define FR_AT ALGR(KC_0) |
| 77 | #define FR_RBRC ALGR(FR_RPRN) | 94 | #define FR_RBRC ALGR(FR_RPRN) |
| 78 | #define FR_RCBR ALGR(FR_EQL) | 95 | #define FR_RCBR ALGR(FR_EQL) |
diff --git a/quantum/keymap_extras/keymap_french_osx.h b/quantum/keymap_extras/keymap_french_osx.h index 004d73ee2..ecade3fe9 100644 --- a/quantum/keymap_extras/keymap_french_osx.h +++ b/quantum/keymap_extras/keymap_french_osx.h | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2016 Sébastien Pérochon | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #ifndef KEYMAP_FRENCH_OSX_H | 16 | #ifndef KEYMAP_FRENCH_OSX_H |
| 2 | #define KEYMAP_FRENCH_OSX_H | 17 | #define KEYMAP_FRENCH_OSX_H |
| 3 | 18 | ||
| @@ -74,4 +89,4 @@ | |||
| 74 | #define FR_PIPE LSFT(LALT(KC_L)) | 89 | #define FR_PIPE LSFT(LALT(KC_L)) |
| 75 | #define FR_BSLS LSFT(LALT(FR_COLN)) | 90 | #define FR_BSLS LSFT(LALT(FR_COLN)) |
| 76 | 91 | ||
| 77 | #endif \ No newline at end of file | 92 | #endif |
diff --git a/quantum/keymap_extras/keymap_german.h b/quantum/keymap_extras/keymap_german.h index 7e2e0ed44..e007c26ef 100644 --- a/quantum/keymap_extras/keymap_german.h +++ b/quantum/keymap_extras/keymap_german.h | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2015-2016 Matthias Schmidtt | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #ifndef KEYMAP_GERMAN | 17 | #ifndef KEYMAP_GERMAN |
| 2 | #define KEYMAP_GERMAN | 18 | #define KEYMAP_GERMAN |
| 3 | 19 | ||
diff --git a/quantum/keymap_extras/keymap_german_ch.h b/quantum/keymap_extras/keymap_german_ch.h index b66d582a4..8332e00af 100644 --- a/quantum/keymap_extras/keymap_german_ch.h +++ b/quantum/keymap_extras/keymap_german_ch.h | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2016 heartsekai | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #ifndef KEYMAP_SWISS_GERMAN | 16 | #ifndef KEYMAP_SWISS_GERMAN |
| 2 | #define KEYMAP_SWISS_GERMAN | 17 | #define KEYMAP_SWISS_GERMAN |
| 3 | 18 | ||
diff --git a/quantum/keymap_extras/keymap_german_osx.h b/quantum/keymap_extras/keymap_german_osx.h index f63f06618..798bb7579 100644 --- a/quantum/keymap_extras/keymap_german_osx.h +++ b/quantum/keymap_extras/keymap_german_osx.h | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2016 Stephen Bösebeck | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #ifndef KEYMAP_GERMAN_OSX | 16 | #ifndef KEYMAP_GERMAN_OSX |
| 2 | #define KEYMAP_GERMAN_OSX | 17 | #define KEYMAP_GERMAN_OSX |
| 3 | 18 | ||
diff --git a/quantum/keymap_extras/keymap_jp.h b/quantum/keymap_extras/keymap_jp.h index e81b5952e..fb74bce8d 100644 --- a/quantum/keymap_extras/keymap_jp.h +++ b/quantum/keymap_extras/keymap_jp.h | |||
| @@ -1,4 +1,19 @@ | |||
| 1 | /* JP106-layout (Japanese Standard) | 1 | /* Copyright 2016 h-youhei |
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | * | ||
| 16 | * JP106-layout (Japanese Standard) | ||
| 2 | * | 17 | * |
| 3 | * For more information, see | 18 | * For more information, see |
| 4 | * http://www2d.biglobe.ne.jp/~msyk/keyboard/layout/usbkeycode.html | 19 | * http://www2d.biglobe.ne.jp/~msyk/keyboard/layout/usbkeycode.html |
diff --git a/quantum/keymap_extras/keymap_neo2.h b/quantum/keymap_extras/keymap_neo2.h index 80439af34..174f4a6ee 100644 --- a/quantum/keymap_extras/keymap_neo2.h +++ b/quantum/keymap_extras/keymap_neo2.h | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2016 Matthias Schmitt | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #ifndef KEYMAP_NEO2 | 16 | #ifndef KEYMAP_NEO2 |
| 2 | #define KEYMAP_NEO2 | 17 | #define KEYMAP_NEO2 |
| 3 | 18 | ||
diff --git a/quantum/keymap_extras/keymap_nordic.h b/quantum/keymap_extras/keymap_nordic.h index 9b0ef35ca..6b34db558 100644 --- a/quantum/keymap_extras/keymap_nordic.h +++ b/quantum/keymap_extras/keymap_nordic.h | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2015-2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #ifndef KEYMAP_NORDIC_H | 16 | #ifndef KEYMAP_NORDIC_H |
| 2 | #define KEYMAP_NORDIC_H | 17 | #define KEYMAP_NORDIC_H |
| 3 | 18 | ||
diff --git a/quantum/keymap_extras/keymap_norwegian.h b/quantum/keymap_extras/keymap_norwegian.h index 5c4e8c495..b7128973a 100644 --- a/quantum/keymap_extras/keymap_norwegian.h +++ b/quantum/keymap_extras/keymap_norwegian.h | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #ifndef KEYMAP_NORWEGIAN_H | 16 | #ifndef KEYMAP_NORWEGIAN_H |
| 2 | #define KEYMAP_NORWEGIAN_H | 17 | #define KEYMAP_NORWEGIAN_H |
| 3 | 18 | ||
diff --git a/quantum/keymap_extras/keymap_plover.h b/quantum/keymap_extras/keymap_plover.h index 9b88f7d84..de6d8c53f 100644 --- a/quantum/keymap_extras/keymap_plover.h +++ b/quantum/keymap_extras/keymap_plover.h | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2016 James Kay | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #ifndef KEYMAP_PLOVER_H | 16 | #ifndef KEYMAP_PLOVER_H |
| 2 | #define KEYMAP_PLOVER_H | 17 | #define KEYMAP_PLOVER_H |
| 3 | 18 | ||
diff --git a/quantum/keymap_extras/keymap_russian.h b/quantum/keymap_extras/keymap_russian.h deleted file mode 100644 index 237e9abde..000000000 --- a/quantum/keymap_extras/keymap_russian.h +++ /dev/null | |||
| @@ -1,77 +0,0 @@ | |||
| 1 | #ifndef KEYMAP_RUSSIAN_H | ||
| 2 | #define KEYMAP_RUSSIAN_H | ||
| 3 | |||
| 4 | #include "keymap.h" | ||
| 5 | |||
| 6 | // Normal Chracters // reg SHIFT | ||
| 7 | #define RU_A KC_F // а and А | ||
| 8 | #define RU_BE KC_COMM // б and Б | ||
| 9 | #define RU_VE KC_D // в and В | ||
| 10 | #define RU_GHE KC_U // г and Г | ||
| 11 | #define RU_DE KC_L // д and Д | ||
| 12 | #define RU_IE KC_T // е and Е | ||
| 13 | #define RU_IO KC_GRV // ё and Ё | ||
| 14 | #define RU_ZHE KC_SCLN // ж and Ж | ||
| 15 | #define RU_ZE KC_P // з and З | ||
| 16 | #define RU_I KC_B // и and И | ||
| 17 | #define RU_SRT_I KC_Q // й and Й | ||
| 18 | #define RU_KA KC_R // к and К | ||
| 19 | #define RU_EL KC_K // л and Л | ||
| 20 | #define RU_EM KC_V // м and М | ||
| 21 | #define RU_EN KC_Y // н and Н | ||
| 22 | #define RU_O KC_J // о and О | ||
| 23 | #define RU_PE KC_G // п and П | ||
| 24 | #define RU_ER KC_H // р and Р | ||
| 25 | #define RU_ES KC_C // с and С | ||
| 26 | #define RU_TE KC_N // т and Т | ||
| 27 | #define RU_U KC_E // у and У | ||
| 28 | #define RU_EF KC_A // ф and Ф | ||
| 29 | #define RU_HA KC_LBRC // х and Х | ||
| 30 | #define RU_TSE KC_W // ц and Ц | ||
| 31 | #define RU_CHE KC_X // ч and Ч | ||
| 32 | #define RU_SHA KC_I // ш and Ш | ||
| 33 | #define RU_SHCHA KC_O // щ and Щ | ||
| 34 | #define RU_HSIGN KC_RBRC // ъ and Ъ | ||
| 35 | #define RU_YERU KC_S // ы and Ы | ||
| 36 | #define RU_SSIGN KC_M // ь and Ь | ||
| 37 | #define RU_E KC_QUOT // э and Э | ||
| 38 | #define RU_YU KC_DOT // ю and Ю | ||
| 39 | #define RU_YA KC_Z // я and Я | ||
| 40 | |||
| 41 | #define RU_1 KC_1 // 1 and ! | ||
| 42 | #define RU_2 KC_2 // 2 and " | ||
| 43 | #define RU_3 KC_3 // 3 and № | ||
| 44 | #define RU_4 KC_4 // 4 and ; | ||
| 45 | #define RU_5 KC_5 // 5 and % | ||
| 46 | #define RU_6 KC_6 // 6 and : | ||
| 47 | #define RU_7 KC_7 // 7 and ? | ||
| 48 | #define RU_8 KC_8 // 8 and * | ||
| 49 | #define RU_9 KC_9 // 9 and ( | ||
| 50 | #define RU_0 KC_0 // 0 and ) | ||
| 51 | |||
| 52 | #define RU_MINS KC_MINS // - and _ | ||
| 53 | #define RU_EQL KC_EQL // = and + | ||
| 54 | #define RU_BSLS KC_BSLS // \ and / | ||
| 55 | #define RU_DOT KC_SLSH // . and , | ||
| 56 | |||
| 57 | // Shifted Chracters | ||
| 58 | #define RU_EXLM LSFT(RU_1) // ! | ||
| 59 | #define RU_DQUT LSFT(RU_2) // " | ||
| 60 | #define RU_NMRO LSFT(RU_3) // № | ||
| 61 | #define RU_SCLN LSFT(RU_4) // ; | ||
| 62 | #define RU_PERC LSFT(RU_5) // % | ||
| 63 | #define RU_COLN LSFT(RU_6) // : | ||
| 64 | #define RU_QUES LSFT(RU_7) // ? | ||
| 65 | #define RU_ASTR LSFT(RU_8) // * | ||
| 66 | #define RU_LPRN LSFT(RU_9) // ( | ||
| 67 | #define RU_RPRN LSFT(RU_0) // ) | ||
| 68 | |||
| 69 | #define RU_UNDR LSFT(RU_MINS) // _ | ||
| 70 | #define RU_PLUS LSFT(RU_EQL) // + | ||
| 71 | #define RU_SLSH LSFT(RU_BSLS) // / | ||
| 72 | #define RU_COMM LSFT(RU_DOT) // , | ||
| 73 | |||
| 74 | // Alt Gr-ed characters | ||
| 75 | #define RU_RUBL RALT(RU_8) // ₽ | ||
| 76 | |||
| 77 | #endif | ||
diff --git a/quantum/keymap_extras/keymap_spanish.h b/quantum/keymap_extras/keymap_spanish.h index 4ba568af2..3a5787e9c 100644 --- a/quantum/keymap_extras/keymap_spanish.h +++ b/quantum/keymap_extras/keymap_spanish.h | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2015-2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #ifndef KEYMAP_SPANISH_H | 16 | #ifndef KEYMAP_SPANISH_H |
| 2 | #define KEYMAP_SPANISH_H | 17 | #define KEYMAP_SPANISH_H |
| 3 | 18 | ||
diff --git a/quantum/keymap_extras/keymap_uk.h b/quantum/keymap_extras/keymap_uk.h index 00c87afc3..9d02efe04 100644 --- a/quantum/keymap_extras/keymap_uk.h +++ b/quantum/keymap_extras/keymap_uk.h | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2015-2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #ifndef KEYMAP_UK_H | 16 | #ifndef KEYMAP_UK_H |
| 2 | #define KEYMAP_UK_H | 17 | #define KEYMAP_UK_H |
| 3 | 18 | ||
diff --git a/quantum/keymap_extras/keymap_unicode_cyrillic.h b/quantum/keymap_extras/keymap_unicode_cyrillic.h deleted file mode 100644 index a40626d91..000000000 --- a/quantum/keymap_extras/keymap_unicode_cyrillic.h +++ /dev/null | |||
| @@ -1,163 +0,0 @@ | |||
| 1 | #ifndef KEYMAP_CYRILLIC_H | ||
| 2 | #define KEYMAP_CYRILLIC_H | ||
| 3 | |||
| 4 | #include "keymap.h" | ||
| 5 | |||
| 6 | /* | ||
| 7 | * This is based off of | ||
| 8 | * https://en.wikipedia.org/wiki/Cyrillic_script | ||
| 9 | * | ||
| 10 | * Unicode is iffy, a software implementation is preferred | ||
| 11 | */ | ||
| 12 | |||
| 13 | // Capital Char russian/ukrainian/bulgarian | ||
| 14 | #define CY_A UC(0x0410) // А rus ukr bul | ||
| 15 | #define CY_BE UC(0x0411) // Б rus ukr bul | ||
| 16 | #define CY_VE UC(0x0412) // В rus ukr bul | ||
| 17 | #define CY_GHE UC(0x0413) // Г rus ukr bul | ||
| 18 | #define CY_GHEUP UC(0x0490) // Ґ ukr | ||
| 19 | #define CY_DE UC(0x0414) // Д rus ukr bul | ||
| 20 | #define CY_DJE UC(0x0402) // Ђ | ||
| 21 | #define CY_GJE UC(0x0403) // Ѓ | ||
| 22 | #define CY_IE UC(0x0415) // Е rus ukr bul | ||
| 23 | #define CY_IO UC(0x0401) // Ё rus | ||
| 24 | #define CY_UIE UC(0x0404) // Є ukr | ||
| 25 | #define CY_ZHE UC(0x0416) // Ж rus ukr bul | ||
| 26 | #define CY_ZE UC(0x0417) // З rus ukr bul | ||
| 27 | #define CY_DZE UC(0x0405) // Ѕ | ||
| 28 | #define CY_I UC(0x0418) // И rus ukr bul | ||
| 29 | #define CY_B_U_I UC(0x0406) // І ukr | ||
| 30 | #define CY_YI UC(0x0407) // Ї ukr | ||
| 31 | #define CY_SRT_I UC(0x0419) // Й rus ukr bul | ||
| 32 | #define CY_JE UC(0x0408) // Ј | ||
| 33 | #define CY_KA UC(0x041a) // К rus ukr bul | ||
| 34 | #define CY_EL UC(0x041b) // Л rus ukr bul | ||
| 35 | #define CY_LJE UC(0x0409) // Љ | ||
| 36 | #define CY_EM UC(0x041c) // М rus ukr bul | ||
| 37 | #define CY_EN UC(0x041d) // Н rus ukr bul | ||
| 38 | #define CY_NJE UC(0x040a) // Њ | ||
| 39 | #define CY_O UC(0x041e) // О rus ukr bul | ||
| 40 | #define CY_PE UC(0x041f) // П rus ukr bul | ||
| 41 | #define CY_ER UC(0x0420) // Р rus ukr bul | ||
| 42 | #define CY_ES UC(0x0421) // С rus ukr bul | ||
| 43 | #define CY_TE UC(0x0422) // Т rus ukr bul | ||
| 44 | #define CY_TSHE UC(0x040b) // Ћ | ||
| 45 | #define CY_KJE UC(0x040c) // Ќ | ||
| 46 | #define CY_U UC(0x0423) // У rus ukr bul | ||
| 47 | #define CY_SRT_U UC(0x040e) // Ў | ||
| 48 | #define CY_EF UC(0x0424) // Ф rus ukr bul | ||
| 49 | #define CY_HA UC(0x0425) // Х rus bul | ||
| 50 | #define CY_TSE UC(0x0426) // Ц rus ukr bul | ||
| 51 | #define CY_CHE UC(0x0427) // Ч rus ukr bul | ||
| 52 | #define CY_DZHE UC(0x040f) // Џ | ||
| 53 | #define CY_SHA UC(0x0428) // Ш rus ukr bul | ||
| 54 | #define CY_SHCHA UC(0x0429) // Щ rus ukr bul | ||
| 55 | #define CY_HSIGN UC(0x042a) // Ъ rus bul | ||
| 56 | #define CY_YERU UC(0x042b) // Ы rus | ||
| 57 | #define CY_SSIGN UC(0x042c) // Ь rus ukr bul | ||
| 58 | #define CY_E UC(0x042d) // Э rus | ||
| 59 | #define CY_YU UC(0x042e) // Ю rus ukr bul | ||
| 60 | #define CY_YA UC(0x042f) // Я rus ukr bul | ||
| 61 | // Important Cyrillic non-Slavic letters | ||
| 62 | #define CY_PALOCHKA UC(0x04c0) // Ӏ | ||
| 63 | #define CY_SCHWA UC(0x04d8) // Ә | ||
| 64 | #define CY_GHE_S UC(0x0492) // Ғ | ||
| 65 | #define CY_ZE_D UC(0x0498) // Ҙ | ||
| 66 | #define CY_ES_D UC(0x04aa) // Ҫ | ||
| 67 | #define CY_BR_KA UC(0x04a0) // Ҡ | ||
| 68 | #define CY_ZHE_D UC(0x0496) // Җ | ||
| 69 | #define CY_KA_D UC(0x049a) // Қ | ||
| 70 | #define CY_EN_D UC(0x04a2) // Ң | ||
| 71 | #define CY_ENGHE UC(0x04a4) // Ҥ | ||
| 72 | #define CY_BRD_O UC(0x04e8) // Ө | ||
| 73 | #define CY_STR_U UC(0x04ae) // Ү | ||
| 74 | #define CY_S_U_S UC(0x04b0) // Ұ | ||
| 75 | #define CY_SHHA UC(0x04ba) // Һ | ||
| 76 | #define CY_HA_D UC(0x04b2) // Ҳ | ||
| 77 | |||
| 78 | |||
| 79 | // Small | ||
| 80 | #define CY_a UC(0x0430) // a rus ukr bul | ||
| 81 | #define CY_be UC(0x0431) // б rus ukr bul | ||
| 82 | #define CY_ve UC(0x0432) // в rus ukr bul | ||
| 83 | #define CY_ghe UC(0x0433) // г rus ukr bul | ||
| 84 | #define CY_gheup UC(0x0491) // ґ ukr | ||
| 85 | #define CY_de UC(0x0434) // д rus ukr bul | ||
| 86 | #define CY_dje UC(0x0452) // ђ | ||
| 87 | #define CY_gje UC(0x0453) // ѓ | ||
| 88 | #define CY_ie UC(0x0435) // е rus ukr bul | ||
| 89 | #define CY_io UC(0x0451) // ё rus | ||
| 90 | #define CY_uie UC(0x0454) // є ukr | ||
| 91 | #define CY_zhe UC(0x0436) // ж rus ukr bul | ||
| 92 | #define CY_ze UC(0x0437) // з rus ukr bul | ||
| 93 | #define CY_dze UC(0x0455) // ѕ | ||
| 94 | #define CY_i UC(0x0438) // и rus ukr bul | ||
| 95 | #define CY_b_u_i UC(0x0456) // і ukr | ||
| 96 | #define CY_yi UC(0x0457) // ї ukr | ||
| 97 | #define CY_srt_i UC(0x0439) // й rus ukr bul | ||
| 98 | #define CY_je UC(0x0458) // ј | ||
| 99 | #define CY_ka UC(0x043a) // к rus ukr bul | ||
| 100 | #define CY_el UC(0x043b) // л rus ukr bul | ||
| 101 | #define CY_lje UC(0x0459) // љ | ||
| 102 | #define CY_em UC(0x043c) // м rus ukr bul | ||
| 103 | #define CY_en UC(0x043d) // н rus ukr bul | ||
| 104 | #define CY_nje UC(0x045a) // њ | ||
| 105 | #define CY_o UC(0x043e) // о rus ukr bul | ||
| 106 | #define CY_pe UC(0x043f) // п rus ukr bul | ||
| 107 | #define CY_er UC(0x0440) // р rus ukr bul | ||
| 108 | #define CY_es UC(0x0441) // с rus ukr bul | ||
| 109 | #define CY_te UC(0x0442) // т rus ukr bul | ||
| 110 | #define CY_tshe UC(0x045b) // ћ | ||
| 111 | #define CY_kje UC(0x045c) // ќ | ||
| 112 | #define CY_u UC(0x0443) // у rus ukr bul | ||
| 113 | #define CY_srt_u UC(0x045e) // ў | ||
| 114 | #define CY_ef UC(0x0444) // ф rus ukr bul | ||
| 115 | #define CY_ha UC(0x0445) // х rus ukr bul | ||
| 116 | #define CY_tse UC(0x0446) // ц rus ukr bul | ||
| 117 | #define CY_che UC(0x0447) // ч rus ukr bul | ||
| 118 | #define CY_dzhe UC(0x045f) // џ | ||
| 119 | #define CY_sha UC(0x0448) // ш rus ukr bul | ||
| 120 | #define CY_shcha UC(0x0449) // щ rus ukr bul | ||
| 121 | #define CY_hsign UC(0x044a) // ъ rus bul | ||
| 122 | #define CY_yeru UC(0x044b) // ы rus | ||
| 123 | #define CY_ssign UC(0x044c) // ь rus ukr bul | ||
| 124 | #define CY_e UC(0x044d) // э rus | ||
| 125 | #define CY_yu UC(0x044e) // ю rus ukr bul | ||
| 126 | #define CY_ya UC(0x044f) // я rus ukr bul | ||
| 127 | // Important Cyrillic non-Slavic letters | ||
| 128 | #define CY_palochka UC(0x04cf) // ӏ | ||
| 129 | #define CY_schwa UC(0x04d9) // ә | ||
| 130 | #define CY_ghe_s UC(0x0493) // ғ | ||
| 131 | #define CY_ze_d UC(0x0499) // ҙ | ||
| 132 | #define CY_es_d UC(0x04ab) // ҫ | ||
| 133 | #define CY_br_ka UC(0x04a1) // ҡ | ||
| 134 | #define CY_zhe_d UC(0x0497) // җ | ||
| 135 | #define CY_ka_d UC(0x049b) // қ | ||
| 136 | #define CY_en_d UC(0x04a3) // ң | ||
| 137 | #define CY_enghe UC(0x04a5) // ҥ | ||
| 138 | #define CY_brd_o UC(0x04e9) // ө | ||
| 139 | #define CY_str_u UC(0x04af) // ү | ||
| 140 | #define CY_s_u_s UC(0x04b1) // ұ | ||
| 141 | #define CY_shha UC(0x04bb) // һ | ||
| 142 | #define CY_ha_d UC(0x04b3) // ҳ | ||
| 143 | |||
| 144 | |||
| 145 | // Extra | ||
| 146 | #define CY_slr_ve UC(0x1c80) // ᲀ CYRILLIC SMALL LETTER ROUNDED VE | ||
| 147 | #define CY_ll_de UC(0x1c81) // ᲁ CYRILLIC SMALL LETTER LONG-LEGGED DE | ||
| 148 | #define CY_ZEMLYA UC(0xa640) // Ꙁ CYRILLIC CAPITAL LETTER ZEMLYA | ||
| 149 | #define CY_zemlya UC(0xa641) // ꙁ CYRILLIC SMALL LETTER ZEMLYA | ||
| 150 | #define CY_RV_DZE UC(0xa644) // Ꙅ CYRILLIC CAPITAL LETTER REVERSED DZE | ||
| 151 | #define CY_rv_DZE UC(0xa645) // ꙅ CYRILLIC SMALL LETTER REVERSED DZE | ||
| 152 | #define CY_slw_es UC(0x1c83) // ᲃ CYRILLIC SMALL LETTER WIDE ES | ||
| 153 | #define CY_st_te UC(0x1c84) // ᲄ CYRILLIC SMALL LETTER TALL TE | ||
| 154 | #define CY_3l_te UC(0x1c85) // ᲅ CYRILLIC SMALL LETTER THREE-LEGGED TE | ||
| 155 | #define CY_thsign UC(0x1c86) // ᲆ CYRILLIC SMALL LETTER TALL HARD SIGN | ||
| 156 | #define CY_YERUBY UC(0xa650) // Ꙑ CYRILLIC CAPITAL LETTER YERU WITH BACK YER | ||
| 157 | #define CY_yeruby UC(0xa651) // ꙑ CYRILLIC SMALL LETTER YERU WITH BACK YER | ||
| 158 | #define CY_RUBL UC(0x20bd) // ₽ | ||
| 159 | #define CY_NMRO UC(0x2116) // № | ||
| 160 | |||
| 161 | // The letters Zje and Sje are made for other letters and accent marks | ||
| 162 | |||
| 163 | #endif | ||
diff --git a/quantum/light_ws2812.c b/quantum/light_ws2812.c index a883b1388..2506e3d8e 100755 --- a/quantum/light_ws2812.c +++ b/quantum/light_ws2812.c | |||
| @@ -7,7 +7,18 @@ | |||
| 7 | * Jan 18th, 2014 v2.0b Initial Version | 7 | * Jan 18th, 2014 v2.0b Initial Version |
| 8 | * Nov 29th, 2015 v2.3 Added SK6812RGBW support | 8 | * Nov 29th, 2015 v2.3 Added SK6812RGBW support |
| 9 | * | 9 | * |
| 10 | * License: GNU GPL v2 (see License.txt) | 10 | * This program is free software: you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by | ||
| 12 | * the Free Software Foundation, either version 2 of the License, or | ||
| 13 | * (at your option) any later version. | ||
| 14 | * | ||
| 15 | * This program is distributed in the hope that it will be useful, | ||
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | * GNU General Public License for more details. | ||
| 19 | * | ||
| 20 | * You should have received a copy of the GNU General Public License | ||
| 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 11 | */ | 22 | */ |
| 12 | 23 | ||
| 13 | #include "light_ws2812.h" | 24 | #include "light_ws2812.h" |
| @@ -70,7 +81,7 @@ void I2C_WriteBit(unsigned char c) | |||
| 70 | 81 | ||
| 71 | // Inits bitbanging port, must be called before using the functions below | 82 | // Inits bitbanging port, must be called before using the functions below |
| 72 | // | 83 | // |
| 73 | void I2C_Init() | 84 | void I2C_Init(void) |
| 74 | { | 85 | { |
| 75 | I2C_PORT &= ~ ((1 << I2C_DAT) | (1 << I2C_CLK)); | 86 | I2C_PORT &= ~ ((1 << I2C_DAT) | (1 << I2C_CLK)); |
| 76 | 87 | ||
| @@ -82,7 +93,7 @@ void I2C_Init() | |||
| 82 | 93 | ||
| 83 | // Send a START Condition | 94 | // Send a START Condition |
| 84 | // | 95 | // |
| 85 | void I2C_Start() | 96 | void I2C_Start(void) |
| 86 | { | 97 | { |
| 87 | // set both to high at the same time | 98 | // set both to high at the same time |
| 88 | I2C_DDR &= ~ ((1 << I2C_DAT) | (1 << I2C_CLK)); | 99 | I2C_DDR &= ~ ((1 << I2C_DAT) | (1 << I2C_CLK)); |
| @@ -97,7 +108,7 @@ void I2C_Start() | |||
| 97 | 108 | ||
| 98 | // Send a STOP Condition | 109 | // Send a STOP Condition |
| 99 | // | 110 | // |
| 100 | void I2C_Stop() | 111 | void I2C_Stop(void) |
| 101 | { | 112 | { |
| 102 | I2C_CLOCK_HI(); | 113 | I2C_CLOCK_HI(); |
| 103 | _delay_us(I2C_DELAY); | 114 | _delay_us(I2C_DELAY); |
diff --git a/quantum/light_ws2812.h b/quantum/light_ws2812.h index 2f78c20fc..60924a0fb 100755 --- a/quantum/light_ws2812.h +++ b/quantum/light_ws2812.h | |||
| @@ -6,8 +6,18 @@ | |||
| 6 | * | 6 | * |
| 7 | * Please do not change this file! All configuration is handled in "ws2812_config.h" | 7 | * Please do not change this file! All configuration is handled in "ws2812_config.h" |
| 8 | * | 8 | * |
| 9 | * License: GNU GPL v2 (see License.txt) | 9 | * This program is free software: you can redistribute it and/or modify |
| 10 | + | 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation, either version 2 of the License, or | ||
| 12 | * (at your option) any later version. | ||
| 13 | * | ||
| 14 | * This program is distributed in the hope that it will be useful, | ||
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | * GNU General Public License for more details. | ||
| 18 | * | ||
| 19 | * You should have received a copy of the GNU General Public License | ||
| 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 11 | */ | 21 | */ |
| 12 | 22 | ||
| 13 | #ifndef LIGHT_WS2812_H_ | 23 | #ifndef LIGHT_WS2812_H_ |
diff --git a/quantum/matrix.c b/quantum/matrix.c index 07eb87bc3..5337e2626 100644 --- a/quantum/matrix.c +++ b/quantum/matrix.c | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | Copyright 2012 Jun Wako | 2 | Copyright 2012-2017 Jun Wako, Jack Humbert |
| 3 | Copyright 2014 Jack Humbert | ||
| 4 | 3 | ||
| 5 | This program is free software: you can redistribute it and/or modify | 4 | This program is free software: you can redistribute it and/or modify |
| 6 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
| @@ -60,13 +59,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 60 | extern const matrix_row_t matrix_mask[]; | 59 | extern const matrix_row_t matrix_mask[]; |
| 61 | #endif | 60 | #endif |
| 62 | 61 | ||
| 62 | #if (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW) | ||
| 63 | static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; | 63 | static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; |
| 64 | static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; | 64 | static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; |
| 65 | #endif | ||
| 65 | 66 | ||
| 66 | /* matrix state(1:on, 0:off) */ | 67 | /* matrix state(1:on, 0:off) */ |
| 67 | static matrix_row_t matrix[MATRIX_ROWS]; | 68 | static matrix_row_t matrix[MATRIX_ROWS]; |
| 68 | 69 | ||
| 69 | static matrix_row_t matrix_raw[MATRIX_ROWS]; | ||
| 70 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | 70 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; |
| 71 | 71 | ||
| 72 | 72 | ||
| @@ -76,7 +76,7 @@ static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | |||
| 76 | static void unselect_rows(void); | 76 | static void unselect_rows(void); |
| 77 | static void select_row(uint8_t row); | 77 | static void select_row(uint8_t row); |
| 78 | static void unselect_row(uint8_t row); | 78 | static void unselect_row(uint8_t row); |
| 79 | #else // ROW2COL | 79 | #elif (DIODE_DIRECTION == ROW2COL) |
| 80 | static void init_rows(void); | 80 | static void init_rows(void); |
| 81 | static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col); | 81 | static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col); |
| 82 | static void unselect_cols(void); | 82 | static void unselect_cols(void); |
| @@ -133,7 +133,7 @@ uint8_t matrix_cols(void) { | |||
| 133 | // /* PORTxn */ | 133 | // /* PORTxn */ |
| 134 | // _SFR_IO8((col_pins[c] >> 4) + 2) |= _BV(col_pins[c] & 0xF); | 134 | // _SFR_IO8((col_pins[c] >> 4) + 2) |= _BV(col_pins[c] & 0xF); |
| 135 | // } | 135 | // } |
| 136 | // #else | 136 | // #elif (DIODE_DIRECTION == ROW2COL) |
| 137 | // for (int8_t c = MATRIX_COLS - 1; c >= 0; --c) { | 137 | // for (int8_t c = MATRIX_COLS - 1; c >= 0; --c) { |
| 138 | // /* DDRxn */ | 138 | // /* DDRxn */ |
| 139 | // _SFR_IO8((col_pins[c] >> 4) + 1) |= _BV(col_pins[c] & 0xF); | 139 | // _SFR_IO8((col_pins[c] >> 4) + 1) |= _BV(col_pins[c] & 0xF); |
| @@ -158,7 +158,7 @@ void matrix_init(void) { | |||
| 158 | #if (DIODE_DIRECTION == COL2ROW) | 158 | #if (DIODE_DIRECTION == COL2ROW) |
| 159 | unselect_rows(); | 159 | unselect_rows(); |
| 160 | init_cols(); | 160 | init_cols(); |
| 161 | #else // ROW2COL | 161 | #elif (DIODE_DIRECTION == ROW2COL) |
| 162 | unselect_cols(); | 162 | unselect_cols(); |
| 163 | init_rows(); | 163 | init_rows(); |
| 164 | #endif | 164 | #endif |
| @@ -166,7 +166,6 @@ void matrix_init(void) { | |||
| 166 | // initialize matrix state: all keys off | 166 | // initialize matrix state: all keys off |
| 167 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | 167 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { |
| 168 | matrix[i] = 0; | 168 | matrix[i] = 0; |
| 169 | matrix_raw[i] = 0; | ||
| 170 | matrix_debouncing[i] = 0; | 169 | matrix_debouncing[i] = 0; |
| 171 | } | 170 | } |
| 172 | 171 | ||
| @@ -194,7 +193,7 @@ uint8_t matrix_scan(void) | |||
| 194 | 193 | ||
| 195 | } | 194 | } |
| 196 | 195 | ||
| 197 | #else // ROW2COL | 196 | #elif (DIODE_DIRECTION == ROW2COL) |
| 198 | 197 | ||
| 199 | // Set col, read rows | 198 | // Set col, read rows |
| 200 | for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { | 199 | for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { |
| @@ -336,7 +335,7 @@ static void unselect_rows(void) | |||
| 336 | } | 335 | } |
| 337 | } | 336 | } |
| 338 | 337 | ||
| 339 | #else // ROW2COL | 338 | #elif (DIODE_DIRECTION == ROW2COL) |
| 340 | 339 | ||
| 341 | static void init_rows(void) | 340 | static void init_rows(void) |
| 342 | { | 341 | { |
diff --git a/quantum/pincontrol.h b/quantum/pincontrol.h index 36ce29ef2..d77977ebe 100644 --- a/quantum/pincontrol.h +++ b/quantum/pincontrol.h | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2016 Wez Furlong | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #pragma once | 16 | #pragma once |
| 2 | // Some helpers for controlling gpio pins | 17 | // Some helpers for controlling gpio pins |
| 3 | #include <avr/io.h> | 18 | #include <avr/io.h> |
diff --git a/quantum/process_keycode/process_audio.c b/quantum/process_keycode/process_audio.c new file mode 100644 index 000000000..0b6380ed3 --- /dev/null +++ b/quantum/process_keycode/process_audio.c | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | #include "audio.h" | ||
| 2 | #include "process_audio.h" | ||
| 3 | |||
| 4 | static float compute_freq_for_midi_note(uint8_t note) | ||
| 5 | { | ||
| 6 | // https://en.wikipedia.org/wiki/MIDI_tuning_standard | ||
| 7 | return pow(2.0, (note - 69) / 12.0) * 440.0f; | ||
| 8 | } | ||
| 9 | |||
| 10 | bool process_audio(uint16_t keycode, keyrecord_t *record) { | ||
| 11 | |||
| 12 | if (keycode == AU_ON && record->event.pressed) { | ||
| 13 | audio_on(); | ||
| 14 | return false; | ||
| 15 | } | ||
| 16 | |||
| 17 | if (keycode == AU_OFF && record->event.pressed) { | ||
| 18 | audio_off(); | ||
| 19 | return false; | ||
| 20 | } | ||
| 21 | |||
| 22 | if (keycode == AU_TOG && record->event.pressed) { | ||
| 23 | if (is_audio_on()) | ||
| 24 | { | ||
| 25 | audio_off(); | ||
| 26 | } | ||
| 27 | else | ||
| 28 | { | ||
| 29 | audio_on(); | ||
| 30 | } | ||
| 31 | return false; | ||
| 32 | } | ||
| 33 | |||
| 34 | if (keycode == MUV_IN && record->event.pressed) { | ||
| 35 | voice_iterate(); | ||
| 36 | music_scale_user(); | ||
| 37 | return false; | ||
| 38 | } | ||
| 39 | |||
| 40 | if (keycode == MUV_DE && record->event.pressed) { | ||
| 41 | voice_deiterate(); | ||
| 42 | music_scale_user(); | ||
| 43 | return false; | ||
| 44 | } | ||
| 45 | |||
| 46 | return true; | ||
| 47 | } | ||
| 48 | |||
| 49 | void process_audio_noteon(uint8_t note) { | ||
| 50 | play_note(compute_freq_for_midi_note(note), 0xF); | ||
| 51 | } | ||
| 52 | |||
| 53 | void process_audio_noteoff(uint8_t note) { | ||
| 54 | stop_note(compute_freq_for_midi_note(note)); | ||
| 55 | } | ||
| 56 | |||
| 57 | void process_audio_all_notes_off(void) { | ||
| 58 | stop_all_notes(); | ||
| 59 | } | ||
| 60 | |||
| 61 | __attribute__ ((weak)) | ||
| 62 | void audio_on_user() {} \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_audio.h b/quantum/process_keycode/process_audio.h new file mode 100644 index 000000000..7ac15b733 --- /dev/null +++ b/quantum/process_keycode/process_audio.h | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | #ifndef PROCESS_AUDIO_H | ||
| 2 | #define PROCESS_AUDIO_H | ||
| 3 | |||
| 4 | bool process_audio(uint16_t keycode, keyrecord_t *record); | ||
| 5 | void process_audio_noteon(uint8_t note); | ||
| 6 | void process_audio_noteoff(uint8_t note); | ||
| 7 | void process_audio_all_notes_off(void); | ||
| 8 | |||
| 9 | void audio_on_user(void); | ||
| 10 | |||
| 11 | #endif \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_chording.c b/quantum/process_keycode/process_chording.c index d7814629f..6c6ebe300 100644 --- a/quantum/process_keycode/process_chording.c +++ b/quantum/process_keycode/process_chording.c | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #include "process_chording.h" | 17 | #include "process_chording.h" |
| 2 | 18 | ||
| 3 | bool keys_chord(uint8_t keys[]) { | 19 | bool keys_chord(uint8_t keys[]) { |
| @@ -57,4 +73,4 @@ bool process_chording(uint16_t keycode, keyrecord_t *record) { | |||
| 57 | } | 73 | } |
| 58 | } | 74 | } |
| 59 | return true; | 75 | return true; |
| 60 | } \ No newline at end of file | 76 | } |
diff --git a/quantum/process_keycode/process_chording.h b/quantum/process_keycode/process_chording.h index 49c97db3b..8c0f4862a 100644 --- a/quantum/process_keycode/process_chording.h +++ b/quantum/process_keycode/process_chording.h | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #ifndef PROCESS_CHORDING_H | 17 | #ifndef PROCESS_CHORDING_H |
| 2 | #define PROCESS_CHORDING_H | 18 | #define PROCESS_CHORDING_H |
| 3 | 19 | ||
| @@ -13,4 +29,4 @@ uint8_t chord_key_down = 0; | |||
| 13 | 29 | ||
| 14 | bool process_chording(uint16_t keycode, keyrecord_t *record); | 30 | bool process_chording(uint16_t keycode, keyrecord_t *record); |
| 15 | 31 | ||
| 16 | #endif \ No newline at end of file | 32 | #endif |
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c new file mode 100644 index 000000000..58d45add2 --- /dev/null +++ b/quantum/process_keycode/process_combo.c | |||
| @@ -0,0 +1,150 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "process_combo.h" | ||
| 18 | #include "print.h" | ||
| 19 | |||
| 20 | |||
| 21 | #define COMBO_TIMER_ELAPSED -1 | ||
| 22 | |||
| 23 | |||
| 24 | __attribute__ ((weak)) | ||
| 25 | combo_t key_combos[] = { | ||
| 26 | |||
| 27 | }; | ||
| 28 | |||
| 29 | __attribute__ ((weak)) | ||
| 30 | void process_combo_event(uint8_t combo_index, bool pressed) { | ||
| 31 | |||
| 32 | } | ||
| 33 | |||
| 34 | static uint8_t current_combo_index = 0; | ||
| 35 | |||
| 36 | static inline void send_combo(uint16_t action, bool pressed) | ||
| 37 | { | ||
| 38 | if (action) { | ||
| 39 | if (pressed) { | ||
| 40 | register_code16(action); | ||
| 41 | } else { | ||
| 42 | unregister_code16(action); | ||
| 43 | } | ||
| 44 | } else { | ||
| 45 | process_combo_event(current_combo_index, pressed); | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | #define ALL_COMBO_KEYS_ARE_DOWN (((1<<count)-1) == combo->state) | ||
| 50 | #define NO_COMBO_KEYS_ARE_DOWN (0 == combo->state) | ||
| 51 | #define KEY_STATE_DOWN(key) do{ combo->state |= (1<<key); } while(0) | ||
| 52 | #define KEY_STATE_UP(key) do{ combo->state &= ~(1<<key); } while(0) | ||
| 53 | static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *record) | ||
| 54 | { | ||
| 55 | uint8_t count = 0; | ||
| 56 | uint8_t index = -1; | ||
| 57 | /* Find index of keycode and number of combo keys */ | ||
| 58 | for (const uint16_t *keys = combo->keys; ;++count) { | ||
| 59 | uint16_t key = pgm_read_word(&keys[count]); | ||
| 60 | if (keycode == key) index = count; | ||
| 61 | if (COMBO_END == key) break; | ||
| 62 | } | ||
| 63 | |||
| 64 | /* Return if not a combo key */ | ||
| 65 | if (-1 == (int8_t)index) return false; | ||
| 66 | |||
| 67 | /* The combos timer is used to signal whether the combo is active */ | ||
| 68 | bool is_combo_active = COMBO_TIMER_ELAPSED == combo->timer ? false : true; | ||
| 69 | |||
| 70 | if (record->event.pressed) { | ||
| 71 | KEY_STATE_DOWN(index); | ||
| 72 | |||
| 73 | if (is_combo_active) { | ||
| 74 | if (ALL_COMBO_KEYS_ARE_DOWN) { /* Combo was pressed */ | ||
| 75 | send_combo(combo->keycode, true); | ||
| 76 | combo->timer = COMBO_TIMER_ELAPSED; | ||
| 77 | } else { /* Combo key was pressed */ | ||
| 78 | combo->timer = timer_read(); | ||
| 79 | #ifdef COMBO_ALLOW_ACTION_KEYS | ||
| 80 | combo->prev_record = *record; | ||
| 81 | #else | ||
| 82 | combo->prev_key = keycode; | ||
| 83 | #endif | ||
| 84 | } | ||
| 85 | } | ||
| 86 | } else { | ||
| 87 | if (ALL_COMBO_KEYS_ARE_DOWN) { /* Combo was released */ | ||
| 88 | send_combo(combo->keycode, false); | ||
| 89 | } | ||
| 90 | |||
| 91 | if (is_combo_active) { /* Combo key was tapped */ | ||
| 92 | #ifdef COMBO_ALLOW_ACTION_KEYS | ||
| 93 | record->event.pressed = true; | ||
| 94 | process_action(record, store_or_get_action(record->event.pressed, record->event.key)); | ||
| 95 | record->event.pressed = false; | ||
| 96 | process_action(record, store_or_get_action(record->event.pressed, record->event.key)); | ||
| 97 | #else | ||
| 98 | register_code16(keycode); | ||
| 99 | send_keyboard_report(); | ||
| 100 | unregister_code16(keycode); | ||
| 101 | #endif | ||
| 102 | combo->timer = 0; | ||
| 103 | } | ||
| 104 | |||
| 105 | KEY_STATE_UP(index); | ||
| 106 | } | ||
| 107 | |||
| 108 | if (NO_COMBO_KEYS_ARE_DOWN) { | ||
| 109 | combo->timer = 0; | ||
| 110 | } | ||
| 111 | |||
| 112 | return is_combo_active; | ||
| 113 | } | ||
| 114 | |||
| 115 | bool process_combo(uint16_t keycode, keyrecord_t *record) | ||
| 116 | { | ||
| 117 | bool is_combo_key = false; | ||
| 118 | |||
| 119 | for (current_combo_index = 0; current_combo_index < COMBO_COUNT; ++current_combo_index) { | ||
| 120 | combo_t *combo = &key_combos[current_combo_index]; | ||
| 121 | is_combo_key |= process_single_combo(combo, keycode, record); | ||
| 122 | } | ||
| 123 | |||
| 124 | return !is_combo_key; | ||
| 125 | } | ||
| 126 | |||
| 127 | void matrix_scan_combo(void) | ||
| 128 | { | ||
| 129 | for (int i = 0; i < COMBO_COUNT; ++i) { | ||
| 130 | combo_t *combo = &key_combos[i]; | ||
| 131 | if (combo->timer && | ||
| 132 | combo->timer != COMBO_TIMER_ELAPSED && | ||
| 133 | timer_elapsed(combo->timer) > COMBO_TERM) { | ||
| 134 | |||
| 135 | /* This disables the combo, meaning key events for this | ||
| 136 | * combo will be handled by the next processors in the chain | ||
| 137 | */ | ||
| 138 | combo->timer = COMBO_TIMER_ELAPSED; | ||
| 139 | |||
| 140 | #ifdef COMBO_ALLOW_ACTION_KEYS | ||
| 141 | process_action(&combo->prev_record, | ||
| 142 | store_or_get_action(combo->prev_record.event.pressed, | ||
| 143 | combo->prev_record.event.key)); | ||
| 144 | #else | ||
| 145 | unregister_code16(combo->prev_key); | ||
| 146 | register_code16(combo->prev_key); | ||
| 147 | #endif | ||
| 148 | } | ||
| 149 | } | ||
| 150 | } | ||
diff --git a/quantum/process_keycode/process_combo.h b/quantum/process_keycode/process_combo.h new file mode 100644 index 000000000..a5dbd788a --- /dev/null +++ b/quantum/process_keycode/process_combo.h | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #ifndef PROCESS_COMBO_H | ||
| 18 | #define PROCESS_COMBO_H | ||
| 19 | |||
| 20 | #include <stdint.h> | ||
| 21 | #include "progmem.h" | ||
| 22 | #include "quantum.h" | ||
| 23 | |||
| 24 | typedef struct | ||
| 25 | { | ||
| 26 | const uint16_t *keys; | ||
| 27 | uint16_t keycode; | ||
| 28 | #ifdef EXTRA_EXTRA_LONG_COMBOS | ||
| 29 | uint32_t state; | ||
| 30 | #elif EXTRA_LONG_COMBOS | ||
| 31 | uint16_t state; | ||
| 32 | #else | ||
| 33 | uint8_t state; | ||
| 34 | #endif | ||
| 35 | uint16_t timer; | ||
| 36 | #ifdef COMBO_ALLOW_ACTION_KEYS | ||
| 37 | keyrecord_t prev_record; | ||
| 38 | #else | ||
| 39 | uint16_t prev_key; | ||
| 40 | #endif | ||
| 41 | } combo_t; | ||
| 42 | |||
| 43 | |||
| 44 | #define COMBO(ck, ca) {.keys = &(ck)[0], .keycode = (ca)} | ||
| 45 | #define COMBO_ACTION(ck) {.keys = &(ck)[0]} | ||
| 46 | |||
| 47 | #define COMBO_END 0 | ||
| 48 | #ifndef COMBO_COUNT | ||
| 49 | #define COMBO_COUNT 0 | ||
| 50 | #endif | ||
| 51 | #ifndef COMBO_TERM | ||
| 52 | #define COMBO_TERM TAPPING_TERM | ||
| 53 | #endif | ||
| 54 | |||
| 55 | bool process_combo(uint16_t keycode, keyrecord_t *record); | ||
| 56 | void matrix_scan_combo(void); | ||
| 57 | void process_combo_event(uint8_t combo_index, bool pressed); | ||
| 58 | |||
| 59 | #endif | ||
diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c index e53d221e7..473906d65 100644 --- a/quantum/process_keycode/process_leader.c +++ b/quantum/process_keycode/process_leader.c | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #include "process_leader.h" | 17 | #include "process_leader.h" |
| 2 | 18 | ||
| 3 | __attribute__ ((weak)) | 19 | __attribute__ ((weak)) |
| @@ -35,4 +51,4 @@ bool process_leader(uint16_t keycode, keyrecord_t *record) { | |||
| 35 | } | 51 | } |
| 36 | } | 52 | } |
| 37 | return true; | 53 | return true; |
| 38 | } \ No newline at end of file | 54 | } |
diff --git a/quantum/process_keycode/process_leader.h b/quantum/process_keycode/process_leader.h index c83db8abb..da7a3d2ef 100644 --- a/quantum/process_keycode/process_leader.h +++ b/quantum/process_keycode/process_leader.h | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #ifndef PROCESS_LEADER_H | 17 | #ifndef PROCESS_LEADER_H |
| 2 | #define PROCESS_LEADER_H | 18 | #define PROCESS_LEADER_H |
| 3 | 19 | ||
| @@ -20,4 +36,4 @@ void leader_end(void); | |||
| 20 | #define LEADER_EXTERNS() extern bool leading; extern uint16_t leader_time; extern uint16_t leader_sequence[5]; extern uint8_t leader_sequence_size | 36 | #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) | 37 | #define LEADER_DICTIONARY() if (leading && timer_elapsed(leader_time) > LEADER_TIMEOUT) |
| 22 | 38 | ||
| 23 | #endif \ No newline at end of file | 39 | #endif |
diff --git a/quantum/process_keycode/process_midi.c b/quantum/process_keycode/process_midi.c index 577dad43a..9184feaae 100644 --- a/quantum/process_keycode/process_midi.c +++ b/quantum/process_keycode/process_midi.c | |||
| @@ -1,68 +1,253 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #include "process_midi.h" | 16 | #include "process_midi.h" |
| 2 | 17 | ||
| 3 | bool midi_activated = false; | 18 | #ifdef MIDI_ENABLE |
| 4 | uint8_t midi_starting_note = 0x0C; | 19 | #include "midi.h" |
| 5 | int midi_offset = 7; | 20 | |
| 6 | 21 | #ifdef MIDI_BASIC | |
| 7 | bool process_midi(uint16_t keycode, keyrecord_t *record) { | 22 | |
| 8 | if (keycode == MI_ON && record->event.pressed) { | 23 | void process_midi_basic_noteon(uint8_t note) |
| 9 | midi_activated = true; | 24 | { |
| 10 | #ifdef AUDIO_ENABLE | 25 | midi_send_noteon(&midi_device, 0, note, 128); |
| 11 | music_scale_user(); | 26 | } |
| 12 | #endif | 27 | |
| 13 | return false; | 28 | void process_midi_basic_noteoff(uint8_t note) |
| 14 | } | 29 | { |
| 30 | midi_send_noteoff(&midi_device, 0, note, 0); | ||
| 31 | } | ||
| 32 | |||
| 33 | void process_midi_all_notes_off(void) | ||
| 34 | { | ||
| 35 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 36 | } | ||
| 37 | |||
| 38 | #endif // MIDI_BASIC | ||
| 39 | |||
| 40 | #ifdef MIDI_ADVANCED | ||
| 41 | |||
| 42 | #include "timer.h" | ||
| 43 | |||
| 44 | static uint8_t tone_status[MIDI_TONE_COUNT]; | ||
| 45 | |||
| 46 | static uint8_t midi_modulation; | ||
| 47 | static int8_t midi_modulation_step; | ||
| 48 | static uint16_t midi_modulation_timer; | ||
| 49 | |||
| 50 | inline uint8_t compute_velocity(uint8_t setting) | ||
| 51 | { | ||
| 52 | return (setting + 1) * (128 / (MIDI_VELOCITY_MAX - MIDI_VELOCITY_MIN + 1)); | ||
| 53 | } | ||
| 15 | 54 | ||
| 16 | if (keycode == MI_OFF && record->event.pressed) { | 55 | void midi_init(void) |
| 17 | midi_activated = false; | 56 | { |
| 18 | midi_send_cc(&midi_device, 0, 0x7B, 0); | 57 | midi_config.octave = MI_OCT_2 - MIDI_OCTAVE_MIN; |
| 19 | return false; | 58 | midi_config.transpose = 0; |
| 59 | midi_config.velocity = (MIDI_VELOCITY_MAX - MIDI_VELOCITY_MIN); | ||
| 60 | midi_config.channel = 0; | ||
| 61 | midi_config.modulation_interval = 8; | ||
| 62 | |||
| 63 | for (uint8_t i = 0; i < MIDI_TONE_COUNT; i++) | ||
| 64 | { | ||
| 65 | tone_status[i] = MIDI_INVALID_NOTE; | ||
| 20 | } | 66 | } |
| 21 | 67 | ||
| 22 | if (midi_activated) { | 68 | midi_modulation = 0; |
| 23 | if (record->event.key.col == (MATRIX_COLS - 1) && record->event.key.row == (MATRIX_ROWS - 1)) { | 69 | midi_modulation_step = 0; |
| 24 | if (record->event.pressed) { | 70 | midi_modulation_timer = 0; |
| 25 | midi_starting_note++; // Change key | 71 | } |
| 26 | midi_send_cc(&midi_device, 0, 0x7B, 0); | 72 | |
| 27 | } | 73 | void midi_task(void) |
| 28 | return false; | 74 | { |
| 29 | } | 75 | if (timer_elapsed(midi_modulation_timer) < midi_config.modulation_interval) |
| 30 | if (record->event.key.col == (MATRIX_COLS - 2) && record->event.key.row == (MATRIX_ROWS - 1)) { | 76 | return; |
| 31 | if (record->event.pressed) { | 77 | midi_modulation_timer = timer_read(); |
| 32 | midi_starting_note--; // Change key | 78 | |
| 33 | midi_send_cc(&midi_device, 0, 0x7B, 0); | 79 | if (midi_modulation_step != 0) |
| 34 | } | 80 | { |
| 35 | return false; | 81 | dprintf("midi modulation %d\n", midi_modulation); |
| 36 | } | 82 | midi_send_cc(&midi_device, midi_config.channel, 0x1, midi_modulation); |
| 37 | if (record->event.key.col == (MATRIX_COLS - 3) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { | 83 | |
| 38 | midi_offset++; // Change scale | 84 | if (midi_modulation_step < 0 && midi_modulation < -midi_modulation_step) { |
| 39 | midi_send_cc(&midi_device, 0, 0x7B, 0); | 85 | midi_modulation = 0; |
| 40 | return false; | 86 | midi_modulation_step = 0; |
| 41 | } | 87 | return; |
| 42 | if (record->event.key.col == (MATRIX_COLS - 4) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { | 88 | } |
| 43 | midi_offset--; // Change scale | 89 | |
| 44 | midi_send_cc(&midi_device, 0, 0x7B, 0); | 90 | midi_modulation += midi_modulation_step; |
| 45 | return false; | 91 | |
| 46 | } | 92 | if (midi_modulation > 127) |
| 47 | // basic | 93 | midi_modulation = 127; |
| 48 | // uint8_t note = (midi_starting_note + SCALE[record->event.key.col + midi_offset])+12*(MATRIX_ROWS - record->event.key.row); | ||
| 49 | // advanced | ||
| 50 | // uint8_t note = (midi_starting_note + record->event.key.col + midi_offset)+12*(MATRIX_ROWS - record->event.key.row); | ||
| 51 | // guitar | ||
| 52 | uint8_t note = (midi_starting_note + record->event.key.col + midi_offset)+5*(MATRIX_ROWS - record->event.key.row); | ||
| 53 | // violin | ||
| 54 | // uint8_t note = (midi_starting_note + record->event.key.col + midi_offset)+7*(MATRIX_ROWS - record->event.key.row); | ||
| 55 | |||
| 56 | if (record->event.pressed) { | ||
| 57 | // midi_send_noteon(&midi_device, record->event.key.row, midi_starting_note + SCALE[record->event.key.col], 127); | ||
| 58 | midi_send_noteon(&midi_device, 0, note, 127); | ||
| 59 | } else { | ||
| 60 | // midi_send_noteoff(&midi_device, record->event.key.row, midi_starting_note + SCALE[record->event.key.col], 127); | ||
| 61 | midi_send_noteoff(&midi_device, 0, note, 127); | ||
| 62 | } | ||
| 63 | |||
| 64 | if (keycode < 0xFF) // ignores all normal keycodes, but lets RAISE, LOWER, etc through | ||
| 65 | return false; | ||
| 66 | } | 94 | } |
| 67 | return true; | ||
| 68 | } | 95 | } |
| 96 | |||
| 97 | uint8_t midi_compute_note(uint16_t keycode) | ||
| 98 | { | ||
| 99 | return 12 * midi_config.octave + (keycode - MIDI_TONE_MIN) + midi_config.transpose; | ||
| 100 | } | ||
| 101 | |||
| 102 | bool process_midi(uint16_t keycode, keyrecord_t *record) | ||
| 103 | { | ||
| 104 | switch (keycode) { | ||
| 105 | case MIDI_TONE_MIN ... MIDI_TONE_MAX: | ||
| 106 | { | ||
| 107 | uint8_t channel = midi_config.channel; | ||
| 108 | uint8_t tone = keycode - MIDI_TONE_MIN; | ||
| 109 | uint8_t velocity = compute_velocity(midi_config.velocity); | ||
| 110 | if (record->event.pressed) { | ||
| 111 | uint8_t note = midi_compute_note(keycode); | ||
| 112 | midi_send_noteon(&midi_device, channel, note, velocity); | ||
| 113 | dprintf("midi noteon channel:%d note:%d velocity:%d\n", channel, note, velocity); | ||
| 114 | tone_status[tone] = note; | ||
| 115 | } | ||
| 116 | else { | ||
| 117 | uint8_t note = tone_status[tone]; | ||
| 118 | if (note != MIDI_INVALID_NOTE) | ||
| 119 | { | ||
| 120 | midi_send_noteoff(&midi_device, channel, note, velocity); | ||
| 121 | dprintf("midi noteoff channel:%d note:%d velocity:%d\n", channel, note, velocity); | ||
| 122 | } | ||
| 123 | tone_status[tone] = MIDI_INVALID_NOTE; | ||
| 124 | } | ||
| 125 | return false; | ||
| 126 | } | ||
| 127 | case MIDI_OCTAVE_MIN ... MIDI_OCTAVE_MAX: | ||
| 128 | if (record->event.pressed) { | ||
| 129 | midi_config.octave = keycode - MIDI_OCTAVE_MIN; | ||
| 130 | dprintf("midi octave %d\n", midi_config.octave); | ||
| 131 | } | ||
| 132 | return false; | ||
| 133 | case MI_OCTD: | ||
| 134 | if (record->event.pressed && midi_config.octave > 0) { | ||
| 135 | midi_config.octave--; | ||
| 136 | dprintf("midi octave %d\n", midi_config.octave); | ||
| 137 | } | ||
| 138 | return false; | ||
| 139 | case MI_OCTU: | ||
| 140 | if (record->event.pressed && midi_config.octave < (MIDI_OCTAVE_MAX - MIDI_OCTAVE_MIN)) { | ||
| 141 | midi_config.octave++; | ||
| 142 | dprintf("midi octave %d\n", midi_config.octave); | ||
| 143 | } | ||
| 144 | return false; | ||
| 145 | case MIDI_TRANSPOSE_MIN ... MIDI_TRANSPOSE_MAX: | ||
| 146 | if (record->event.pressed) { | ||
| 147 | midi_config.transpose = keycode - MI_TRNS_0; | ||
| 148 | dprintf("midi transpose %d\n", midi_config.transpose); | ||
| 149 | } | ||
| 150 | return false; | ||
| 151 | case MI_TRNSD: | ||
| 152 | if (record->event.pressed && midi_config.transpose > (MIDI_TRANSPOSE_MIN - MI_TRNS_0)) { | ||
| 153 | midi_config.transpose--; | ||
| 154 | dprintf("midi transpose %d\n", midi_config.transpose); | ||
| 155 | } | ||
| 156 | return false; | ||
| 157 | case MI_TRNSU: | ||
| 158 | if (record->event.pressed && midi_config.transpose < (MIDI_TRANSPOSE_MAX - MI_TRNS_0)) { | ||
| 159 | const bool positive = midi_config.transpose > 0; | ||
| 160 | midi_config.transpose++; | ||
| 161 | if (positive && midi_config.transpose < 0) | ||
| 162 | midi_config.transpose--; | ||
| 163 | dprintf("midi transpose %d\n", midi_config.transpose); | ||
| 164 | } | ||
| 165 | return false; | ||
| 166 | case MIDI_VELOCITY_MIN ... MIDI_VELOCITY_MAX: | ||
| 167 | if (record->event.pressed) { | ||
| 168 | midi_config.velocity = keycode - MIDI_VELOCITY_MIN; | ||
| 169 | dprintf("midi velocity %d\n", midi_config.velocity); | ||
| 170 | } | ||
| 171 | return false; | ||
| 172 | case MI_VELD: | ||
| 173 | if (record->event.pressed && midi_config.velocity > 0) { | ||
| 174 | midi_config.velocity--; | ||
| 175 | dprintf("midi velocity %d\n", midi_config.velocity); | ||
| 176 | } | ||
| 177 | return false; | ||
| 178 | case MI_VELU: | ||
| 179 | if (record->event.pressed) { | ||
| 180 | midi_config.velocity++; | ||
| 181 | dprintf("midi velocity %d\n", midi_config.velocity); | ||
| 182 | } | ||
| 183 | return false; | ||
| 184 | case MIDI_CHANNEL_MIN ... MIDI_CHANNEL_MAX: | ||
| 185 | if (record->event.pressed) { | ||
| 186 | midi_config.channel = keycode - MIDI_CHANNEL_MIN; | ||
| 187 | dprintf("midi channel %d\n", midi_config.channel); | ||
| 188 | } | ||
| 189 | return false; | ||
| 190 | case MI_CHD: | ||
| 191 | if (record->event.pressed) { | ||
| 192 | midi_config.channel--; | ||
| 193 | dprintf("midi channel %d\n", midi_config.channel); | ||
| 194 | } | ||
| 195 | return false; | ||
| 196 | case MI_CHU: | ||
| 197 | if (record->event.pressed) { | ||
| 198 | midi_config.channel++; | ||
| 199 | dprintf("midi channel %d\n", midi_config.channel); | ||
| 200 | } | ||
| 201 | return false; | ||
| 202 | case MI_ALLOFF: | ||
| 203 | if (record->event.pressed) { | ||
| 204 | midi_send_cc(&midi_device, midi_config.channel, 0x7B, 0); | ||
| 205 | dprintf("midi all notes off\n"); | ||
| 206 | } | ||
| 207 | return false; | ||
| 208 | case MI_SUS: | ||
| 209 | midi_send_cc(&midi_device, midi_config.channel, 0x40, record->event.pressed ? 127 : 0); | ||
| 210 | dprintf("midi sustain %d\n", record->event.pressed); | ||
| 211 | return false; | ||
| 212 | case MI_PORT: | ||
| 213 | midi_send_cc(&midi_device, midi_config.channel, 0x41, record->event.pressed ? 127 : 0); | ||
| 214 | dprintf("midi portamento %d\n", record->event.pressed); | ||
| 215 | return false; | ||
| 216 | case MI_SOST: | ||
| 217 | midi_send_cc(&midi_device, midi_config.channel, 0x42, record->event.pressed ? 127 : 0); | ||
| 218 | dprintf("midi sostenuto %d\n", record->event.pressed); | ||
| 219 | return false; | ||
| 220 | case MI_SOFT: | ||
| 221 | midi_send_cc(&midi_device, midi_config.channel, 0x43, record->event.pressed ? 127 : 0); | ||
| 222 | dprintf("midi soft %d\n", record->event.pressed); | ||
| 223 | return false; | ||
| 224 | case MI_LEG: | ||
| 225 | midi_send_cc(&midi_device, midi_config.channel, 0x43, record->event.pressed ? 127 : 0); | ||
| 226 | dprintf("midi legato %d\n", record->event.pressed); | ||
| 227 | return false; | ||
| 228 | case MI_MOD: | ||
| 229 | midi_modulation_step = record->event.pressed ? 1 : -1; | ||
| 230 | return false; | ||
| 231 | case MI_MODSD: | ||
| 232 | if (record->event.pressed) { | ||
| 233 | midi_config.modulation_interval++; | ||
| 234 | // prevent overflow | ||
| 235 | if (midi_config.modulation_interval == 0) | ||
| 236 | midi_config.modulation_interval--; | ||
| 237 | dprintf("midi modulation interval %d\n", midi_config.modulation_interval); | ||
| 238 | } | ||
| 239 | return false; | ||
| 240 | case MI_MODSU: | ||
| 241 | if (record->event.pressed && midi_config.modulation_interval > 0) { | ||
| 242 | midi_config.modulation_interval--; | ||
| 243 | dprintf("midi modulation interval %d\n", midi_config.modulation_interval); | ||
| 244 | } | ||
| 245 | return false; | ||
| 246 | }; | ||
| 247 | |||
| 248 | return true; | ||
| 249 | } | ||
| 250 | |||
| 251 | #endif // MIDI_ADVANCED | ||
| 252 | |||
| 253 | #endif // MIDI_ENABLE | ||
diff --git a/quantum/process_keycode/process_midi.h b/quantum/process_keycode/process_midi.h index acd4fc1b1..ccac8981a 100644 --- a/quantum/process_keycode/process_midi.h +++ b/quantum/process_keycode/process_midi.h | |||
| @@ -1,207 +1,56 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #ifndef PROCESS_MIDI_H | 17 | #ifndef PROCESS_MIDI_H |
| 2 | #define PROCESS_MIDI_H | 18 | #define PROCESS_MIDI_H |
| 3 | 19 | ||
| 4 | #include "quantum.h" | 20 | #include "quantum.h" |
| 5 | 21 | ||
| 6 | bool process_midi(uint16_t keycode, keyrecord_t *record); | 22 | #ifdef MIDI_ENABLE |
| 23 | |||
| 24 | #ifdef MIDI_BASIC | ||
| 25 | void process_midi_basic_noteon(uint8_t note); | ||
| 26 | void process_midi_basic_noteoff(uint8_t note); | ||
| 27 | void process_midi_all_notes_off(void); | ||
| 28 | #endif | ||
| 7 | 29 | ||
| 8 | #define MIDI(n) ((n) | 0x6000) | 30 | #ifdef MIDI_ADVANCED |
| 9 | #define MIDI12 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000 | 31 | typedef union { |
| 32 | uint32_t raw; | ||
| 33 | struct { | ||
| 34 | uint8_t octave :4; | ||
| 35 | int8_t transpose :4; | ||
| 36 | uint8_t velocity :4; | ||
| 37 | uint8_t channel :4; | ||
| 38 | uint8_t modulation_interval :4; | ||
| 39 | }; | ||
| 40 | } midi_config_t; | ||
| 41 | |||
| 42 | midi_config_t midi_config; | ||
| 43 | |||
| 44 | void midi_init(void); | ||
| 45 | void midi_task(void); | ||
| 46 | bool process_midi(uint16_t keycode, keyrecord_t *record); | ||
| 10 | 47 | ||
| 11 | #define CHNL(note, channel) (note + (channel << 8)) | 48 | #define MIDI_INVALID_NOTE 0xFF |
| 49 | #define MIDI_TONE_COUNT (MIDI_TONE_MAX - MIDI_TONE_MIN + 1) | ||
| 12 | 50 | ||
| 13 | #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), \ | 51 | uint8_t midi_compute_note(uint16_t keycode); |
| 14 | 0 + (12*1), 2 + (12*1), 4 + (12*1), 5 + (12*1), 7 + (12*1), 9 + (12*1), 11 + (12*1), \ | 52 | #endif // MIDI_ADVANCED |
| 15 | 0 + (12*2), 2 + (12*2), 4 + (12*2), 5 + (12*2), 7 + (12*2), 9 + (12*2), 11 + (12*2), \ | ||
| 16 | 0 + (12*3), 2 + (12*3), 4 + (12*3), 5 + (12*3), 7 + (12*3), 9 + (12*3), 11 + (12*3), \ | ||
| 17 | 0 + (12*4), 2 + (12*4), 4 + (12*4), 5 + (12*4), 7 + (12*4), 9 + (12*4), 11 + (12*4), } | ||
| 18 | 53 | ||
| 19 | #define N_CN1 (0x600C + (12 * -1) + 0 ) | 54 | #endif // MIDI_ENABLE |
| 20 | #define N_CN1S (0x600C + (12 * -1) + 1 ) | ||
| 21 | #define N_DN1F (0x600C + (12 * -1) + 1 ) | ||
| 22 | #define N_DN1 (0x600C + (12 * -1) + 2 ) | ||
| 23 | #define N_DN1S (0x600C + (12 * -1) + 3 ) | ||
| 24 | #define N_EN1F (0x600C + (12 * -1) + 3 ) | ||
| 25 | #define N_EN1 (0x600C + (12 * -1) + 4 ) | ||
| 26 | #define N_FN1 (0x600C + (12 * -1) + 5 ) | ||
| 27 | #define N_FN1S (0x600C + (12 * -1) + 6 ) | ||
| 28 | #define N_GN1F (0x600C + (12 * -1) + 6 ) | ||
| 29 | #define N_GN1 (0x600C + (12 * -1) + 7 ) | ||
| 30 | #define N_GN1S (0x600C + (12 * -1) + 8 ) | ||
| 31 | #define N_AN1F (0x600C + (12 * -1) + 8 ) | ||
| 32 | #define N_AN1 (0x600C + (12 * -1) + 9 ) | ||
| 33 | #define N_AN1S (0x600C + (12 * -1) + 10) | ||
| 34 | #define N_BN1F (0x600C + (12 * -1) + 10) | ||
| 35 | #define N_BN1 (0x600C + (12 * -1) + 11) | ||
| 36 | #define N_C0 (0x600C + (12 * 0) + 0 ) | ||
| 37 | #define N_C0S (0x600C + (12 * 0) + 1 ) | ||
| 38 | #define N_D0F (0x600C + (12 * 0) + 1 ) | ||
| 39 | #define N_D0 (0x600C + (12 * 0) + 2 ) | ||
| 40 | #define N_D0S (0x600C + (12 * 0) + 3 ) | ||
| 41 | #define N_E0F (0x600C + (12 * 0) + 3 ) | ||
| 42 | #define N_E0 (0x600C + (12 * 0) + 4 ) | ||
| 43 | #define N_F0 (0x600C + (12 * 0) + 5 ) | ||
| 44 | #define N_F0S (0x600C + (12 * 0) + 6 ) | ||
| 45 | #define N_G0F (0x600C + (12 * 0) + 6 ) | ||
| 46 | #define N_G0 (0x600C + (12 * 0) + 7 ) | ||
| 47 | #define N_G0S (0x600C + (12 * 0) + 8 ) | ||
| 48 | #define N_A0F (0x600C + (12 * 0) + 8 ) | ||
| 49 | #define N_A0 (0x600C + (12 * 0) + 9 ) | ||
| 50 | #define N_A0S (0x600C + (12 * 0) + 10) | ||
| 51 | #define N_B0F (0x600C + (12 * 0) + 10) | ||
| 52 | #define N_B0 (0x600C + (12 * 0) + 11) | ||
| 53 | #define N_C1 (0x600C + (12 * 1) + 0 ) | ||
| 54 | #define N_C1S (0x600C + (12 * 1) + 1 ) | ||
| 55 | #define N_D1F (0x600C + (12 * 1) + 1 ) | ||
| 56 | #define N_D1 (0x600C + (12 * 1) + 2 ) | ||
| 57 | #define N_D1S (0x600C + (12 * 1) + 3 ) | ||
| 58 | #define N_E1F (0x600C + (12 * 1) + 3 ) | ||
| 59 | #define N_E1 (0x600C + (12 * 1) + 4 ) | ||
| 60 | #define N_F1 (0x600C + (12 * 1) + 5 ) | ||
| 61 | #define N_F1S (0x600C + (12 * 1) + 6 ) | ||
| 62 | #define N_G1F (0x600C + (12 * 1) + 6 ) | ||
| 63 | #define N_G1 (0x600C + (12 * 1) + 7 ) | ||
| 64 | #define N_G1S (0x600C + (12 * 1) + 8 ) | ||
| 65 | #define N_A1F (0x600C + (12 * 1) + 8 ) | ||
| 66 | #define N_A1 (0x600C + (12 * 1) + 9 ) | ||
| 67 | #define N_A1S (0x600C + (12 * 1) + 10) | ||
| 68 | #define N_B1F (0x600C + (12 * 1) + 10) | ||
| 69 | #define N_B1 (0x600C + (12 * 1) + 11) | ||
| 70 | #define N_C2 (0x600C + (12 * 2) + 0 ) | ||
| 71 | #define N_C2S (0x600C + (12 * 2) + 1 ) | ||
| 72 | #define N_D2F (0x600C + (12 * 2) + 1 ) | ||
| 73 | #define N_D2 (0x600C + (12 * 2) + 2 ) | ||
| 74 | #define N_D2S (0x600C + (12 * 2) + 3 ) | ||
| 75 | #define N_E2F (0x600C + (12 * 2) + 3 ) | ||
| 76 | #define N_E2 (0x600C + (12 * 2) + 4 ) | ||
| 77 | #define N_F2 (0x600C + (12 * 2) + 5 ) | ||
| 78 | #define N_F2S (0x600C + (12 * 2) + 6 ) | ||
| 79 | #define N_G2F (0x600C + (12 * 2) + 6 ) | ||
| 80 | #define N_G2 (0x600C + (12 * 2) + 7 ) | ||
| 81 | #define N_G2S (0x600C + (12 * 2) + 8 ) | ||
| 82 | #define N_A2F (0x600C + (12 * 2) + 8 ) | ||
| 83 | #define N_A2 (0x600C + (12 * 2) + 9 ) | ||
| 84 | #define N_A2S (0x600C + (12 * 2) + 10) | ||
| 85 | #define N_B2F (0x600C + (12 * 2) + 10) | ||
| 86 | #define N_B2 (0x600C + (12 * 2) + 11) | ||
| 87 | #define N_C3 (0x600C + (12 * 3) + 0 ) | ||
| 88 | #define N_C3S (0x600C + (12 * 3) + 1 ) | ||
| 89 | #define N_D3F (0x600C + (12 * 3) + 1 ) | ||
| 90 | #define N_D3 (0x600C + (12 * 3) + 2 ) | ||
| 91 | #define N_D3S (0x600C + (12 * 3) + 3 ) | ||
| 92 | #define N_E3F (0x600C + (12 * 3) + 3 ) | ||
| 93 | #define N_E3 (0x600C + (12 * 3) + 4 ) | ||
| 94 | #define N_F3 (0x600C + (12 * 3) + 5 ) | ||
| 95 | #define N_F3S (0x600C + (12 * 3) + 6 ) | ||
| 96 | #define N_G3F (0x600C + (12 * 3) + 6 ) | ||
| 97 | #define N_G3 (0x600C + (12 * 3) + 7 ) | ||
| 98 | #define N_G3S (0x600C + (12 * 3) + 8 ) | ||
| 99 | #define N_A3F (0x600C + (12 * 3) + 8 ) | ||
| 100 | #define N_A3 (0x600C + (12 * 3) + 9 ) | ||
| 101 | #define N_A3S (0x600C + (12 * 3) + 10) | ||
| 102 | #define N_B3F (0x600C + (12 * 3) + 10) | ||
| 103 | #define N_B3 (0x600C + (12 * 3) + 11) | ||
| 104 | #define N_C4 (0x600C + (12 * 4) + 0 ) | ||
| 105 | #define N_C4S (0x600C + (12 * 4) + 1 ) | ||
| 106 | #define N_D4F (0x600C + (12 * 4) + 1 ) | ||
| 107 | #define N_D4 (0x600C + (12 * 4) + 2 ) | ||
| 108 | #define N_D4S (0x600C + (12 * 4) + 3 ) | ||
| 109 | #define N_E4F (0x600C + (12 * 4) + 3 ) | ||
| 110 | #define N_E4 (0x600C + (12 * 4) + 4 ) | ||
| 111 | #define N_F4 (0x600C + (12 * 4) + 5 ) | ||
| 112 | #define N_F4S (0x600C + (12 * 4) + 6 ) | ||
| 113 | #define N_G4F (0x600C + (12 * 4) + 6 ) | ||
| 114 | #define N_G4 (0x600C + (12 * 4) + 7 ) | ||
| 115 | #define N_G4S (0x600C + (12 * 4) + 8 ) | ||
| 116 | #define N_A4F (0x600C + (12 * 4) + 8 ) | ||
| 117 | #define N_A4 (0x600C + (12 * 4) + 9 ) | ||
| 118 | #define N_A4S (0x600C + (12 * 4) + 10) | ||
| 119 | #define N_B4F (0x600C + (12 * 4) + 10) | ||
| 120 | #define N_B4 (0x600C + (12 * 4) + 11) | ||
| 121 | #define N_C5 (0x600C + (12 * 5) + 0 ) | ||
| 122 | #define N_C5S (0x600C + (12 * 5) + 1 ) | ||
| 123 | #define N_D5F (0x600C + (12 * 5) + 1 ) | ||
| 124 | #define N_D5 (0x600C + (12 * 5) + 2 ) | ||
| 125 | #define N_D5S (0x600C + (12 * 5) + 3 ) | ||
| 126 | #define N_E5F (0x600C + (12 * 5) + 3 ) | ||
| 127 | #define N_E5 (0x600C + (12 * 5) + 4 ) | ||
| 128 | #define N_F5 (0x600C + (12 * 5) + 5 ) | ||
| 129 | #define N_F5S (0x600C + (12 * 5) + 6 ) | ||
| 130 | #define N_G5F (0x600C + (12 * 5) + 6 ) | ||
| 131 | #define N_G5 (0x600C + (12 * 5) + 7 ) | ||
| 132 | #define N_G5S (0x600C + (12 * 5) + 8 ) | ||
| 133 | #define N_A5F (0x600C + (12 * 5) + 8 ) | ||
| 134 | #define N_A5 (0x600C + (12 * 5) + 9 ) | ||
| 135 | #define N_A5S (0x600C + (12 * 5) + 10) | ||
| 136 | #define N_B5F (0x600C + (12 * 5) + 10) | ||
| 137 | #define N_B5 (0x600C + (12 * 5) + 11) | ||
| 138 | #define N_C6 (0x600C + (12 * 6) + 0 ) | ||
| 139 | #define N_C6S (0x600C + (12 * 6) + 1 ) | ||
| 140 | #define N_D6F (0x600C + (12 * 6) + 1 ) | ||
| 141 | #define N_D6 (0x600C + (12 * 6) + 2 ) | ||
| 142 | #define N_D6S (0x600C + (12 * 6) + 3 ) | ||
| 143 | #define N_E6F (0x600C + (12 * 6) + 3 ) | ||
| 144 | #define N_E6 (0x600C + (12 * 6) + 4 ) | ||
| 145 | #define N_F6 (0x600C + (12 * 6) + 5 ) | ||
| 146 | #define N_F6S (0x600C + (12 * 6) + 6 ) | ||
| 147 | #define N_G6F (0x600C + (12 * 6) + 6 ) | ||
| 148 | #define N_G6 (0x600C + (12 * 6) + 7 ) | ||
| 149 | #define N_G6S (0x600C + (12 * 6) + 8 ) | ||
| 150 | #define N_A6F (0x600C + (12 * 6) + 8 ) | ||
| 151 | #define N_A6 (0x600C + (12 * 6) + 9 ) | ||
| 152 | #define N_A6S (0x600C + (12 * 6) + 10) | ||
| 153 | #define N_B6F (0x600C + (12 * 6) + 10) | ||
| 154 | #define N_B6 (0x600C + (12 * 6) + 11) | ||
| 155 | #define N_C7 (0x600C + (12 * 7) + 0 ) | ||
| 156 | #define N_C7S (0x600C + (12 * 7) + 1 ) | ||
| 157 | #define N_D7F (0x600C + (12 * 7) + 1 ) | ||
| 158 | #define N_D7 (0x600C + (12 * 7) + 2 ) | ||
| 159 | #define N_D7S (0x600C + (12 * 7) + 3 ) | ||
| 160 | #define N_E7F (0x600C + (12 * 7) + 3 ) | ||
| 161 | #define N_E7 (0x600C + (12 * 7) + 4 ) | ||
| 162 | #define N_F7 (0x600C + (12 * 7) + 5 ) | ||
| 163 | #define N_F7S (0x600C + (12 * 7) + 6 ) | ||
| 164 | #define N_G7F (0x600C + (12 * 7) + 6 ) | ||
| 165 | #define N_G7 (0x600C + (12 * 7) + 7 ) | ||
| 166 | #define N_G7S (0x600C + (12 * 7) + 8 ) | ||
| 167 | #define N_A7F (0x600C + (12 * 7) + 8 ) | ||
| 168 | #define N_A7 (0x600C + (12 * 7) + 9 ) | ||
| 169 | #define N_A7S (0x600C + (12 * 7) + 10) | ||
| 170 | #define N_B7F (0x600C + (12 * 7) + 10) | ||
| 171 | #define N_B7 (0x600C + (12 * 7) + 11) | ||
| 172 | #define N_C8 (0x600C + (12 * 8) + 0 ) | ||
| 173 | #define N_C8S (0x600C + (12 * 8) + 1 ) | ||
| 174 | #define N_D8F (0x600C + (12 * 8) + 1 ) | ||
| 175 | #define N_D8 (0x600C + (12 * 8) + 2 ) | ||
| 176 | #define N_D8S (0x600C + (12 * 8) + 3 ) | ||
| 177 | #define N_E8F (0x600C + (12 * 8) + 3 ) | ||
| 178 | #define N_E8 (0x600C + (12 * 8) + 4 ) | ||
| 179 | #define N_F8 (0x600C + (12 * 8) + 5 ) | ||
| 180 | #define N_F8S (0x600C + (12 * 8) + 6 ) | ||
| 181 | #define N_G8F (0x600C + (12 * 8) + 6 ) | ||
| 182 | #define N_G8 (0x600C + (12 * 8) + 7 ) | ||
| 183 | #define N_G8S (0x600C + (12 * 8) + 8 ) | ||
| 184 | #define N_A8F (0x600C + (12 * 8) + 8 ) | ||
| 185 | #define N_A8 (0x600C + (12 * 8) + 9 ) | ||
| 186 | #define N_A8S (0x600C + (12 * 8) + 10) | ||
| 187 | #define N_B8F (0x600C + (12 * 8) + 10) | ||
| 188 | #define N_B8 (0x600C + (12 * 8) + 11) | ||
| 189 | #define N_C8 (0x600C + (12 * 8) + 0 ) | ||
| 190 | #define N_C8S (0x600C + (12 * 8) + 1 ) | ||
| 191 | #define N_D8F (0x600C + (12 * 8) + 1 ) | ||
| 192 | #define N_D8 (0x600C + (12 * 8) + 2 ) | ||
| 193 | #define N_D8S (0x600C + (12 * 8) + 3 ) | ||
| 194 | #define N_E8F (0x600C + (12 * 8) + 3 ) | ||
| 195 | #define N_E8 (0x600C + (12 * 8) + 4 ) | ||
| 196 | #define N_F8 (0x600C + (12 * 8) + 5 ) | ||
| 197 | #define N_F8S (0x600C + (12 * 8) + 6 ) | ||
| 198 | #define N_G8F (0x600C + (12 * 8) + 6 ) | ||
| 199 | #define N_G8 (0x600C + (12 * 8) + 7 ) | ||
| 200 | #define N_G8S (0x600C + (12 * 8) + 8 ) | ||
| 201 | #define N_A8F (0x600C + (12 * 8) + 8 ) | ||
| 202 | #define N_A8 (0x600C + (12 * 8) + 9 ) | ||
| 203 | #define N_A8S (0x600C + (12 * 8) + 10) | ||
| 204 | #define N_B8F (0x600C + (12 * 8) + 10) | ||
| 205 | #define N_B8 (0x600C + (12 * 8) + 11) | ||
| 206 | 55 | ||
| 207 | #endif \ No newline at end of file | 56 | #endif |
diff --git a/quantum/process_keycode/process_music.c b/quantum/process_keycode/process_music.c index ca68bef6c..217dca280 100644 --- a/quantum/process_keycode/process_music.c +++ b/quantum/process_keycode/process_music.c | |||
| @@ -1,5 +1,29 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #include "process_music.h" | 16 | #include "process_music.h" |
| 2 | 17 | ||
| 18 | #ifdef AUDIO_ENABLE | ||
| 19 | #include "process_audio.h" | ||
| 20 | #endif | ||
| 21 | #if defined(MIDI_ENABLE) && defined(MIDI_BASIC) | ||
| 22 | #include "process_midi.h" | ||
| 23 | #endif | ||
| 24 | |||
| 25 | #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) | ||
| 26 | |||
| 3 | bool music_activated = false; | 27 | bool music_activated = false; |
| 4 | uint8_t music_starting_note = 0x0C; | 28 | uint8_t music_starting_note = 0x0C; |
| 5 | int music_offset = 7; | 29 | int music_offset = 7; |
| @@ -8,36 +32,41 @@ int music_offset = 7; | |||
| 8 | static bool music_sequence_recording = false; | 32 | static bool music_sequence_recording = false; |
| 9 | static bool music_sequence_recorded = false; | 33 | static bool music_sequence_recorded = false; |
| 10 | static bool music_sequence_playing = false; | 34 | static bool music_sequence_playing = false; |
| 11 | static float music_sequence[16] = {0}; | 35 | static uint8_t music_sequence[16] = {0}; |
| 12 | static uint8_t music_sequence_count = 0; | 36 | static uint8_t music_sequence_count = 0; |
| 13 | static uint8_t music_sequence_position = 0; | 37 | static uint8_t music_sequence_position = 0; |
| 14 | 38 | ||
| 15 | static uint16_t music_sequence_timer = 0; | 39 | static uint16_t music_sequence_timer = 0; |
| 16 | static uint16_t music_sequence_interval = 100; | 40 | static uint16_t music_sequence_interval = 100; |
| 17 | 41 | ||
| 18 | bool process_music(uint16_t keycode, keyrecord_t *record) { | 42 | static void music_noteon(uint8_t note) { |
| 43 | #ifdef AUDIO_ENABLE | ||
| 44 | process_audio_noteon(note); | ||
| 45 | #endif | ||
| 46 | #if defined(MIDI_ENABLE) && defined(MIDI_BASIC) | ||
| 47 | process_midi_basic_noteon(note); | ||
| 48 | #endif | ||
| 49 | } | ||
| 19 | 50 | ||
| 20 | if (keycode == AU_ON && record->event.pressed) { | 51 | static void music_noteoff(uint8_t note) { |
| 21 | audio_on(); | 52 | #ifdef AUDIO_ENABLE |
| 22 | return false; | 53 | process_audio_noteoff(note); |
| 23 | } | 54 | #endif |
| 55 | #if defined(MIDI_ENABLE) && defined(MIDI_BASIC) | ||
| 56 | process_midi_basic_noteoff(note); | ||
| 57 | #endif | ||
| 58 | } | ||
| 24 | 59 | ||
| 25 | if (keycode == AU_OFF && record->event.pressed) { | 60 | void music_all_notes_off(void) { |
| 26 | audio_off(); | 61 | #ifdef AUDIO_ENABLE |
| 27 | return false; | 62 | process_audio_all_notes_off(); |
| 28 | } | 63 | #endif |
| 64 | #if defined(MIDI_ENABLE) && defined(MIDI_BASIC) | ||
| 65 | process_midi_all_notes_off(); | ||
| 66 | #endif | ||
| 67 | } | ||
| 29 | 68 | ||
| 30 | if (keycode == AU_TOG && record->event.pressed) { | 69 | bool process_music(uint16_t keycode, keyrecord_t *record) { |
| 31 | if (is_audio_on()) | ||
| 32 | { | ||
| 33 | audio_off(); | ||
| 34 | } | ||
| 35 | else | ||
| 36 | { | ||
| 37 | audio_on(); | ||
| 38 | } | ||
| 39 | return false; | ||
| 40 | } | ||
| 41 | 70 | ||
| 42 | if (keycode == MU_ON && record->event.pressed) { | 71 | if (keycode == MU_ON && record->event.pressed) { |
| 43 | music_on(); | 72 | music_on(); |
| @@ -61,22 +90,10 @@ bool process_music(uint16_t keycode, keyrecord_t *record) { | |||
| 61 | return false; | 90 | return false; |
| 62 | } | 91 | } |
| 63 | 92 | ||
| 64 | if (keycode == MUV_IN && record->event.pressed) { | ||
| 65 | voice_iterate(); | ||
| 66 | music_scale_user(); | ||
| 67 | return false; | ||
| 68 | } | ||
| 69 | |||
| 70 | if (keycode == MUV_DE && record->event.pressed) { | ||
| 71 | voice_deiterate(); | ||
| 72 | music_scale_user(); | ||
| 73 | return false; | ||
| 74 | } | ||
| 75 | |||
| 76 | if (music_activated) { | 93 | if (music_activated) { |
| 77 | 94 | ||
| 78 | if (keycode == KC_LCTL && record->event.pressed) { // Start recording | 95 | if (keycode == KC_LCTL && record->event.pressed) { // Start recording |
| 79 | stop_all_notes(); | 96 | music_all_notes_off(); |
| 80 | music_sequence_recording = true; | 97 | music_sequence_recording = true; |
| 81 | music_sequence_recorded = false; | 98 | music_sequence_recorded = false; |
| 82 | music_sequence_playing = false; | 99 | music_sequence_playing = false; |
| @@ -85,7 +102,7 @@ bool process_music(uint16_t keycode, keyrecord_t *record) { | |||
| 85 | } | 102 | } |
| 86 | 103 | ||
| 87 | if (keycode == KC_LALT && record->event.pressed) { // Stop recording/playing | 104 | if (keycode == KC_LALT && record->event.pressed) { // Stop recording/playing |
| 88 | stop_all_notes(); | 105 | music_all_notes_off(); |
| 89 | if (music_sequence_recording) { // was recording | 106 | if (music_sequence_recording) { // was recording |
| 90 | music_sequence_recorded = true; | 107 | music_sequence_recorded = true; |
| 91 | } | 108 | } |
| @@ -95,7 +112,7 @@ bool process_music(uint16_t keycode, keyrecord_t *record) { | |||
| 95 | } | 112 | } |
| 96 | 113 | ||
| 97 | if (keycode == KC_LGUI && record->event.pressed && music_sequence_recorded) { // Start playing | 114 | if (keycode == KC_LGUI && record->event.pressed && music_sequence_recorded) { // Start playing |
| 98 | stop_all_notes(); | 115 | music_all_notes_off(); |
| 99 | music_sequence_recording = false; | 116 | music_sequence_recording = false; |
| 100 | music_sequence_playing = true; | 117 | music_sequence_playing = true; |
| 101 | music_sequence_position = 0; | 118 | music_sequence_position = 0; |
| @@ -115,30 +132,33 @@ bool process_music(uint16_t keycode, keyrecord_t *record) { | |||
| 115 | return false; | 132 | return false; |
| 116 | } | 133 | } |
| 117 | 134 | ||
| 135 | #define MUSIC_MODE_GUITAR | ||
| 136 | |||
| 118 | #ifdef MUSIC_MODE_CHROMATIC | 137 | #ifdef MUSIC_MODE_CHROMATIC |
| 119 | float freq = ((float)220.0)*pow(2.0, -5.0)*pow(2.0,(music_starting_note + record->event.key.col + music_offset)/12.0+(MATRIX_ROWS - record->event.key.row)); | 138 | uint8_t note = (music_starting_note + record->event.key.col + music_offset - 3)+12*(MATRIX_ROWS - record->event.key.row); |
| 120 | #elif defined(MUSIC_MODE_GUITAR) | 139 | #elif defined(MUSIC_MODE_GUITAR) |
| 121 | float freq = ((float)220.0)*pow(2.0, -5.0)*pow(2.0,(music_starting_note + record->event.key.col + music_offset)/12.0+(float)(MATRIX_ROWS - record->event.key.row + 7)*5.0/12); | 140 | uint8_t note = (music_starting_note + record->event.key.col + music_offset + 32)+5*(MATRIX_ROWS - record->event.key.row); |
| 122 | #elif defined(MUSIC_MODE_VIOLIN) | 141 | #elif defined(MUSIC_MODE_VIOLIN) |
| 123 | float freq = ((float)220.0)*pow(2.0, -5.0)*pow(2.0,(music_starting_note + record->event.key.col + music_offset)/12.0+(float)(MATRIX_ROWS - record->event.key.row + 5)*7.0/12); | 142 | uint8_t note = (music_starting_note + record->event.key.col + music_offset + 32)+7*(MATRIX_ROWS - record->event.key.row); |
| 124 | #else | 143 | #else |
| 125 | float freq = ((float)220.0)*pow(2.0, -5.0)*pow(2.0,(music_starting_note + SCALE[record->event.key.col + music_offset])/12.0+(MATRIX_ROWS - record->event.key.row)); | 144 | uint8_t note = (music_starting_note + SCALE[record->event.key.col + music_offset] - 3)+12*(MATRIX_ROWS - record->event.key.row); |
| 126 | #endif | 145 | #endif |
| 127 | 146 | ||
| 128 | if (record->event.pressed) { | 147 | if (record->event.pressed) { |
| 129 | play_note(freq, 0xF); | 148 | music_noteon(note); |
| 130 | if (music_sequence_recording) { | 149 | if (music_sequence_recording) { |
| 131 | music_sequence[music_sequence_count] = freq; | 150 | music_sequence[music_sequence_count] = note; |
| 132 | music_sequence_count++; | 151 | music_sequence_count++; |
| 133 | } | 152 | } |
| 134 | } else { | 153 | } else { |
| 135 | stop_note(freq); | 154 | music_noteoff(note); |
| 136 | } | 155 | } |
| 137 | 156 | ||
| 138 | if (keycode < 0xFF) // ignores all normal keycodes, but lets RAISE, LOWER, etc through | 157 | if (keycode < 0xFF) // ignores all normal keycodes, but lets RAISE, LOWER, etc through |
| 139 | return false; | 158 | return false; |
| 140 | } | 159 | } |
| 141 | return true; | 160 | |
| 161 | return true; | ||
| 142 | } | 162 | } |
| 143 | 163 | ||
| 144 | bool is_music_on(void) { | 164 | bool is_music_on(void) { |
| @@ -160,26 +180,26 @@ void music_on(void) { | |||
| 160 | 180 | ||
| 161 | void music_off(void) { | 181 | void music_off(void) { |
| 162 | music_activated = 0; | 182 | music_activated = 0; |
| 163 | stop_all_notes(); | 183 | music_all_notes_off(); |
| 164 | } | 184 | } |
| 165 | 185 | ||
| 166 | |||
| 167 | __attribute__ ((weak)) | ||
| 168 | void music_on_user() {} | ||
| 169 | |||
| 170 | __attribute__ ((weak)) | ||
| 171 | void audio_on_user() {} | ||
| 172 | |||
| 173 | __attribute__ ((weak)) | ||
| 174 | void music_scale_user() {} | ||
| 175 | |||
| 176 | void matrix_scan_music(void) { | 186 | void matrix_scan_music(void) { |
| 177 | if (music_sequence_playing) { | 187 | if (music_sequence_playing) { |
| 178 | if ((music_sequence_timer == 0) || (timer_elapsed(music_sequence_timer) > music_sequence_interval)) { | 188 | if ((music_sequence_timer == 0) || (timer_elapsed(music_sequence_timer) > music_sequence_interval)) { |
| 179 | music_sequence_timer = timer_read(); | 189 | music_sequence_timer = timer_read(); |
| 180 | stop_note(music_sequence[(music_sequence_position - 1 < 0)?(music_sequence_position - 1 + music_sequence_count):(music_sequence_position - 1)]); | 190 | uint8_t prev_note = music_sequence[(music_sequence_position - 1 < 0)?(music_sequence_position - 1 + music_sequence_count):(music_sequence_position - 1)]; |
| 181 | play_note(music_sequence[music_sequence_position], 0xF); | 191 | uint8_t next_note = music_sequence[music_sequence_position]; |
| 192 | music_noteoff(prev_note); | ||
| 193 | music_noteon(next_note); | ||
| 182 | music_sequence_position = (music_sequence_position + 1) % music_sequence_count; | 194 | music_sequence_position = (music_sequence_position + 1) % music_sequence_count; |
| 183 | } | 195 | } |
| 184 | } | 196 | } |
| 185 | } | 197 | } |
| 198 | |||
| 199 | __attribute__ ((weak)) | ||
| 200 | void music_on_user() {} | ||
| 201 | |||
| 202 | __attribute__ ((weak)) | ||
| 203 | void music_scale_user() {} | ||
| 204 | |||
| 205 | #endif // defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_music.h b/quantum/process_keycode/process_music.h index 318b3e387..8dfbf041f 100644 --- a/quantum/process_keycode/process_music.h +++ b/quantum/process_keycode/process_music.h | |||
| @@ -1,8 +1,26 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #ifndef PROCESS_MUSIC_H | 17 | #ifndef PROCESS_MUSIC_H |
| 2 | #define PROCESS_MUSIC_H | 18 | #define PROCESS_MUSIC_H |
| 3 | 19 | ||
| 4 | #include "quantum.h" | 20 | #include "quantum.h" |
| 5 | 21 | ||
| 22 | #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) | ||
| 23 | |||
| 6 | bool process_music(uint16_t keycode, keyrecord_t *record); | 24 | bool process_music(uint16_t keycode, keyrecord_t *record); |
| 7 | 25 | ||
| 8 | bool is_music_on(void); | 26 | bool is_music_on(void); |
| @@ -10,9 +28,9 @@ void music_toggle(void); | |||
| 10 | void music_on(void); | 28 | void music_on(void); |
| 11 | void music_off(void); | 29 | void music_off(void); |
| 12 | 30 | ||
| 13 | void audio_on_user(void); | ||
| 14 | void music_on_user(void); | 31 | void music_on_user(void); |
| 15 | void music_scale_user(void); | 32 | void music_scale_user(void); |
| 33 | void music_all_notes_off(void); | ||
| 16 | 34 | ||
| 17 | void matrix_scan_music(void); | 35 | void matrix_scan_music(void); |
| 18 | 36 | ||
| @@ -24,4 +42,6 @@ void matrix_scan_music(void); | |||
| 24 | 0 + (12*4), 2 + (12*4), 4 + (12*4), 5 + (12*4), 7 + (12*4), 9 + (12*4), 11 + (12*4), } | 42 | 0 + (12*4), 2 + (12*4), 4 + (12*4), 5 + (12*4), 7 + (12*4), 9 + (12*4), 11 + (12*4), } |
| 25 | #endif | 43 | #endif |
| 26 | 44 | ||
| 27 | #endif \ No newline at end of file | 45 | #endif // defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) |
| 46 | |||
| 47 | #endif | ||
diff --git a/quantum/process_keycode/process_printer.c b/quantum/process_keycode/process_printer.c index 2e11dd366..807f7a0b9 100644 --- a/quantum/process_keycode/process_printer.c +++ b/quantum/process_keycode/process_printer.c | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #include "process_printer.h" | 17 | #include "process_printer.h" |
| 2 | #include "action_util.h" | 18 | #include "action_util.h" |
| 3 | 19 | ||
| @@ -251,4 +267,4 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 251 | } | 267 | } |
| 252 | return true; | 268 | return true; |
| 253 | 269 | ||
| 254 | } \ No newline at end of file | 270 | } |
diff --git a/quantum/process_keycode/process_printer.h b/quantum/process_keycode/process_printer.h index fdd36d75a..aa494ac8a 100644 --- a/quantum/process_keycode/process_printer.h +++ b/quantum/process_keycode/process_printer.h | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #ifndef PROCESS_PRINTER_H | 17 | #ifndef PROCESS_PRINTER_H |
| 2 | #define PROCESS_PRINTER_H | 18 | #define PROCESS_PRINTER_H |
| 3 | 19 | ||
| @@ -5,4 +21,4 @@ | |||
| 5 | 21 | ||
| 6 | #include "protocol/serial.h" | 22 | #include "protocol/serial.h" |
| 7 | 23 | ||
| 8 | #endif \ No newline at end of file | 24 | #endif |
diff --git a/quantum/process_keycode/process_printer_bb.c b/quantum/process_keycode/process_printer_bb.c index 1924d0377..55d3b552b 100644 --- a/quantum/process_keycode/process_printer_bb.c +++ b/quantum/process_keycode/process_printer_bb.c | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #include "process_printer.h" | 17 | #include "process_printer.h" |
| 2 | #include "action_util.h" | 18 | #include "action_util.h" |
| 3 | 19 | ||
| @@ -257,4 +273,4 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 257 | } | 273 | } |
| 258 | return true; | 274 | return true; |
| 259 | 275 | ||
| 260 | } \ No newline at end of file | 276 | } |
diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c index 6ae362c4c..b807ec3c3 100644 --- a/quantum/process_keycode/process_tap_dance.c +++ b/quantum/process_keycode/process_tap_dance.c | |||
| @@ -1,6 +1,23 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #include "quantum.h" | 16 | #include "quantum.h" |
| 2 | #include "action_tapping.h" | 17 | #include "action_tapping.h" |
| 3 | 18 | ||
| 19 | uint8_t get_oneshot_mods(void); | ||
| 20 | |||
| 4 | static uint16_t last_td; | 21 | static uint16_t last_td; |
| 5 | static int8_t highest_td = -1; | 22 | static int8_t highest_td = -1; |
| 6 | 23 | ||
| @@ -43,12 +60,16 @@ static inline void process_tap_dance_action_on_dance_finished (qk_tap_dance_acti | |||
| 43 | if (action->state.finished) | 60 | if (action->state.finished) |
| 44 | return; | 61 | return; |
| 45 | action->state.finished = true; | 62 | action->state.finished = true; |
| 63 | add_mods(action->state.oneshot_mods); | ||
| 64 | send_keyboard_report(); | ||
| 46 | _process_tap_dance_action_fn (&action->state, action->user_data, action->fn.on_dance_finished); | 65 | _process_tap_dance_action_fn (&action->state, action->user_data, action->fn.on_dance_finished); |
| 47 | } | 66 | } |
| 48 | 67 | ||
| 49 | static inline void process_tap_dance_action_on_reset (qk_tap_dance_action_t *action) | 68 | static inline void process_tap_dance_action_on_reset (qk_tap_dance_action_t *action) |
| 50 | { | 69 | { |
| 51 | _process_tap_dance_action_fn (&action->state, action->user_data, action->fn.on_reset); | 70 | _process_tap_dance_action_fn (&action->state, action->user_data, action->fn.on_reset); |
| 71 | del_mods(action->state.oneshot_mods); | ||
| 72 | send_keyboard_report(); | ||
| 52 | } | 73 | } |
| 53 | 74 | ||
| 54 | bool process_tap_dance(uint16_t keycode, keyrecord_t *record) { | 75 | bool process_tap_dance(uint16_t keycode, keyrecord_t *record) { |
| @@ -70,6 +91,7 @@ bool process_tap_dance(uint16_t keycode, keyrecord_t *record) { | |||
| 70 | action->state.keycode = keycode; | 91 | action->state.keycode = keycode; |
| 71 | action->state.count++; | 92 | action->state.count++; |
| 72 | action->state.timer = timer_read(); | 93 | action->state.timer = timer_read(); |
| 94 | action->state.oneshot_mods = get_oneshot_mods(); | ||
| 73 | process_tap_dance_action_on_each_tap (action); | 95 | process_tap_dance_action_on_each_tap (action); |
| 74 | 96 | ||
| 75 | if (last_td && last_td != keycode) { | 97 | if (last_td && last_td != keycode) { |
| @@ -109,7 +131,7 @@ void matrix_scan_tap_dance () { | |||
| 109 | if (highest_td == -1) | 131 | if (highest_td == -1) |
| 110 | return; | 132 | return; |
| 111 | 133 | ||
| 112 | for (int i = 0; i <= highest_td; i++) { | 134 | for (int i = 0; i <= highest_td; i++) { |
| 113 | qk_tap_dance_action_t *action = &tap_dance_actions[i]; | 135 | qk_tap_dance_action_t *action = &tap_dance_actions[i]; |
| 114 | 136 | ||
| 115 | if (action->state.count && timer_elapsed (action->state.timer) > TAPPING_TERM) { | 137 | if (action->state.count && timer_elapsed (action->state.timer) > TAPPING_TERM) { |
diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h index f753cbba6..330809f83 100644 --- a/quantum/process_keycode/process_tap_dance.h +++ b/quantum/process_keycode/process_tap_dance.h | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #ifndef PROCESS_TAP_DANCE_H | 16 | #ifndef PROCESS_TAP_DANCE_H |
| 2 | #define PROCESS_TAP_DANCE_H | 17 | #define PROCESS_TAP_DANCE_H |
| 3 | 18 | ||
| @@ -9,6 +24,7 @@ | |||
| 9 | typedef struct | 24 | typedef struct |
| 10 | { | 25 | { |
| 11 | uint8_t count; | 26 | uint8_t count; |
| 27 | uint8_t oneshot_mods; | ||
| 12 | uint16_t keycode; | 28 | uint16_t keycode; |
| 13 | uint16_t timer; | 29 | uint16_t timer; |
| 14 | bool interrupted; | 30 | bool interrupted; |
diff --git a/quantum/process_keycode/process_ucis.c b/quantum/process_keycode/process_ucis.c new file mode 100644 index 000000000..86c0937f5 --- /dev/null +++ b/quantum/process_keycode/process_ucis.c | |||
| @@ -0,0 +1,149 @@ | |||
| 1 | /* Copyright 2017 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "process_ucis.h" | ||
| 18 | |||
| 19 | qk_ucis_state_t qk_ucis_state; | ||
| 20 | |||
| 21 | void qk_ucis_start(void) { | ||
| 22 | qk_ucis_state.count = 0; | ||
| 23 | qk_ucis_state.in_progress = true; | ||
| 24 | |||
| 25 | qk_ucis_start_user(); | ||
| 26 | } | ||
| 27 | |||
| 28 | __attribute__((weak)) | ||
| 29 | void qk_ucis_start_user(void) { | ||
| 30 | unicode_input_start(); | ||
| 31 | register_hex(0x2328); | ||
| 32 | unicode_input_finish(); | ||
| 33 | } | ||
| 34 | |||
| 35 | static bool is_uni_seq(char *seq) { | ||
| 36 | uint8_t i; | ||
| 37 | |||
| 38 | for (i = 0; seq[i]; i++) { | ||
| 39 | uint16_t code; | ||
| 40 | if (('1' <= seq[i]) && (seq[i] <= '0')) | ||
| 41 | code = seq[i] - '1' + KC_1; | ||
| 42 | else | ||
| 43 | code = seq[i] - 'a' + KC_A; | ||
| 44 | |||
| 45 | if (i > qk_ucis_state.count || qk_ucis_state.codes[i] != code) | ||
| 46 | return false; | ||
| 47 | } | ||
| 48 | |||
| 49 | return (qk_ucis_state.codes[i] == KC_ENT || | ||
| 50 | qk_ucis_state.codes[i] == KC_SPC); | ||
| 51 | } | ||
| 52 | |||
| 53 | __attribute__((weak)) | ||
| 54 | void qk_ucis_symbol_fallback (void) { | ||
| 55 | for (uint8_t i = 0; i < qk_ucis_state.count - 1; i++) { | ||
| 56 | uint8_t code = qk_ucis_state.codes[i]; | ||
| 57 | register_code(code); | ||
| 58 | unregister_code(code); | ||
| 59 | wait_ms(UNICODE_TYPE_DELAY); | ||
| 60 | } | ||
| 61 | } | ||
| 62 | |||
| 63 | void register_ucis(const char *hex) { | ||
| 64 | for(int i = 0; hex[i]; i++) { | ||
| 65 | uint8_t kc = 0; | ||
| 66 | char c = hex[i]; | ||
| 67 | |||
| 68 | switch (c) { | ||
| 69 | case '0': | ||
| 70 | kc = KC_0; | ||
| 71 | break; | ||
| 72 | case '1' ... '9': | ||
| 73 | kc = c - '1' + KC_1; | ||
| 74 | break; | ||
| 75 | case 'a' ... 'f': | ||
| 76 | kc = c - 'a' + KC_A; | ||
| 77 | break; | ||
| 78 | case 'A' ... 'F': | ||
| 79 | kc = c - 'A' + KC_A; | ||
| 80 | break; | ||
| 81 | } | ||
| 82 | |||
| 83 | if (kc) { | ||
| 84 | register_code (kc); | ||
| 85 | unregister_code (kc); | ||
| 86 | wait_ms (UNICODE_TYPE_DELAY); | ||
| 87 | } | ||
| 88 | } | ||
| 89 | } | ||
| 90 | |||
| 91 | bool process_ucis (uint16_t keycode, keyrecord_t *record) { | ||
| 92 | uint8_t i; | ||
| 93 | |||
| 94 | if (!qk_ucis_state.in_progress) | ||
| 95 | return true; | ||
| 96 | |||
| 97 | if (qk_ucis_state.count >= UCIS_MAX_SYMBOL_LENGTH && | ||
| 98 | !(keycode == KC_BSPC || keycode == KC_ESC || keycode == KC_SPC || keycode == KC_ENT)) { | ||
| 99 | return false; | ||
| 100 | } | ||
| 101 | |||
| 102 | if (!record->event.pressed) | ||
| 103 | return true; | ||
| 104 | |||
| 105 | qk_ucis_state.codes[qk_ucis_state.count] = keycode; | ||
| 106 | qk_ucis_state.count++; | ||
| 107 | |||
| 108 | if (keycode == KC_BSPC) { | ||
| 109 | if (qk_ucis_state.count >= 2) { | ||
| 110 | qk_ucis_state.count -= 2; | ||
| 111 | return true; | ||
| 112 | } else { | ||
| 113 | qk_ucis_state.count--; | ||
| 114 | return false; | ||
| 115 | } | ||
| 116 | } | ||
| 117 | |||
| 118 | if (keycode == KC_ENT || keycode == KC_SPC || keycode == KC_ESC) { | ||
| 119 | bool symbol_found = false; | ||
| 120 | |||
| 121 | for (i = qk_ucis_state.count; i > 0; i--) { | ||
| 122 | register_code (KC_BSPC); | ||
| 123 | unregister_code (KC_BSPC); | ||
| 124 | wait_ms(UNICODE_TYPE_DELAY); | ||
| 125 | } | ||
| 126 | |||
| 127 | if (keycode == KC_ESC) { | ||
| 128 | qk_ucis_state.in_progress = false; | ||
| 129 | return false; | ||
| 130 | } | ||
| 131 | |||
| 132 | unicode_input_start(); | ||
| 133 | for (i = 0; ucis_symbol_table[i].symbol; i++) { | ||
| 134 | if (is_uni_seq (ucis_symbol_table[i].symbol)) { | ||
| 135 | symbol_found = true; | ||
| 136 | register_ucis(ucis_symbol_table[i].code + 2); | ||
| 137 | break; | ||
| 138 | } | ||
| 139 | } | ||
| 140 | if (!symbol_found) { | ||
| 141 | qk_ucis_symbol_fallback(); | ||
| 142 | } | ||
| 143 | unicode_input_finish(); | ||
| 144 | |||
| 145 | qk_ucis_state.in_progress = false; | ||
| 146 | return false; | ||
| 147 | } | ||
| 148 | return true; | ||
| 149 | } | ||
diff --git a/quantum/process_keycode/process_ucis.h b/quantum/process_keycode/process_ucis.h new file mode 100644 index 000000000..3f736a709 --- /dev/null +++ b/quantum/process_keycode/process_ucis.h | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | /* Copyright 2017 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #ifndef PROCESS_UCIS_H | ||
| 18 | #define PROCESS_UCIS_H | ||
| 19 | |||
| 20 | #include "quantum.h" | ||
| 21 | #include "process_unicode_common.h" | ||
| 22 | |||
| 23 | #ifndef UCIS_MAX_SYMBOL_LENGTH | ||
| 24 | #define UCIS_MAX_SYMBOL_LENGTH 32 | ||
| 25 | #endif | ||
| 26 | |||
| 27 | typedef struct { | ||
| 28 | char *symbol; | ||
| 29 | char *code; | ||
| 30 | } qk_ucis_symbol_t; | ||
| 31 | |||
| 32 | typedef struct { | ||
| 33 | uint8_t count; | ||
| 34 | uint16_t codes[UCIS_MAX_SYMBOL_LENGTH]; | ||
| 35 | bool in_progress:1; | ||
| 36 | } qk_ucis_state_t; | ||
| 37 | |||
| 38 | extern qk_ucis_state_t qk_ucis_state; | ||
| 39 | |||
| 40 | #define UCIS_TABLE(...) {__VA_ARGS__, {NULL, NULL}} | ||
| 41 | #define UCIS_SYM(name, code) {name, #code} | ||
| 42 | |||
| 43 | extern const qk_ucis_symbol_t ucis_symbol_table[]; | ||
| 44 | |||
| 45 | void qk_ucis_start(void); | ||
| 46 | void qk_ucis_start_user(void); | ||
| 47 | void qk_ucis_symbol_fallback (void); | ||
| 48 | void register_ucis(const char *hex); | ||
| 49 | bool process_ucis (uint16_t keycode, keyrecord_t *record); | ||
| 50 | |||
| 51 | #endif | ||
diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c index a30e93ae3..678a15234 100644 --- a/quantum/process_keycode/process_unicode.c +++ b/quantum/process_keycode/process_unicode.c | |||
| @@ -1,105 +1,29 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #include "process_unicode.h" | 16 | #include "process_unicode.h" |
| 2 | #include "action_util.h" | 17 | #include "action_util.h" |
| 3 | 18 | ||
| 4 | static uint8_t input_mode; | 19 | static uint8_t first_flag = 0; |
| 5 | uint8_t mods; | ||
| 6 | |||
| 7 | __attribute__((weak)) | ||
| 8 | uint16_t hex_to_keycode(uint8_t hex) | ||
| 9 | { | ||
| 10 | if (hex == 0x0) { | ||
| 11 | return KC_0; | ||
| 12 | } else if (hex < 0xA) { | ||
| 13 | return KC_1 + (hex - 0x1); | ||
| 14 | } else { | ||
| 15 | return KC_A + (hex - 0xA); | ||
| 16 | } | ||
| 17 | } | ||
| 18 | |||
| 19 | void set_unicode_input_mode(uint8_t os_target) | ||
| 20 | { | ||
| 21 | input_mode = os_target; | ||
| 22 | } | ||
| 23 | |||
| 24 | uint8_t get_unicode_input_mode(void) { | ||
| 25 | return input_mode; | ||
| 26 | } | ||
| 27 | |||
| 28 | __attribute__((weak)) | ||
| 29 | void unicode_input_start (void) { | ||
| 30 | // save current mods | ||
| 31 | mods = keyboard_report->mods; | ||
| 32 | |||
| 33 | // unregister all mods to start from clean state | ||
| 34 | if (mods & MOD_BIT(KC_LSFT)) unregister_code(KC_LSFT); | ||
| 35 | if (mods & MOD_BIT(KC_RSFT)) unregister_code(KC_RSFT); | ||
| 36 | if (mods & MOD_BIT(KC_LCTL)) unregister_code(KC_LCTL); | ||
| 37 | if (mods & MOD_BIT(KC_RCTL)) unregister_code(KC_RCTL); | ||
| 38 | if (mods & MOD_BIT(KC_LALT)) unregister_code(KC_LALT); | ||
| 39 | if (mods & MOD_BIT(KC_RALT)) unregister_code(KC_RALT); | ||
| 40 | if (mods & MOD_BIT(KC_LGUI)) unregister_code(KC_LGUI); | ||
| 41 | if (mods & MOD_BIT(KC_RGUI)) unregister_code(KC_RGUI); | ||
| 42 | |||
| 43 | switch(input_mode) { | ||
| 44 | case UC_OSX: | ||
| 45 | register_code(KC_LALT); | ||
| 46 | break; | ||
| 47 | case UC_LNX: | ||
| 48 | register_code(KC_LCTL); | ||
| 49 | register_code(KC_LSFT); | ||
| 50 | register_code(KC_U); | ||
| 51 | unregister_code(KC_U); | ||
| 52 | unregister_code(KC_LSFT); | ||
| 53 | unregister_code(KC_LCTL); | ||
| 54 | break; | ||
| 55 | case UC_WIN: | ||
| 56 | register_code(KC_LALT); | ||
| 57 | register_code(KC_PPLS); | ||
| 58 | unregister_code(KC_PPLS); | ||
| 59 | break; | ||
| 60 | case UC_WINC: | ||
| 61 | register_code(KC_RALT); | ||
| 62 | unregister_code(KC_RALT); | ||
| 63 | register_code(KC_U); | ||
| 64 | unregister_code(KC_U); | ||
| 65 | } | ||
| 66 | wait_ms(UNICODE_TYPE_DELAY); | ||
| 67 | } | ||
| 68 | |||
| 69 | __attribute__((weak)) | ||
| 70 | void unicode_input_finish (void) { | ||
| 71 | switch(input_mode) { | ||
| 72 | case UC_OSX: | ||
| 73 | case UC_WIN: | ||
| 74 | unregister_code(KC_LALT); | ||
| 75 | break; | ||
| 76 | case UC_LNX: | ||
| 77 | register_code(KC_SPC); | ||
| 78 | unregister_code(KC_SPC); | ||
| 79 | break; | ||
| 80 | } | ||
| 81 | |||
| 82 | // reregister previously set mods | ||
| 83 | if (mods & MOD_BIT(KC_LSFT)) register_code(KC_LSFT); | ||
| 84 | if (mods & MOD_BIT(KC_RSFT)) register_code(KC_RSFT); | ||
| 85 | if (mods & MOD_BIT(KC_LCTL)) register_code(KC_LCTL); | ||
| 86 | if (mods & MOD_BIT(KC_RCTL)) register_code(KC_RCTL); | ||
| 87 | if (mods & MOD_BIT(KC_LALT)) register_code(KC_LALT); | ||
| 88 | if (mods & MOD_BIT(KC_RALT)) register_code(KC_RALT); | ||
| 89 | if (mods & MOD_BIT(KC_LGUI)) register_code(KC_LGUI); | ||
| 90 | if (mods & MOD_BIT(KC_RGUI)) register_code(KC_RGUI); | ||
| 91 | } | ||
| 92 | |||
| 93 | void register_hex(uint16_t hex) { | ||
| 94 | for(int i = 3; i >= 0; i--) { | ||
| 95 | uint8_t digit = ((hex >> (i*4)) & 0xF); | ||
| 96 | register_code(hex_to_keycode(digit)); | ||
| 97 | unregister_code(hex_to_keycode(digit)); | ||
| 98 | } | ||
| 99 | } | ||
| 100 | 20 | ||
| 101 | bool process_unicode(uint16_t keycode, keyrecord_t *record) { | 21 | bool process_unicode(uint16_t keycode, keyrecord_t *record) { |
| 102 | if (keycode > QK_UNICODE && record->event.pressed) { | 22 | if (keycode > QK_UNICODE && record->event.pressed) { |
| 23 | if (first_flag == 0) { | ||
| 24 | set_unicode_input_mode(eeprom_read_byte(EECONFIG_UNICODEMODE)); | ||
| 25 | first_flag = 1; | ||
| 26 | } | ||
| 103 | uint16_t unicode = keycode & 0x7FFF; | 27 | uint16_t unicode = keycode & 0x7FFF; |
| 104 | unicode_input_start(); | 28 | unicode_input_start(); |
| 105 | register_hex(unicode); | 29 | register_hex(unicode); |
| @@ -108,182 +32,3 @@ bool process_unicode(uint16_t keycode, keyrecord_t *record) { | |||
| 108 | return true; | 32 | return true; |
| 109 | } | 33 | } |
| 110 | 34 | ||
| 111 | #ifdef UNICODEMAP_ENABLE | ||
| 112 | __attribute__((weak)) | ||
| 113 | const uint32_t PROGMEM unicode_map[] = { | ||
| 114 | }; | ||
| 115 | |||
| 116 | void register_hex32(uint32_t hex) { | ||
| 117 | uint8_t onzerostart = 1; | ||
| 118 | for(int i = 7; i >= 0; i--) { | ||
| 119 | if (i <= 3) { | ||
| 120 | onzerostart = 0; | ||
| 121 | } | ||
| 122 | uint8_t digit = ((hex >> (i*4)) & 0xF); | ||
| 123 | if (digit == 0) { | ||
| 124 | if (onzerostart == 0) { | ||
| 125 | register_code(hex_to_keycode(digit)); | ||
| 126 | unregister_code(hex_to_keycode(digit)); | ||
| 127 | } | ||
| 128 | } else { | ||
| 129 | register_code(hex_to_keycode(digit)); | ||
| 130 | unregister_code(hex_to_keycode(digit)); | ||
| 131 | onzerostart = 0; | ||
| 132 | } | ||
| 133 | } | ||
| 134 | } | ||
| 135 | |||
| 136 | __attribute__((weak)) | ||
| 137 | void unicode_map_input_error() {} | ||
| 138 | |||
| 139 | bool process_unicode_map(uint16_t keycode, keyrecord_t *record) { | ||
| 140 | if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) { | ||
| 141 | const uint32_t* map = unicode_map; | ||
| 142 | uint16_t index = keycode & 0x7FF; | ||
| 143 | uint32_t code = pgm_read_dword_far(&map[index]); | ||
| 144 | if ((code > 0xFFFF && input_mode == UC_OSX) || (code > 0xFFFFF && input_mode == UC_LNX)) { | ||
| 145 | // when character is out of range supported by the OS | ||
| 146 | unicode_map_input_error(); | ||
| 147 | } else { | ||
| 148 | unicode_input_start(); | ||
| 149 | register_hex32(code); | ||
| 150 | unicode_input_finish(); | ||
| 151 | } | ||
| 152 | } | ||
| 153 | return true; | ||
| 154 | } | ||
| 155 | #endif | ||
| 156 | |||
| 157 | #ifdef UCIS_ENABLE | ||
| 158 | qk_ucis_state_t qk_ucis_state; | ||
| 159 | |||
| 160 | void qk_ucis_start(void) { | ||
| 161 | qk_ucis_state.count = 0; | ||
| 162 | qk_ucis_state.in_progress = true; | ||
| 163 | |||
| 164 | qk_ucis_start_user(); | ||
| 165 | } | ||
| 166 | |||
| 167 | __attribute__((weak)) | ||
| 168 | void qk_ucis_start_user(void) { | ||
| 169 | unicode_input_start(); | ||
| 170 | register_hex(0x2328); | ||
| 171 | unicode_input_finish(); | ||
| 172 | } | ||
| 173 | |||
| 174 | static bool is_uni_seq(char *seq) { | ||
| 175 | uint8_t i; | ||
| 176 | |||
| 177 | for (i = 0; seq[i]; i++) { | ||
| 178 | uint16_t code; | ||
| 179 | if (('1' <= seq[i]) && (seq[i] <= '0')) | ||
| 180 | code = seq[i] - '1' + KC_1; | ||
| 181 | else | ||
| 182 | code = seq[i] - 'a' + KC_A; | ||
| 183 | |||
| 184 | if (i > qk_ucis_state.count || qk_ucis_state.codes[i] != code) | ||
| 185 | return false; | ||
| 186 | } | ||
| 187 | |||
| 188 | return (qk_ucis_state.codes[i] == KC_ENT || | ||
| 189 | qk_ucis_state.codes[i] == KC_SPC); | ||
| 190 | } | ||
| 191 | |||
| 192 | __attribute__((weak)) | ||
| 193 | void qk_ucis_symbol_fallback (void) { | ||
| 194 | for (uint8_t i = 0; i < qk_ucis_state.count - 1; i++) { | ||
| 195 | uint8_t code = qk_ucis_state.codes[i]; | ||
| 196 | register_code(code); | ||
| 197 | unregister_code(code); | ||
| 198 | wait_ms(UNICODE_TYPE_DELAY); | ||
| 199 | } | ||
| 200 | } | ||
| 201 | |||
| 202 | void register_ucis(const char *hex) { | ||
| 203 | for(int i = 0; hex[i]; i++) { | ||
| 204 | uint8_t kc = 0; | ||
| 205 | char c = hex[i]; | ||
| 206 | |||
| 207 | switch (c) { | ||
| 208 | case '0': | ||
| 209 | kc = KC_0; | ||
| 210 | break; | ||
| 211 | case '1' ... '9': | ||
| 212 | kc = c - '1' + KC_1; | ||
| 213 | break; | ||
| 214 | case 'a' ... 'f': | ||
| 215 | kc = c - 'a' + KC_A; | ||
| 216 | break; | ||
| 217 | case 'A' ... 'F': | ||
| 218 | kc = c - 'A' + KC_A; | ||
| 219 | break; | ||
| 220 | } | ||
| 221 | |||
| 222 | if (kc) { | ||
| 223 | register_code (kc); | ||
| 224 | unregister_code (kc); | ||
| 225 | wait_ms (UNICODE_TYPE_DELAY); | ||
| 226 | } | ||
| 227 | } | ||
| 228 | } | ||
| 229 | |||
| 230 | bool process_ucis (uint16_t keycode, keyrecord_t *record) { | ||
| 231 | uint8_t i; | ||
| 232 | |||
| 233 | if (!qk_ucis_state.in_progress) | ||
| 234 | return true; | ||
| 235 | |||
| 236 | if (qk_ucis_state.count >= UCIS_MAX_SYMBOL_LENGTH && | ||
| 237 | !(keycode == KC_BSPC || keycode == KC_ESC || keycode == KC_SPC || keycode == KC_ENT)) { | ||
| 238 | return false; | ||
| 239 | } | ||
| 240 | |||
| 241 | if (!record->event.pressed) | ||
| 242 | return true; | ||
| 243 | |||
| 244 | qk_ucis_state.codes[qk_ucis_state.count] = keycode; | ||
| 245 | qk_ucis_state.count++; | ||
| 246 | |||
| 247 | if (keycode == KC_BSPC) { | ||
| 248 | if (qk_ucis_state.count >= 2) { | ||
| 249 | qk_ucis_state.count -= 2; | ||
| 250 | return true; | ||
| 251 | } else { | ||
| 252 | qk_ucis_state.count--; | ||
| 253 | return false; | ||
| 254 | } | ||
| 255 | } | ||
| 256 | |||
| 257 | if (keycode == KC_ENT || keycode == KC_SPC || keycode == KC_ESC) { | ||
| 258 | bool symbol_found = false; | ||
| 259 | |||
| 260 | for (i = qk_ucis_state.count; i > 0; i--) { | ||
| 261 | register_code (KC_BSPC); | ||
| 262 | unregister_code (KC_BSPC); | ||
| 263 | wait_ms(UNICODE_TYPE_DELAY); | ||
| 264 | } | ||
| 265 | |||
| 266 | if (keycode == KC_ESC) { | ||
| 267 | qk_ucis_state.in_progress = false; | ||
| 268 | return false; | ||
| 269 | } | ||
| 270 | |||
| 271 | unicode_input_start(); | ||
| 272 | for (i = 0; ucis_symbol_table[i].symbol; i++) { | ||
| 273 | if (is_uni_seq (ucis_symbol_table[i].symbol)) { | ||
| 274 | symbol_found = true; | ||
| 275 | register_ucis(ucis_symbol_table[i].code + 2); | ||
| 276 | break; | ||
| 277 | } | ||
| 278 | } | ||
| 279 | if (!symbol_found) { | ||
| 280 | qk_ucis_symbol_fallback(); | ||
| 281 | } | ||
| 282 | unicode_input_finish(); | ||
| 283 | |||
| 284 | qk_ucis_state.in_progress = false; | ||
| 285 | return false; | ||
| 286 | } | ||
| 287 | return true; | ||
| 288 | } | ||
| 289 | #endif | ||
diff --git a/quantum/process_keycode/process_unicode.h b/quantum/process_keycode/process_unicode.h index f17cfa6cf..c525b74f0 100644 --- a/quantum/process_keycode/process_unicode.h +++ b/quantum/process_keycode/process_unicode.h | |||
| @@ -1,167 +1,24 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #ifndef PROCESS_UNICODE_H | 16 | #ifndef PROCESS_UNICODE_H |
| 2 | #define PROCESS_UNICODE_H | 17 | #define PROCESS_UNICODE_H |
| 3 | 18 | ||
| 4 | #include "quantum.h" | 19 | #include "quantum.h" |
| 5 | 20 | #include "process_unicode_common.h" | |
| 6 | #define UC_OSX 0 // Mac OS X | ||
| 7 | #define UC_LNX 1 // Linux | ||
| 8 | #define UC_WIN 2 // Windows 'HexNumpad' | ||
| 9 | #define UC_BSD 3 // BSD (not implemented) | ||
| 10 | #define UC_WINC 4 // WinCompose https://github.com/samhocevar/wincompose | ||
| 11 | |||
| 12 | #ifndef UNICODE_TYPE_DELAY | ||
| 13 | #define UNICODE_TYPE_DELAY 10 | ||
| 14 | #endif | ||
| 15 | |||
| 16 | void set_unicode_input_mode(uint8_t os_target); | ||
| 17 | uint8_t get_unicode_input_mode(void); | ||
| 18 | void unicode_input_start(void); | ||
| 19 | void unicode_input_finish(void); | ||
| 20 | void register_hex(uint16_t hex); | ||
| 21 | 21 | ||
| 22 | bool process_unicode(uint16_t keycode, keyrecord_t *record); | 22 | bool process_unicode(uint16_t keycode, keyrecord_t *record); |
| 23 | 23 | ||
| 24 | #ifdef UNICODEMAP_ENABLE | ||
| 25 | void unicode_map_input_error(void); | ||
| 26 | bool process_unicode_map(uint16_t keycode, keyrecord_t *record); | ||
| 27 | #endif | ||
| 28 | |||
| 29 | #ifdef UCIS_ENABLE | ||
| 30 | #ifndef UCIS_MAX_SYMBOL_LENGTH | ||
| 31 | #define UCIS_MAX_SYMBOL_LENGTH 32 | ||
| 32 | #endif | ||
| 33 | |||
| 34 | typedef struct { | ||
| 35 | char *symbol; | ||
| 36 | char *code; | ||
| 37 | } qk_ucis_symbol_t; | ||
| 38 | |||
| 39 | typedef struct { | ||
| 40 | uint8_t count; | ||
| 41 | uint16_t codes[UCIS_MAX_SYMBOL_LENGTH]; | ||
| 42 | bool in_progress:1; | ||
| 43 | } qk_ucis_state_t; | ||
| 44 | |||
| 45 | extern qk_ucis_state_t qk_ucis_state; | ||
| 46 | |||
| 47 | #define UCIS_TABLE(...) {__VA_ARGS__, {NULL, NULL}} | ||
| 48 | #define UCIS_SYM(name, code) {name, #code} | ||
| 49 | |||
| 50 | extern const qk_ucis_symbol_t ucis_symbol_table[]; | ||
| 51 | |||
| 52 | void qk_ucis_start(void); | ||
| 53 | void qk_ucis_start_user(void); | ||
| 54 | void qk_ucis_symbol_fallback (void); | ||
| 55 | void register_ucis(const char *hex); | ||
| 56 | bool process_ucis (uint16_t keycode, keyrecord_t *record); | ||
| 57 | |||
| 58 | #endif | ||
| 59 | |||
| 60 | #define UC_BSPC UC(0x0008) | ||
| 61 | |||
| 62 | #define UC_SPC UC(0x0020) | ||
| 63 | |||
| 64 | #define UC_EXLM UC(0x0021) | ||
| 65 | #define UC_DQUT UC(0x0022) | ||
| 66 | #define UC_HASH UC(0x0023) | ||
| 67 | #define UC_DLR UC(0x0024) | ||
| 68 | #define UC_PERC UC(0x0025) | ||
| 69 | #define UC_AMPR UC(0x0026) | ||
| 70 | #define UC_QUOT UC(0x0027) | ||
| 71 | #define UC_LPRN UC(0x0028) | ||
| 72 | #define UC_RPRN UC(0x0029) | ||
| 73 | #define UC_ASTR UC(0x002A) | ||
| 74 | #define UC_PLUS UC(0x002B) | ||
| 75 | #define UC_COMM UC(0x002C) | ||
| 76 | #define UC_DASH UC(0x002D) | ||
| 77 | #define UC_DOT UC(0x002E) | ||
| 78 | #define UC_SLSH UC(0x002F) | ||
| 79 | |||
| 80 | #define UC_0 UC(0x0030) | ||
| 81 | #define UC_1 UC(0x0031) | ||
| 82 | #define UC_2 UC(0x0032) | ||
| 83 | #define UC_3 UC(0x0033) | ||
| 84 | #define UC_4 UC(0x0034) | ||
| 85 | #define UC_5 UC(0x0035) | ||
| 86 | #define UC_6 UC(0x0036) | ||
| 87 | #define UC_7 UC(0x0037) | ||
| 88 | #define UC_8 UC(0x0038) | ||
| 89 | #define UC_9 UC(0x0039) | ||
| 90 | |||
| 91 | #define UC_COLN UC(0x003A) | ||
| 92 | #define UC_SCLN UC(0x003B) | ||
| 93 | #define UC_LT UC(0x003C) | ||
| 94 | #define UC_EQL UC(0x003D) | ||
| 95 | #define UC_GT UC(0x003E) | ||
| 96 | #define UC_QUES UC(0x003F) | ||
| 97 | #define UC_AT UC(0x0040) | ||
| 98 | |||
| 99 | #define UC_A UC(0x0041) | ||
| 100 | #define UC_B UC(0x0042) | ||
| 101 | #define UC_C UC(0x0043) | ||
| 102 | #define UC_D UC(0x0044) | ||
| 103 | #define UC_E UC(0x0045) | ||
| 104 | #define UC_F UC(0x0046) | ||
| 105 | #define UC_G UC(0x0047) | ||
| 106 | #define UC_H UC(0x0048) | ||
| 107 | #define UC_I UC(0x0049) | ||
| 108 | #define UC_J UC(0x004A) | ||
| 109 | #define UC_K UC(0x004B) | ||
| 110 | #define UC_L UC(0x004C) | ||
| 111 | #define UC_M UC(0x004D) | ||
| 112 | #define UC_N UC(0x004E) | ||
| 113 | #define UC_O UC(0x004F) | ||
| 114 | #define UC_P UC(0x0050) | ||
| 115 | #define UC_Q UC(0x0051) | ||
| 116 | #define UC_R UC(0x0052) | ||
| 117 | #define UC_S UC(0x0053) | ||
| 118 | #define UC_T UC(0x0054) | ||
| 119 | #define UC_U UC(0x0055) | ||
| 120 | #define UC_V UC(0x0056) | ||
| 121 | #define UC_W UC(0x0057) | ||
| 122 | #define UC_X UC(0x0058) | ||
| 123 | #define UC_Y UC(0x0059) | ||
| 124 | #define UC_Z UC(0x005A) | ||
| 125 | |||
| 126 | #define UC_LBRC UC(0x005B) | ||
| 127 | #define UC_BSLS UC(0x005C) | ||
| 128 | #define UC_RBRC UC(0x005D) | ||
| 129 | #define UC_CIRM UC(0x005E) | ||
| 130 | #define UC_UNDR UC(0x005F) | ||
| 131 | |||
| 132 | #define UC_GRV UC(0x0060) | ||
| 133 | |||
| 134 | #define UC_a UC(0x0061) | ||
| 135 | #define UC_b UC(0x0062) | ||
| 136 | #define UC_c UC(0x0063) | ||
| 137 | #define UC_d UC(0x0064) | ||
| 138 | #define UC_e UC(0x0065) | ||
| 139 | #define UC_f UC(0x0066) | ||
| 140 | #define UC_g UC(0x0067) | ||
| 141 | #define UC_h UC(0x0068) | ||
| 142 | #define UC_i UC(0x0069) | ||
| 143 | #define UC_j UC(0x006A) | ||
| 144 | #define UC_k UC(0x006B) | ||
| 145 | #define UC_l UC(0x006C) | ||
| 146 | #define UC_m UC(0x006D) | ||
| 147 | #define UC_n UC(0x006E) | ||
| 148 | #define UC_o UC(0x006F) | ||
| 149 | #define UC_p UC(0x0070) | ||
| 150 | #define UC_q UC(0x0071) | ||
| 151 | #define UC_r UC(0x0072) | ||
| 152 | #define UC_s UC(0x0073) | ||
| 153 | #define UC_t UC(0x0074) | ||
| 154 | #define UC_u UC(0x0075) | ||
| 155 | #define UC_v UC(0x0076) | ||
| 156 | #define UC_w UC(0x0077) | ||
| 157 | #define UC_x UC(0x0078) | ||
| 158 | #define UC_y UC(0x0079) | ||
| 159 | #define UC_z UC(0x007A) | ||
| 160 | |||
| 161 | #define UC_LCBR UC(0x007B) | ||
| 162 | #define UC_PIPE UC(0x007C) | ||
| 163 | #define UC_RCBR UC(0x007D) | ||
| 164 | #define UC_TILD UC(0x007E) | ||
| 165 | #define UC_DEL UC(0x007F) | ||
| 166 | |||
| 167 | #endif | 24 | #endif |
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c new file mode 100644 index 000000000..1dbdec3e7 --- /dev/null +++ b/quantum/process_keycode/process_unicode_common.c | |||
| @@ -0,0 +1,115 @@ | |||
| 1 | /* Copyright 2017 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "process_unicode_common.h" | ||
| 18 | |||
| 19 | static uint8_t input_mode; | ||
| 20 | uint8_t mods; | ||
| 21 | |||
| 22 | void set_unicode_input_mode(uint8_t os_target) | ||
| 23 | { | ||
| 24 | input_mode = os_target; | ||
| 25 | eeprom_update_byte(EECONFIG_UNICODEMODE, os_target); | ||
| 26 | } | ||
| 27 | |||
| 28 | uint8_t get_unicode_input_mode(void) { | ||
| 29 | return input_mode; | ||
| 30 | } | ||
| 31 | |||
| 32 | __attribute__((weak)) | ||
| 33 | void unicode_input_start (void) { | ||
| 34 | // save current mods | ||
| 35 | mods = keyboard_report->mods; | ||
| 36 | |||
| 37 | // unregister all mods to start from clean state | ||
| 38 | if (mods & MOD_BIT(KC_LSFT)) unregister_code(KC_LSFT); | ||
| 39 | if (mods & MOD_BIT(KC_RSFT)) unregister_code(KC_RSFT); | ||
| 40 | if (mods & MOD_BIT(KC_LCTL)) unregister_code(KC_LCTL); | ||
| 41 | if (mods & MOD_BIT(KC_RCTL)) unregister_code(KC_RCTL); | ||
| 42 | if (mods & MOD_BIT(KC_LALT)) unregister_code(KC_LALT); | ||
| 43 | if (mods & MOD_BIT(KC_RALT)) unregister_code(KC_RALT); | ||
| 44 | if (mods & MOD_BIT(KC_LGUI)) unregister_code(KC_LGUI); | ||
| 45 | if (mods & MOD_BIT(KC_RGUI)) unregister_code(KC_RGUI); | ||
| 46 | |||
| 47 | switch(input_mode) { | ||
| 48 | case UC_OSX: | ||
| 49 | register_code(KC_LALT); | ||
| 50 | break; | ||
| 51 | case UC_LNX: | ||
| 52 | register_code(KC_LCTL); | ||
| 53 | register_code(KC_LSFT); | ||
| 54 | register_code(KC_U); | ||
| 55 | unregister_code(KC_U); | ||
| 56 | unregister_code(KC_LSFT); | ||
| 57 | unregister_code(KC_LCTL); | ||
| 58 | break; | ||
| 59 | case UC_WIN: | ||
| 60 | register_code(KC_LALT); | ||
| 61 | register_code(KC_PPLS); | ||
| 62 | unregister_code(KC_PPLS); | ||
| 63 | break; | ||
| 64 | case UC_WINC: | ||
| 65 | register_code(KC_RALT); | ||
| 66 | unregister_code(KC_RALT); | ||
| 67 | register_code(KC_U); | ||
| 68 | unregister_code(KC_U); | ||
| 69 | } | ||
| 70 | wait_ms(UNICODE_TYPE_DELAY); | ||
| 71 | } | ||
| 72 | |||
| 73 | __attribute__((weak)) | ||
| 74 | void unicode_input_finish (void) { | ||
| 75 | switch(input_mode) { | ||
| 76 | case UC_OSX: | ||
| 77 | case UC_WIN: | ||
| 78 | unregister_code(KC_LALT); | ||
| 79 | break; | ||
| 80 | case UC_LNX: | ||
| 81 | register_code(KC_SPC); | ||
| 82 | unregister_code(KC_SPC); | ||
| 83 | break; | ||
| 84 | } | ||
| 85 | |||
| 86 | // reregister previously set mods | ||
| 87 | if (mods & MOD_BIT(KC_LSFT)) register_code(KC_LSFT); | ||
| 88 | if (mods & MOD_BIT(KC_RSFT)) register_code(KC_RSFT); | ||
| 89 | if (mods & MOD_BIT(KC_LCTL)) register_code(KC_LCTL); | ||
| 90 | if (mods & MOD_BIT(KC_RCTL)) register_code(KC_RCTL); | ||
| 91 | if (mods & MOD_BIT(KC_LALT)) register_code(KC_LALT); | ||
| 92 | if (mods & MOD_BIT(KC_RALT)) register_code(KC_RALT); | ||
| 93 | if (mods & MOD_BIT(KC_LGUI)) register_code(KC_LGUI); | ||
| 94 | if (mods & MOD_BIT(KC_RGUI)) register_code(KC_RGUI); | ||
| 95 | } | ||
| 96 | |||
| 97 | __attribute__((weak)) | ||
| 98 | uint16_t hex_to_keycode(uint8_t hex) | ||
| 99 | { | ||
| 100 | if (hex == 0x0) { | ||
| 101 | return KC_0; | ||
| 102 | } else if (hex < 0xA) { | ||
| 103 | return KC_1 + (hex - 0x1); | ||
| 104 | } else { | ||
| 105 | return KC_A + (hex - 0xA); | ||
| 106 | } | ||
| 107 | } | ||
| 108 | |||
| 109 | void register_hex(uint16_t hex) { | ||
| 110 | for(int i = 3; i >= 0; i--) { | ||
| 111 | uint8_t digit = ((hex >> (i*4)) & 0xF); | ||
| 112 | register_code(hex_to_keycode(digit)); | ||
| 113 | unregister_code(hex_to_keycode(digit)); | ||
| 114 | } | ||
| 115 | } | ||
diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h new file mode 100644 index 000000000..f5be1da5c --- /dev/null +++ b/quantum/process_keycode/process_unicode_common.h | |||
| @@ -0,0 +1,148 @@ | |||
| 1 | /* Copyright 2017 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #ifndef PROCESS_UNICODE_COMMON_H | ||
| 18 | #define PROCESS_UNICODE_COMMON_H | ||
| 19 | |||
| 20 | #include "quantum.h" | ||
| 21 | |||
| 22 | #ifndef UNICODE_TYPE_DELAY | ||
| 23 | #define UNICODE_TYPE_DELAY 10 | ||
| 24 | #endif | ||
| 25 | |||
| 26 | __attribute__ ((unused)) | ||
| 27 | static uint8_t input_mode; | ||
| 28 | |||
| 29 | void set_unicode_input_mode(uint8_t os_target); | ||
| 30 | uint8_t get_unicode_input_mode(void); | ||
| 31 | void unicode_input_start(void); | ||
| 32 | void unicode_input_finish(void); | ||
| 33 | void register_hex(uint16_t hex); | ||
| 34 | |||
| 35 | #define UC_OSX 0 // Mac OS X | ||
| 36 | #define UC_LNX 1 // Linux | ||
| 37 | #define UC_WIN 2 // Windows 'HexNumpad' | ||
| 38 | #define UC_BSD 3 // BSD (not implemented) | ||
| 39 | #define UC_WINC 4 // WinCompose https://github.com/samhocevar/wincompose | ||
| 40 | |||
| 41 | #define UC_BSPC UC(0x0008) | ||
| 42 | |||
| 43 | #define UC_SPC UC(0x0020) | ||
| 44 | |||
| 45 | #define UC_EXLM UC(0x0021) | ||
| 46 | #define UC_DQUT UC(0x0022) | ||
| 47 | #define UC_HASH UC(0x0023) | ||
| 48 | #define UC_DLR UC(0x0024) | ||
| 49 | #define UC_PERC UC(0x0025) | ||
| 50 | #define UC_AMPR UC(0x0026) | ||
| 51 | #define UC_QUOT UC(0x0027) | ||
| 52 | #define UC_LPRN UC(0x0028) | ||
| 53 | #define UC_RPRN UC(0x0029) | ||
| 54 | #define UC_ASTR UC(0x002A) | ||
| 55 | #define UC_PLUS UC(0x002B) | ||
| 56 | #define UC_COMM UC(0x002C) | ||
| 57 | #define UC_DASH UC(0x002D) | ||
| 58 | #define UC_DOT UC(0x002E) | ||
| 59 | #define UC_SLSH UC(0x002F) | ||
| 60 | |||
| 61 | #define UC_0 UC(0x0030) | ||
| 62 | #define UC_1 UC(0x0031) | ||
| 63 | #define UC_2 UC(0x0032) | ||
| 64 | #define UC_3 UC(0x0033) | ||
| 65 | #define UC_4 UC(0x0034) | ||
| 66 | #define UC_5 UC(0x0035) | ||
| 67 | #define UC_6 UC(0x0036) | ||
| 68 | #define UC_7 UC(0x0037) | ||
| 69 | #define UC_8 UC(0x0038) | ||
| 70 | #define UC_9 UC(0x0039) | ||
| 71 | |||
| 72 | #define UC_COLN UC(0x003A) | ||
| 73 | #define UC_SCLN UC(0x003B) | ||
| 74 | #define UC_LT UC(0x003C) | ||
| 75 | #define UC_EQL UC(0x003D) | ||
| 76 | #define UC_GT UC(0x003E) | ||
| 77 | #define UC_QUES UC(0x003F) | ||
| 78 | #define UC_AT UC(0x0040) | ||
| 79 | |||
| 80 | #define UC_A UC(0x0041) | ||
| 81 | #define UC_B UC(0x0042) | ||
| 82 | #define UC_C UC(0x0043) | ||
| 83 | #define UC_D UC(0x0044) | ||
| 84 | #define UC_E UC(0x0045) | ||
| 85 | #define UC_F UC(0x0046) | ||
| 86 | #define UC_G UC(0x0047) | ||
| 87 | #define UC_H UC(0x0048) | ||
| 88 | #define UC_I UC(0x0049) | ||
| 89 | #define UC_J UC(0x004A) | ||
| 90 | #define UC_K UC(0x004B) | ||
| 91 | #define UC_L UC(0x004C) | ||
| 92 | #define UC_M UC(0x004D) | ||
| 93 | #define UC_N UC(0x004E) | ||
| 94 | #define UC_O UC(0x004F) | ||
| 95 | #define UC_P UC(0x0050) | ||
| 96 | #define UC_Q UC(0x0051) | ||
| 97 | #define UC_R UC(0x0052) | ||
| 98 | #define UC_S UC(0x0053) | ||
| 99 | #define UC_T UC(0x0054) | ||
| 100 | #define UC_U UC(0x0055) | ||
| 101 | #define UC_V UC(0x0056) | ||
| 102 | #define UC_W UC(0x0057) | ||
| 103 | #define UC_X UC(0x0058) | ||
| 104 | #define UC_Y UC(0x0059) | ||
| 105 | #define UC_Z UC(0x005A) | ||
| 106 | |||
| 107 | #define UC_LBRC UC(0x005B) | ||
| 108 | #define UC_BSLS UC(0x005C) | ||
| 109 | #define UC_RBRC UC(0x005D) | ||
| 110 | #define UC_CIRM UC(0x005E) | ||
| 111 | #define UC_UNDR UC(0x005F) | ||
| 112 | |||
| 113 | #define UC_GRV UC(0x0060) | ||
| 114 | |||
| 115 | #define UC_a UC(0x0061) | ||
| 116 | #define UC_b UC(0x0062) | ||
| 117 | #define UC_c UC(0x0063) | ||
| 118 | #define UC_d UC(0x0064) | ||
| 119 | #define UC_e UC(0x0065) | ||
| 120 | #define UC_f UC(0x0066) | ||
| 121 | #define UC_g UC(0x0067) | ||
| 122 | #define UC_h UC(0x0068) | ||
| 123 | #define UC_i UC(0x0069) | ||
| 124 | #define UC_j UC(0x006A) | ||
| 125 | #define UC_k UC(0x006B) | ||
| 126 | #define UC_l UC(0x006C) | ||
| 127 | #define UC_m UC(0x006D) | ||
| 128 | #define UC_n UC(0x006E) | ||
| 129 | #define UC_o UC(0x006F) | ||
| 130 | #define UC_p UC(0x0070) | ||
| 131 | #define UC_q UC(0x0071) | ||
| 132 | #define UC_r UC(0x0072) | ||
| 133 | #define UC_s UC(0x0073) | ||
| 134 | #define UC_t UC(0x0074) | ||
| 135 | #define UC_u UC(0x0075) | ||
| 136 | #define UC_v UC(0x0076) | ||
| 137 | #define UC_w UC(0x0077) | ||
| 138 | #define UC_x UC(0x0078) | ||
| 139 | #define UC_y UC(0x0079) | ||
| 140 | #define UC_z UC(0x007A) | ||
| 141 | |||
| 142 | #define UC_LCBR UC(0x007B) | ||
| 143 | #define UC_PIPE UC(0x007C) | ||
| 144 | #define UC_RCBR UC(0x007D) | ||
| 145 | #define UC_TILD UC(0x007E) | ||
| 146 | #define UC_DEL UC(0x007F) | ||
| 147 | |||
| 148 | #endif | ||
diff --git a/quantum/process_keycode/process_unicodemap.c b/quantum/process_keycode/process_unicodemap.c new file mode 100644 index 000000000..0227fbdd7 --- /dev/null +++ b/quantum/process_keycode/process_unicodemap.c | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | /* Copyright 2017 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "process_unicodemap.h" | ||
| 18 | #include "process_unicode_common.h" | ||
| 19 | |||
| 20 | __attribute__((weak)) | ||
| 21 | const uint32_t PROGMEM unicode_map[] = { | ||
| 22 | }; | ||
| 23 | |||
| 24 | void register_hex32(uint32_t hex) { | ||
| 25 | bool onzerostart = true; | ||
| 26 | for(int i = 7; i >= 0; i--) { | ||
| 27 | if (i <= 3) { | ||
| 28 | onzerostart = false; | ||
| 29 | } | ||
| 30 | uint8_t digit = ((hex >> (i*4)) & 0xF); | ||
| 31 | if (digit == 0) { | ||
| 32 | if (!onzerostart) { | ||
| 33 | register_code(hex_to_keycode(digit)); | ||
| 34 | unregister_code(hex_to_keycode(digit)); | ||
| 35 | } | ||
| 36 | } else { | ||
| 37 | register_code(hex_to_keycode(digit)); | ||
| 38 | unregister_code(hex_to_keycode(digit)); | ||
| 39 | onzerostart = false; | ||
| 40 | } | ||
| 41 | } | ||
| 42 | } | ||
| 43 | |||
| 44 | __attribute__((weak)) | ||
| 45 | void unicode_map_input_error() {} | ||
| 46 | |||
| 47 | bool process_unicode_map(uint16_t keycode, keyrecord_t *record) { | ||
| 48 | uint8_t input_mode = get_unicode_input_mode(); | ||
| 49 | if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) { | ||
| 50 | const uint32_t* map = unicode_map; | ||
| 51 | uint16_t index = keycode - QK_UNICODE_MAP; | ||
| 52 | uint32_t code = pgm_read_dword_far(&map[index]); | ||
| 53 | if (code > 0xFFFF && code <= 0x10ffff && input_mode == UC_OSX) { | ||
| 54 | // Convert to UTF-16 surrogate pair | ||
| 55 | code -= 0x10000; | ||
| 56 | uint32_t lo = code & 0x3ff; | ||
| 57 | uint32_t hi = (code & 0xffc00) >> 10; | ||
| 58 | unicode_input_start(); | ||
| 59 | register_hex32(hi + 0xd800); | ||
| 60 | register_hex32(lo + 0xdc00); | ||
| 61 | unicode_input_finish(); | ||
| 62 | } else if ((code > 0x10ffff && input_mode == UC_OSX) || (code > 0xFFFFF && input_mode == UC_LNX)) { | ||
| 63 | // when character is out of range supported by the OS | ||
| 64 | unicode_map_input_error(); | ||
| 65 | } else { | ||
| 66 | unicode_input_start(); | ||
| 67 | register_hex32(code); | ||
| 68 | unicode_input_finish(); | ||
| 69 | } | ||
| 70 | } | ||
| 71 | return true; | ||
| 72 | } | ||
diff --git a/quantum/process_keycode/process_unicodemap.h b/quantum/process_keycode/process_unicodemap.h new file mode 100644 index 000000000..929c88c0b --- /dev/null +++ b/quantum/process_keycode/process_unicodemap.h | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | /* Copyright 2017 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #ifndef PROCESS_UNICODEMAP_H | ||
| 18 | #define PROCESS_UNICODEMAP_H | ||
| 19 | |||
| 20 | #include "quantum.h" | ||
| 21 | #include "process_unicode_common.h" | ||
| 22 | |||
| 23 | void unicode_map_input_error(void); | ||
| 24 | bool process_unicode_map(uint16_t keycode, keyrecord_t *record); | ||
| 25 | #endif | ||
diff --git a/quantum/quantum.c b/quantum/quantum.c index 63ffe2074..4f4cee4e9 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -1,9 +1,35 @@ | |||
| 1 | /* Copyright 2016-2017 Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #include "quantum.h" | 17 | #include "quantum.h" |
| 18 | #ifdef PROTOCOL_LUFA | ||
| 19 | #include "outputselect.h" | ||
| 20 | #endif | ||
| 2 | 21 | ||
| 3 | #ifndef TAPPING_TERM | 22 | #ifndef TAPPING_TERM |
| 4 | #define TAPPING_TERM 200 | 23 | #define TAPPING_TERM 200 |
| 5 | #endif | 24 | #endif |
| 6 | 25 | ||
| 26 | #include "backlight.h" | ||
| 27 | extern backlight_config_t backlight_config; | ||
| 28 | |||
| 29 | #ifdef FAUXCLICKY_ENABLE | ||
| 30 | #include "fauxclicky.h" | ||
| 31 | #endif | ||
| 32 | |||
| 7 | static void do_code16 (uint16_t code, void (*f) (uint8_t)) { | 33 | static void do_code16 (uint16_t code, void (*f) (uint8_t)) { |
| 8 | switch (code) { | 34 | switch (code) { |
| 9 | case QK_MODS ... QK_MODS_MAX: | 35 | case QK_MODS ... QK_MODS_MAX: |
| @@ -33,14 +59,42 @@ static void do_code16 (uint16_t code, void (*f) (uint8_t)) { | |||
| 33 | f(KC_RGUI); | 59 | f(KC_RGUI); |
| 34 | } | 60 | } |
| 35 | 61 | ||
| 62 | static inline void qk_register_weak_mods(uint8_t kc) { | ||
| 63 | add_weak_mods(MOD_BIT(kc)); | ||
| 64 | send_keyboard_report(); | ||
| 65 | } | ||
| 66 | |||
| 67 | static inline void qk_unregister_weak_mods(uint8_t kc) { | ||
| 68 | del_weak_mods(MOD_BIT(kc)); | ||
| 69 | send_keyboard_report(); | ||
| 70 | } | ||
| 71 | |||
| 72 | static inline void qk_register_mods(uint8_t kc) { | ||
| 73 | add_weak_mods(MOD_BIT(kc)); | ||
| 74 | send_keyboard_report(); | ||
| 75 | } | ||
| 76 | |||
| 77 | static inline void qk_unregister_mods(uint8_t kc) { | ||
| 78 | del_weak_mods(MOD_BIT(kc)); | ||
| 79 | send_keyboard_report(); | ||
| 80 | } | ||
| 81 | |||
| 36 | void register_code16 (uint16_t code) { | 82 | void register_code16 (uint16_t code) { |
| 37 | do_code16 (code, register_code); | 83 | if (IS_MOD(code) || code == KC_NO) { |
| 84 | do_code16 (code, qk_register_mods); | ||
| 85 | } else { | ||
| 86 | do_code16 (code, qk_register_weak_mods); | ||
| 87 | } | ||
| 38 | register_code (code); | 88 | register_code (code); |
| 39 | } | 89 | } |
| 40 | 90 | ||
| 41 | void unregister_code16 (uint16_t code) { | 91 | void unregister_code16 (uint16_t code) { |
| 42 | unregister_code (code); | 92 | unregister_code (code); |
| 43 | do_code16 (code, unregister_code); | 93 | if (IS_MOD(code) || code == KC_NO) { |
| 94 | do_code16 (code, qk_unregister_mods); | ||
| 95 | } else { | ||
| 96 | do_code16 (code, qk_unregister_weak_mods); | ||
| 97 | } | ||
| 44 | } | 98 | } |
| 45 | 99 | ||
| 46 | __attribute__ ((weak)) | 100 | __attribute__ ((weak)) |
| @@ -60,8 +114,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 60 | 114 | ||
| 61 | void reset_keyboard(void) { | 115 | void reset_keyboard(void) { |
| 62 | clear_keyboard(); | 116 | clear_keyboard(); |
| 63 | #ifdef AUDIO_ENABLE | 117 | #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_ENABLE_BASIC)) |
| 64 | stop_all_notes(); | 118 | music_all_notes_off(); |
| 65 | shutdown_user(); | 119 | shutdown_user(); |
| 66 | #endif | 120 | #endif |
| 67 | wait_ms(250); | 121 | wait_ms(250); |
| @@ -81,7 +135,7 @@ void reset_keyboard(void) { | |||
| 81 | #endif | 135 | #endif |
| 82 | 136 | ||
| 83 | static bool shift_interrupted[2] = {0, 0}; | 137 | static bool shift_interrupted[2] = {0, 0}; |
| 84 | static uint16_t scs_timer = 0; | 138 | static uint16_t scs_timer[2] = {0, 0}; |
| 85 | 139 | ||
| 86 | bool process_record_quantum(keyrecord_t *record) { | 140 | bool process_record_quantum(keyrecord_t *record) { |
| 87 | 141 | ||
| @@ -115,10 +169,13 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 115 | 169 | ||
| 116 | if (!( | 170 | if (!( |
| 117 | process_record_kb(keycode, record) && | 171 | process_record_kb(keycode, record) && |
| 118 | #ifdef MIDI_ENABLE | 172 | #if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED) |
| 119 | process_midi(keycode, record) && | 173 | process_midi(keycode, record) && |
| 120 | #endif | 174 | #endif |
| 121 | #ifdef AUDIO_ENABLE | 175 | #ifdef AUDIO_ENABLE |
| 176 | process_audio(keycode, record) && | ||
| 177 | #endif | ||
| 178 | #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) | ||
| 122 | process_music(keycode, record) && | 179 | process_music(keycode, record) && |
| 123 | #endif | 180 | #endif |
| 124 | #ifdef TAP_DANCE_ENABLE | 181 | #ifdef TAP_DANCE_ENABLE |
| @@ -130,6 +187,9 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 130 | #ifndef DISABLE_CHORDING | 187 | #ifndef DISABLE_CHORDING |
| 131 | process_chording(keycode, record) && | 188 | process_chording(keycode, record) && |
| 132 | #endif | 189 | #endif |
| 190 | #ifdef COMBO_ENABLE | ||
| 191 | process_combo(keycode, record) && | ||
| 192 | #endif | ||
| 133 | #ifdef UNICODE_ENABLE | 193 | #ifdef UNICODE_ENABLE |
| 134 | process_unicode(keycode, record) && | 194 | process_unicode(keycode, record) && |
| 135 | #endif | 195 | #endif |
| @@ -162,6 +222,26 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 162 | } | 222 | } |
| 163 | return false; | 223 | return false; |
| 164 | break; | 224 | break; |
| 225 | #ifdef FAUXCLICKY_ENABLE | ||
| 226 | case FC_TOG: | ||
| 227 | if (record->event.pressed) { | ||
| 228 | FAUXCLICKY_TOGGLE; | ||
| 229 | } | ||
| 230 | return false; | ||
| 231 | break; | ||
| 232 | case FC_ON: | ||
| 233 | if (record->event.pressed) { | ||
| 234 | FAUXCLICKY_ON; | ||
| 235 | } | ||
| 236 | return false; | ||
| 237 | break; | ||
| 238 | case FC_OFF: | ||
| 239 | if (record->event.pressed) { | ||
| 240 | FAUXCLICKY_OFF; | ||
| 241 | } | ||
| 242 | return false; | ||
| 243 | break; | ||
| 244 | #endif | ||
| 165 | #ifdef RGBLIGHT_ENABLE | 245 | #ifdef RGBLIGHT_ENABLE |
| 166 | case RGB_TOG: | 246 | case RGB_TOG: |
| 167 | if (record->event.pressed) { | 247 | if (record->event.pressed) { |
| @@ -212,6 +292,28 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 212 | return false; | 292 | return false; |
| 213 | break; | 293 | break; |
| 214 | #endif | 294 | #endif |
| 295 | #ifdef PROTOCOL_LUFA | ||
| 296 | case OUT_AUTO: | ||
| 297 | if (record->event.pressed) { | ||
| 298 | set_output(OUTPUT_AUTO); | ||
| 299 | } | ||
| 300 | return false; | ||
| 301 | break; | ||
| 302 | case OUT_USB: | ||
| 303 | if (record->event.pressed) { | ||
| 304 | set_output(OUTPUT_USB); | ||
| 305 | } | ||
| 306 | return false; | ||
| 307 | break; | ||
| 308 | #ifdef BLUETOOTH_ENABLE | ||
| 309 | case OUT_BT: | ||
| 310 | if (record->event.pressed) { | ||
| 311 | set_output(OUTPUT_BLUETOOTH); | ||
| 312 | } | ||
| 313 | return false; | ||
| 314 | break; | ||
| 315 | #endif | ||
| 316 | #endif | ||
| 215 | case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_NKRO: | 317 | case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_NKRO: |
| 216 | if (record->event.pressed) { | 318 | if (record->event.pressed) { |
| 217 | // MAGIC actions (BOOTMAGIC without the boot) | 319 | // MAGIC actions (BOOTMAGIC without the boot) |
| @@ -293,7 +395,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 293 | case KC_LSPO: { | 395 | case KC_LSPO: { |
| 294 | if (record->event.pressed) { | 396 | if (record->event.pressed) { |
| 295 | shift_interrupted[0] = false; | 397 | shift_interrupted[0] = false; |
| 296 | scs_timer = timer_read (); | 398 | scs_timer[0] = timer_read (); |
| 297 | register_mods(MOD_BIT(KC_LSFT)); | 399 | register_mods(MOD_BIT(KC_LSFT)); |
| 298 | } | 400 | } |
| 299 | else { | 401 | else { |
| @@ -303,7 +405,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 303 | shift_interrupted[1] = true; | 405 | shift_interrupted[1] = true; |
| 304 | } | 406 | } |
| 305 | #endif | 407 | #endif |
| 306 | if (!shift_interrupted[0] && timer_elapsed(scs_timer) < TAPPING_TERM) { | 408 | if (!shift_interrupted[0] && timer_elapsed(scs_timer[0]) < TAPPING_TERM) { |
| 307 | register_code(LSPO_KEY); | 409 | register_code(LSPO_KEY); |
| 308 | unregister_code(LSPO_KEY); | 410 | unregister_code(LSPO_KEY); |
| 309 | } | 411 | } |
| @@ -316,7 +418,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 316 | case KC_RSPC: { | 418 | case KC_RSPC: { |
| 317 | if (record->event.pressed) { | 419 | if (record->event.pressed) { |
| 318 | shift_interrupted[1] = false; | 420 | shift_interrupted[1] = false; |
| 319 | scs_timer = timer_read (); | 421 | scs_timer[1] = timer_read (); |
| 320 | register_mods(MOD_BIT(KC_RSFT)); | 422 | register_mods(MOD_BIT(KC_RSFT)); |
| 321 | } | 423 | } |
| 322 | else { | 424 | else { |
| @@ -326,7 +428,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 326 | shift_interrupted[1] = true; | 428 | shift_interrupted[1] = true; |
| 327 | } | 429 | } |
| 328 | #endif | 430 | #endif |
| 329 | if (!shift_interrupted[1] && timer_elapsed(scs_timer) < TAPPING_TERM) { | 431 | if (!shift_interrupted[1] && timer_elapsed(scs_timer[1]) < TAPPING_TERM) { |
| 330 | register_code(RSPC_KEY); | 432 | register_code(RSPC_KEY); |
| 331 | unregister_code(RSPC_KEY); | 433 | unregister_code(RSPC_KEY); |
| 332 | } | 434 | } |
| @@ -508,6 +610,15 @@ void matrix_scan_quantum() { | |||
| 508 | #ifdef TAP_DANCE_ENABLE | 610 | #ifdef TAP_DANCE_ENABLE |
| 509 | matrix_scan_tap_dance(); | 611 | matrix_scan_tap_dance(); |
| 510 | #endif | 612 | #endif |
| 613 | |||
| 614 | #ifdef COMBO_ENABLE | ||
| 615 | matrix_scan_combo(); | ||
| 616 | #endif | ||
| 617 | |||
| 618 | #if defined(BACKLIGHT_ENABLE) && defined(BACKLIGHT_PIN) | ||
| 619 | backlight_task(); | ||
| 620 | #endif | ||
| 621 | |||
| 511 | matrix_scan_kb(); | 622 | matrix_scan_kb(); |
| 512 | } | 623 | } |
| 513 | 624 | ||
| @@ -525,34 +636,45 @@ static const uint8_t backlight_pin = BACKLIGHT_PIN; | |||
| 525 | # define COM1x1 COM1A1 | 636 | # define COM1x1 COM1A1 |
| 526 | # define OCR1x OCR1A | 637 | # define OCR1x OCR1A |
| 527 | #else | 638 | #else |
| 528 | # error "Backlight pin not supported - use B5, B6, or B7" | 639 | # define NO_BACKLIGHT_CLOCK |
| 640 | #endif | ||
| 641 | |||
| 642 | #ifndef BACKLIGHT_ON_STATE | ||
| 643 | #define BACKLIGHT_ON_STATE 0 | ||
| 529 | #endif | 644 | #endif |
| 530 | 645 | ||
| 531 | __attribute__ ((weak)) | 646 | __attribute__ ((weak)) |
| 532 | void backlight_init_ports(void) | 647 | void backlight_init_ports(void) |
| 533 | { | 648 | { |
| 534 | 649 | ||
| 535 | // Setup backlight pin as output and output low. | 650 | // Setup backlight pin as output and output to on state. |
| 536 | // DDRx |= n | 651 | // DDRx |= n |
| 537 | _SFR_IO8((backlight_pin >> 4) + 1) |= _BV(backlight_pin & 0xF); | 652 | _SFR_IO8((backlight_pin >> 4) + 1) |= _BV(backlight_pin & 0xF); |
| 538 | // PORTx &= ~n | 653 | #if BACKLIGHT_ON_STATE == 0 |
| 539 | _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); | 654 | // PORTx &= ~n |
| 655 | _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); | ||
| 656 | #else | ||
| 657 | // PORTx |= n | ||
| 658 | _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF); | ||
| 659 | #endif | ||
| 540 | 660 | ||
| 541 | // Use full 16-bit resolution. | 661 | #ifndef NO_BACKLIGHT_CLOCK |
| 542 | ICR1 = 0xFFFF; | 662 | // Use full 16-bit resolution. |
| 663 | ICR1 = 0xFFFF; | ||
| 543 | 664 | ||
| 544 | // I could write a wall of text here to explain... but TL;DW | 665 | // I could write a wall of text here to explain... but TL;DW |
| 545 | // Go read the ATmega32u4 datasheet. | 666 | // Go read the ATmega32u4 datasheet. |
| 546 | // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on | 667 | // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on |
| 547 | 668 | ||
| 548 | // Pin PB7 = OCR1C (Timer 1, Channel C) | 669 | // Pin PB7 = OCR1C (Timer 1, Channel C) |
| 549 | // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0 | 670 | // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0 |
| 550 | // (i.e. start high, go low when counter matches.) | 671 | // (i.e. start high, go low when counter matches.) |
| 551 | // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0 | 672 | // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0 |
| 552 | // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1 | 673 | // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1 |
| 553 | 674 | ||
| 554 | TCCR1A = _BV(COM1x1) | _BV(WGM11); // = 0b00001010; | 675 | TCCR1A = _BV(COM1x1) | _BV(WGM11); // = 0b00001010; |
| 555 | TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; | 676 | TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; |
| 677 | #endif | ||
| 556 | 678 | ||
| 557 | backlight_init(); | 679 | backlight_init(); |
| 558 | #ifdef BACKLIGHT_BREATHING | 680 | #ifdef BACKLIGHT_BREATHING |
| @@ -564,30 +686,73 @@ __attribute__ ((weak)) | |||
| 564 | void backlight_set(uint8_t level) | 686 | void backlight_set(uint8_t level) |
| 565 | { | 687 | { |
| 566 | // Prevent backlight blink on lowest level | 688 | // Prevent backlight blink on lowest level |
| 567 | // PORTx &= ~n | 689 | // #if BACKLIGHT_ON_STATE == 0 |
| 568 | _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); | 690 | // // PORTx &= ~n |
| 691 | // _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); | ||
| 692 | // #else | ||
| 693 | // // PORTx |= n | ||
| 694 | // _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF); | ||
| 695 | // #endif | ||
| 569 | 696 | ||
| 570 | if ( level == 0 ) { | 697 | if ( level == 0 ) { |
| 571 | // Turn off PWM control on backlight pin, revert to output low. | 698 | #ifndef NO_BACKLIGHT_CLOCK |
| 572 | TCCR1A &= ~(_BV(COM1x1)); | 699 | // Turn off PWM control on backlight pin, revert to output low. |
| 573 | OCR1x = 0x0; | 700 | TCCR1A &= ~(_BV(COM1x1)); |
| 574 | } else if ( level == BACKLIGHT_LEVELS ) { | 701 | OCR1x = 0x0; |
| 575 | // Turn on PWM control of backlight pin | 702 | #else |
| 576 | TCCR1A |= _BV(COM1x1); | 703 | // #if BACKLIGHT_ON_STATE == 0 |
| 577 | // Set the brightness | 704 | // // PORTx |= n |
| 578 | OCR1x = 0xFFFF; | 705 | // _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF); |
| 579 | } else { | 706 | // #else |
| 580 | // Turn on PWM control of backlight pin | 707 | // // PORTx &= ~n |
| 581 | TCCR1A |= _BV(COM1x1); | 708 | // _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); |
| 582 | // Set the brightness | 709 | // #endif |
| 583 | OCR1x = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2)); | 710 | #endif |
| 584 | } | 711 | } |
| 712 | #ifndef NO_BACKLIGHT_CLOCK | ||
| 713 | else if ( level == BACKLIGHT_LEVELS ) { | ||
| 714 | // Turn on PWM control of backlight pin | ||
| 715 | TCCR1A |= _BV(COM1x1); | ||
| 716 | // Set the brightness | ||
| 717 | OCR1x = 0xFFFF; | ||
| 718 | } | ||
| 719 | else { | ||
| 720 | // Turn on PWM control of backlight pin | ||
| 721 | TCCR1A |= _BV(COM1x1); | ||
| 722 | // Set the brightness | ||
| 723 | OCR1x = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2)); | ||
| 724 | } | ||
| 725 | #endif | ||
| 585 | 726 | ||
| 586 | #ifdef BACKLIGHT_BREATHING | 727 | #ifdef BACKLIGHT_BREATHING |
| 587 | breathing_intensity_default(); | 728 | breathing_intensity_default(); |
| 588 | #endif | 729 | #endif |
| 589 | } | 730 | } |
| 590 | 731 | ||
| 732 | uint8_t backlight_tick = 0; | ||
| 733 | |||
| 734 | void backlight_task(void) { | ||
| 735 | #ifdef NO_BACKLIGHT_CLOCK | ||
| 736 | if ((0xFFFF >> ((BACKLIGHT_LEVELS - backlight_config.level) * ((BACKLIGHT_LEVELS + 1) / 2))) & (1 << backlight_tick)) { | ||
| 737 | #if BACKLIGHT_ON_STATE == 0 | ||
| 738 | // PORTx &= ~n | ||
| 739 | _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); | ||
| 740 | #else | ||
| 741 | // PORTx |= n | ||
| 742 | _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF); | ||
| 743 | #endif | ||
| 744 | } else { | ||
| 745 | #if BACKLIGHT_ON_STATE == 0 | ||
| 746 | // PORTx |= n | ||
| 747 | _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF); | ||
| 748 | #else | ||
| 749 | // PORTx &= ~n | ||
| 750 | _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); | ||
| 751 | #endif | ||
| 752 | } | ||
| 753 | backlight_tick = (backlight_tick + 1) % 16; | ||
| 754 | #endif | ||
| 755 | } | ||
| 591 | 756 | ||
| 592 | #ifdef BACKLIGHT_BREATHING | 757 | #ifdef BACKLIGHT_BREATHING |
| 593 | 758 | ||
| @@ -849,6 +1014,19 @@ void send_nibble(uint8_t number) { | |||
| 849 | } | 1014 | } |
| 850 | } | 1015 | } |
| 851 | 1016 | ||
| 1017 | |||
| 1018 | __attribute__((weak)) | ||
| 1019 | uint16_t hex_to_keycode(uint8_t hex) | ||
| 1020 | { | ||
| 1021 | if (hex == 0x0) { | ||
| 1022 | return KC_0; | ||
| 1023 | } else if (hex < 0xA) { | ||
| 1024 | return KC_1 + (hex - 0x1); | ||
| 1025 | } else { | ||
| 1026 | return KC_A + (hex - 0xA); | ||
| 1027 | } | ||
| 1028 | } | ||
| 1029 | |||
| 852 | void api_send_unicode(uint32_t unicode) { | 1030 | void api_send_unicode(uint32_t unicode) { |
| 853 | #ifdef API_ENABLE | 1031 | #ifdef API_ENABLE |
| 854 | uint8_t chunk[4]; | 1032 | uint8_t chunk[4]; |
diff --git a/quantum/quantum.h b/quantum/quantum.h index e6adf974a..2bf18d095 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2016-2017 Erez Zukerman, Jack Humbert | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #ifndef QUANTUM_H | 16 | #ifndef QUANTUM_H |
| 2 | #define QUANTUM_H | 17 | #define QUANTUM_H |
| 3 | 18 | ||
| @@ -15,7 +30,6 @@ | |||
| 15 | #ifdef RGBLIGHT_ENABLE | 30 | #ifdef RGBLIGHT_ENABLE |
| 16 | #include "rgblight.h" | 31 | #include "rgblight.h" |
| 17 | #endif | 32 | #endif |
| 18 | |||
| 19 | #include "action_layer.h" | 33 | #include "action_layer.h" |
| 20 | #include "eeconfig.h" | 34 | #include "eeconfig.h" |
| 21 | #include <stddef.h> | 35 | #include <stddef.h> |
| @@ -36,11 +50,16 @@ extern uint32_t default_layer_state; | |||
| 36 | 50 | ||
| 37 | #ifdef MIDI_ENABLE | 51 | #ifdef MIDI_ENABLE |
| 38 | #include <lufa.h> | 52 | #include <lufa.h> |
| 53 | #ifdef MIDI_ADVANCED | ||
| 39 | #include "process_midi.h" | 54 | #include "process_midi.h" |
| 40 | #endif | 55 | #endif |
| 56 | #endif // MIDI_ENABLE | ||
| 41 | 57 | ||
| 42 | #ifdef AUDIO_ENABLE | 58 | #ifdef AUDIO_ENABLE |
| 43 | #include "audio.h" | 59 | #include "process_audio.h" |
| 60 | #endif | ||
| 61 | |||
| 62 | #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) | ||
| 44 | #include "process_music.h" | 63 | #include "process_music.h" |
| 45 | #endif | 64 | #endif |
| 46 | 65 | ||
| @@ -57,12 +76,24 @@ extern uint32_t default_layer_state; | |||
| 57 | #include "process_unicode.h" | 76 | #include "process_unicode.h" |
| 58 | #endif | 77 | #endif |
| 59 | 78 | ||
| 79 | #ifdef UCIS_ENABLE | ||
| 80 | #include "process_ucis.h" | ||
| 81 | #endif | ||
| 82 | |||
| 83 | #ifdef UNICODEMAP_ENABLE | ||
| 84 | #include "process_unicodemap.h" | ||
| 85 | #endif | ||
| 86 | |||
| 60 | #include "process_tap_dance.h" | 87 | #include "process_tap_dance.h" |
| 61 | 88 | ||
| 62 | #ifdef PRINTING_ENABLE | 89 | #ifdef PRINTING_ENABLE |
| 63 | #include "process_printer.h" | 90 | #include "process_printer.h" |
| 64 | #endif | 91 | #endif |
| 65 | 92 | ||
| 93 | #ifdef COMBO_ENABLE | ||
| 94 | #include "process_combo.h" | ||
| 95 | #endif | ||
| 96 | |||
| 66 | #define SEND_STRING(str) send_string(PSTR(str)) | 97 | #define SEND_STRING(str) send_string(PSTR(str)) |
| 67 | void send_string(const char *str); | 98 | void send_string(const char *str); |
| 68 | 99 | ||
| @@ -92,6 +123,7 @@ void unregister_code16 (uint16_t code); | |||
| 92 | 123 | ||
| 93 | #ifdef BACKLIGHT_ENABLE | 124 | #ifdef BACKLIGHT_ENABLE |
| 94 | void backlight_init_ports(void); | 125 | void backlight_init_ports(void); |
| 126 | void backlight_task(void); | ||
| 95 | 127 | ||
| 96 | #ifdef BACKLIGHT_BREATHING | 128 | #ifdef BACKLIGHT_BREATHING |
| 97 | void breathing_enable(void); | 129 | void breathing_enable(void); |
| @@ -114,7 +146,7 @@ void send_dword(uint32_t number); | |||
| 114 | void send_word(uint16_t number); | 146 | void send_word(uint16_t number); |
| 115 | void send_byte(uint8_t number); | 147 | void send_byte(uint8_t number); |
| 116 | void send_nibble(uint8_t number); | 148 | void send_nibble(uint8_t number); |
| 117 | 149 | uint16_t hex_to_keycode(uint8_t hex); | |
| 118 | 150 | ||
| 119 | void led_set_user(uint8_t usb_led); | 151 | void led_set_user(uint8_t usb_led); |
| 120 | void led_set_kb(uint8_t usb_led); | 152 | void led_set_kb(uint8_t usb_led); |
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 4853655f9..7354ae0da 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h | |||
| @@ -1,7 +1,31 @@ | |||
| 1 | 1 | /* Copyright 2016-2017 Jack Humbert | |
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 2 | #ifndef QUANTUM_KEYCODES_H | 16 | #ifndef QUANTUM_KEYCODES_H |
| 3 | #define QUANTUM_KEYCODES_H | 17 | #define QUANTUM_KEYCODES_H |
| 4 | 18 | ||
| 19 | #ifndef MIDI_ENABLE_STRICT | ||
| 20 | #define MIDI_ENABLE_STRICT 0 | ||
| 21 | #endif | ||
| 22 | |||
| 23 | #if !MIDI_ENABLE_STRICT || (defined(MIDI_ENABLE) && defined(MIDI_ADVANCED)) | ||
| 24 | #ifndef MIDI_TONE_KEYCODE_OCTAVES | ||
| 25 | #define MIDI_TONE_KEYCODE_OCTAVES 3 | ||
| 26 | #endif | ||
| 27 | #endif | ||
| 28 | |||
| 5 | enum quantum_keycodes { | 29 | enum quantum_keycodes { |
| 6 | // Ranges used in shortucuts - not to be used directly | 30 | // Ranges used in shortucuts - not to be used directly |
| 7 | QK_TMK = 0x0000, | 31 | QK_TMK = 0x0000, |
| @@ -39,22 +63,27 @@ enum quantum_keycodes { | |||
| 39 | QK_CHORDING = 0x5600, | 63 | QK_CHORDING = 0x5600, |
| 40 | QK_CHORDING_MAX = 0x56FF, | 64 | QK_CHORDING_MAX = 0x56FF, |
| 41 | #endif | 65 | #endif |
| 66 | QK_TAP_DANCE = 0x5700, | ||
| 67 | QK_TAP_DANCE_MAX = 0x57FF, | ||
| 68 | QK_LAYER_TAP_TOGGLE = 0x5800, | ||
| 69 | QK_LAYER_TAP_TOGGLE_MAX = 0x58FF, | ||
| 42 | QK_MOD_TAP = 0x6000, | 70 | QK_MOD_TAP = 0x6000, |
| 43 | QK_MOD_TAP_MAX = 0x6FFF, | 71 | QK_MOD_TAP_MAX = 0x7FFF, |
| 44 | QK_TAP_DANCE = 0x7100, | 72 | #if defined(UNICODEMAP_ENABLE) && defined(UNICODE_ENABLE) |
| 45 | QK_TAP_DANCE_MAX = 0x71FF, | 73 | #error "Cannot enable both UNICODEMAP && UNICODE" |
| 46 | #ifdef UNICODEMAP_ENABLE | ||
| 47 | QK_UNICODE_MAP = 0x7800, | ||
| 48 | QK_UNICODE_MAP_MAX = 0x7FFF, | ||
| 49 | #endif | 74 | #endif |
| 50 | #ifdef UNICODE_ENABLE | 75 | #ifdef UNICODE_ENABLE |
| 51 | QK_UNICODE = 0x8000, | 76 | QK_UNICODE = 0x8000, |
| 52 | QK_UNICODE_MAX = 0xFFFF, | 77 | QK_UNICODE_MAX = 0xFFFF, |
| 53 | #endif | 78 | #endif |
| 79 | #ifdef UNICODEMAP_ENABLE | ||
| 80 | QK_UNICODE_MAP = 0x8000, | ||
| 81 | QK_UNICODE_MAP_MAX = 0x83FF, | ||
| 82 | #endif | ||
| 54 | 83 | ||
| 55 | // Loose keycodes - to be used directly | 84 | // Loose keycodes - to be used directly |
| 56 | 85 | ||
| 57 | RESET = 0x7000, | 86 | RESET = 0x5C00, |
| 58 | DEBUG, | 87 | DEBUG, |
| 59 | MAGIC_SWAP_CONTROL_CAPSLOCK, | 88 | MAGIC_SWAP_CONTROL_CAPSLOCK, |
| 60 | MAGIC_CAPSLOCK_TO_CONTROL, | 89 | MAGIC_CAPSLOCK_TO_CONTROL, |
| @@ -86,6 +115,13 @@ enum quantum_keycodes { | |||
| 86 | AU_OFF, | 115 | AU_OFF, |
| 87 | AU_TOG, | 116 | AU_TOG, |
| 88 | 117 | ||
| 118 | #ifdef FAUXCLICKY_ENABLE | ||
| 119 | // Faux clicky | ||
| 120 | FC_ON, | ||
| 121 | FC_OFF, | ||
| 122 | FC_TOG, | ||
| 123 | #endif | ||
| 124 | |||
| 89 | // Music mode on/off/toggle | 125 | // Music mode on/off/toggle |
| 90 | MU_ON, | 126 | MU_ON, |
| 91 | MU_OFF, | 127 | MU_OFF, |
| @@ -95,9 +131,230 @@ enum quantum_keycodes { | |||
| 95 | MUV_IN, | 131 | MUV_IN, |
| 96 | MUV_DE, | 132 | MUV_DE, |
| 97 | 133 | ||
| 98 | // Midi mode on/off | 134 | // Midi |
| 99 | MIDI_ON, | 135 | #if !MIDI_ENABLE_STRICT || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) |
| 100 | MIDI_OFF, | 136 | MI_ON, // send midi notes when music mode is enabled |
| 137 | MI_OFF, // don't send midi notes when music mode is enabled | ||
| 138 | #endif | ||
| 139 | |||
| 140 | #if !MIDI_ENABLE_STRICT || (defined(MIDI_ENABLE) && defined(MIDI_ADVANCED)) | ||
| 141 | MIDI_TONE_MIN, | ||
| 142 | |||
| 143 | #if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 0 | ||
| 144 | MI_C = MIDI_TONE_MIN, | ||
| 145 | MI_Cs, | ||
| 146 | MI_Db = MI_Cs, | ||
| 147 | MI_D, | ||
| 148 | MI_Ds, | ||
| 149 | MI_Eb = MI_Ds, | ||
| 150 | MI_E, | ||
| 151 | MI_F, | ||
| 152 | MI_Fs, | ||
| 153 | MI_Gb = MI_Fs, | ||
| 154 | MI_G, | ||
| 155 | MI_Gs, | ||
| 156 | MI_Ab = MI_Gs, | ||
| 157 | MI_A, | ||
| 158 | MI_As, | ||
| 159 | MI_Bb = MI_As, | ||
| 160 | MI_B, | ||
| 161 | #endif | ||
| 162 | |||
| 163 | #if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 1 | ||
| 164 | MI_C_1, | ||
| 165 | MI_Cs_1, | ||
| 166 | MI_Db_1 = MI_Cs_1, | ||
| 167 | MI_D_1, | ||
| 168 | MI_Ds_1, | ||
| 169 | MI_Eb_1 = MI_Ds_1, | ||
| 170 | MI_E_1, | ||
| 171 | MI_F_1, | ||
| 172 | MI_Fs_1, | ||
| 173 | MI_Gb_1 = MI_Fs_1, | ||
| 174 | MI_G_1, | ||
| 175 | MI_Gs_1, | ||
| 176 | MI_Ab_1 = MI_Gs_1, | ||
| 177 | MI_A_1, | ||
| 178 | MI_As_1, | ||
| 179 | MI_Bb_1 = MI_As_1, | ||
| 180 | MI_B_1, | ||
| 181 | #endif | ||
| 182 | |||
| 183 | #if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 2 | ||
| 184 | MI_C_2, | ||
| 185 | MI_Cs_2, | ||
| 186 | MI_Db_2 = MI_Cs_2, | ||
| 187 | MI_D_2, | ||
| 188 | MI_Ds_2, | ||
| 189 | MI_Eb_2 = MI_Ds_2, | ||
| 190 | MI_E_2, | ||
| 191 | MI_F_2, | ||
| 192 | MI_Fs_2, | ||
| 193 | MI_Gb_2 = MI_Fs_2, | ||
| 194 | MI_G_2, | ||
| 195 | MI_Gs_2, | ||
| 196 | MI_Ab_2 = MI_Gs_2, | ||
| 197 | MI_A_2, | ||
| 198 | MI_As_2, | ||
| 199 | MI_Bb_2 = MI_As_2, | ||
| 200 | MI_B_2, | ||
| 201 | #endif | ||
| 202 | |||
| 203 | #if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 3 | ||
| 204 | MI_C_3, | ||
| 205 | MI_Cs_3, | ||
| 206 | MI_Db_3 = MI_Cs_3, | ||
| 207 | MI_D_3, | ||
| 208 | MI_Ds_3, | ||
| 209 | MI_Eb_3 = MI_Ds_3, | ||
| 210 | MI_E_3, | ||
| 211 | MI_F_3, | ||
| 212 | MI_Fs_3, | ||
| 213 | MI_Gb_3 = MI_Fs_3, | ||
| 214 | MI_G_3, | ||
| 215 | MI_Gs_3, | ||
| 216 | MI_Ab_3 = MI_Gs_3, | ||
| 217 | MI_A_3, | ||
| 218 | MI_As_3, | ||
| 219 | MI_Bb_3 = MI_As_3, | ||
| 220 | MI_B_3, | ||
| 221 | #endif | ||
| 222 | |||
| 223 | #if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 4 | ||
| 224 | MI_C_4, | ||
| 225 | MI_Cs_4, | ||
| 226 | MI_Db_4 = MI_Cs_4, | ||
| 227 | MI_D_4, | ||
| 228 | MI_Ds_4, | ||
| 229 | MI_Eb_4 = MI_Ds_4, | ||
| 230 | MI_E_4, | ||
| 231 | MI_F_4, | ||
| 232 | MI_Fs_4, | ||
| 233 | MI_Gb_4 = MI_Fs_4, | ||
| 234 | MI_G_4, | ||
| 235 | MI_Gs_4, | ||
| 236 | MI_Ab_4 = MI_Gs_4, | ||
| 237 | MI_A_4, | ||
| 238 | MI_As_4, | ||
| 239 | MI_Bb_4 = MI_As_4, | ||
| 240 | MI_B_4, | ||
| 241 | #endif | ||
| 242 | |||
| 243 | #if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 5 | ||
| 244 | MI_C_5, | ||
| 245 | MI_Cs_5, | ||
| 246 | MI_Db_5 = MI_Cs_5, | ||
| 247 | MI_D_5, | ||
| 248 | MI_Ds_5, | ||
| 249 | MI_Eb_5 = MI_Ds_5, | ||
| 250 | MI_E_5, | ||
| 251 | MI_F_5, | ||
| 252 | MI_Fs_5, | ||
| 253 | MI_Gb_5 = MI_Fs_5, | ||
| 254 | MI_G_5, | ||
| 255 | MI_Gs_5, | ||
| 256 | MI_Ab_5 = MI_Gs_5, | ||
| 257 | MI_A_5, | ||
| 258 | MI_As_5, | ||
| 259 | MI_Bb_5 = MI_As_5, | ||
| 260 | MI_B_5, | ||
| 261 | #endif | ||
| 262 | |||
| 263 | #if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 5 | ||
| 264 | MIDI_TONE_MAX = MI_B_5, | ||
| 265 | #elif MIDI_TONE_KEYCODE_OCTAVES > 4 | ||
| 266 | MIDI_TONE_MAX = MI_B_4, | ||
| 267 | #elif MIDI_TONE_KEYCODE_OCTAVES > 3 | ||
| 268 | MIDI_TONE_MAX = MI_B_3, | ||
| 269 | #elif MIDI_TONE_KEYCODE_OCTAVES > 2 | ||
| 270 | MIDI_TONE_MAX = MI_B_2, | ||
| 271 | #elif MIDI_TONE_KEYCODE_OCTAVES > 1 | ||
| 272 | MIDI_TONE_MAX = MI_B_1, | ||
| 273 | #elif MIDI_TONE_KEYCODE_OCTAVES > 0 | ||
| 274 | MIDI_TONE_MAX = MI_B, | ||
| 275 | #endif | ||
| 276 | |||
| 277 | MIDI_OCTAVE_MIN, | ||
| 278 | MI_OCT_N2 = MIDI_OCTAVE_MIN, | ||
| 279 | MI_OCT_N1, | ||
| 280 | MI_OCT_0, | ||
| 281 | MI_OCT_1, | ||
| 282 | MI_OCT_2, | ||
| 283 | MI_OCT_3, | ||
| 284 | MI_OCT_4, | ||
| 285 | MI_OCT_5, | ||
| 286 | MI_OCT_6, | ||
| 287 | MI_OCT_7, | ||
| 288 | MIDI_OCTAVE_MAX = MI_OCT_7, | ||
| 289 | MI_OCTD, // octave down | ||
| 290 | MI_OCTU, // octave up | ||
| 291 | |||
| 292 | MIDI_TRANSPOSE_MIN, | ||
| 293 | MI_TRNS_N6 = MIDI_TRANSPOSE_MIN, | ||
| 294 | MI_TRNS_N5, | ||
| 295 | MI_TRNS_N4, | ||
| 296 | MI_TRNS_N3, | ||
| 297 | MI_TRNS_N2, | ||
| 298 | MI_TRNS_N1, | ||
| 299 | MI_TRNS_0, | ||
| 300 | MI_TRNS_1, | ||
| 301 | MI_TRNS_2, | ||
| 302 | MI_TRNS_3, | ||
| 303 | MI_TRNS_4, | ||
| 304 | MI_TRNS_5, | ||
| 305 | MI_TRNS_6, | ||
| 306 | MIDI_TRANSPOSE_MAX = MI_TRNS_6, | ||
| 307 | MI_TRNSD, // transpose down | ||
| 308 | MI_TRNSU, // transpose up | ||
| 309 | |||
| 310 | MIDI_VELOCITY_MIN, | ||
| 311 | MI_VEL_1 = MIDI_VELOCITY_MIN, | ||
| 312 | MI_VEL_2, | ||
| 313 | MI_VEL_3, | ||
| 314 | MI_VEL_4, | ||
| 315 | MI_VEL_5, | ||
| 316 | MI_VEL_6, | ||
| 317 | MI_VEL_7, | ||
| 318 | MI_VEL_8, | ||
| 319 | MI_VEL_9, | ||
| 320 | MI_VEL_10, | ||
| 321 | MIDI_VELOCITY_MAX = MI_VEL_10, | ||
| 322 | MI_VELD, // velocity down | ||
| 323 | MI_VELU, // velocity up | ||
| 324 | |||
| 325 | MIDI_CHANNEL_MIN, | ||
| 326 | MI_CH1 = MIDI_CHANNEL_MIN, | ||
| 327 | MI_CH2, | ||
| 328 | MI_CH3, | ||
| 329 | MI_CH4, | ||
| 330 | MI_CH5, | ||
| 331 | MI_CH6, | ||
| 332 | MI_CH7, | ||
| 333 | MI_CH8, | ||
| 334 | MI_CH9, | ||
| 335 | MI_CH10, | ||
| 336 | MI_CH11, | ||
| 337 | MI_CH12, | ||
| 338 | MI_CH13, | ||
| 339 | MI_CH14, | ||
| 340 | MI_CH15, | ||
| 341 | MI_CH16, | ||
| 342 | MIDI_CHANNEL_MAX = MI_CH16, | ||
| 343 | MI_CHD, // previous channel | ||
| 344 | MI_CHU, // next channel | ||
| 345 | |||
| 346 | MI_ALLOFF, // all notes off | ||
| 347 | |||
| 348 | MI_SUS, // sustain | ||
| 349 | MI_PORT, // portamento | ||
| 350 | MI_SOST, // sostenuto | ||
| 351 | MI_SOFT, // soft pedal | ||
| 352 | MI_LEG, // legato | ||
| 353 | |||
| 354 | MI_MOD, // modulation | ||
| 355 | MI_MODSD, // decrease modulation speed | ||
| 356 | MI_MODSU, // increase modulation speed | ||
| 357 | #endif // MIDI_ADVANCED | ||
| 101 | 358 | ||
| 102 | // Backlight functionality | 359 | // Backlight functionality |
| 103 | BL_0, | 360 | BL_0, |
| @@ -141,6 +398,13 @@ enum quantum_keycodes { | |||
| 141 | PRINT_ON, | 398 | PRINT_ON, |
| 142 | PRINT_OFF, | 399 | PRINT_OFF, |
| 143 | 400 | ||
| 401 | // output selection | ||
| 402 | OUT_AUTO, | ||
| 403 | OUT_USB, | ||
| 404 | #ifdef BLUETOOTH_ENABLE | ||
| 405 | OUT_BT, | ||
| 406 | #endif | ||
| 407 | |||
| 144 | // always leave at the end | 408 | // always leave at the end |
| 145 | SAFE_RANGE | 409 | SAFE_RANGE |
| 146 | }; | 410 | }; |
| @@ -161,6 +425,7 @@ enum quantum_keycodes { | |||
| 161 | #define ALTG(kc) (kc | QK_RCTL | QK_RALT) | 425 | #define ALTG(kc) (kc | QK_RCTL | QK_RALT) |
| 162 | #define SCMD(kc) (kc | QK_LGUI | QK_LSFT) | 426 | #define SCMD(kc) (kc | QK_LGUI | QK_LSFT) |
| 163 | #define SWIN(kc) SCMD(kc) | 427 | #define SWIN(kc) SCMD(kc) |
| 428 | #define LCA(kc) (kc | QK_LCTL | QK_LALT) | ||
| 164 | 429 | ||
| 165 | #define MOD_HYPR 0xf | 430 | #define MOD_HYPR 0xf |
| 166 | #define MOD_MEH 0x7 | 431 | #define MOD_MEH 0x7 |
| @@ -246,8 +511,10 @@ enum quantum_keycodes { | |||
| 246 | 511 | ||
| 247 | #define M(kc) (kc | QK_MACRO) | 512 | #define M(kc) (kc | QK_MACRO) |
| 248 | 513 | ||
| 514 | #define MACROTAP(kc) (kc | QK_MACRO | FUNC_TAP<<8) | ||
| 249 | #define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE) | 515 | #define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE) |
| 250 | 516 | ||
| 517 | |||
| 251 | // L-ayer, T-ap - 256 keycode max, 16 layer max | 518 | // L-ayer, T-ap - 256 keycode max, 16 layer max |
| 252 | #define LT(layer, kc) (kc | QK_LAYER_TAP | ((layer & 0xF) << 8)) | 519 | #define LT(layer, kc) (kc | QK_LAYER_TAP | ((layer & 0xF) << 8)) |
| 253 | 520 | ||
| @@ -257,9 +524,6 @@ enum quantum_keycodes { | |||
| 257 | #define BL_ON BL_9 | 524 | #define BL_ON BL_9 |
| 258 | #define BL_OFF BL_0 | 525 | #define BL_OFF BL_0 |
| 259 | 526 | ||
| 260 | #define MI_ON MIDI_ON | ||
| 261 | #define MI_OFF MIDI_OFF | ||
| 262 | |||
| 263 | // GOTO layer - 16 layers max | 527 | // GOTO layer - 16 layers max |
| 264 | // when: | 528 | // when: |
| 265 | // ON_PRESS = 1 | 529 | // ON_PRESS = 1 |
| @@ -285,18 +549,37 @@ enum quantum_keycodes { | |||
| 285 | // One-shot mod | 549 | // One-shot mod |
| 286 | #define OSM(mod) (mod | QK_ONE_SHOT_MOD) | 550 | #define OSM(mod) (mod | QK_ONE_SHOT_MOD) |
| 287 | 551 | ||
| 552 | // Layer tap-toggle | ||
| 553 | #define TT(layer) (layer | QK_LAYER_TAP_TOGGLE) | ||
| 554 | |||
| 288 | // M-od, T-ap - 256 keycode max | 555 | // M-od, T-ap - 256 keycode max |
| 289 | #define MT(mod, kc) (kc | QK_MOD_TAP | ((mod & 0xF) << 8)) | 556 | #define MT(mod, kc) (kc | QK_MOD_TAP | ((mod & 0x1F) << 8)) |
| 557 | |||
| 290 | #define CTL_T(kc) MT(MOD_LCTL, kc) | 558 | #define CTL_T(kc) MT(MOD_LCTL, kc) |
| 559 | #define LCTL_T(kc) MT(MOD_LCTL, kc) | ||
| 560 | #define RCTL_T(kc) MT(MOD_RCTL, kc) | ||
| 561 | |||
| 291 | #define SFT_T(kc) MT(MOD_LSFT, kc) | 562 | #define SFT_T(kc) MT(MOD_LSFT, kc) |
| 563 | #define LSFT_T(kc) MT(MOD_LSFT, kc) | ||
| 564 | #define RSFT_T(kc) MT(MOD_RSFT, kc) | ||
| 565 | |||
| 292 | #define ALT_T(kc) MT(MOD_LALT, kc) | 566 | #define ALT_T(kc) MT(MOD_LALT, kc) |
| 567 | #define LALT_T(kc) MT(MOD_LALT, kc) | ||
| 568 | #define RALT_T(kc) MT(MOD_RALT, kc) | ||
| 569 | #define ALGR_T(kc) MT(MOD_RALT, kc) // dual-function AltGR | ||
| 570 | |||
| 293 | #define GUI_T(kc) MT(MOD_LGUI, kc) | 571 | #define GUI_T(kc) MT(MOD_LGUI, kc) |
| 572 | #define LGUI_T(kc) MT(MOD_LGUI, kc) | ||
| 573 | #define RGUI_T(kc) MT(MOD_RGUI, kc) | ||
| 574 | |||
| 294 | #define C_S_T(kc) MT((MOD_LCTL | MOD_LSFT), kc) // Control + Shift e.g. for gnome-terminal | 575 | #define C_S_T(kc) MT((MOD_LCTL | MOD_LSFT), kc) // Control + Shift e.g. for gnome-terminal |
| 295 | #define MEH_T(kc) MT((MOD_LCTL | MOD_LSFT | MOD_LALT), kc) // Meh is a less hyper version of the Hyper key -- doesn't include Win or Cmd, so just alt+shift+ctrl | 576 | #define MEH_T(kc) MT((MOD_LCTL | MOD_LSFT | MOD_LALT), kc) // Meh is a less hyper version of the Hyper key -- doesn't include Win or Cmd, so just alt+shift+ctrl |
| 296 | #define LCAG_T(kc) MT((MOD_LCTL | MOD_LALT | MOD_LGUI), kc) // Left control alt and gui | 577 | #define LCAG_T(kc) MT((MOD_LCTL | MOD_LALT | MOD_LGUI), kc) // Left control alt and gui |
| 578 | #define RCAG_T(kc) MT((MOD_RCTL | MOD_RALT | MOD_RGUI), kc) // Right control alt and gui | ||
| 297 | #define ALL_T(kc) MT((MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI), kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/ | 579 | #define ALL_T(kc) MT((MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI), kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/ |
| 298 | #define SCMD_T(kc) MT((MOD_LGUI | MOD_LSFT), kc) | 580 | #define SCMD_T(kc) MT((MOD_LGUI | MOD_LSFT), kc) |
| 299 | #define SWIN_T(kc) SCMD_T(kc) | 581 | #define SWIN_T(kc) SCMD_T(kc) |
| 582 | #define LCA_T(kc) MT((MOD_LCTL | MOD_LALT), kc) // Left control and left alt | ||
| 300 | 583 | ||
| 301 | // Dedicated keycode versions for Hyper and Meh, if you want to use them as standalone keys rather than mod-tap | 584 | // Dedicated keycode versions for Hyper and Meh, if you want to use them as standalone keys rather than mod-tap |
| 302 | #define KC_HYPR HYPR(KC_NO) | 585 | #define KC_HYPR HYPR(KC_NO) |
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 52a09817a..eff70aae1 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2016-2017 Yang Liu | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #include <avr/eeprom.h> | 16 | #include <avr/eeprom.h> |
| 2 | #include <avr/interrupt.h> | 17 | #include <avr/interrupt.h> |
| 3 | #include <util/delay.h> | 18 | #include <util/delay.h> |
| @@ -66,6 +81,8 @@ __attribute__ ((weak)) | |||
| 66 | const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20}; | 81 | const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20}; |
| 67 | __attribute__ ((weak)) | 82 | __attribute__ ((weak)) |
| 68 | const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {100, 50, 20}; | 83 | const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {100, 50, 20}; |
| 84 | __attribute__ ((weak)) | ||
| 85 | const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90}; | ||
| 69 | 86 | ||
| 70 | rgblight_config_t rgblight_config; | 87 | rgblight_config_t rgblight_config; |
| 71 | rgblight_config_t inmem_config; | 88 | rgblight_config_t inmem_config; |
| @@ -219,6 +236,14 @@ void rgblight_step(void) { | |||
| 219 | } | 236 | } |
| 220 | rgblight_mode(mode); | 237 | rgblight_mode(mode); |
| 221 | } | 238 | } |
| 239 | void rgblight_step_reverse(void) { | ||
| 240 | uint8_t mode = 0; | ||
| 241 | mode = rgblight_config.mode - 1; | ||
| 242 | if (mode < 1) { | ||
| 243 | mode = RGBLIGHT_MODES; | ||
| 244 | } | ||
| 245 | rgblight_mode(mode); | ||
| 246 | } | ||
| 222 | 247 | ||
| 223 | void rgblight_mode(uint8_t mode) { | 248 | void rgblight_mode(uint8_t mode) { |
| 224 | if (!rgblight_config.enable) { | 249 | if (!rgblight_config.enable) { |
| @@ -237,7 +262,7 @@ void rgblight_mode(uint8_t mode) { | |||
| 237 | #ifdef RGBLIGHT_ANIMATIONS | 262 | #ifdef RGBLIGHT_ANIMATIONS |
| 238 | rgblight_timer_disable(); | 263 | rgblight_timer_disable(); |
| 239 | #endif | 264 | #endif |
| 240 | } else if (rgblight_config.mode >= 2 && rgblight_config.mode <= 23) { | 265 | } else if (rgblight_config.mode >= 2 && rgblight_config.mode <= 24) { |
| 241 | // MODE 2-5, breathing | 266 | // MODE 2-5, breathing |
| 242 | // MODE 6-8, rainbow mood | 267 | // MODE 6-8, rainbow mood |
| 243 | // MODE 9-14, rainbow swirl | 268 | // MODE 9-14, rainbow swirl |
| @@ -247,6 +272,12 @@ void rgblight_mode(uint8_t mode) { | |||
| 247 | #ifdef RGBLIGHT_ANIMATIONS | 272 | #ifdef RGBLIGHT_ANIMATIONS |
| 248 | rgblight_timer_enable(); | 273 | rgblight_timer_enable(); |
| 249 | #endif | 274 | #endif |
| 275 | } else if (rgblight_config.mode >= 25 && rgblight_config.mode <= 34) { | ||
| 276 | // MODE 25-34, static gradient | ||
| 277 | |||
| 278 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 279 | rgblight_timer_disable(); | ||
| 280 | #endif | ||
| 250 | } | 281 | } |
| 251 | rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); | 282 | rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); |
| 252 | } | 283 | } |
| @@ -350,6 +381,17 @@ void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { | |||
| 350 | } else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 14) { | 381 | } else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 14) { |
| 351 | // rainbow mood and rainbow swirl, ignore the change of hue | 382 | // rainbow mood and rainbow swirl, ignore the change of hue |
| 352 | hue = rgblight_config.hue; | 383 | hue = rgblight_config.hue; |
| 384 | } else if (rgblight_config.mode >= 25 && rgblight_config.mode <= 34) { | ||
| 385 | // static gradient | ||
| 386 | uint16_t _hue; | ||
| 387 | int8_t direction = ((rgblight_config.mode - 25) % 2) ? -1 : 1; | ||
| 388 | uint16_t range = pgm_read_word(&RGBLED_GRADIENT_RANGES[(rgblight_config.mode - 25) / 2]); | ||
| 389 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { | ||
| 390 | _hue = (range / RGBLED_NUM * i * direction + hue + 360) % 360; | ||
| 391 | dprintf("rgblight rainbow set hsv: %u,%u,%d,%u\n", i, _hue, direction, range); | ||
| 392 | sethsv(_hue, sat, val, (LED_TYPE *)&led[i]); | ||
| 393 | } | ||
| 394 | rgblight_set(); | ||
| 353 | } | 395 | } |
| 354 | } | 396 | } |
| 355 | rgblight_config.hue = hue; | 397 | rgblight_config.hue = hue; |
| @@ -450,7 +492,7 @@ void rgblight_task(void) { | |||
| 450 | } else if (rgblight_config.mode >= 21 && rgblight_config.mode <= 23) { | 492 | } else if (rgblight_config.mode >= 21 && rgblight_config.mode <= 23) { |
| 451 | // mode = 21 to 23, knight mode | 493 | // mode = 21 to 23, knight mode |
| 452 | rgblight_effect_knight(rgblight_config.mode - 21); | 494 | rgblight_effect_knight(rgblight_config.mode - 21); |
| 453 | } else { | 495 | } else if (rgblight_config.mode == 24) { |
| 454 | // mode = 24, christmas mode | 496 | // mode = 24, christmas mode |
| 455 | rgblight_effect_christmas(); | 497 | rgblight_effect_christmas(); |
| 456 | } | 498 | } |
| @@ -604,13 +646,13 @@ void rgblight_effect_christmas(void) { | |||
| 604 | static uint16_t last_timer = 0; | 646 | static uint16_t last_timer = 0; |
| 605 | uint16_t hue; | 647 | uint16_t hue; |
| 606 | uint8_t i; | 648 | uint8_t i; |
| 607 | if (timer_elapsed(last_timer) < 1000) { | 649 | if (timer_elapsed(last_timer) < RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL) { |
| 608 | return; | 650 | return; |
| 609 | } | 651 | } |
| 610 | last_timer = timer_read(); | 652 | last_timer = timer_read(); |
| 611 | current_offset = (current_offset + 1) % 2; | 653 | current_offset = (current_offset + 1) % 2; |
| 612 | for (i = 0; i < RGBLED_NUM; i++) { | 654 | for (i = 0; i < RGBLED_NUM; i++) { |
| 613 | hue = 0 + ((RGBLED_NUM * (i + current_offset)) % 2) * 80; | 655 | hue = 0 + ((i/RGBLIGHT_EFFECT_CHRISTMAS_STEP + current_offset) % 2) * 120; |
| 614 | sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]); | 656 | sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]); |
| 615 | } | 657 | } |
| 616 | rgblight_set(); | 658 | rgblight_set(); |
diff --git a/quantum/rgblight.h b/quantum/rgblight.h index 726b8de72..92130192c 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h | |||
| @@ -1,8 +1,23 @@ | |||
| 1 | /* Copyright 2017 Yang Liu | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #ifndef RGBLIGHT_H | 16 | #ifndef RGBLIGHT_H |
| 2 | #define RGBLIGHT_H | 17 | #define RGBLIGHT_H |
| 3 | 18 | ||
| 4 | #ifdef RGBLIGHT_ANIMATIONS | 19 | #ifdef RGBLIGHT_ANIMATIONS |
| 5 | #define RGBLIGHT_MODES 24 | 20 | #define RGBLIGHT_MODES 34 |
| 6 | #else | 21 | #else |
| 7 | #define RGBLIGHT_MODES 1 | 22 | #define RGBLIGHT_MODES 1 |
| 8 | #endif | 23 | #endif |
| @@ -22,6 +37,14 @@ | |||
| 22 | #define RGBLIGHT_EFFECT_DUALKNIGHT_LENGTH 4 | 37 | #define RGBLIGHT_EFFECT_DUALKNIGHT_LENGTH 4 |
| 23 | #endif | 38 | #endif |
| 24 | 39 | ||
| 40 | #ifndef RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL | ||
| 41 | #define RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL 1000 | ||
| 42 | #endif | ||
| 43 | |||
| 44 | #ifndef RGBLIGHT_EFFECT_CHRISTMAS_STEP | ||
| 45 | #define RGBLIGHT_EFFECT_CHRISTMAS_STEP 2 | ||
| 46 | #endif | ||
| 47 | |||
| 25 | #ifndef RGBLIGHT_HUE_STEP | 48 | #ifndef RGBLIGHT_HUE_STEP |
| 26 | #define RGBLIGHT_HUE_STEP 10 | 49 | #define RGBLIGHT_HUE_STEP 10 |
| 27 | #endif | 50 | #endif |
| @@ -65,6 +88,7 @@ void rgblight_decrease(void); | |||
| 65 | void rgblight_toggle(void); | 88 | void rgblight_toggle(void); |
| 66 | void rgblight_enable(void); | 89 | void rgblight_enable(void); |
| 67 | void rgblight_step(void); | 90 | void rgblight_step(void); |
| 91 | void rgblight_step_reverse(void); | ||
| 68 | void rgblight_mode(uint8_t mode); | 92 | void rgblight_mode(uint8_t mode); |
| 69 | void rgblight_set(void); | 93 | void rgblight_set(void); |
| 70 | void rgblight_update_dword(uint32_t dword); | 94 | void rgblight_update_dword(uint32_t dword); |
diff --git a/quantum/serial_link/LICENSE b/quantum/serial_link/LICENSE index d7cc3198c..d13cc4b26 100644 --- a/quantum/serial_link/LICENSE +++ b/quantum/serial_link/LICENSE | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | The MIT License (MIT) | 1 | The MIT License (MIT) |
| 2 | 2 | ||
| 3 | Copyright (c) 2016 Fred Sundvik | ||
| 4 | |||
| 5 | Permission is hereby granted, free of charge, to any person obtaining a copy | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | of this software and associated documentation files (the "Software"), to deal | 4 | of this software and associated documentation files (the "Software"), to deal |
| 7 | in the Software without restriction, including without limitation the rights | 5 | in the Software without restriction, including without limitation the rights |
diff --git a/quantum/template/Makefile b/quantum/template/Makefile index 4e2a6f00f..840dc9a28 100644 --- a/quantum/template/Makefile +++ b/quantum/template/Makefile | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | # Copyright 2013 Jun Wako <wakojun@gmail.com> | ||
| 2 | # | ||
| 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 | # | ||
| 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 | # | ||
| 13 | # You should have received a copy of the GNU General Public License | ||
| 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | |||
| 1 | ifndef MAKEFILE_INCLUDED | 16 | ifndef MAKEFILE_INCLUDED |
| 2 | include ../../Makefile | 17 | include ../../Makefile |
| 3 | endif \ No newline at end of file | 18 | endif |
diff --git a/quantum/template/config.h b/quantum/template/config.h index b02f0c7eb..dbca45765 100644 --- a/quantum/template/config.h +++ b/quantum/template/config.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | 2 | Copyright 2017 REPLACE_WITH_YOUR_NAME |
| 3 | 3 | ||
| 4 | This program is free software: you can redistribute it and/or modify | 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 | 5 | it under the terms of the GNU General Public License as published by |
| @@ -46,7 +46,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 46 | #define MATRIX_COL_PINS { F1, F0, B0 } | 46 | #define MATRIX_COL_PINS { F1, F0, B0 } |
| 47 | #define UNUSED_PINS | 47 | #define UNUSED_PINS |
| 48 | 48 | ||
| 49 | /* COL2ROW or ROW2COL */ | 49 | /* COL2ROW, ROW2COL, or CUSTOM_MATRIX */ |
| 50 | #define DIODE_DIRECTION COL2ROW | 50 | #define DIODE_DIRECTION COL2ROW |
| 51 | 51 | ||
| 52 | // #define BACKLIGHT_PIN B7 | 52 | // #define BACKLIGHT_PIN B7 |
| @@ -159,4 +159,27 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 159 | //#define NO_ACTION_MACRO | 159 | //#define NO_ACTION_MACRO |
| 160 | //#define NO_ACTION_FUNCTION | 160 | //#define NO_ACTION_FUNCTION |
| 161 | 161 | ||
| 162 | /* | ||
| 163 | * MIDI options | ||
| 164 | */ | ||
| 165 | |||
| 166 | /* Prevent use of disabled MIDI features in the keymap */ | ||
| 167 | //#define MIDI_ENABLE_STRICT 1 | ||
| 168 | |||
| 169 | /* enable basic MIDI features: | ||
| 170 | - MIDI notes can be sent when in Music mode is on | ||
| 171 | */ | ||
| 172 | //#define MIDI_BASIC | ||
| 173 | |||
| 174 | /* enable advanced MIDI features: | ||
| 175 | - MIDI notes can be added to the keymap | ||
| 176 | - Octave shift and transpose | ||
| 177 | - Virtual sustain, portamento, and modulation wheel | ||
| 178 | - etc. | ||
| 179 | */ | ||
| 180 | //#define MIDI_ADVANCED | ||
| 181 | |||
| 182 | /* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */ | ||
| 183 | //#define MIDI_TONE_KEYCODE_OCTAVES 1 | ||
| 184 | |||
| 162 | #endif | 185 | #endif |
diff --git a/quantum/template/keymaps/default/Makefile b/quantum/template/keymaps/default/Makefile index f4671a9d1..b8879076b 100644 --- a/quantum/template/keymaps/default/Makefile +++ b/quantum/template/keymaps/default/Makefile | |||
| @@ -1,4 +1,20 @@ | |||
| 1 | # Build Options | 1 | # Copyright 2013 Jun Wako <wakojun@gmail.com> |
| 2 | # | ||
| 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 | # | ||
| 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 | # | ||
| 13 | # You should have received a copy of the GNU General Public License | ||
| 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | |||
| 16 | |||
| 17 | # QMK Build Options | ||
| 2 | # change to "no" to disable the options, or define them in the Makefile in | 18 | # change to "no" to disable the options, or define them in the Makefile in |
| 3 | # the appropriate keymap folder that will get included automatically | 19 | # the appropriate keymap folder that will get included automatically |
| 4 | # | 20 | # |
| @@ -9,7 +25,7 @@ CONSOLE_ENABLE = no # Console for debug(+400) | |||
| 9 | COMMAND_ENABLE = yes # Commands for debug and configuration | 25 | COMMAND_ENABLE = yes # 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 | 26 | 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 = no # Enable keyboard backlight functionality | 27 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality |
| 12 | MIDI_ENABLE = no # MIDI controls | 28 | MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config) |
| 13 | AUDIO_ENABLE = no # Audio output on port C6 | 29 | AUDIO_ENABLE = no # Audio output on port C6 |
| 14 | UNICODE_ENABLE = no # Unicode | 30 | UNICODE_ENABLE = no # Unicode |
| 15 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | 31 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID |
| @@ -18,4 +34,4 @@ SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | |||
| 18 | 34 | ||
| 19 | ifndef QUANTUM_DIR | 35 | ifndef QUANTUM_DIR |
| 20 | include ../../../../Makefile | 36 | include ../../../../Makefile |
| 21 | endif \ No newline at end of file | 37 | endif |
diff --git a/quantum/template/keymaps/default/config.h b/quantum/template/keymaps/default/config.h index df06a2620..f52a97bbc 100644 --- a/quantum/template/keymaps/default/config.h +++ b/quantum/template/keymaps/default/config.h | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2017 REPLACE_WITH_YOUR_NAME | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #ifndef CONFIG_USER_H | 17 | #ifndef CONFIG_USER_H |
| 2 | #define CONFIG_USER_H | 18 | #define CONFIG_USER_H |
| 3 | 19 | ||
| @@ -5,4 +21,4 @@ | |||
| 5 | 21 | ||
| 6 | // place overrides here | 22 | // place overrides here |
| 7 | 23 | ||
| 8 | #endif \ No newline at end of file | 24 | #endif |
diff --git a/quantum/template/keymaps/default/keymap.c b/quantum/template/keymaps/default/keymap.c index e28a4723e..a123cd7ba 100644 --- a/quantum/template/keymaps/default/keymap.c +++ b/quantum/template/keymaps/default/keymap.c | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2017 REPLACE_WITH_YOUR_NAME | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #include "%KEYBOARD%.h" | 16 | #include "%KEYBOARD%.h" |
| 2 | 17 | ||
| 3 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | 18 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { |
| @@ -41,4 +56,4 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 41 | 56 | ||
| 42 | void led_set_user(uint8_t usb_led) { | 57 | void led_set_user(uint8_t usb_led) { |
| 43 | 58 | ||
| 44 | } \ No newline at end of file | 59 | } |
diff --git a/quantum/template/rules.mk b/quantum/template/rules.mk index 55898147d..a1f9377d8 100644 --- a/quantum/template/rules.mk +++ b/quantum/template/rules.mk | |||
| @@ -61,7 +61,8 @@ SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend | |||
| 61 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | 61 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work |
| 62 | NKRO_ENABLE ?= no # USB Nkey Rollover | 62 | NKRO_ENABLE ?= no # USB Nkey Rollover |
| 63 | BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality on B7 by default | 63 | BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality on B7 by default |
| 64 | MIDI_ENABLE ?= no # MIDI controls | 64 | MIDI_ENABLE ?= no # MIDI support (+2400 to 4200, depending on config) |
| 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/quantum/template/template.c b/quantum/template/template.c index 5ef349583..97f788654 100644 --- a/quantum/template/template.c +++ b/quantum/template/template.c | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2017 REPLACE_WITH_YOUR_NAME | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #include "%KEYBOARD%.h" | 16 | #include "%KEYBOARD%.h" |
| 2 | 17 | ||
| 3 | void matrix_init_kb(void) { | 18 | void matrix_init_kb(void) { |
diff --git a/quantum/template/template.h b/quantum/template/template.h index cd78a54e3..7e2b14f3c 100644 --- a/quantum/template/template.h +++ b/quantum/template/template.h | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2017 REPLACE_WITH_YOUR_NAME | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #ifndef %KEYBOARD_UPPERCASE%_H | 16 | #ifndef %KEYBOARD_UPPERCASE%_H |
| 2 | #define %KEYBOARD_UPPERCASE%_H | 17 | #define %KEYBOARD_UPPERCASE%_H |
| 3 | 18 | ||
| @@ -5,7 +20,7 @@ | |||
| 5 | 20 | ||
| 6 | // This a shortcut to help you visually see your layout. | 21 | // This a shortcut to help you visually see your layout. |
| 7 | // The following is an example using the Planck MIT layout | 22 | // The following is an example using the Planck MIT layout |
| 8 | // The first section contains all of the arguements | 23 | // The first section contains all of the arguments |
| 9 | // The second converts the arguments into a two-dimensional array | 24 | // The second converts the arguments into a two-dimensional array |
| 10 | #define KEYMAP( \ | 25 | #define KEYMAP( \ |
| 11 | k00, k01, k02, \ | 26 | k00, k01, k02, \ |
diff --git a/quantum/variable_trace.c b/quantum/variable_trace.c index de580244c..713747cfc 100644 --- a/quantum/variable_trace.c +++ b/quantum/variable_trace.c | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2016 Fred Sundvik | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #include "variable_trace.h" | 17 | #include "variable_trace.h" |
| 2 | #include <stddef.h> | 18 | #include <stddef.h> |
| 3 | #include <string.h> | 19 | #include <string.h> |
diff --git a/quantum/variable_trace.h b/quantum/variable_trace.h index 46bd82786..dacc13858 100644 --- a/quantum/variable_trace.h +++ b/quantum/variable_trace.h | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2016 Fred Sundvik | ||
| 2 | * | ||
| 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 | * | ||
| 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 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #ifndef VARIABLE_TRACE_H | 17 | #ifndef VARIABLE_TRACE_H |
| 2 | #define VARIABLE_TRACE_H | 18 | #define VARIABLE_TRACE_H |
| 3 | 19 | ||
diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c index 54f6faaa4..5826d909e 100644 --- a/quantum/visualizer/visualizer.c +++ b/quantum/visualizer/visualizer.c | |||
| @@ -53,10 +53,13 @@ SOFTWARE. | |||
| 53 | #define "Visualizer thread priority not defined" | 53 | #define "Visualizer thread priority not defined" |
| 54 | #endif | 54 | #endif |
| 55 | 55 | ||
| 56 | // mods status | ||
| 57 | #include "action_util.h" | ||
| 56 | 58 | ||
| 57 | static visualizer_keyboard_status_t current_status = { | 59 | static visualizer_keyboard_status_t current_status = { |
| 58 | .layer = 0xFFFFFFFF, | 60 | .layer = 0xFFFFFFFF, |
| 59 | .default_layer = 0xFFFFFFFF, | 61 | .default_layer = 0xFFFFFFFF, |
| 62 | .mods = 0xFF, | ||
| 60 | .leds = 0xFFFFFFFF, | 63 | .leds = 0xFFFFFFFF, |
| 61 | .suspended = false, | 64 | .suspended = false, |
| 62 | }; | 65 | }; |
| @@ -64,6 +67,7 @@ static visualizer_keyboard_status_t current_status = { | |||
| 64 | static bool same_status(visualizer_keyboard_status_t* status1, visualizer_keyboard_status_t* status2) { | 67 | static bool same_status(visualizer_keyboard_status_t* status1, visualizer_keyboard_status_t* status2) { |
| 65 | return status1->layer == status2->layer && | 68 | return status1->layer == status2->layer && |
| 66 | status1->default_layer == status2->default_layer && | 69 | status1->default_layer == status2->default_layer && |
| 70 | status1->mods == status2->mods && | ||
| 67 | status1->leds == status2->leds && | 71 | status1->leds == status2->leds && |
| 68 | status1->suspended == status2->suspended; | 72 | status1->suspended == status2->suspended; |
| 69 | } | 73 | } |
| @@ -307,6 +311,45 @@ bool keyframe_display_layer_bitmap(keyframe_animation_t* animation, visualizer_s | |||
| 307 | gdispFlush(); | 311 | gdispFlush(); |
| 308 | return false; | 312 | return false; |
| 309 | } | 313 | } |
| 314 | |||
| 315 | static void format_mods_bitmap_string(uint8_t mods, char* buffer) { | ||
| 316 | *buffer = ' '; | ||
| 317 | ++buffer; | ||
| 318 | |||
| 319 | for (int i = 0; i<8; i++) | ||
| 320 | { | ||
| 321 | uint32_t mask = (1u << i); | ||
| 322 | if (mods & mask) { | ||
| 323 | *buffer = '1'; | ||
| 324 | } else { | ||
| 325 | *buffer = '0'; | ||
| 326 | } | ||
| 327 | ++buffer; | ||
| 328 | |||
| 329 | if (i==3) { | ||
| 330 | *buffer = ' '; | ||
| 331 | ++buffer; | ||
| 332 | } | ||
| 333 | } | ||
| 334 | *buffer = 0; | ||
| 335 | } | ||
| 336 | |||
| 337 | bool keyframe_display_mods_bitmap(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 338 | (void)animation; | ||
| 339 | |||
| 340 | const char* title = "Modifier states"; | ||
| 341 | const char* mods_header = " CSAG CSAG "; | ||
| 342 | char status_buffer[12]; | ||
| 343 | |||
| 344 | gdispClear(White); | ||
| 345 | gdispDrawString(0, 0, title, state->font_fixed5x8, Black); | ||
| 346 | gdispDrawString(0, 10, mods_header, state->font_fixed5x8, Black); | ||
| 347 | format_mods_bitmap_string(state->status.mods, status_buffer); | ||
| 348 | gdispDrawString(0, 20, status_buffer, state->font_fixed5x8, Black); | ||
| 349 | |||
| 350 | gdispFlush(); | ||
| 351 | return false; | ||
| 352 | } | ||
| 310 | #endif // LCD_ENABLE | 353 | #endif // LCD_ENABLE |
| 311 | 354 | ||
| 312 | bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state) { | 355 | bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state) { |
| @@ -350,6 +393,7 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) { | |||
| 350 | visualizer_keyboard_status_t initial_status = { | 393 | visualizer_keyboard_status_t initial_status = { |
| 351 | .default_layer = 0xFFFFFFFF, | 394 | .default_layer = 0xFFFFFFFF, |
| 352 | .layer = 0xFFFFFFFF, | 395 | .layer = 0xFFFFFFFF, |
| 396 | .mods = 0xFF, | ||
| 353 | .leds = 0xFFFFFFFF, | 397 | .leds = 0xFFFFFFFF, |
| 354 | .suspended = false, | 398 | .suspended = false, |
| 355 | }; | 399 | }; |
| @@ -499,7 +543,18 @@ void update_status(bool changed) { | |||
| 499 | #endif | 543 | #endif |
| 500 | } | 544 | } |
| 501 | 545 | ||
| 502 | void visualizer_update(uint32_t default_state, uint32_t state, uint32_t leds) { | 546 | uint8_t visualizer_get_mods() { |
| 547 | uint8_t mods = get_mods(); | ||
| 548 | |||
| 549 | #ifndef NO_ACTION_ONESHOT | ||
| 550 | if (!has_oneshot_mods_timed_out()) { | ||
| 551 | mods |= get_oneshot_mods(); | ||
| 552 | } | ||
| 553 | #endif | ||
| 554 | return mods; | ||
| 555 | } | ||
| 556 | |||
| 557 | void visualizer_update(uint32_t default_state, uint32_t state, uint8_t mods, uint32_t leds) { | ||
| 503 | // Note that there's a small race condition here, the thread could read | 558 | // Note that there's a small race condition here, the thread could read |
| 504 | // a state where one of these are set but not the other. But this should | 559 | // a state where one of these are set but not the other. But this should |
| 505 | // not really matter as it will be fixed during the next loop step. | 560 | // not really matter as it will be fixed during the next loop step. |
| @@ -523,6 +578,7 @@ void visualizer_update(uint32_t default_state, uint32_t state, uint32_t leds) { | |||
| 523 | visualizer_keyboard_status_t new_status = { | 578 | visualizer_keyboard_status_t new_status = { |
| 524 | .layer = state, | 579 | .layer = state, |
| 525 | .default_layer = default_state, | 580 | .default_layer = default_state, |
| 581 | .mods = mods, | ||
| 526 | .leds = leds, | 582 | .leds = leds, |
| 527 | .suspended = current_status.suspended, | 583 | .suspended = current_status.suspended, |
| 528 | }; | 584 | }; |
diff --git a/quantum/visualizer/visualizer.h b/quantum/visualizer/visualizer.h index 53e250725..315af5022 100644 --- a/quantum/visualizer/visualizer.h +++ b/quantum/visualizer/visualizer.h | |||
| @@ -34,10 +34,14 @@ SOFTWARE. | |||
| 34 | #include "lcd_backlight.h" | 34 | #include "lcd_backlight.h" |
| 35 | #endif | 35 | #endif |
| 36 | 36 | ||
| 37 | // use this function to merget both real_mods and oneshot_mods in a uint16_t | ||
| 38 | uint8_t visualizer_get_mods(void); | ||
| 39 | |||
| 37 | // This need to be called once at the start | 40 | // This need to be called once at the start |
| 38 | void visualizer_init(void); | 41 | void visualizer_init(void); |
| 39 | // This should be called at every matrix scan | 42 | // This should be called at every matrix scan |
| 40 | void visualizer_update(uint32_t default_state, uint32_t state, uint32_t leds); | 43 | void visualizer_update(uint32_t default_state, uint32_t state, uint8_t mods, uint32_t leds); |
| 44 | |||
| 41 | // This should be called when the keyboard goes to suspend state | 45 | // This should be called when the keyboard goes to suspend state |
| 42 | void visualizer_suspend(void); | 46 | void visualizer_suspend(void); |
| 43 | // This should be called when the keyboard wakes up from suspend state | 47 | // This should be called when the keyboard wakes up from suspend state |
| @@ -61,6 +65,7 @@ struct keyframe_animation_t; | |||
| 61 | typedef struct { | 65 | typedef struct { |
| 62 | uint32_t layer; | 66 | uint32_t layer; |
| 63 | uint32_t default_layer; | 67 | uint32_t default_layer; |
| 68 | uint8_t mods; | ||
| 64 | uint32_t leds; // See led.h for available statuses | 69 | uint32_t leds; // See led.h for available statuses |
| 65 | bool suspended; | 70 | bool suspended; |
| 66 | } visualizer_keyboard_status_t; | 71 | } visualizer_keyboard_status_t; |
| @@ -129,6 +134,8 @@ bool keyframe_set_backlight_color(keyframe_animation_t* animation, visualizer_st | |||
| 129 | bool keyframe_display_layer_text(keyframe_animation_t* animation, visualizer_state_t* state); | 134 | bool keyframe_display_layer_text(keyframe_animation_t* animation, visualizer_state_t* state); |
| 130 | // Displays a bitmap (0/1) of all the currently active layers | 135 | // Displays a bitmap (0/1) of all the currently active layers |
| 131 | bool keyframe_display_layer_bitmap(keyframe_animation_t* animation, visualizer_state_t* state); | 136 | bool keyframe_display_layer_bitmap(keyframe_animation_t* animation, visualizer_state_t* state); |
| 137 | // Displays a bitmap (0/1) of all the currently active mods | ||
| 138 | bool keyframe_display_mods_bitmap(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 132 | 139 | ||
| 133 | bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state); | 140 | bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state); |
| 134 | bool keyframe_enable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state); | 141 | bool keyframe_enable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state); |
