diff options
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r-- | quantum/process_keycode/process_ucis.h | 1 | ||||
-rw-r--r-- | quantum/process_keycode/process_unicode.c | 85 | ||||
-rw-r--r-- | quantum/process_keycode/process_unicode.h | 124 | ||||
-rw-r--r-- | quantum/process_keycode/process_unicode_common.h | 130 | ||||
-rw-r--r-- | quantum/process_keycode/process_unicodemap.c | 2 | ||||
-rw-r--r-- | quantum/process_keycode/process_unicodemap.h | 1 |
6 files changed, 134 insertions, 209 deletions
diff --git a/quantum/process_keycode/process_ucis.h b/quantum/process_keycode/process_ucis.h index 520db8042..4332f57b3 100644 --- a/quantum/process_keycode/process_ucis.h +++ b/quantum/process_keycode/process_ucis.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define PROCESS_UCIS_H | 2 | #define PROCESS_UCIS_H |
3 | 3 | ||
4 | #include "quantum.h" | 4 | #include "quantum.h" |
5 | #include "process_unicode_common.h" | ||
5 | 6 | ||
6 | #ifndef UCIS_MAX_SYMBOL_LENGTH | 7 | #ifndef UCIS_MAX_SYMBOL_LENGTH |
7 | #define UCIS_MAX_SYMBOL_LENGTH 32 | 8 | #define UCIS_MAX_SYMBOL_LENGTH 32 |
diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c index 898e168a3..ccae6fdca 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; |
diff --git a/quantum/process_keycode/process_unicode.h b/quantum/process_keycode/process_unicode.h index 7ed9e54d5..4c21f11eb 100644 --- a/quantum/process_keycode/process_unicode.h +++ b/quantum/process_keycode/process_unicode.h | |||
@@ -2,130 +2,8 @@ | |||
2 | #define PROCESS_UNICODE_H | 2 | #define PROCESS_UNICODE_H |
3 | 3 | ||
4 | #include "quantum.h" | 4 | #include "quantum.h" |
5 | 5 | #include "process_unicode_common.h" | |
6 | #define UC_OSX 0 // Mac OS X | ||
7 | #define UC_LNX 1 // Linux | ||
8 | #define UC_WIN 2 // Windows 'HexNumpad' | ||
9 | #define UC_BSD 3 // BSD (not implemented) | ||
10 | #define UC_WINC 4 // WinCompose https://github.com/samhocevar/wincompose | ||
11 | |||
12 | #ifndef UNICODE_TYPE_DELAY | ||
13 | #define UNICODE_TYPE_DELAY 10 | ||
14 | #endif | ||
15 | |||
16 | void set_unicode_input_mode(uint8_t os_target); | ||
17 | uint8_t get_unicode_input_mode(void); | ||
18 | void unicode_input_start(void); | ||
19 | void unicode_input_finish(void); | ||
20 | void register_hex(uint16_t hex); | ||
21 | 6 | ||
22 | bool process_unicode(uint16_t keycode, keyrecord_t *record); | 7 | bool process_unicode(uint16_t keycode, keyrecord_t *record); |
23 | 8 | ||
24 | #define UC_BSPC UC(0x0008) | ||
25 | |||
26 | #define UC_SPC UC(0x0020) | ||
27 | |||
28 | #define UC_EXLM UC(0x0021) | ||
29 | #define UC_DQUT UC(0x0022) | ||
30 | #define UC_HASH UC(0x0023) | ||
31 | #define UC_DLR UC(0x0024) | ||
32 | #define UC_PERC UC(0x0025) | ||
33 | #define UC_AMPR UC(0x0026) | ||
34 | #define UC_QUOT UC(0x0027) | ||
35 | #define UC_LPRN UC(0x0028) | ||
36 | #define UC_RPRN UC(0x0029) | ||
37 | #define UC_ASTR UC(0x002A) | ||
38 | #define UC_PLUS UC(0x002B) | ||
39 | #define UC_COMM UC(0x002C) | ||
40 | #define UC_DASH UC(0x002D) | ||
41 | #define UC_DOT UC(0x002E) | ||
42 | #define UC_SLSH UC(0x002F) | ||
43 | |||
44 | #define UC_0 UC(0x0030) | ||
45 | #define UC_1 UC(0x0031) | ||
46 | #define UC_2 UC(0x0032) | ||
47 | #define UC_3 UC(0x0033) | ||
48 | #define UC_4 UC(0x0034) | ||
49 | #define UC_5 UC(0x0035) | ||
50 | #define UC_6 UC(0x0036) | ||
51 | #define UC_7 UC(0x0037) | ||
52 | #define UC_8 UC(0x0038) | ||
53 | #define UC_9 UC(0x0039) | ||
54 | |||
55 | #define UC_COLN UC(0x003A) | ||
56 | #define UC_SCLN UC(0x003B) | ||
57 | #define UC_LT UC(0x003C) | ||
58 | #define UC_EQL UC(0x003D) | ||
59 | #define UC_GT UC(0x003E) | ||
60 | #define UC_QUES UC(0x003F) | ||
61 | #define UC_AT UC(0x0040) | ||
62 | |||
63 | #define UC_A UC(0x0041) | ||
64 | #define UC_B UC(0x0042) | ||
65 | #define UC_C UC(0x0043) | ||
66 | #define UC_D UC(0x0044) | ||
67 | #define UC_E UC(0x0045) | ||
68 | #define UC_F UC(0x0046) | ||
69 | #define UC_G UC(0x0047) | ||
70 | #define UC_H UC(0x0048) | ||
71 | #define UC_I UC(0x0049) | ||
72 | #define UC_J UC(0x004A) | ||
73 | #define UC_K UC(0x004B) | ||
74 | #define UC_L UC(0x004C) | ||
75 | #define UC_M UC(0x004D) | ||
76 | #define UC_N UC(0x004E) | ||
77 | #define UC_O UC(0x004F) | ||
78 | #define UC_P UC(0x0050) | ||
79 | #define UC_Q UC(0x0051) | ||
80 | #define UC_R UC(0x0052) | ||
81 | #define UC_S UC(0x0053) | ||
82 | #define UC_T UC(0x0054) | ||
83 | #define UC_U UC(0x0055) | ||
84 | #define UC_V UC(0x0056) | ||
85 | #define UC_W UC(0x0057) | ||
86 | #define UC_X UC(0x0058) | ||
87 | #define UC_Y UC(0x0059) | ||
88 | #define UC_Z UC(0x005A) | ||
89 | |||
90 | #define UC_LBRC UC(0x005B) | ||
91 | #define UC_BSLS UC(0x005C) | ||
92 | #define UC_RBRC UC(0x005D) | ||
93 | #define UC_CIRM UC(0x005E) | ||
94 | #define UC_UNDR UC(0x005F) | ||
95 | |||
96 | #define UC_GRV UC(0x0060) | ||
97 | |||
98 | #define UC_a UC(0x0061) | ||
99 | #define UC_b UC(0x0062) | ||
100 | #define UC_c UC(0x0063) | ||
101 | #define UC_d UC(0x0064) | ||
102 | #define UC_e UC(0x0065) | ||
103 | #define UC_f UC(0x0066) | ||
104 | #define UC_g UC(0x0067) | ||
105 | #define UC_h UC(0x0068) | ||
106 | #define UC_i UC(0x0069) | ||
107 | #define UC_j UC(0x006A) | ||
108 | #define UC_k UC(0x006B) | ||
109 | #define UC_l UC(0x006C) | ||
110 | #define UC_m UC(0x006D) | ||
111 | #define UC_n UC(0x006E) | ||
112 | #define UC_o UC(0x006F) | ||
113 | #define UC_p UC(0x0070) | ||
114 | #define UC_q UC(0x0071) | ||
115 | #define UC_r UC(0x0072) | ||
116 | #define UC_s UC(0x0073) | ||
117 | #define UC_t UC(0x0074) | ||
118 | #define UC_u UC(0x0075) | ||
119 | #define UC_v UC(0x0076) | ||
120 | #define UC_w UC(0x0077) | ||
121 | #define UC_x UC(0x0078) | ||
122 | #define UC_y UC(0x0079) | ||
123 | #define UC_z UC(0x007A) | ||
124 | |||
125 | #define UC_LCBR UC(0x007B) | ||
126 | #define UC_PIPE UC(0x007C) | ||
127 | #define UC_RCBR UC(0x007D) | ||
128 | #define UC_TILD UC(0x007E) | ||
129 | #define UC_DEL UC(0x007F) | ||
130 | |||
131 | #endif | 9 | #endif |
diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h new file mode 100644 index 000000000..171ecbca1 --- /dev/null +++ b/quantum/process_keycode/process_unicode_common.h | |||
@@ -0,0 +1,130 @@ | |||
1 | #ifndef PROCESS_UNICODE_COMMON_H | ||
2 | #define PROCESS_UNICODE_COMMON_H | ||
3 | |||
4 | #include "quantum.h" | ||
5 | |||
6 | #ifndef UNICODE_TYPE_DELAY | ||
7 | #define UNICODE_TYPE_DELAY 10 | ||
8 | #endif | ||
9 | |||
10 | void set_unicode_input_mode(uint8_t os_target); | ||
11 | uint8_t get_unicode_input_mode(void); | ||
12 | void unicode_input_start(void); | ||
13 | void unicode_input_finish(void); | ||
14 | void register_hex(uint16_t hex); | ||
15 | |||
16 | |||
17 | #define UC_OSX 0 // Mac OS X | ||
18 | #define UC_LNX 1 // Linux | ||
19 | #define UC_WIN 2 // Windows 'HexNumpad' | ||
20 | #define UC_BSD 3 // BSD (not implemented) | ||
21 | #define UC_WINC 4 // WinCompose https://github.com/samhocevar/wincompose | ||
22 | |||
23 | #define UC_BSPC UC(0x0008) | ||
24 | |||
25 | #define UC_SPC UC(0x0020) | ||
26 | |||
27 | #define UC_EXLM UC(0x0021) | ||
28 | #define UC_DQUT UC(0x0022) | ||
29 | #define UC_HASH UC(0x0023) | ||
30 | #define UC_DLR UC(0x0024) | ||
31 | #define UC_PERC UC(0x0025) | ||
32 | #define UC_AMPR UC(0x0026) | ||
33 | #define UC_QUOT UC(0x0027) | ||
34 | #define UC_LPRN UC(0x0028) | ||
35 | #define UC_RPRN UC(0x0029) | ||
36 | #define UC_ASTR UC(0x002A) | ||
37 | #define UC_PLUS UC(0x002B) | ||
38 | #define UC_COMM UC(0x002C) | ||
39 | #define UC_DASH UC(0x002D) | ||
40 | #define UC_DOT UC(0x002E) | ||
41 | #define UC_SLSH UC(0x002F) | ||
42 | |||
43 | #define UC_0 UC(0x0030) | ||
44 | #define UC_1 UC(0x0031) | ||
45 | #define UC_2 UC(0x0032) | ||
46 | #define UC_3 UC(0x0033) | ||
47 | #define UC_4 UC(0x0034) | ||
48 | #define UC_5 UC(0x0035) | ||
49 | #define UC_6 UC(0x0036) | ||
50 | #define UC_7 UC(0x0037) | ||
51 | #define UC_8 UC(0x0038) | ||
52 | #define UC_9 UC(0x0039) | ||
53 | |||
54 | #define UC_COLN UC(0x003A) | ||
55 | #define UC_SCLN UC(0x003B) | ||
56 | #define UC_LT UC(0x003C) | ||
57 | #define UC_EQL UC(0x003D) | ||
58 | #define UC_GT UC(0x003E) | ||
59 | #define UC_QUES UC(0x003F) | ||
60 | #define UC_AT UC(0x0040) | ||
61 | |||
62 | #define UC_A UC(0x0041) | ||
63 | #define UC_B UC(0x0042) | ||
64 | #define UC_C UC(0x0043) | ||
65 | #define UC_D UC(0x0044) | ||
66 | #define UC_E UC(0x0045) | ||
67 | #define UC_F UC(0x0046) | ||
68 | #define UC_G UC(0x0047) | ||
69 | #define UC_H UC(0x0048) | ||
70 | #define UC_I UC(0x0049) | ||
71 | #define UC_J UC(0x004A) | ||
72 | #define UC_K UC(0x004B) | ||
73 | #define UC_L UC(0x004C) | ||
74 | #define UC_M UC(0x004D) | ||
75 | #define UC_N UC(0x004E) | ||
76 | #define UC_O UC(0x004F) | ||
77 | #define UC_P UC(0x0050) | ||
78 | #define UC_Q UC(0x0051) | ||
79 | #define UC_R UC(0x0052) | ||
80 | #define UC_S UC(0x0053) | ||
81 | #define UC_T UC(0x0054) | ||
82 | #define UC_U UC(0x0055) | ||
83 | #define UC_V UC(0x0056) | ||
84 | #define UC_W UC(0x0057) | ||
85 | #define UC_X UC(0x0058) | ||
86 | #define UC_Y UC(0x0059) | ||
87 | #define UC_Z UC(0x005A) | ||
88 | |||
89 | #define UC_LBRC UC(0x005B) | ||
90 | #define UC_BSLS UC(0x005C) | ||
91 | #define UC_RBRC UC(0x005D) | ||
92 | #define UC_CIRM UC(0x005E) | ||
93 | #define UC_UNDR UC(0x005F) | ||
94 | |||
95 | #define UC_GRV UC(0x0060) | ||
96 | |||
97 | #define UC_a UC(0x0061) | ||
98 | #define UC_b UC(0x0062) | ||
99 | #define UC_c UC(0x0063) | ||
100 | #define UC_d UC(0x0064) | ||
101 | #define UC_e UC(0x0065) | ||
102 | #define UC_f UC(0x0066) | ||
103 | #define UC_g UC(0x0067) | ||
104 | #define UC_h UC(0x0068) | ||
105 | #define UC_i UC(0x0069) | ||
106 | #define UC_j UC(0x006A) | ||
107 | #define UC_k UC(0x006B) | ||
108 | #define UC_l UC(0x006C) | ||
109 | #define UC_m UC(0x006D) | ||
110 | #define UC_n UC(0x006E) | ||
111 | #define UC_o UC(0x006F) | ||
112 | #define UC_p UC(0x0070) | ||
113 | #define UC_q UC(0x0071) | ||
114 | #define UC_r UC(0x0072) | ||
115 | #define UC_s UC(0x0073) | ||
116 | #define UC_t UC(0x0074) | ||
117 | #define UC_u UC(0x0075) | ||
118 | #define UC_v UC(0x0076) | ||
119 | #define UC_w UC(0x0077) | ||
120 | #define UC_x UC(0x0078) | ||
121 | #define UC_y UC(0x0079) | ||
122 | #define UC_z UC(0x007A) | ||
123 | |||
124 | #define UC_LCBR UC(0x007B) | ||
125 | #define UC_PIPE UC(0x007C) | ||
126 | #define UC_RCBR UC(0x007D) | ||
127 | #define UC_TILD UC(0x007E) | ||
128 | #define UC_DEL UC(0x007F) | ||
129 | |||
130 | #endif \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_unicodemap.c b/quantum/process_keycode/process_unicodemap.c index b8cdeaa97..37f10df86 100644 --- a/quantum/process_keycode/process_unicodemap.c +++ b/quantum/process_keycode/process_unicodemap.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #include "process_unicode_map.h" | 1 | #include "process_unicodemap.h" |
2 | 2 | ||
3 | __attribute__((weak)) | 3 | __attribute__((weak)) |
4 | const uint32_t PROGMEM unicode_map[] = { | 4 | const uint32_t PROGMEM unicode_map[] = { |
diff --git a/quantum/process_keycode/process_unicodemap.h b/quantum/process_keycode/process_unicodemap.h index 291bd8de0..64a7a0109 100644 --- a/quantum/process_keycode/process_unicodemap.h +++ b/quantum/process_keycode/process_unicodemap.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define PROCESS_UNICODEMAP_H | 2 | #define PROCESS_UNICODEMAP_H |
3 | 3 | ||
4 | #include "quantum.h" | 4 | #include "quantum.h" |
5 | #include "process_unicode_common.h" | ||
5 | 6 | ||
6 | void unicode_map_input_error(void); | 7 | void unicode_map_input_error(void); |
7 | bool process_unicode_map(uint16_t keycode, keyrecord_t *record); | 8 | bool process_unicode_map(uint16_t keycode, keyrecord_t *record); |