process_unicode: Replace register_hex32
It turns out that register_hex32 did not work reliably, and some systems only allow 7 chars after the unicode magic sequence, while others allow 8. To remedy the situation, store the codes as strings, and type those in instead of doing bit shifting magic. Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
This commit is contained in:
parent
a312cbf712
commit
43d08629cf
@ -60,14 +60,6 @@ void register_hex(uint16_t hex) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void register_hex32(uint32_t hex) {
|
|
||||||
for(int i = 7; i >= 0; i--) {
|
|
||||||
uint8_t digit = ((hex >> (i*8)) & 0xF);
|
|
||||||
register_code(hex_to_keycode(digit));
|
|
||||||
unregister_code(hex_to_keycode(digit));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool process_unicode(uint16_t keycode, keyrecord_t *record) {
|
bool process_unicode(uint16_t keycode, keyrecord_t *record) {
|
||||||
if (keycode > QK_UNICODE && record->event.pressed) {
|
if (keycode > QK_UNICODE && record->event.pressed) {
|
||||||
uint16_t unicode = keycode & 0x7FFF;
|
uint16_t unicode = keycode & 0x7FFF;
|
||||||
@ -120,6 +112,33 @@ void qk_ucis_symbol_fallback (void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void register_ucis(const char *hex) {
|
||||||
|
for(int i = 0; hex[i]; i++) {
|
||||||
|
uint8_t kc = 0;
|
||||||
|
char c = hex[i];
|
||||||
|
|
||||||
|
switch (c) {
|
||||||
|
case '0':
|
||||||
|
kc = KC_0;
|
||||||
|
break;
|
||||||
|
case '1' ... '9':
|
||||||
|
kc = c - '1' + KC_1;
|
||||||
|
break;
|
||||||
|
case 'a' ... 'f':
|
||||||
|
kc = c - 'a' + KC_A;
|
||||||
|
break;
|
||||||
|
case 'A' ... 'F':
|
||||||
|
kc = c - 'A' + KC_A;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (kc) {
|
||||||
|
register_code (kc);
|
||||||
|
unregister_code (kc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool process_ucis (uint16_t keycode, keyrecord_t *record) {
|
bool process_ucis (uint16_t keycode, keyrecord_t *record) {
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
|
||||||
@ -164,7 +183,7 @@ bool process_ucis (uint16_t keycode, keyrecord_t *record) {
|
|||||||
for (i = 0; ucis_symbol_table[i].symbol; i++) {
|
for (i = 0; ucis_symbol_table[i].symbol; i++) {
|
||||||
if (is_uni_seq (ucis_symbol_table[i].symbol)) {
|
if (is_uni_seq (ucis_symbol_table[i].symbol)) {
|
||||||
symbol_found = true;
|
symbol_found = true;
|
||||||
register_hex32(ucis_symbol_table[i].code);
|
register_ucis(ucis_symbol_table[i].code + 2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ void set_unicode_input_mode(uint8_t os_target);
|
|||||||
void unicode_input_start(void);
|
void unicode_input_start(void);
|
||||||
void unicode_input_finish(void);
|
void unicode_input_finish(void);
|
||||||
void register_hex(uint16_t hex);
|
void register_hex(uint16_t hex);
|
||||||
void register_hex32(uint32_t hex);
|
|
||||||
|
|
||||||
bool process_unicode(uint16_t keycode, keyrecord_t *record);
|
bool process_unicode(uint16_t keycode, keyrecord_t *record);
|
||||||
|
|
||||||
@ -23,7 +22,7 @@ bool process_unicode(uint16_t keycode, keyrecord_t *record);
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *symbol;
|
char *symbol;
|
||||||
uint32_t code;
|
char *code;
|
||||||
} qk_ucis_symbol_t;
|
} qk_ucis_symbol_t;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
@ -32,14 +31,15 @@ struct {
|
|||||||
bool in_progress:1;
|
bool in_progress:1;
|
||||||
} qk_ucis_state;
|
} qk_ucis_state;
|
||||||
|
|
||||||
#define UCIS_TABLE(...) {__VA_ARGS__, {NULL, 0}}
|
#define UCIS_TABLE(...) {__VA_ARGS__, {NULL, NULL}}
|
||||||
#define UCIS_SYM(name, code) {name, code}
|
#define UCIS_SYM(name, code) {name, #code}
|
||||||
|
|
||||||
extern const qk_ucis_symbol_t ucis_symbol_table[];
|
extern const qk_ucis_symbol_t ucis_symbol_table[];
|
||||||
|
|
||||||
void qk_ucis_start(void);
|
void qk_ucis_start(void);
|
||||||
void qk_ucis_start_user(void);
|
void qk_ucis_start_user(void);
|
||||||
void qk_ucis_symbol_fallback (void);
|
void qk_ucis_symbol_fallback (void);
|
||||||
|
void register_ucis(const char *hex);
|
||||||
bool process_ucis (uint16_t keycode, keyrecord_t *record);
|
bool process_ucis (uint16_t keycode, keyrecord_t *record);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user