diff options
| author | Jack Humbert <jack.humb@gmail.com> | 2017-01-08 21:12:02 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-01-08 21:12:02 -0500 |
| commit | 176b93d08eb5cc0c65a6d571fc2c1fec5f575854 (patch) | |
| tree | e4445b1869a5e7a28913f50dd50306112e2c1510 /quantum | |
| parent | 18d013b25b3b6604b943bb0d889642ad18e49cc3 (diff) | |
| parent | 30b80a23f3cafd846937b37b249f2df4411e1f5a (diff) | |
| download | qmk_firmware-176b93d08eb5cc0c65a6d571fc2c1fec5f575854.tar.gz qmk_firmware-176b93d08eb5cc0c65a6d571fc2c1fec5f575854.zip | |
Merge pull request #994 from priyadi/unicode_mods_fix
Unregister all mods before inputting Unicode, and reregister afterwards
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/process_keycode/process_unicode.c | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c index cd3a610b4..a30e93ae3 100644 --- a/quantum/process_keycode/process_unicode.c +++ b/quantum/process_keycode/process_unicode.c | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #include "process_unicode.h" | 1 | #include "process_unicode.h" |
| 2 | #include "action_util.h" | ||
| 2 | 3 | ||
| 3 | static uint8_t input_mode; | 4 | static uint8_t input_mode; |
| 5 | uint8_t mods; | ||
| 4 | 6 | ||
| 5 | __attribute__((weak)) | 7 | __attribute__((weak)) |
| 6 | uint16_t hex_to_keycode(uint8_t hex) | 8 | uint16_t hex_to_keycode(uint8_t hex) |
| @@ -25,6 +27,19 @@ uint8_t get_unicode_input_mode(void) { | |||
| 25 | 27 | ||
| 26 | __attribute__((weak)) | 28 | __attribute__((weak)) |
| 27 | void unicode_input_start (void) { | 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 | |||
| 28 | switch(input_mode) { | 43 | switch(input_mode) { |
| 29 | case UC_OSX: | 44 | case UC_OSX: |
| 30 | register_code(KC_LALT); | 45 | register_code(KC_LALT); |
| @@ -54,15 +69,25 @@ void unicode_input_start (void) { | |||
| 54 | __attribute__((weak)) | 69 | __attribute__((weak)) |
| 55 | void unicode_input_finish (void) { | 70 | void unicode_input_finish (void) { |
| 56 | switch(input_mode) { | 71 | switch(input_mode) { |
| 57 | case UC_OSX: | 72 | case UC_OSX: |
| 58 | case UC_WIN: | 73 | case UC_WIN: |
| 59 | unregister_code(KC_LALT); | 74 | unregister_code(KC_LALT); |
| 60 | break; | 75 | break; |
| 61 | case UC_LNX: | 76 | case UC_LNX: |
| 62 | register_code(KC_SPC); | 77 | register_code(KC_SPC); |
| 63 | unregister_code(KC_SPC); | 78 | unregister_code(KC_SPC); |
| 64 | break; | 79 | break; |
| 65 | } | 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); | ||
| 66 | } | 91 | } |
| 67 | 92 | ||
| 68 | void register_hex(uint16_t hex) { | 93 | void register_hex(uint16_t hex) { |
