diff options
| author | Jack Humbert <jack.humb@gmail.com> | 2017-02-15 17:09:35 -0500 |
|---|---|---|
| committer | Jack Humbert <jack.humb@gmail.com> | 2017-02-15 17:09:35 -0500 |
| commit | 09add35e7f0b17f720862bc9b0f8478763937328 (patch) | |
| tree | 1b2316ac1015642b9389dbf66d7b1f0c0c8f3280 /quantum/process_keycode/process_unicode.c | |
| parent | cbabb4d417ef58f5d484dc256b637f61619efaa8 (diff) | |
add unicode common file, get names right
Diffstat (limited to 'quantum/process_keycode/process_unicode.c')
| -rw-r--r-- | quantum/process_keycode/process_unicode.c | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c index 898e168a30..ccae6fdcad 100644 --- a/quantum/process_keycode/process_unicode.c +++ b/quantum/process_keycode/process_unicode.c | |||
| @@ -1,91 +1,6 @@ | |||
| 1 | #include "process_unicode.h" | 1 | #include "process_unicode.h" |
| 2 | #include "action_util.h" | 2 | #include "action_util.h" |
| 3 | 3 | ||
| 4 | static uint8_t input_mode; | ||
| 5 | uint8_t mods; | ||
| 6 | |||
| 7 | void set_unicode_input_mode(uint8_t os_target) | ||
| 8 | { | ||
| 9 | input_mode = os_target; | ||
| 10 | } | ||
| 11 | |||
| 12 | uint8_t get_unicode_input_mode(void) { | ||
| 13 | return input_mode; | ||
| 14 | } | ||
| 15 | |||
| 16 | __attribute__((weak)) | ||
| 17 | void unicode_input_start (void) { | ||
| 18 | // save current mods | ||
| 19 | mods = keyboard_report->mods; | ||
| 20 | |||
| 21 | // unregister all mods to start from clean state | ||
| 22 | if (mods & MOD_BIT(KC_LSFT)) unregister_code(KC_LSFT); | ||
| 23 | if (mods & MOD_BIT(KC_RSFT)) unregister_code(KC_RSFT); | ||
| 24 | if (mods & MOD_BIT(KC_LCTL)) unregister_code(KC_LCTL); | ||
| 25 | if (mods & MOD_BIT(KC_RCTL)) unregister_code(KC_RCTL); | ||
| 26 | if (mods & MOD_BIT(KC_LALT)) unregister_code(KC_LALT); | ||
| 27 | if (mods & MOD_BIT(KC_RALT)) unregister_code(KC_RALT); | ||
| 28 | if (mods & MOD_BIT(KC_LGUI)) unregister_code(KC_LGUI); | ||
| 29 | if (mods & MOD_BIT(KC_RGUI)) unregister_code(KC_RGUI); | ||
| 30 | |||
| 31 | switch(input_mode) { | ||
| 32 | case UC_OSX: | ||
| 33 | register_code(KC_LALT); | ||
| 34 | break; | ||
| 35 | case UC_LNX: | ||
| 36 | register_code(KC_LCTL); | ||
| 37 | register_code(KC_LSFT); | ||
| 38 | register_code(KC_U); | ||
| 39 | unregister_code(KC_U); | ||
| 40 | unregister_code(KC_LSFT); | ||
| 41 | unregister_code(KC_LCTL); | ||
| 42 | break; | ||
| 43 | case UC_WIN: | ||
| 44 | register_code(KC_LALT); | ||
| 45 | register_code(KC_PPLS); | ||
| 46 | unregister_code(KC_PPLS); | ||
| 47 | break; | ||
| 48 | case UC_WINC: | ||
| 49 | register_code(KC_RALT); | ||
| 50 | unregister_code(KC_RALT); | ||
| 51 | register_code(KC_U); | ||
| 52 | unregister_code(KC_U); | ||
| 53 | } | ||
| 54 | wait_ms(UNICODE_TYPE_DELAY); | ||
| 55 | } | ||
| 56 | |||
| 57 | __attribute__((weak)) | ||
| 58 | void unicode_input_finish (void) { | ||
| 59 | switch(input_mode) { | ||
| 60 | case UC_OSX: | ||
| 61 | case UC_WIN: | ||
| 62 | unregister_code(KC_LALT); | ||
| 63 | break; | ||
| 64 | case UC_LNX: | ||
| 65 | register_code(KC_SPC); | ||
| 66 | unregister_code(KC_SPC); | ||
| 67 | break; | ||
| 68 | } | ||
| 69 | |||
| 70 | // reregister previously set mods | ||
| 71 | if (mods & MOD_BIT(KC_LSFT)) register_code(KC_LSFT); | ||
| 72 | if (mods & MOD_BIT(KC_RSFT)) register_code(KC_RSFT); | ||
| 73 | if (mods & MOD_BIT(KC_LCTL)) register_code(KC_LCTL); | ||
| 74 | if (mods & MOD_BIT(KC_RCTL)) register_code(KC_RCTL); | ||
| 75 | if (mods & MOD_BIT(KC_LALT)) register_code(KC_LALT); | ||
| 76 | if (mods & MOD_BIT(KC_RALT)) register_code(KC_RALT); | ||
| 77 | if (mods & MOD_BIT(KC_LGUI)) register_code(KC_LGUI); | ||
| 78 | if (mods & MOD_BIT(KC_RGUI)) register_code(KC_RGUI); | ||
| 79 | } | ||
| 80 | |||
| 81 | void register_hex(uint16_t hex) { | ||
| 82 | for(int i = 3; i >= 0; i--) { | ||
| 83 | uint8_t digit = ((hex >> (i*4)) & 0xF); | ||
| 84 | register_code(hex_to_keycode(digit)); | ||
| 85 | unregister_code(hex_to_keycode(digit)); | ||
| 86 | } | ||
| 87 | } | ||
| 88 | |||
| 89 | bool process_unicode(uint16_t keycode, keyrecord_t *record) { | 4 | bool process_unicode(uint16_t keycode, keyrecord_t *record) { |
| 90 | if (keycode > QK_UNICODE && record->event.pressed) { | 5 | if (keycode > QK_UNICODE && record->event.pressed) { |
| 91 | uint16_t unicode = keycode & 0x7FFF; | 6 | uint16_t unicode = keycode & 0x7FFF; |
