diff options
| author | Jack Humbert <jack.humb@gmail.com> | 2016-05-18 23:47:16 -0400 |
|---|---|---|
| committer | Jack Humbert <jack.humb@gmail.com> | 2016-05-18 23:47:16 -0400 |
| commit | b732b79b49b098dba8e14493c745075f336747d8 (patch) | |
| tree | 069f529df73ba8bfbcf7003f5ddd3987ecaadc57 /quantum | |
| parent | bf545061f2a71b054ccdca6f6261bb7c2ffa4957 (diff) | |
| download | qmk_firmware-b732b79b49b098dba8e14493c745075f336747d8.tar.gz qmk_firmware-b732b79b49b098dba8e14493c745075f336747d8.zip | |
adapts unicode to quantum.c (#333)
* Unicode
to have unicode input you need to:
- set your OS input method to UNICODE if needed
- enable unicode in your makefile
- copy the action_function from
keyboard/planck/keymaps/unicode/unicode.c to your keymap.c
set the target OS method in your keymap.c: void matrix_init_user() {
set_unicode_mode(UC_OSX); } you can then switch when you want with:
set_unicode_mode(UC_OSX); set_unicode_mode(UC_LNX);
set_unicode_mode(UC_WIN);
put some unicode codes in your keymap like so: UC(0x0061)
I did change the bit mask in quantum/keymap_common.c and .h
I’m afraid we will need uint32 to get a total support for all unicode
tables or relocate the handler as @mbarkhau did.
* rearranges keycode values, hooks-up unicode
* removes extra lalt ref
* adds unicode shortcuts and example
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/keymap_common.c | 26 | ||||
| -rw-r--r-- | quantum/keymap_common.h | 76 | ||||
| -rw-r--r-- | quantum/keymap_unicode.c | 61 | ||||
| -rw-r--r-- | quantum/quantum.c | 79 | ||||
| -rw-r--r-- | quantum/quantum.h | 44 | ||||
| -rw-r--r-- | quantum/quantum.mk | 4 | ||||
| -rw-r--r-- | quantum/unicode.h | 128 |
7 files changed, 278 insertions, 140 deletions
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 2aae13e67..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 ... 0x56FF: ; | 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,18 +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 | case 0x7000 ... 0x7FFF: | 286 | case MT(0, 0) ... MT(0xF, 0xFF): |
| 286 | action.code = ACTION_MODS_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); | 287 | action.code = ACTION_MODS_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); |
| 287 | break; | 288 | break; |
| 288 | case 0x8000 ... 0x8FFF: | ||
| 289 | action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); | ||
| 290 | break; | ||
| 291 | #ifdef UNICODE_ENABLE | ||
| 292 | case 0x8000000 ... 0x8FFFFFF: | ||
| 293 | uint16_t unicode = keycode & ~(0x8000); | ||
| 294 | action.code = ACTION_FUNCTION_OPT(unicode & 0xFF, (unicode & 0xFF00) >> 8); | ||
| 295 | break; | ||
| 296 | #endif | ||
| 297 | default: | 289 | default: |
| 298 | action.code = ACTION_NO; | 290 | action.code = ACTION_NO; |
| 299 | break; | 291 | break; |
diff --git a/quantum/keymap_common.h b/quantum/keymap_common.h index 1cbe8c61c..91d5c09c1 100644 --- a/quantum/keymap_common.h +++ b/quantum/keymap_common.h | |||
| @@ -163,38 +163,13 @@ extern const uint16_t fn_actions[]; | |||
| 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 |
| 194 | #define KC_LEAD 0x5014 | ||
| 195 | |||
| 196 | |||
| 197 | |||
| 198 | 173 | ||
| 199 | // MAGIC keycodes | 174 | // MAGIC keycodes |
| 200 | #define MAGIC_SWAP_CONTROL_CAPSLOCK 0x5002 | 175 | #define MAGIC_SWAP_CONTROL_CAPSLOCK 0x5002 |
| @@ -239,6 +214,32 @@ extern const uint16_t fn_actions[]; | |||
| 239 | #define MI_ON 0x5028 | 214 | #define MI_ON 0x5028 |
| 240 | #define MI_OFF 0x5029 | 215 | #define MI_OFF 0x5029 |
| 241 | 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 | ||
| 242 | |||
| 242 | // GOTO layer - 16 layers max | 243 | // GOTO layer - 16 layers max |
| 243 | // when: | 244 | // when: |
| 244 | // ON_PRESS = 1 | 245 | // ON_PRESS = 1 |
| @@ -261,6 +262,8 @@ extern const uint16_t fn_actions[]; | |||
| 261 | // One-shot mod | 262 | // One-shot mod |
| 262 | #define OSM(layer) (layer | 0x5600) | 263 | #define OSM(layer) (layer | 0x5600) |
| 263 | 264 | ||
| 265 | // chording is currently at 0x57xx | ||
| 266 | |||
| 264 | // M-od, T-ap - 256 keycode max | 267 | // M-od, T-ap - 256 keycode max |
| 265 | #define MT(mod, kc) (kc | 0x7000 | ((mod & 0xF) << 8)) | 268 | #define MT(mod, kc) (kc | 0x7000 | ((mod & 0xF) << 8)) |
| 266 | #define CTL_T(kc) MT(0x1, kc) | 269 | #define CTL_T(kc) MT(0x1, kc) |
| @@ -276,14 +279,13 @@ extern const uint16_t fn_actions[]; | |||
| 276 | #define KC_HYPR HYPR(KC_NO) | 279 | #define KC_HYPR HYPR(KC_NO) |
| 277 | #define KC_MEH MEH(KC_NO) | 280 | #define KC_MEH MEH(KC_NO) |
| 278 | 281 | ||
| 279 | // L-ayer, T-ap - 256 keycode max, 16 layer max | 282 | #ifdef UNICODE_ENABLE |
| 280 | #define LT(layer, kc) (kc | 0x8000 | ((layer & 0xF) << 8)) | 283 | // For sending unicode codes. |
| 281 | 284 | // You may not send codes over 7FFF -- this supports most of UTF8. | |
| 282 | // For sending unicode codes. | 285 | // To have a key that sends out Œ, go UC(0x0152) |
| 283 | // You may not send codes over 1FFF -- this supports most of UTF8. | 286 | #define UNICODE(n) (n | 0x8000) |
| 284 | // To have a key that sends out Œ, go UC(0x0152) | 287 | #define UC(n) UNICODE(n) |
| 285 | #define UNICODE(n) (n | 0x8000) | 288 | #endif |
| 286 | #define UC(n) UNICODE(n) | ||
| 287 | 289 | ||
| 288 | // For tri-layer | 290 | // For tri-layer |
| 289 | 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_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/quantum.c b/quantum/quantum.c index e4d7b9185..1e91ac04a 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -23,6 +23,18 @@ int offset = 7; | |||
| 23 | 23 | ||
| 24 | #ifdef AUDIO_ENABLE | 24 | #ifdef AUDIO_ENABLE |
| 25 | bool music_activated = false; | 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 | |||
| 26 | #endif | 38 | #endif |
| 27 | 39 | ||
| 28 | #ifdef MIDI_ENABLE | 40 | #ifdef MIDI_ENABLE |
| @@ -44,6 +56,10 @@ uint8_t chord_keys[CHORDING_MAX] = {0}; | |||
| 44 | uint8_t chord_key_count = 0; | 56 | uint8_t chord_key_count = 0; |
| 45 | uint8_t chord_key_down = 0; | 57 | uint8_t chord_key_down = 0; |
| 46 | 58 | ||
| 59 | #ifdef UNICODE_ENABLE | ||
| 60 | static uint8_t input_mode; | ||
| 61 | #endif | ||
| 62 | |||
| 47 | bool keys_chord(uint8_t keys[]) { | 63 | bool keys_chord(uint8_t keys[]) { |
| 48 | uint8_t keys_size = sizeof(keys)/sizeof(keys[0]); | 64 | uint8_t keys_size = sizeof(keys)/sizeof(keys[0]); |
| 49 | bool pass = true; | 65 | bool pass = true; |
| @@ -66,14 +82,25 @@ bool keys_chord(uint8_t keys[]) { | |||
| 66 | return (pass && (in == keys_size)); | 82 | return (pass && (in == keys_size)); |
| 67 | } | 83 | } |
| 68 | 84 | ||
| 69 | static bool music_sequence_recording = false; | 85 | #ifdef UNICODE_ENABLE |
| 70 | static bool music_sequence_playing = false; | 86 | |
| 71 | static float music_sequence[16] = {0}; | 87 | uint16_t hex_to_keycode(uint8_t hex) |
| 72 | static uint8_t music_sequence_count = 0; | 88 | { |
| 73 | static uint8_t music_sequence_position = 0; | 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 | } | ||
| 74 | 102 | ||
| 75 | static uint16_t music_sequence_timer = 0; | 103 | #endif |
| 76 | static uint16_t music_sequence_interval = 100; | ||
| 77 | 104 | ||
| 78 | bool process_record_quantum(keyrecord_t *record) { | 105 | bool process_record_quantum(keyrecord_t *record) { |
| 79 | 106 | ||
| @@ -347,6 +374,44 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 347 | 374 | ||
| 348 | #endif | 375 | #endif |
| 349 | 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 | ||
| 350 | 415 | ||
| 351 | return process_action_kb(record); | 416 | return process_action_kb(record); |
| 352 | } | 417 | } |
diff --git a/quantum/quantum.h b/quantum/quantum.h index f4d8f09d4..d4da77289 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
| @@ -13,9 +13,12 @@ | |||
| 13 | #include "audio.h" | 13 | #include "audio.h" |
| 14 | #endif | 14 | #endif |
| 15 | #ifdef MIDI_ENABLE | 15 | #ifdef MIDI_ENABLE |
| 16 | // #include <keymap_midi.h> | ||
| 17 | #include <lufa.h> | 16 | #include <lufa.h> |
| 18 | #endif | 17 | #endif |
| 18 | #ifdef UNICODE_ENABLE | ||
| 19 | #include "unicode.h" | ||
| 20 | #endif | ||
| 21 | |||
| 19 | #include "action_layer.h" | 22 | #include "action_layer.h" |
| 20 | #include "eeconfig.h" | 23 | #include "eeconfig.h" |
| 21 | #include <stddef.h> | 24 | #include <stddef.h> |
| @@ -27,24 +30,37 @@ extern uint32_t default_layer_state; | |||
| 27 | extern uint32_t layer_state; | 30 | extern uint32_t layer_state; |
| 28 | #endif | 31 | #endif |
| 29 | 32 | ||
| 30 | bool music_activated; | 33 | #ifdef AUDIO_ENABLE |
| 34 | bool music_activated; | ||
| 35 | #endif | ||
| 31 | 36 | ||
| 32 | void matrix_init_kb(void); | 37 | #ifdef UNICODE_ENABLE |
| 33 | void matrix_scan_kb(void); | 38 | #define UC_OSX 0 |
| 34 | bool process_action_kb(keyrecord_t *record); | 39 | #define UC_LNX 1 |
| 40 | #define UC_WIN 2 | ||
| 41 | #define UC_BSD 3 | ||
| 35 | 42 | ||
| 36 | void leader_start(void); | 43 | void set_unicode_input_mode(uint8_t os_target); |
| 37 | void leader_end(void); | 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)) | ||
| 38 | 56 | ||
| 39 | #ifndef LEADER_TIMEOUT | 57 | #define LEADER_EXTERNS() extern bool leading; extern uint16_t leader_time; extern uint16_t leader_sequence[3]; extern uint8_t leader_sequence_size |
| 40 | #define LEADER_TIMEOUT 200 | 58 | #define LEADER_DICTIONARY() if (leading && timer_elapsed(leader_time) > LEADER_TIMEOUT) |
| 41 | #endif | 59 | #endif |
| 42 | #define SEQ_ONE_KEY(key) if (leader_sequence[0] == (key) && leader_sequence[1] == 0 && leader_sequence[2] == 0) | ||
| 43 | #define SEQ_TWO_KEYS(key1, key2) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == 0) | ||
| 44 | #define SEQ_THREE_KEYS(key1, key2, key3) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == (key3)) | ||
| 45 | 60 | ||
| 46 | #define LEADER_EXTERNS() extern bool leading; extern uint16_t leader_time; extern uint16_t leader_sequence[3]; extern uint8_t leader_sequence_size | 61 | void matrix_init_kb(void); |
| 47 | #define LEADER_DICTIONARY() if (leading && timer_elapsed(leader_time) > LEADER_TIMEOUT) | 62 | void matrix_scan_kb(void); |
| 63 | bool process_action_kb(keyrecord_t *record); | ||
| 48 | 64 | ||
| 49 | bool is_music_on(void); | 65 | bool is_music_on(void); |
| 50 | void music_toggle(void); | 66 | void music_toggle(void); |
diff --git a/quantum/quantum.mk b/quantum/quantum.mk index e7ccfd659..c099d6793 100644 --- a/quantum/quantum.mk +++ b/quantum/quantum.mk | |||
| @@ -34,10 +34,6 @@ ifeq ($(strip $(AUDIO_ENABLE)), yes) | |||
| 34 | SRC += $(QUANTUM_DIR)/audio/luts.c | 34 | SRC += $(QUANTUM_DIR)/audio/luts.c |
| 35 | endif | 35 | endif |
| 36 | 36 | ||
| 37 | ifeq ($(strip $(UNICODE_ENABLE)), yes) | ||
| 38 | SRC += $(QUANTUM_DIR)/keymap_unicode.c | ||
| 39 | endif | ||
| 40 | |||
| 41 | ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) | 37 | ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) |
| 42 | SRC += $(QUANTUM_DIR)/light_ws2812.c | 38 | SRC += $(QUANTUM_DIR)/light_ws2812.c |
| 43 | SRC += $(QUANTUM_DIR)/rgblight.c | 39 | SRC += $(QUANTUM_DIR)/rgblight.c |
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 | ||
