diff options
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/audio/audio.c | 17 | ||||
| -rw-r--r-- | quantum/audio/audio.h | 5 | ||||
| -rw-r--r-- | quantum/keymap_common.c | 31 | ||||
| -rw-r--r-- | quantum/keymap_common.h | 93 | ||||
| -rw-r--r-- | quantum/keymap_extras/keymap_german_ch.h | 102 | ||||
| -rw-r--r-- | quantum/keymap_unicode.c | 61 | ||||
| -rw-r--r-- | quantum/matrix.c | 8 | ||||
| -rw-r--r-- | quantum/quantum.c | 463 | ||||
| -rw-r--r-- | quantum/quantum.h | 72 | ||||
| -rw-r--r-- | quantum/quantum.mk | 13 | ||||
| -rw-r--r-- | quantum/template/template.c | 7 | ||||
| -rw-r--r-- | quantum/template/template.h | 2 | ||||
| -rw-r--r-- | quantum/unicode.h | 128 |
13 files changed, 861 insertions, 141 deletions
diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index 27b64f8c9..32f64417e 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c | |||
| @@ -381,11 +381,14 @@ bool is_audio_on(void) { | |||
| 381 | void audio_toggle(void) { | 381 | void audio_toggle(void) { |
| 382 | audio_config.enable ^= 1; | 382 | audio_config.enable ^= 1; |
| 383 | eeconfig_update_audio(audio_config.raw); | 383 | eeconfig_update_audio(audio_config.raw); |
| 384 | if (audio_config.enable) | ||
| 385 | audio_on_user(); | ||
| 384 | } | 386 | } |
| 385 | 387 | ||
| 386 | void audio_on(void) { | 388 | void audio_on(void) { |
| 387 | audio_config.enable = 1; | 389 | audio_config.enable = 1; |
| 388 | eeconfig_update_audio(audio_config.raw); | 390 | eeconfig_update_audio(audio_config.raw); |
| 391 | audio_on_user(); | ||
| 389 | } | 392 | } |
| 390 | 393 | ||
| 391 | void audio_off(void) { | 394 | void audio_off(void) { |
| @@ -478,12 +481,14 @@ void increase_tempo(uint8_t tempo_change) { | |||
| 478 | // Override these functions in your keymap file to play different tunes on | 481 | // Override these functions in your keymap file to play different tunes on |
| 479 | // startup and bootloader jump | 482 | // startup and bootloader jump |
| 480 | __attribute__ ((weak)) | 483 | __attribute__ ((weak)) |
| 481 | void play_startup_tone() | 484 | void play_startup_tone() {} |
| 482 | { | ||
| 483 | } | ||
| 484 | 485 | ||
| 485 | __attribute__ ((weak)) | 486 | __attribute__ ((weak)) |
| 486 | void play_goodbye_tone() | 487 | void play_goodbye_tone() {} |
| 487 | { | 488 | |
| 488 | } | 489 | __attribute__ ((weak)) |
| 490 | void audio_on_user() {} | ||
| 491 | |||
| 492 | __attribute__ ((weak)) | ||
| 493 | void play_music_scale() {} | ||
| 489 | //------------------------------------------------------------------------------ | 494 | //------------------------------------------------------------------------------ |
diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index 4ba879bbb..b46f587bb 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h | |||
| @@ -86,9 +86,10 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) | |||
| 86 | 86 | ||
| 87 | 87 | ||
| 88 | bool is_playing_notes(void); | 88 | bool is_playing_notes(void); |
| 89 | |||
| 89 | void play_goodbye_tone(void); | 90 | void play_goodbye_tone(void); |
| 90 | void play_startup_tone(void); | 91 | void play_startup_tone(void); |
| 91 | 92 | void audio_on_user(void); | |
| 92 | 93 | void play_music_scale(void); | |
| 93 | 94 | ||
| 94 | #endif \ No newline at end of file | 95 | #endif \ No newline at end of file |
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 8f00f9cc3..1d9ab2e05 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c | |||
| @@ -31,7 +31,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 31 | #include "keymap_midi.h" | 31 | #include "keymap_midi.h" |
| 32 | #endif | 32 | #endif |
| 33 | 33 | ||
| 34 | |||
| 35 | extern keymap_config_t keymap_config; | 34 | extern keymap_config_t keymap_config; |
| 36 | 35 | ||
| 37 | #include <stdio.h> | 36 | #include <stdio.h> |
| @@ -154,20 +153,22 @@ static action_t keycode_to_action(uint16_t keycode) | |||
| 154 | case KC_TRNS: | 153 | case KC_TRNS: |
| 155 | action.code = ACTION_TRANSPARENT; | 154 | action.code = ACTION_TRANSPARENT; |
| 156 | break; | 155 | break; |
| 157 | case 0x0100 ... 0x1FFF: ; | 156 | case LCTL(0) ... 0x1FFF: ; |
| 158 | // Has a modifier | 157 | // Has a modifier |
| 159 | // Split it up | 158 | // Split it up |
| 160 | action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key | 159 | action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key |
| 161 | break; | 160 | break; |
| 162 | case 0x2000 ... 0x2FFF: | 161 | case FUNC(0) ... FUNC(0xFFF): ; |
| 163 | // Is a shortcut for function layer, pull last 12bits | 162 | // Is a shortcut for function layer, pull last 12bits |
| 164 | // This means we have 4,096 FN macros at our disposal | 163 | // This means we have 4,096 FN macros at our disposal |
| 165 | return keymap_func_to_action(keycode & 0xFFF); | 164 | return keymap_func_to_action(keycode & 0xFFF); |
| 166 | break; | 165 | break; |
| 167 | case 0x3000 ... 0x3FFF: ; | 166 | case M(0) ... M(0xFF): |
| 168 | // When the code starts with 3, it's an action macro. | ||
| 169 | action.code = ACTION_MACRO(keycode & 0xFF); | 167 | action.code = ACTION_MACRO(keycode & 0xFF); |
| 170 | break; | 168 | break; |
| 169 | case LT(0, 0) ... LT(0xFF, 0xF): | ||
| 170 | action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); | ||
| 171 | break; | ||
| 171 | #ifdef BACKLIGHT_ENABLE | 172 | #ifdef BACKLIGHT_ENABLE |
| 172 | case BL_0 ... BL_15: | 173 | case BL_0 ... BL_15: |
| 173 | action.code = ACTION_BACKLIGHT_LEVEL(keycode & 0x000F); | 174 | action.code = ACTION_BACKLIGHT_LEVEL(keycode & 0x000F); |
| @@ -201,7 +202,7 @@ static action_t keycode_to_action(uint16_t keycode) | |||
| 201 | print("\nDEBUG: enabled.\n"); | 202 | print("\nDEBUG: enabled.\n"); |
| 202 | debug_enable = true; | 203 | debug_enable = true; |
| 203 | break; | 204 | break; |
| 204 | case 0x5002 ... 0x50FF: | 205 | case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_UNSWAP_ALT_GUI: |
| 205 | // MAGIC actions (BOOTMAGIC without the boot) | 206 | // MAGIC actions (BOOTMAGIC without the boot) |
| 206 | if (!eeconfig_is_enabled()) { | 207 | if (!eeconfig_is_enabled()) { |
| 207 | eeconfig_init(); | 208 | eeconfig_init(); |
| @@ -251,7 +252,7 @@ static action_t keycode_to_action(uint16_t keycode) | |||
| 251 | } | 252 | } |
| 252 | eeconfig_update_keymap(keymap_config.raw); | 253 | eeconfig_update_keymap(keymap_config.raw); |
| 253 | break; | 254 | break; |
| 254 | case 0x5100 ... 0x5FFF: ; | 255 | case TO(0, 1) ... OSM(0xFF): ; |
| 255 | // Layer movement shortcuts | 256 | // Layer movement shortcuts |
| 256 | // See .h to see constraints/usage | 257 | // See .h to see constraints/usage |
| 257 | int type = (keycode >> 0x8) & 0xF; | 258 | int type = (keycode >> 0x8) & 0xF; |
| @@ -282,23 +283,9 @@ static action_t keycode_to_action(uint16_t keycode) | |||
| 282 | action.code = ACTION_MODS_ONESHOT(mod); | 283 | action.code = ACTION_MODS_ONESHOT(mod); |
| 283 | } | 284 | } |
| 284 | break; | 285 | break; |
| 285 | #ifdef MIDI_ENABLE | 286 | case MT(0, 0) ... MT(0xF, 0xFF): |
| 286 | case 0x6000 ... 0x6FFF: | ||
| 287 | action.code = ACTION_FUNCTION_OPT(keycode & 0xFF, (keycode & 0x0F00) >> 8); | ||
| 288 | break; | ||
| 289 | #endif | ||
| 290 | case 0x7000 ... 0x7FFF: | ||
| 291 | action.code = ACTION_MODS_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); | 287 | action.code = ACTION_MODS_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); |
| 292 | break; | 288 | break; |
| 293 | case 0x8000 ... 0x8FFF: | ||
| 294 | action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); | ||
| 295 | break; | ||
| 296 | #ifdef UNICODE_ENABLE | ||
| 297 | case 0x8000000 ... 0x8FFFFFF: | ||
| 298 | uint16_t unicode = keycode & ~(0x8000); | ||
| 299 | action.code = ACTION_FUNCTION_OPT(unicode & 0xFF, (unicode & 0xFF00) >> 8); | ||
| 300 | break; | ||
| 301 | #endif | ||
| 302 | default: | 289 | default: |
| 303 | action.code = ACTION_NO; | 290 | action.code = ACTION_NO; |
| 304 | break; | 291 | break; |
diff --git a/quantum/keymap_common.h b/quantum/keymap_common.h index 322fda498..91d5c09c1 100644 --- a/quantum/keymap_common.h +++ b/quantum/keymap_common.h | |||
| @@ -159,35 +159,14 @@ extern const uint16_t fn_actions[]; | |||
| 159 | #define S(kc) LSFT(kc) | 159 | #define S(kc) LSFT(kc) |
| 160 | #define F(kc) FUNC(kc) | 160 | #define F(kc) FUNC(kc) |
| 161 | 161 | ||
| 162 | #define M(kc) kc | 0x3000 | 162 | #define M(kc) (kc | 0x3000) |
| 163 | 163 | ||
| 164 | #define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE) | 164 | #define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE) |
| 165 | 165 | ||
| 166 | // These affect the backlight (if your keyboard has one). | 166 | // 0x3100+ is free |
| 167 | // We don't need to comment them out if your keyboard doesn't have a backlight, | 167 | |
| 168 | // since they don't take up any space. | 168 | // L-ayer, T-ap - 256 keycode max, 16 layer max |
| 169 | #define BL_ON 0x4009 | 169 | #define LT(layer, kc) (kc | 0x4000 | ((layer & 0xF) << 8)) |
| 170 | #define BL_OFF 0x4000 | ||
| 171 | #define BL_0 0x4000 | ||
| 172 | #define BL_1 0x4001 | ||
| 173 | #define BL_2 0x4002 | ||
| 174 | #define BL_3 0x4003 | ||
| 175 | #define BL_4 0x4004 | ||
| 176 | #define BL_5 0x4005 | ||
| 177 | #define BL_6 0x4006 | ||
| 178 | #define BL_7 0x4007 | ||
| 179 | #define BL_8 0x4008 | ||
| 180 | #define BL_9 0x4009 | ||
| 181 | #define BL_10 0x400A | ||
| 182 | #define BL_11 0x400B | ||
| 183 | #define BL_12 0x400C | ||
| 184 | #define BL_13 0x400D | ||
| 185 | #define BL_14 0x400E | ||
| 186 | #define BL_15 0x400F | ||
| 187 | #define BL_DEC 0x4010 | ||
| 188 | #define BL_INC 0x4011 | ||
| 189 | #define BL_TOGG 0x4012 | ||
| 190 | #define BL_STEP 0x4013 | ||
| 191 | 170 | ||
| 192 | #define RESET 0x5000 | 171 | #define RESET 0x5000 |
| 193 | #define DEBUG 0x5001 | 172 | #define DEBUG 0x5001 |
| @@ -215,6 +194,51 @@ extern const uint16_t fn_actions[]; | |||
| 215 | #define AG_SWAP MAGIC_SWAP_ALT_GUI | 194 | #define AG_SWAP MAGIC_SWAP_ALT_GUI |
| 216 | #define AG_NORM MAGIC_UNSWAP_ALT_GUI | 195 | #define AG_NORM MAGIC_UNSWAP_ALT_GUI |
| 217 | 196 | ||
| 197 | #define KC_LEAD 0x5014 | ||
| 198 | |||
| 199 | // Audio on/off | ||
| 200 | #define AU_ON 0x5020 | ||
| 201 | #define AU_OFF 0x5021 | ||
| 202 | #define AU_TOG 0x5022 | ||
| 203 | |||
| 204 | // Music mode on/off | ||
| 205 | #define MU_ON 0x5023 | ||
| 206 | #define MU_OFF 0x5024 | ||
| 207 | #define MU_TOG 0x5025 | ||
| 208 | |||
| 209 | // Music voice iterate | ||
| 210 | #define MUV_IN 0x5026 | ||
| 211 | #define MUV_DE 0x5027 | ||
| 212 | |||
| 213 | // Midi mode on/off | ||
| 214 | #define MI_ON 0x5028 | ||
| 215 | #define MI_OFF 0x5029 | ||
| 216 | |||
| 217 | // These affect the backlight (if your keyboard has one). | ||
| 218 | // We don't need to comment them out if your keyboard doesn't have a backlight, | ||
| 219 | // since they don't take up any space. | ||
| 220 | #define BL_ON 0x5079 | ||
| 221 | #define BL_OFF 0x5070 | ||
| 222 | #define BL_0 0x5070 | ||
| 223 | #define BL_1 0x5071 | ||
| 224 | #define BL_2 0x5072 | ||
| 225 | #define BL_3 0x5073 | ||
| 226 | #define BL_4 0x5074 | ||
| 227 | #define BL_5 0x5075 | ||
| 228 | #define BL_6 0x5076 | ||
| 229 | #define BL_7 0x5077 | ||
| 230 | #define BL_8 0x5078 | ||
| 231 | #define BL_9 0x5079 | ||
| 232 | #define BL_10 0x507A | ||
| 233 | #define BL_11 0x507B | ||
| 234 | #define BL_12 0x507C | ||
| 235 | #define BL_13 0x507D | ||
| 236 | #define BL_14 0x507E | ||
| 237 | #define BL_15 0x507F | ||
| 238 | #define BL_DEC 0x5080 | ||
| 239 | #define BL_INC 0x5081 | ||
| 240 | #define BL_TOGG 0x5082 | ||
| 241 | #define BL_STEP 0x5083 | ||
| 218 | 242 | ||
| 219 | // GOTO layer - 16 layers max | 243 | // GOTO layer - 16 layers max |
| 220 | // when: | 244 | // when: |
| @@ -238,6 +262,8 @@ extern const uint16_t fn_actions[]; | |||
| 238 | // One-shot mod | 262 | // One-shot mod |
| 239 | #define OSM(layer) (layer | 0x5600) | 263 | #define OSM(layer) (layer | 0x5600) |
| 240 | 264 | ||
| 265 | // chording is currently at 0x57xx | ||
| 266 | |||
| 241 | // M-od, T-ap - 256 keycode max | 267 | // M-od, T-ap - 256 keycode max |
| 242 | #define MT(mod, kc) (kc | 0x7000 | ((mod & 0xF) << 8)) | 268 | #define MT(mod, kc) (kc | 0x7000 | ((mod & 0xF) << 8)) |
| 243 | #define CTL_T(kc) MT(0x1, kc) | 269 | #define CTL_T(kc) MT(0x1, kc) |
| @@ -253,14 +279,13 @@ extern const uint16_t fn_actions[]; | |||
| 253 | #define KC_HYPR HYPR(KC_NO) | 279 | #define KC_HYPR HYPR(KC_NO) |
| 254 | #define KC_MEH MEH(KC_NO) | 280 | #define KC_MEH MEH(KC_NO) |
| 255 | 281 | ||
| 256 | // L-ayer, T-ap - 256 keycode max, 16 layer max | 282 | #ifdef UNICODE_ENABLE |
| 257 | #define LT(layer, kc) (kc | 0x8000 | ((layer & 0xF) << 8)) | 283 | // For sending unicode codes. |
| 258 | 284 | // You may not send codes over 7FFF -- this supports most of UTF8. | |
| 259 | // For sending unicode codes. | 285 | // To have a key that sends out Å’, go UC(0x0152) |
| 260 | // You may not send codes over 1FFF -- this supports most of UTF8. | 286 | #define UNICODE(n) (n | 0x8000) |
| 261 | // To have a key that sends out Å’, go UC(0x0152) | 287 | #define UC(n) UNICODE(n) |
| 262 | #define UNICODE(n) (n | 0x8000) | 288 | #endif |
| 263 | #define UC(n) UNICODE(n) | ||
| 264 | 289 | ||
| 265 | // For tri-layer | 290 | // For tri-layer |
| 266 | void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3); | 291 | void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3); |
diff --git a/quantum/keymap_extras/keymap_german_ch.h b/quantum/keymap_extras/keymap_german_ch.h new file mode 100644 index 000000000..0874abf7d --- /dev/null +++ b/quantum/keymap_extras/keymap_german_ch.h | |||
| @@ -0,0 +1,102 @@ | |||
| 1 | #ifndef KEYMAP_SWISS_GERMAN | ||
| 2 | #define KEYMAP_SWISS_GERMAN | ||
| 3 | |||
| 4 | #include "keymap_common.h" | ||
| 5 | |||
| 6 | // Alt gr | ||
| 7 | #define ALGR(kc) kc | 0x1400 | ||
| 8 | #define CH_ALGR KC_RALT | ||
| 9 | |||
| 10 | // normal characters | ||
| 11 | #define CH_Z KC_Y | ||
| 12 | #define CH_Y KC_Z | ||
| 13 | |||
| 14 | #define CH_A KC_A | ||
| 15 | #define CH_B KC_B | ||
| 16 | #define CH_C KC_C | ||
| 17 | #define CH_D KC_D | ||
| 18 | #define CH_E KC_E | ||
| 19 | #define CH_F KC_F | ||
| 20 | #define CH_G KC_G | ||
| 21 | #define CH_H KC_H | ||
| 22 | #define CH_I KC_I | ||
| 23 | #define CH_J KC_J | ||
| 24 | #define CH_K KC_K | ||
| 25 | #define CH_L KC_L | ||
| 26 | #define CH_M KC_M | ||
| 27 | #define CH_N KC_N | ||
| 28 | #define CH_O KC_O | ||
| 29 | #define CH_P KC_P | ||
| 30 | #define CH_Q KC_Q | ||
| 31 | #define CH_R KC_R | ||
| 32 | #define CH_S KC_S | ||
| 33 | #define CH_T KC_T | ||
| 34 | #define CH_U KC_U | ||
| 35 | #define CH_V KC_V | ||
| 36 | #define CH_W KC_W | ||
| 37 | #define CH_X KC_X | ||
| 38 | |||
| 39 | #define CH_0 KC_0 | ||
| 40 | #define CH_1 KC_1 | ||
| 41 | #define CH_2 KC_2 | ||
| 42 | #define CH_3 KC_3 | ||
| 43 | #define CH_4 KC_4 | ||
| 44 | #define CH_5 KC_5 | ||
| 45 | #define CH_6 KC_6 | ||
| 46 | #define CH_7 KC_7 | ||
| 47 | #define CH_8 KC_8 | ||
| 48 | #define CH_9 KC_9 | ||
| 49 | |||
| 50 | #define CH_DOT KC_DOT | ||
| 51 | #define CH_COMM KC_COMM | ||
| 52 | |||
| 53 | #define CH_QUOT KC_MINS // ' ? ´ | ||
| 54 | #define CH_AE KC_QUOT | ||
| 55 | #define CH_UE KC_LBRC | ||
| 56 | #define CH_OE KC_SCLN | ||
| 57 | |||
| 58 | #define CH_PARA KC_GRAVE // secction sign § and ° | ||
| 59 | #define CH_CARR KC_EQL // carret ^ ` ~ | ||
| 60 | #define CH_DIER KC_RBRC // dieresis ¨ ! ] | ||
| 61 | #define CH_DLR KC_BSLS // $ £ } | ||
| 62 | #define CH_LESS KC_NUBS // < and > and backslash | ||
| 63 | #define CH_MINS KC_SLSH // - and _ | ||
| 64 | |||
| 65 | // shifted characters | ||
| 66 | #define CH_RING LSFT(CH_PARA) // ° | ||
| 67 | #define CH_PLUS LSFT(KC_1) // + | ||
| 68 | #define CH_DQOT LSFT(KC_2) // " | ||
| 69 | #define CH_PAST LSFT(KC_3) // * | ||
| 70 | #define CH_CELA LSFT(KC_4) // ç | ||
| 71 | #define CH_PERC LSFT(KC_5) // % | ||
| 72 | #define CH_AMPR LSFT(KC_6) // & | ||
| 73 | #define CH_SLSH LSFT(KC_7) // / | ||
| 74 | #define CH_LPRN LSFT(KC_8) // ( | ||
| 75 | #define CH_RPRN LSFT(KC_9) // ) | ||
| 76 | #define CH_EQL LSFT(KC_0) // = | ||
| 77 | #define CH_QST LSFT(CH_QUOT) // ? | ||
| 78 | #define CH_GRV LSFT(CH_CARR) // ` | ||
| 79 | #define CH_EXLM LSFT(CH_DIER) // ! | ||
| 80 | #define CH_POND LSFT(CH_DLR) // £ | ||
| 81 | #define CH_MORE LSFT(CH_LESS) // > | ||
| 82 | #define CH_COLN LSFT(KC_DOT) // : | ||
| 83 | #define CH_SCLN LSFT(KC_COMM) // ; | ||
| 84 | #define CH_UNDS LSFT(CH_MINS) // _ | ||
| 85 | |||
| 86 | // Alt Gr-ed characters | ||
| 87 | #define CH_BRBR ALGR(KC_1) // ¦ brocken bar | ||
| 88 | #define CH_AT ALGR(KC_2) // @ | ||
| 89 | #define CH_HASH ALGR(KC_3) // # | ||
| 90 | #define CH_NOTL ALGR(KC_6) // ¬ negative logic | ||
| 91 | #define CH_PIPE ALGR(KC_7) // | | ||
| 92 | #define CH_CENT ALGR(KC_8) // ¢ cent | ||
| 93 | #define CH_ACUT ALGR(CH_QUOT) // ´ | ||
| 94 | #define CH_TILD ALGR(CH_CARR) // ~ | ||
| 95 | #define CH_EURO ALGR(KC_E) // € | ||
| 96 | #define CH_LBRC ALGR(CH_UE) // [ | ||
| 97 | #define CH_RBRC ALGR(CH_DIER) // ] | ||
| 98 | #define CH_LCBR ALGR(CH_AE) // { | ||
| 99 | #define CH_RCBR ALGR(CH_DLR) // } | ||
| 100 | #define CH_BSLS ALGR(CH_LESS) // backslash | ||
| 101 | |||
| 102 | #endif | ||
diff --git a/quantum/keymap_unicode.c b/quantum/keymap_unicode.c deleted file mode 100644 index a44965e61..000000000 --- a/quantum/keymap_unicode.c +++ /dev/null | |||
| @@ -1,61 +0,0 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2015 Jack Humbert <jack.humb@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include "keymap_common.h" | ||
| 19 | |||
| 20 | uint16_t hextokeycode(int hex) { | ||
| 21 | if (hex == 0x0) { | ||
| 22 | return KC_0; | ||
| 23 | } else if (hex < 0xA) { | ||
| 24 | return KC_1 + (hex - 0x1); | ||
| 25 | } else { | ||
| 26 | return KC_A + (hex - 0xA); | ||
| 27 | } | ||
| 28 | } | ||
| 29 | |||
| 30 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) | ||
| 31 | { | ||
| 32 | |||
| 33 | // For more info on how this works per OS, see here: https://en.wikipedia.org/wiki/Unicode_input#Hexadecimal_code_input | ||
| 34 | |||
| 35 | if (record->event.pressed) { | ||
| 36 | uint16_t unicode = (opt << 8) | id; | ||
| 37 | register_code(KC_LALT); | ||
| 38 | |||
| 39 | register_code(hextokeycode((unicode & 0xF000) >> 12)); | ||
| 40 | unregister_code(hextokeycode((unicode & 0xF000) >> 12)); | ||
| 41 | register_code(hextokeycode((unicode & 0x0F00) >> 8)); | ||
| 42 | unregister_code(hextokeycode((unicode & 0x0F00) >> 8)); | ||
| 43 | register_code(hextokeycode((unicode & 0x00F0) >> 4)); | ||
| 44 | unregister_code(hextokeycode((unicode & 0x00F0) >> 4)); | ||
| 45 | register_code(hextokeycode((unicode & 0x000F))); | ||
| 46 | unregister_code(hextokeycode((unicode & 0x000F))); | ||
| 47 | |||
| 48 | /* Test 'a' */ | ||
| 49 | // register_code(hextokeycode(0x0)); | ||
| 50 | // unregister_code(hextokeycode(0x0)); | ||
| 51 | // register_code(hextokeycode(0x0)); | ||
| 52 | // unregister_code(hextokeycode(0x0)); | ||
| 53 | // register_code(hextokeycode(0x6)); | ||
| 54 | // unregister_code(hextokeycode(0x6)); | ||
| 55 | // register_code(hextokeycode(0x1)); | ||
| 56 | // unregister_code(hextokeycode(0x1)); | ||
| 57 | |||
| 58 | unregister_code(KC_LALT); | ||
| 59 | } | ||
| 60 | return; | ||
| 61 | } \ No newline at end of file | ||
diff --git a/quantum/matrix.c b/quantum/matrix.c index 7d70f728d..cab39e117 100644 --- a/quantum/matrix.c +++ b/quantum/matrix.c | |||
| @@ -55,12 +55,12 @@ static void unselect_rows(void); | |||
| 55 | static void select_row(uint8_t row); | 55 | static void select_row(uint8_t row); |
| 56 | 56 | ||
| 57 | __attribute__ ((weak)) | 57 | __attribute__ ((weak)) |
| 58 | void matrix_init_kb(void) { | 58 | void matrix_init_quantum(void) { |
| 59 | 59 | ||
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | __attribute__ ((weak)) | 62 | __attribute__ ((weak)) |
| 63 | void matrix_scan_kb(void) { | 63 | void matrix_scan_quantum(void) { |
| 64 | 64 | ||
| 65 | } | 65 | } |
| 66 | 66 | ||
| @@ -93,7 +93,7 @@ void matrix_init(void) | |||
| 93 | matrix_debouncing[i] = 0; | 93 | matrix_debouncing[i] = 0; |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | matrix_init_kb(); | 96 | matrix_init_quantum(); |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | 99 | ||
| @@ -157,7 +157,7 @@ uint8_t matrix_scan(void) | |||
| 157 | } | 157 | } |
| 158 | #endif | 158 | #endif |
| 159 | 159 | ||
| 160 | matrix_scan_kb(); | 160 | matrix_scan_quantum(); |
| 161 | 161 | ||
| 162 | return 1; | 162 | return 1; |
| 163 | } | 163 | } |
diff --git a/quantum/quantum.c b/quantum/quantum.c new file mode 100644 index 000000000..34c575af4 --- /dev/null +++ b/quantum/quantum.c | |||
| @@ -0,0 +1,463 @@ | |||
| 1 | #include "quantum.h" | ||
| 2 | #include "timer.h" | ||
| 3 | |||
| 4 | __attribute__ ((weak)) | ||
| 5 | void matrix_init_kb(void) {} | ||
| 6 | |||
| 7 | __attribute__ ((weak)) | ||
| 8 | void matrix_scan_kb(void) {} | ||
| 9 | |||
| 10 | __attribute__ ((weak)) | ||
| 11 | bool process_action_kb(keyrecord_t *record) { | ||
| 12 | return true; | ||
| 13 | } | ||
| 14 | |||
| 15 | __attribute__ ((weak)) | ||
| 16 | void leader_start(void) {} | ||
| 17 | |||
| 18 | __attribute__ ((weak)) | ||
| 19 | void leader_end(void) {} | ||
| 20 | |||
| 21 | uint8_t starting_note = 0x0C; | ||
| 22 | int offset = 7; | ||
| 23 | |||
| 24 | #ifdef AUDIO_ENABLE | ||
| 25 | bool music_activated = false; | ||
| 26 | float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); | ||
| 27 | |||
| 28 | // music sequencer | ||
| 29 | static bool music_sequence_recording = false; | ||
| 30 | static bool music_sequence_playing = false; | ||
| 31 | static float music_sequence[16] = {0}; | ||
| 32 | static uint8_t music_sequence_count = 0; | ||
| 33 | static uint8_t music_sequence_position = 0; | ||
| 34 | |||
| 35 | static uint16_t music_sequence_timer = 0; | ||
| 36 | static uint16_t music_sequence_interval = 100; | ||
| 37 | |||
| 38 | #endif | ||
| 39 | |||
| 40 | #ifdef MIDI_ENABLE | ||
| 41 | bool midi_activated = false; | ||
| 42 | #endif | ||
| 43 | |||
| 44 | // Leader key stuff | ||
| 45 | bool leading = false; | ||
| 46 | uint16_t leader_time = 0; | ||
| 47 | |||
| 48 | uint16_t leader_sequence[3] = {0, 0, 0}; | ||
| 49 | uint8_t leader_sequence_size = 0; | ||
| 50 | |||
| 51 | // Chording stuff | ||
| 52 | #define CHORDING_MAX 4 | ||
| 53 | bool chording = false; | ||
| 54 | |||
| 55 | uint8_t chord_keys[CHORDING_MAX] = {0}; | ||
| 56 | uint8_t chord_key_count = 0; | ||
| 57 | uint8_t chord_key_down = 0; | ||
| 58 | |||
| 59 | #ifdef UNICODE_ENABLE | ||
| 60 | static uint8_t input_mode; | ||
| 61 | #endif | ||
| 62 | |||
| 63 | bool keys_chord(uint8_t keys[]) { | ||
| 64 | uint8_t keys_size = sizeof(keys)/sizeof(keys[0]); | ||
| 65 | bool pass = true; | ||
| 66 | uint8_t in = 0; | ||
| 67 | for (uint8_t i = 0; i < chord_key_count; i++) { | ||
| 68 | bool found = false; | ||
| 69 | for (uint8_t j = 0; j < keys_size; j++) { | ||
| 70 | if (chord_keys[i] == (keys[j] & 0xFF)) { | ||
| 71 | in++; // detects key in chord | ||
| 72 | found = true; | ||
| 73 | break; | ||
| 74 | } | ||
| 75 | } | ||
| 76 | if (found) | ||
| 77 | continue; | ||
| 78 | if (chord_keys[i] != 0) { | ||
| 79 | pass = false; // makes sure rest are blank | ||
| 80 | } | ||
| 81 | } | ||
| 82 | return (pass && (in == keys_size)); | ||
| 83 | } | ||
| 84 | |||
| 85 | #ifdef UNICODE_ENABLE | ||
| 86 | |||
| 87 | uint16_t hex_to_keycode(uint8_t hex) | ||
| 88 | { | ||
| 89 | if (hex == 0x0) { | ||
| 90 | return KC_0; | ||
| 91 | } else if (hex < 0xA) { | ||
| 92 | return KC_1 + (hex - 0x1); | ||
| 93 | } else { | ||
| 94 | return KC_A + (hex - 0xA); | ||
| 95 | } | ||
| 96 | } | ||
| 97 | |||
| 98 | void set_unicode_mode(uint8_t os_target) | ||
| 99 | { | ||
| 100 | input_mode = os_target; | ||
| 101 | } | ||
| 102 | |||
| 103 | #endif | ||
| 104 | |||
| 105 | bool process_record_quantum(keyrecord_t *record) { | ||
| 106 | |||
| 107 | /* This gets the keycode from the key pressed */ | ||
| 108 | keypos_t key = record->event.key; | ||
| 109 | uint16_t keycode; | ||
| 110 | |||
| 111 | #if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS) | ||
| 112 | uint8_t layer; | ||
| 113 | |||
| 114 | if (record->event.pressed) { | ||
| 115 | layer = layer_switch_get_layer(key); | ||
| 116 | update_source_layers_cache(key, layer); | ||
| 117 | } else { | ||
| 118 | layer = read_source_layers_cache(key); | ||
| 119 | } | ||
| 120 | keycode = keymap_key_to_keycode(layer, key); | ||
| 121 | #else | ||
| 122 | keycode = keymap_key_to_keycode(layer_switch_get_layer(key), key); | ||
| 123 | #endif | ||
| 124 | |||
| 125 | // This is how you use actions here | ||
| 126 | // if (keycode == KC_LEAD) { | ||
| 127 | // action_t action; | ||
| 128 | // action.code = ACTION_DEFAULT_LAYER_SET(0); | ||
| 129 | // process_action(record, action); | ||
| 130 | // return false; | ||
| 131 | // } | ||
| 132 | |||
| 133 | #ifdef MIDI_ENABLE | ||
| 134 | if (keycode == MI_ON && record->event.pressed) { | ||
| 135 | midi_activated = true; | ||
| 136 | play_music_scale(); | ||
| 137 | return false; | ||
| 138 | } | ||
| 139 | |||
| 140 | if (keycode == MI_OFF && record->event.pressed) { | ||
| 141 | midi_activated = false; | ||
| 142 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 143 | return false; | ||
| 144 | } | ||
| 145 | |||
| 146 | if (midi_activated) { | ||
| 147 | if (record->event.key.col == (MATRIX_COLS - 1) && record->event.key.row == (MATRIX_ROWS - 1)) { | ||
| 148 | if (record->event.pressed) { | ||
| 149 | starting_note++; // Change key | ||
| 150 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 151 | // midi_send_cc(&midi_device, 1, 0x7B, 0); | ||
| 152 | // midi_send_cc(&midi_device, 2, 0x7B, 0); | ||
| 153 | // midi_send_cc(&midi_device, 3, 0x7B, 0); | ||
| 154 | // midi_send_cc(&midi_device, 4, 0x7B, 0); | ||
| 155 | } | ||
| 156 | return false; | ||
| 157 | } | ||
| 158 | if (record->event.key.col == (MATRIX_COLS - 2) && record->event.key.row == (MATRIX_ROWS - 1)) { | ||
| 159 | if (record->event.pressed) { | ||
| 160 | starting_note--; // Change key | ||
| 161 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 162 | // midi_send_cc(&midi_device, 1, 0x7B, 0); | ||
| 163 | // midi_send_cc(&midi_device, 2, 0x7B, 0); | ||
| 164 | // midi_send_cc(&midi_device, 3, 0x7B, 0); | ||
| 165 | // midi_send_cc(&midi_device, 4, 0x7B, 0); | ||
| 166 | } | ||
| 167 | return false; | ||
| 168 | } | ||
| 169 | if (record->event.key.col == (MATRIX_COLS - 3) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { | ||
| 170 | offset++; // Change scale | ||
| 171 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 172 | // midi_send_cc(&midi_device, 1, 0x7B, 0); | ||
| 173 | // midi_send_cc(&midi_device, 2, 0x7B, 0); | ||
| 174 | // midi_send_cc(&midi_device, 3, 0x7B, 0); | ||
| 175 | // midi_send_cc(&midi_device, 4, 0x7B, 0); | ||
| 176 | return false; | ||
| 177 | } | ||
| 178 | if (record->event.key.col == (MATRIX_COLS - 4) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { | ||
| 179 | offset--; // Change scale | ||
| 180 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 181 | // midi_send_cc(&midi_device, 1, 0x7B, 0); | ||
| 182 | // midi_send_cc(&midi_device, 2, 0x7B, 0); | ||
| 183 | // midi_send_cc(&midi_device, 3, 0x7B, 0); | ||
| 184 | // midi_send_cc(&midi_device, 4, 0x7B, 0); | ||
| 185 | return false; | ||
| 186 | } | ||
| 187 | // basic | ||
| 188 | // uint8_t note = (starting_note + SCALE[record->event.key.col + offset])+12*(MATRIX_ROWS - record->event.key.row); | ||
| 189 | // advanced | ||
| 190 | // uint8_t note = (starting_note + record->event.key.col + offset)+12*(MATRIX_ROWS - record->event.key.row); | ||
| 191 | // guitar | ||
| 192 | uint8_t note = (starting_note + record->event.key.col + offset)+5*(MATRIX_ROWS - record->event.key.row); | ||
| 193 | // violin | ||
| 194 | // uint8_t note = (starting_note + record->event.key.col + offset)+7*(MATRIX_ROWS - record->event.key.row); | ||
| 195 | |||
| 196 | if (record->event.pressed) { | ||
| 197 | // midi_send_noteon(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127); | ||
| 198 | midi_send_noteon(&midi_device, 0, note, 127); | ||
| 199 | } else { | ||
| 200 | // midi_send_noteoff(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127); | ||
| 201 | midi_send_noteoff(&midi_device, 0, note, 127); | ||
| 202 | } | ||
| 203 | |||
| 204 | if (keycode < 0xFF) // ignores all normal keycodes, but lets RAISE, LOWER, etc through | ||
| 205 | return false; | ||
| 206 | } | ||
| 207 | #endif | ||
| 208 | |||
| 209 | #ifdef AUDIO_ENABLE | ||
| 210 | if (keycode == AU_ON && record->event.pressed) { | ||
| 211 | audio_on(); | ||
| 212 | return false; | ||
| 213 | } | ||
| 214 | |||
| 215 | if (keycode == AU_OFF && record->event.pressed) { | ||
| 216 | audio_off(); | ||
| 217 | return false; | ||
| 218 | } | ||
| 219 | |||
| 220 | if (keycode == AU_TOG && record->event.pressed) { | ||
| 221 | if (is_audio_on()) | ||
| 222 | { | ||
| 223 | audio_off(); | ||
| 224 | } | ||
| 225 | else | ||
| 226 | { | ||
| 227 | audio_on(); | ||
| 228 | } | ||
| 229 | return false; | ||
| 230 | } | ||
| 231 | |||
| 232 | if (keycode == MU_ON && record->event.pressed) { | ||
| 233 | music_on(); | ||
| 234 | return false; | ||
| 235 | } | ||
| 236 | |||
| 237 | if (keycode == MU_OFF && record->event.pressed) { | ||
| 238 | music_off(); | ||
| 239 | return false; | ||
| 240 | } | ||
| 241 | |||
| 242 | if (keycode == MU_TOG && record->event.pressed) { | ||
| 243 | if (music_activated) | ||
| 244 | { | ||
| 245 | music_off(); | ||
| 246 | } | ||
| 247 | else | ||
| 248 | { | ||
| 249 | music_on(); | ||
| 250 | } | ||
| 251 | return false; | ||
| 252 | } | ||
| 253 | |||
| 254 | if (keycode == MUV_IN && record->event.pressed) { | ||
| 255 | voice_iterate(); | ||
| 256 | play_music_scale(); | ||
| 257 | return false; | ||
| 258 | } | ||
| 259 | |||
| 260 | if (keycode == MUV_DE && record->event.pressed) { | ||
| 261 | voice_deiterate(); | ||
| 262 | play_music_scale(); | ||
| 263 | return false; | ||
| 264 | } | ||
| 265 | |||
| 266 | if (music_activated) { | ||
| 267 | |||
| 268 | if (keycode == KC_LCTL && record->event.pressed) { // Start recording | ||
| 269 | stop_all_notes(); | ||
| 270 | music_sequence_recording = true; | ||
| 271 | music_sequence_playing = false; | ||
| 272 | music_sequence_count = 0; | ||
| 273 | return false; | ||
| 274 | } | ||
| 275 | if (keycode == KC_LALT && record->event.pressed) { // Stop recording/playing | ||
| 276 | stop_all_notes(); | ||
| 277 | music_sequence_recording = false; | ||
| 278 | music_sequence_playing = false; | ||
| 279 | return false; | ||
| 280 | } | ||
| 281 | if (keycode == KC_LGUI && record->event.pressed) { // Start playing | ||
| 282 | stop_all_notes(); | ||
| 283 | music_sequence_recording = false; | ||
| 284 | music_sequence_playing = true; | ||
| 285 | music_sequence_position = 0; | ||
| 286 | music_sequence_timer = 0; | ||
| 287 | return false; | ||
| 288 | } | ||
| 289 | |||
| 290 | if (keycode == KC_UP) { | ||
| 291 | if (record->event.pressed) | ||
| 292 | music_sequence_interval-=10; | ||
| 293 | return false; | ||
| 294 | } | ||
| 295 | if (keycode == KC_DOWN) { | ||
| 296 | if (record->event.pressed) | ||
| 297 | music_sequence_interval+=10; | ||
| 298 | return false; | ||
| 299 | } | ||
| 300 | |||
| 301 | float freq = ((float)220.0)*pow(2.0, -5.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)); | ||
| 302 | if (record->event.pressed) { | ||
| 303 | play_note(freq, 0xF); | ||
| 304 | if (music_sequence_recording) { | ||
| 305 | music_sequence[music_sequence_count] = freq; | ||
| 306 | music_sequence_count++; | ||
| 307 | } | ||
| 308 | } else { | ||
| 309 | stop_note(freq); | ||
| 310 | } | ||
| 311 | |||
| 312 | if (keycode < 0xFF) // ignores all normal keycodes, but lets RAISE, LOWER, etc through | ||
| 313 | return false; | ||
| 314 | } | ||
| 315 | #endif | ||
| 316 | |||
| 317 | #ifndef DISABLE_LEADER | ||
| 318 | // Leader key set-up | ||
| 319 | if (record->event.pressed) { | ||
| 320 | if (!leading && keycode == KC_LEAD) { | ||
| 321 | leader_start(); | ||
| 322 | leading = true; | ||
| 323 | leader_time = timer_read(); | ||
| 324 | leader_sequence_size = 0; | ||
| 325 | leader_sequence[0] = 0; | ||
| 326 | leader_sequence[1] = 0; | ||
| 327 | leader_sequence[2] = 0; | ||
| 328 | return false; | ||
| 329 | } | ||
| 330 | if (leading && timer_elapsed(leader_time) < LEADER_TIMEOUT) { | ||
| 331 | leader_sequence[leader_sequence_size] = keycode; | ||
| 332 | leader_sequence_size++; | ||
| 333 | return false; | ||
| 334 | } | ||
| 335 | } | ||
| 336 | #endif | ||
| 337 | |||
| 338 | #define DISABLE_CHORDING | ||
| 339 | #ifndef DISABLE_CHORDING | ||
| 340 | |||
| 341 | if (keycode >= 0x5700 && keycode <= 0x57FF) { | ||
| 342 | if (record->event.pressed) { | ||
| 343 | if (!chording) { | ||
| 344 | chording = true; | ||
| 345 | for (uint8_t i = 0; i < CHORDING_MAX; i++) | ||
| 346 | chord_keys[i] = 0; | ||
| 347 | chord_key_count = 0; | ||
| 348 | chord_key_down = 0; | ||
| 349 | } | ||
| 350 | chord_keys[chord_key_count] = (keycode & 0xFF); | ||
| 351 | chord_key_count++; | ||
| 352 | chord_key_down++; | ||
| 353 | return false; | ||
| 354 | } else { | ||
| 355 | if (chording) { | ||
| 356 | chord_key_down--; | ||
| 357 | if (chord_key_down == 0) { | ||
| 358 | chording = false; | ||
| 359 | // Chord Dictionary | ||
| 360 | if (keys_chord((uint8_t[]){KC_ENTER, KC_SPACE})) { | ||
| 361 | register_code(KC_A); | ||
| 362 | unregister_code(KC_A); | ||
| 363 | return false; | ||
| 364 | } | ||
| 365 | for (uint8_t i = 0; i < chord_key_count; i++) { | ||
| 366 | register_code(chord_keys[i]); | ||
| 367 | unregister_code(chord_keys[i]); | ||
| 368 | return false; | ||
| 369 | } | ||
| 370 | } | ||
| 371 | } | ||
| 372 | } | ||
| 373 | } | ||
| 374 | |||
| 375 | #endif | ||
| 376 | |||
| 377 | #ifdef UNICODE_ENABLE | ||
| 378 | |||
| 379 | if (keycode > UNICODE(0) && record->event.pressed) { | ||
| 380 | uint16_t unicode = keycode & 0x7FFF; | ||
| 381 | switch(input_mode) { | ||
| 382 | case UC_OSX: | ||
| 383 | register_code(KC_LALT); | ||
| 384 | break; | ||
| 385 | case UC_LNX: | ||
| 386 | register_code(KC_LCTL); | ||
| 387 | register_code(KC_LSFT); | ||
| 388 | register_code(KC_U); | ||
| 389 | unregister_code(KC_U); | ||
| 390 | break; | ||
| 391 | case UC_WIN: | ||
| 392 | register_code(KC_LALT); | ||
| 393 | register_code(KC_PPLS); | ||
| 394 | unregister_code(KC_PPLS); | ||
| 395 | break; | ||
| 396 | } | ||
| 397 | for(int i = 3; i >= 0; i--) { | ||
| 398 | uint8_t digit = ((unicode >> (i*4)) & 0xF); | ||
| 399 | register_code(hex_to_keycode(digit)); | ||
| 400 | unregister_code(hex_to_keycode(digit)); | ||
| 401 | } | ||
| 402 | switch(input_mode) { | ||
| 403 | case UC_OSX: | ||
| 404 | case UC_WIN: | ||
| 405 | unregister_code(KC_LALT); | ||
| 406 | break; | ||
| 407 | case UC_LNX: | ||
| 408 | unregister_code(KC_LCTL); | ||
| 409 | unregister_code(KC_LSFT); | ||
| 410 | break; | ||
| 411 | } | ||
| 412 | } | ||
| 413 | |||
| 414 | #endif | ||
| 415 | |||
| 416 | return process_action_kb(record); | ||
| 417 | } | ||
| 418 | |||
| 419 | void matrix_init_quantum() { | ||
| 420 | matrix_init_kb(); | ||
| 421 | } | ||
| 422 | |||
| 423 | void matrix_scan_quantum() { | ||
| 424 | #ifdef AUDIO_ENABLE | ||
| 425 | if (music_sequence_playing) { | ||
| 426 | if ((music_sequence_timer == 0) || (timer_elapsed(music_sequence_timer) > music_sequence_interval)) { | ||
| 427 | music_sequence_timer = timer_read(); | ||
| 428 | stop_note(music_sequence[(music_sequence_position - 1 < 0)?(music_sequence_position - 1 + music_sequence_count):(music_sequence_position - 1)]); | ||
| 429 | play_note(music_sequence[music_sequence_position], 0xF); | ||
| 430 | music_sequence_position = (music_sequence_position + 1) % music_sequence_count; | ||
| 431 | } | ||
| 432 | } | ||
| 433 | |||
| 434 | #endif | ||
| 435 | |||
| 436 | matrix_scan_kb(); | ||
| 437 | } | ||
| 438 | #ifdef AUDIO_ENABLE | ||
| 439 | bool is_music_on(void) { | ||
| 440 | return (music_activated != 0); | ||
| 441 | } | ||
| 442 | |||
| 443 | void music_toggle(void) { | ||
| 444 | if (!music_activated) { | ||
| 445 | music_on(); | ||
| 446 | } else { | ||
| 447 | music_off(); | ||
| 448 | } | ||
| 449 | } | ||
| 450 | |||
| 451 | void music_on(void) { | ||
| 452 | music_activated = 1; | ||
| 453 | music_on_user(); | ||
| 454 | } | ||
| 455 | |||
| 456 | void music_off(void) { | ||
| 457 | music_activated = 0; | ||
| 458 | stop_all_notes(); | ||
| 459 | } | ||
| 460 | |||
| 461 | #endif | ||
| 462 | __attribute__ ((weak)) | ||
| 463 | void music_on_user() {} | ||
diff --git a/quantum/quantum.h b/quantum/quantum.h new file mode 100644 index 000000000..d4da77289 --- /dev/null +++ b/quantum/quantum.h | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | #ifndef QUANTUM_H | ||
| 2 | #define QUANTUM_H | ||
| 3 | |||
| 4 | #include "matrix.h" | ||
| 5 | #include "keymap_common.h" | ||
| 6 | #ifdef BACKLIGHT_ENABLE | ||
| 7 | #include "backlight.h" | ||
| 8 | #endif | ||
| 9 | #ifdef RGBLIGHT_ENABLE | ||
| 10 | #include "rgblight.h" | ||
| 11 | #endif | ||
| 12 | #ifdef AUDIO_ENABLE | ||
| 13 | #include "audio.h" | ||
| 14 | #endif | ||
| 15 | #ifdef MIDI_ENABLE | ||
| 16 | #include <lufa.h> | ||
| 17 | #endif | ||
| 18 | #ifdef UNICODE_ENABLE | ||
| 19 | #include "unicode.h" | ||
| 20 | #endif | ||
| 21 | |||
| 22 | #include "action_layer.h" | ||
| 23 | #include "eeconfig.h" | ||
| 24 | #include <stddef.h> | ||
| 25 | #include <avr/io.h> | ||
| 26 | |||
| 27 | extern uint32_t default_layer_state; | ||
| 28 | |||
| 29 | #ifndef NO_ACTION_LAYER | ||
| 30 | extern uint32_t layer_state; | ||
| 31 | #endif | ||
| 32 | |||
| 33 | #ifdef AUDIO_ENABLE | ||
| 34 | bool music_activated; | ||
| 35 | #endif | ||
| 36 | |||
| 37 | #ifdef UNICODE_ENABLE | ||
| 38 | #define UC_OSX 0 | ||
| 39 | #define UC_LNX 1 | ||
| 40 | #define UC_WIN 2 | ||
| 41 | #define UC_BSD 3 | ||
| 42 | |||
| 43 | void set_unicode_input_mode(uint8_t os_target); | ||
| 44 | #endif | ||
| 45 | |||
| 46 | #ifndef DISABLE_LEADER | ||
| 47 | void leader_start(void); | ||
| 48 | void leader_end(void); | ||
| 49 | |||
| 50 | #ifndef LEADER_TIMEOUT | ||
| 51 | #define LEADER_TIMEOUT 200 | ||
| 52 | #endif | ||
| 53 | #define SEQ_ONE_KEY(key) if (leader_sequence[0] == (key) && leader_sequence[1] == 0 && leader_sequence[2] == 0) | ||
| 54 | #define SEQ_TWO_KEYS(key1, key2) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == 0) | ||
| 55 | #define SEQ_THREE_KEYS(key1, key2, key3) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == (key3)) | ||
| 56 | |||
| 57 | #define LEADER_EXTERNS() extern bool leading; extern uint16_t leader_time; extern uint16_t leader_sequence[3]; extern uint8_t leader_sequence_size | ||
| 58 | #define LEADER_DICTIONARY() if (leading && timer_elapsed(leader_time) > LEADER_TIMEOUT) | ||
| 59 | #endif | ||
| 60 | |||
| 61 | void matrix_init_kb(void); | ||
| 62 | void matrix_scan_kb(void); | ||
| 63 | bool process_action_kb(keyrecord_t *record); | ||
| 64 | |||
| 65 | bool is_music_on(void); | ||
| 66 | void music_toggle(void); | ||
| 67 | void music_on(void); | ||
| 68 | void music_off(void); | ||
| 69 | |||
| 70 | void music_on_user(void); | ||
| 71 | |||
| 72 | #endif \ No newline at end of file | ||
diff --git a/quantum/quantum.mk b/quantum/quantum.mk index 5f4c2f045..c099d6793 100644 --- a/quantum/quantum.mk +++ b/quantum/quantum.mk | |||
| @@ -1,7 +1,8 @@ | |||
| 1 | QUANTUM_DIR = quantum | 1 | QUANTUM_DIR = quantum |
| 2 | 2 | ||
| 3 | # # project specific files | 3 | # # project specific files |
| 4 | SRC += $(QUANTUM_DIR)/keymap_common.c \ | 4 | SRC += $(QUANTUM_DIR)/quantum.c \ |
| 5 | $(QUANTUM_DIR)/keymap_common.c \ | ||
| 5 | $(QUANTUM_DIR)/led.c | 6 | $(QUANTUM_DIR)/led.c |
| 6 | 7 | ||
| 7 | # ifdef KEYMAP_FILE | 8 | # ifdef KEYMAP_FILE |
| @@ -23,9 +24,9 @@ ifndef CUSTOM_MATRIX | |||
| 23 | SRC += $(QUANTUM_DIR)/matrix.c | 24 | SRC += $(QUANTUM_DIR)/matrix.c |
| 24 | endif | 25 | endif |
| 25 | 26 | ||
| 26 | ifeq ($(strip $(MIDI_ENABLE)), yes) | 27 | #ifeq ($(strip $(MIDI_ENABLE)), yes) |
| 27 | SRC += $(QUANTUM_DIR)/keymap_midi.c | 28 | # SRC += $(QUANTUM_DIR)/keymap_midi.c |
| 28 | endif | 29 | #endif |
| 29 | 30 | ||
| 30 | ifeq ($(strip $(AUDIO_ENABLE)), yes) | 31 | ifeq ($(strip $(AUDIO_ENABLE)), yes) |
| 31 | SRC += $(QUANTUM_DIR)/audio/audio.c | 32 | SRC += $(QUANTUM_DIR)/audio/audio.c |
| @@ -33,10 +34,6 @@ ifeq ($(strip $(AUDIO_ENABLE)), yes) | |||
| 33 | SRC += $(QUANTUM_DIR)/audio/luts.c | 34 | SRC += $(QUANTUM_DIR)/audio/luts.c |
| 34 | endif | 35 | endif |
| 35 | 36 | ||
| 36 | ifeq ($(strip $(UNICODE_ENABLE)), yes) | ||
| 37 | SRC += $(QUANTUM_DIR)/keymap_unicode.c | ||
| 38 | endif | ||
| 39 | |||
| 40 | ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) | 37 | ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) |
| 41 | SRC += $(QUANTUM_DIR)/light_ws2812.c | 38 | SRC += $(QUANTUM_DIR)/light_ws2812.c |
| 42 | SRC += $(QUANTUM_DIR)/rgblight.c | 39 | SRC += $(QUANTUM_DIR)/rgblight.c |
diff --git a/quantum/template/template.c b/quantum/template/template.c index 6050a2d20..649072eb2 100644 --- a/quantum/template/template.c +++ b/quantum/template/template.c | |||
| @@ -11,8 +11,9 @@ void matrix_scan_user(void) { | |||
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | __attribute__ ((weak)) | 13 | __attribute__ ((weak)) |
| 14 | void process_action_user(keyrecord_t *record) { | 14 | bool process_action_user(keyrecord_t *record) { |
| 15 | // leave this function blank - it can be defined in a keymap file | 15 | // leave this function blank - it can be defined in a keymap file |
| 16 | return true; | ||
| 16 | } | 17 | } |
| 17 | 18 | ||
| 18 | __attribute__ ((weak)) | 19 | __attribute__ ((weak)) |
| @@ -34,11 +35,11 @@ void matrix_scan_kb(void) { | |||
| 34 | matrix_scan_user(); | 35 | matrix_scan_user(); |
| 35 | } | 36 | } |
| 36 | 37 | ||
| 37 | void process_action_kb(keyrecord_t *record) { | 38 | bool process_action_kb(keyrecord_t *record) { |
| 38 | // put your per-action keyboard code here | 39 | // put your per-action keyboard code here |
| 39 | // runs for every action, just before processing by the firmware | 40 | // runs for every action, just before processing by the firmware |
| 40 | 41 | ||
| 41 | process_action_user(record); | 42 | return process_action_user(record); |
| 42 | } | 43 | } |
| 43 | 44 | ||
| 44 | void led_set_kb(uint8_t usb_led) { | 45 | void led_set_kb(uint8_t usb_led) { |
diff --git a/quantum/template/template.h b/quantum/template/template.h index 22742105a..8537e3b4b 100644 --- a/quantum/template/template.h +++ b/quantum/template/template.h | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | 24 | ||
| 25 | void matrix_init_user(void); | 25 | void matrix_init_user(void); |
| 26 | void matrix_scan_user(void); | 26 | void matrix_scan_user(void); |
| 27 | void process_action_user(keyrecord_t *record); | 27 | bool process_action_user(keyrecord_t *record); |
| 28 | void led_set_user(uint8_t usb_led); | 28 | void led_set_user(uint8_t usb_led); |
| 29 | 29 | ||
| 30 | #endif | 30 | #endif |
diff --git a/quantum/unicode.h b/quantum/unicode.h new file mode 100644 index 000000000..756ec8bc3 --- /dev/null +++ b/quantum/unicode.h | |||
| @@ -0,0 +1,128 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2016 Jack Humbert <jack.humb@gmail.com> | ||
| 3 | This program is free software: you can redistribute it and/or modify | ||
| 4 | it under the terms of the GNU General Public License as published by | ||
| 5 | the Free Software Foundation, either version 2 of the License, or | ||
| 6 | (at your option) any later version. | ||
| 7 | This program is distributed in the hope that it will be useful, | ||
| 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 10 | GNU General Public License for more details. | ||
| 11 | You should have received a copy of the GNU General Public License | ||
| 12 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 13 | */ | ||
| 14 | |||
| 15 | #ifndef UNICODE_H | ||
| 16 | #define UNICODE_H | ||
| 17 | |||
| 18 | #include "quantum.h" | ||
| 19 | #include <math.h> | ||
| 20 | |||
| 21 | #define UC_BSPC UC(0x0008) | ||
| 22 | |||
| 23 | #define UC_SPC UC(0x0020) | ||
| 24 | |||
| 25 | #define UC_EXLM UC(0x0021) | ||
| 26 | #define UC_DQUT UC(0x0022) | ||
| 27 | #define UC_HASH UC(0x0023) | ||
| 28 | #define UC_DLR UC(0x0024) | ||
| 29 | #define UC_PERC UC(0x0025) | ||
| 30 | #define UC_AMPR UC(0x0026) | ||
| 31 | #define UC_QUOT UC(0x0027) | ||
| 32 | #define UC_LPRN UC(0x0028) | ||
| 33 | #define UC_RPRN UC(0x0029) | ||
| 34 | #define UC_ASTR UC(0x002A) | ||
| 35 | #define UC_PLUS UC(0x002B) | ||
| 36 | #define UC_COMM UC(0x002C) | ||
| 37 | #define UC_DASH UC(0x002D) | ||
| 38 | #define UC_DOT UC(0x002E) | ||
| 39 | #define UC_SLSH UC(0x002F) | ||
| 40 | |||
| 41 | #define UC_0 UC(0x0030) | ||
| 42 | #define UC_1 UC(0x0031) | ||
| 43 | #define UC_2 UC(0x0032) | ||
| 44 | #define UC_3 UC(0x0033) | ||
| 45 | #define UC_4 UC(0x0034) | ||
| 46 | #define UC_5 UC(0x0035) | ||
| 47 | #define UC_6 UC(0x0036) | ||
| 48 | #define UC_7 UC(0x0037) | ||
| 49 | #define UC_8 UC(0x0038) | ||
| 50 | #define UC_9 UC(0x0039) | ||
| 51 | |||
| 52 | #define UC_COLN UC(0x003A) | ||
| 53 | #define UC_SCLN UC(0x003B) | ||
| 54 | #define UC_LT UC(0x003C) | ||
| 55 | #define UC_EQL UC(0x003D) | ||
| 56 | #define UC_GT UC(0x003E) | ||
| 57 | #define UC_QUES UC(0x003F) | ||
| 58 | #define UC_AT UC(0x0040) | ||
| 59 | |||
| 60 | #define UC_A UC(0x0041) | ||
| 61 | #define UC_B UC(0x0042) | ||
| 62 | #define UC_C UC(0x0043) | ||
| 63 | #define UC_D UC(0x0044) | ||
| 64 | #define UC_E UC(0x0045) | ||
| 65 | #define UC_F UC(0x0046) | ||
| 66 | #define UC_G UC(0x0047) | ||
| 67 | #define UC_H UC(0x0048) | ||
| 68 | #define UC_I UC(0x0049) | ||
| 69 | #define UC_J UC(0x004A) | ||
| 70 | #define UC_K UC(0x004B) | ||
| 71 | #define UC_L UC(0x004C) | ||
| 72 | #define UC_M UC(0x004D) | ||
| 73 | #define UC_N UC(0x004E) | ||
| 74 | #define UC_O UC(0x004F) | ||
| 75 | #define UC_P UC(0x0050) | ||
| 76 | #define UC_Q UC(0x0051) | ||
| 77 | #define UC_R UC(0x0052) | ||
| 78 | #define UC_S UC(0x0053) | ||
| 79 | #define UC_T UC(0x0054) | ||
| 80 | #define UC_U UC(0x0055) | ||
| 81 | #define UC_V UC(0x0056) | ||
| 82 | #define UC_W UC(0x0057) | ||
| 83 | #define UC_X UC(0x0058) | ||
| 84 | #define UC_Y UC(0x0059) | ||
| 85 | #define UC_Z UC(0x005A) | ||
| 86 | |||
| 87 | #define UC_LBRC UC(0x005B) | ||
| 88 | #define UC_BSLS UC(0x005C) | ||
| 89 | #define UC_RBRC UC(0x005D) | ||
| 90 | #define UC_CIRM UC(0x005E) | ||
| 91 | #define UC_UNDR UC(0x005F) | ||
| 92 | |||
| 93 | #define UC_GRV UC(0x0060) | ||
| 94 | |||
| 95 | #define UC_a UC(0x0061) | ||
| 96 | #define UC_b UC(0x0062) | ||
| 97 | #define UC_c UC(0x0063) | ||
| 98 | #define UC_d UC(0x0064) | ||
| 99 | #define UC_e UC(0x0065) | ||
| 100 | #define UC_f UC(0x0066) | ||
| 101 | #define UC_g UC(0x0067) | ||
| 102 | #define UC_h UC(0x0068) | ||
| 103 | #define UC_i UC(0x0069) | ||
| 104 | #define UC_j UC(0x006A) | ||
| 105 | #define UC_k UC(0x006B) | ||
| 106 | #define UC_l UC(0x006C) | ||
| 107 | #define UC_m UC(0x006D) | ||
| 108 | #define UC_n UC(0x006E) | ||
| 109 | #define UC_o UC(0x006F) | ||
| 110 | #define UC_p UC(0x0070) | ||
| 111 | #define UC_q UC(0x0071) | ||
| 112 | #define UC_r UC(0x0072) | ||
| 113 | #define UC_s UC(0x0073) | ||
| 114 | #define UC_t UC(0x0074) | ||
| 115 | #define UC_u UC(0x0075) | ||
| 116 | #define UC_v UC(0x0076) | ||
| 117 | #define UC_w UC(0x0077) | ||
| 118 | #define UC_x UC(0x0078) | ||
| 119 | #define UC_y UC(0x0079) | ||
| 120 | #define UC_z UC(0x007A) | ||
| 121 | |||
| 122 | #define UC_LCBR UC(0x007B) | ||
| 123 | #define UC_PIPE UC(0x007C) | ||
| 124 | #define UC_RCBR UC(0x007D) | ||
| 125 | #define UC_TILD UC(0x007E) | ||
| 126 | #define UC_DEL UC(0x007F) | ||
| 127 | |||
| 128 | #endif \ No newline at end of file | ||
