]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
process_unicode: Use uint32_t for UCIS purposes
authorGergely Nagy <algernon@madhouse-project.org>
Sun, 14 Aug 2016 12:34:52 +0000 (14:34 +0200)
committerGergely Nagy <algernon@madhouse-project.org>
Mon, 15 Aug 2016 08:08:53 +0000 (10:08 +0200)
Use a single uint32_t to store the unicode of a symbol, instead of an
array of uint16_ts.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
quantum/process_keycode/process_unicode.c
quantum/process_keycode/process_unicode.h

index c474483e7fa7d980e8286709345cf407597257ed..698cc3c02524ada6fb86b253f6b11cd7b80b962e 100644 (file)
@@ -60,6 +60,14 @@ 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) {
   if (keycode > QK_UNICODE && record->event.pressed) {
     uint16_t unicode = keycode & 0x7FFF;
@@ -156,9 +164,7 @@ bool process_ucis (uint16_t keycode, keyrecord_t *record) {
     for (i = 0; ucis_symbol_table[i].symbol; i++) {
       if (is_uni_seq (ucis_symbol_table[i].symbol)) {
         symbol_found = true;
-        for (uint8_t j = 0; ucis_symbol_table[i].codes[j]; j++) {
-          register_hex(ucis_symbol_table[i].codes[j]);
-        }
+        register_hex32(ucis_symbol_table[i].code);
         break;
       }
     }
index 75607e40e81c04f6962483cc40893a3679004660..dd6dd71384d5badfaab396b9ea373b7574e07b81 100644 (file)
@@ -12,6 +12,7 @@ void set_unicode_input_mode(uint8_t os_target);
 void unicode_input_start(void);
 void unicode_input_finish(void);
 void register_hex(uint16_t hex);
+void register_hex32(uint32_t hex);
 
 bool process_unicode(uint16_t keycode, keyrecord_t *record);
 
@@ -22,7 +23,7 @@ bool process_unicode(uint16_t keycode, keyrecord_t *record);
 
 typedef struct {
   char *symbol;
-  uint16_t codes[4];
+  uint32_t code;
 } qk_ucis_symbol_t;
 
 struct {
@@ -31,8 +32,8 @@ struct {
   bool in_progress:1;
 } qk_ucis_state;
 
-#define UCIS_TABLE(...) {__VA_ARGS__, {NULL, {}}}
-#define UCIS_SYM(name, ...) {name, {__VA_ARGS__, 0}}
+#define UCIS_TABLE(...) {__VA_ARGS__, {NULL, 0}}
+#define UCIS_SYM(name, code) {name, code}
 
 extern const qk_ucis_symbol_t ucis_symbol_table[];