diff options
| author | IBNobody <protospherex@gmail.com> | 2016-10-28 09:28:47 -0500 |
|---|---|---|
| committer | IBNobody <protospherex@gmail.com> | 2016-10-28 09:28:47 -0500 |
| commit | a0fdb6b81aa33c493bc4fccab178fcbe02231578 (patch) | |
| tree | ae2eb2212acb86966efefb98fb7f04686c94b7da /quantum/process_keycode/process_unicode.c | |
| parent | ef8f6180272c3e112f97a6beb9dd90bece3c2131 (diff) | |
| parent | f44ead146214381aa78344f1d4fe3e1b24010c95 (diff) | |
| download | qmk_firmware-a0fdb6b81aa33c493bc4fccab178fcbe02231578.tar.gz qmk_firmware-a0fdb6b81aa33c493bc4fccab178fcbe02231578.zip | |
Merge remote-tracking branch 'refs/remotes/jackhumbert/master'
Diffstat (limited to 'quantum/process_keycode/process_unicode.c')
| -rw-r--r-- | quantum/process_keycode/process_unicode.c | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c index 37dd471ff..cd3a610b4 100644 --- a/quantum/process_keycode/process_unicode.c +++ b/quantum/process_keycode/process_unicode.c | |||
| @@ -42,6 +42,11 @@ void unicode_input_start (void) { | |||
| 42 | register_code(KC_PPLS); | 42 | register_code(KC_PPLS); |
| 43 | unregister_code(KC_PPLS); | 43 | unregister_code(KC_PPLS); |
| 44 | break; | 44 | break; |
| 45 | case UC_WINC: | ||
| 46 | register_code(KC_RALT); | ||
| 47 | unregister_code(KC_RALT); | ||
| 48 | register_code(KC_U); | ||
| 49 | unregister_code(KC_U); | ||
| 45 | } | 50 | } |
| 46 | wait_ms(UNICODE_TYPE_DELAY); | 51 | wait_ms(UNICODE_TYPE_DELAY); |
| 47 | } | 52 | } |
| @@ -83,22 +88,42 @@ __attribute__((weak)) | |||
| 83 | const uint32_t PROGMEM unicode_map[] = { | 88 | const uint32_t PROGMEM unicode_map[] = { |
| 84 | }; | 89 | }; |
| 85 | 90 | ||
| 86 | // 5 digit max because of linux limitation | ||
| 87 | void register_hex32(uint32_t hex) { | 91 | void register_hex32(uint32_t hex) { |
| 88 | for(int i = 4; i >= 0; i--) { | 92 | uint8_t onzerostart = 1; |
| 93 | for(int i = 7; i >= 0; i--) { | ||
| 94 | if (i <= 3) { | ||
| 95 | onzerostart = 0; | ||
| 96 | } | ||
| 89 | uint8_t digit = ((hex >> (i*4)) & 0xF); | 97 | uint8_t digit = ((hex >> (i*4)) & 0xF); |
| 90 | register_code(hex_to_keycode(digit)); | 98 | if (digit == 0) { |
| 91 | unregister_code(hex_to_keycode(digit)); | 99 | if (onzerostart == 0) { |
| 100 | register_code(hex_to_keycode(digit)); | ||
| 101 | unregister_code(hex_to_keycode(digit)); | ||
| 102 | } | ||
| 103 | } else { | ||
| 104 | register_code(hex_to_keycode(digit)); | ||
| 105 | unregister_code(hex_to_keycode(digit)); | ||
| 106 | onzerostart = 0; | ||
| 107 | } | ||
| 92 | } | 108 | } |
| 93 | } | 109 | } |
| 94 | 110 | ||
| 111 | __attribute__((weak)) | ||
| 112 | void unicode_map_input_error() {} | ||
| 113 | |||
| 95 | bool process_unicode_map(uint16_t keycode, keyrecord_t *record) { | 114 | bool process_unicode_map(uint16_t keycode, keyrecord_t *record) { |
| 96 | if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) { | 115 | if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) { |
| 97 | const uint32_t* map = unicode_map; | 116 | const uint32_t* map = unicode_map; |
| 98 | uint16_t index = keycode & 0x7FF; | 117 | uint16_t index = keycode & 0x7FF; |
| 99 | unicode_input_start(); | 118 | uint32_t code = pgm_read_dword_far(&map[index]); |
| 100 | register_hex32(pgm_read_dword_far(&map[index])); | 119 | if ((code > 0xFFFF && input_mode == UC_OSX) || (code > 0xFFFFF && input_mode == UC_LNX)) { |
| 101 | unicode_input_finish(); | 120 | // when character is out of range supported by the OS |
| 121 | unicode_map_input_error(); | ||
| 122 | } else { | ||
| 123 | unicode_input_start(); | ||
| 124 | register_hex32(code); | ||
| 125 | unicode_input_finish(); | ||
| 126 | } | ||
| 102 | } | 127 | } |
| 103 | return true; | 128 | return true; |
| 104 | } | 129 | } |
