aboutsummaryrefslogtreecommitdiff
path: root/quantum/process_keycode
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r--quantum/process_keycode/process_unicode.c75
-rw-r--r--quantum/process_keycode/process_unicode_common.c15
2 files changed, 15 insertions, 75 deletions
diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c
index cecfaeee9..1f16b9bdb 100644
--- a/quantum/process_keycode/process_unicode.c
+++ b/quantum/process_keycode/process_unicode.c
@@ -16,81 +16,6 @@
16#include "process_unicode.h" 16#include "process_unicode.h"
17#include "action_util.h" 17#include "action_util.h"
18 18
19static uint8_t input_mode;
20static uint8_t first_flag = 0;
21
22__attribute__((weak))
23uint16_t hex_to_keycode(uint8_t hex)
24{
25 if (hex == 0x0) {
26 return KC_0;
27 } else if (hex < 0xA) {
28 return KC_1 + (hex - 0x1);
29 } else {
30 return KC_A + (hex - 0xA);
31 }
32}
33
34void set_unicode_input_mode(uint8_t os_target)
35{
36 input_mode = os_target;
37 eeprom_update_byte(EECONFIG_UNICODEMODE, os_target);
38}
39
40uint8_t get_unicode_input_mode(void) {
41 return input_mode;
42}
43
44__attribute__((weak))
45void unicode_input_start (void) {
46 switch(input_mode) {
47 case UC_OSX:
48 register_code(KC_LALT);
49 break;
50 case UC_LNX:
51 register_code(KC_LCTL);
52 register_code(KC_LSFT);
53 register_code(KC_U);
54 unregister_code(KC_U);
55 unregister_code(KC_LSFT);
56 unregister_code(KC_LCTL);
57 break;
58 case UC_WIN:
59 register_code(KC_LALT);
60 register_code(KC_PPLS);
61 unregister_code(KC_PPLS);
62 break;
63 case UC_WINC:
64 register_code(KC_RALT);
65 unregister_code(KC_RALT);
66 register_code(KC_U);
67 unregister_code(KC_U);
68 }
69 wait_ms(UNICODE_TYPE_DELAY);
70}
71
72__attribute__((weak))
73void unicode_input_finish (void) {
74 switch(input_mode) {
75 case UC_OSX:
76 case UC_WIN:
77 unregister_code(KC_LALT);
78 break;
79 case UC_LNX:
80 register_code(KC_SPC);
81 unregister_code(KC_SPC);
82 break;
83 }
84}
85
86void register_hex(uint16_t hex) {
87 for(int i = 3; i >= 0; i--) {
88 uint8_t digit = ((hex >> (i*4)) & 0xF);
89 register_code(hex_to_keycode(digit));
90 unregister_code(hex_to_keycode(digit));
91 }
92}
93
94 19
95bool process_unicode(uint16_t keycode, keyrecord_t *record) { 20bool process_unicode(uint16_t keycode, keyrecord_t *record) {
96 if (keycode > QK_UNICODE && record->event.pressed) { 21 if (keycode > QK_UNICODE && record->event.pressed) {
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c
index 6012b4f07..b4d4231db 100644
--- a/quantum/process_keycode/process_unicode_common.c
+++ b/quantum/process_keycode/process_unicode_common.c
@@ -16,11 +16,14 @@
16 16
17#include "process_unicode_common.h" 17#include "process_unicode_common.h"
18 18
19static uint8_t input_mode;
20static uint8_t first_flag = 0;
19uint8_t mods; 21uint8_t mods;
20 22
21void set_unicode_input_mode(uint8_t os_target) 23void set_unicode_input_mode(uint8_t os_target)
22{ 24{
23 input_mode = os_target; 25 input_mode = os_target;
26 eeprom_update_byte(EECONFIG_UNICODEMODE, os_target);
24} 27}
25 28
26uint8_t get_unicode_input_mode(void) { 29uint8_t get_unicode_input_mode(void) {
@@ -92,6 +95,18 @@ void unicode_input_finish (void) {
92 if (mods & MOD_BIT(KC_RGUI)) register_code(KC_RGUI); 95 if (mods & MOD_BIT(KC_RGUI)) register_code(KC_RGUI);
93} 96}
94 97
98__attribute__((weak))
99uint16_t hex_to_keycode(uint8_t hex)
100{
101 if (hex == 0x0) {
102 return KC_0;
103 } else if (hex < 0xA) {
104 return KC_1 + (hex - 0x1);
105 } else {
106 return KC_A + (hex - 0xA);
107 }
108}
109
95void register_hex(uint16_t hex) { 110void register_hex(uint16_t hex) {
96 for(int i = 3; i >= 0; i--) { 111 for(int i = 3; i >= 0; i--) {
97 uint8_t digit = ((hex >> (i*4)) & 0xF); 112 uint8_t digit = ((hex >> (i*4)) & 0xF);