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