diff options
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/process_keycode/process_unicode.c | 41 | ||||
| -rw-r--r-- | quantum/quantum_keycodes.h | 4 |
2 files changed, 37 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) { |
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 5cd3c8e78..4853655f9 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h | |||
| @@ -159,6 +159,8 @@ enum quantum_keycodes { | |||
| 159 | #define MEH(kc) (kc | QK_LCTL | QK_LSFT | QK_LALT) | 159 | #define MEH(kc) (kc | QK_LCTL | QK_LSFT | QK_LALT) |
| 160 | #define LCAG(kc) (kc | QK_LCTL | QK_LALT | QK_LGUI) | 160 | #define LCAG(kc) (kc | QK_LCTL | QK_LALT | QK_LGUI) |
| 161 | #define ALTG(kc) (kc | QK_RCTL | QK_RALT) | 161 | #define ALTG(kc) (kc | QK_RCTL | QK_RALT) |
| 162 | #define SCMD(kc) (kc | QK_LGUI | QK_LSFT) | ||
| 163 | #define SWIN(kc) SCMD(kc) | ||
| 162 | 164 | ||
| 163 | #define MOD_HYPR 0xf | 165 | #define MOD_HYPR 0xf |
| 164 | #define MOD_MEH 0x7 | 166 | #define MOD_MEH 0x7 |
| @@ -293,6 +295,8 @@ enum quantum_keycodes { | |||
| 293 | #define MEH_T(kc) MT((MOD_LCTL | MOD_LSFT | MOD_LALT), kc) // Meh is a less hyper version of the Hyper key -- doesn't include Win or Cmd, so just alt+shift+ctrl | 295 | #define MEH_T(kc) MT((MOD_LCTL | MOD_LSFT | MOD_LALT), kc) // Meh is a less hyper version of the Hyper key -- doesn't include Win or Cmd, so just alt+shift+ctrl |
| 294 | #define LCAG_T(kc) MT((MOD_LCTL | MOD_LALT | MOD_LGUI), kc) // Left control alt and gui | 296 | #define LCAG_T(kc) MT((MOD_LCTL | MOD_LALT | MOD_LGUI), kc) // Left control alt and gui |
| 295 | #define ALL_T(kc) MT((MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI), kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/ | 297 | #define ALL_T(kc) MT((MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI), kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/ |
| 298 | #define SCMD_T(kc) MT((MOD_LGUI | MOD_LSFT), kc) | ||
| 299 | #define SWIN_T(kc) SCMD_T(kc) | ||
| 296 | 300 | ||
| 297 | // Dedicated keycode versions for Hyper and Meh, if you want to use them as standalone keys rather than mod-tap | 301 | // Dedicated keycode versions for Hyper and Meh, if you want to use them as standalone keys rather than mod-tap |
| 298 | #define KC_HYPR HYPR(KC_NO) | 302 | #define KC_HYPR HYPR(KC_NO) |
