diff options
| author | Ryan <fauxpark@gmail.com> | 2023-08-27 16:51:19 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-27 16:51:19 +1000 |
| commit | 66b744b63b6328a206f9ab463b4acb44002e4bb0 (patch) | |
| tree | 8a5d4a8b4222301ec9145a4bbd799cc72e33de41 | |
| parent | 70e34e491c297231a3f987fd69760d38e79dbfa4 (diff) | |
Clean up Unicode API usage in user keymaps (#21849)
| -rw-r--r-- | keyboards/input_club/ergodox_infinity/keymaps/not-quite-neo/keymap.c | 20 | ||||
| -rw-r--r-- | keyboards/planck/keymaps/rootiest/keymap.c | 16 | ||||
| -rw-r--r-- | users/romus/romus.c | 56 | ||||
| -rw-r--r-- | users/rupa/unicode.c | 11 | ||||
| -rw-r--r-- | users/spidey3/spidey3.c | 16 |
5 files changed, 31 insertions, 88 deletions
diff --git a/keyboards/input_club/ergodox_infinity/keymaps/not-quite-neo/keymap.c b/keyboards/input_club/ergodox_infinity/keymaps/not-quite-neo/keymap.c index a345e075d9..a49fe882ea 100644 --- a/keyboards/input_club/ergodox_infinity/keymaps/not-quite-neo/keymap.c +++ b/keyboards/input_club/ergodox_infinity/keymaps/not-quite-neo/keymap.c | |||
| @@ -21,11 +21,6 @@ A layout based on neo2 | |||
| 21 | #endif | 21 | #endif |
| 22 | #define LEADER_TIMEOUT 300 | 22 | #define LEADER_TIMEOUT 300 |
| 23 | 23 | ||
| 24 | #define TAP_ONCE(code) \ | ||
| 25 | register_code (code); \ | ||
| 26 | unregister_code (code) | ||
| 27 | |||
| 28 | |||
| 29 | // Automatic number generation of important keywords | 24 | // Automatic number generation of important keywords |
| 30 | enum my_keycodes{ | 25 | enum my_keycodes{ |
| 31 | // Layer numbers follow the neo2 terminology, i.e. base layer = layer 1 | 26 | // Layer numbers follow the neo2 terminology, i.e. base layer = layer 1 |
| @@ -257,22 +252,11 @@ L06 -> <TBD>: UNSPECIFIED | |||
| 257 | 252 | ||
| 258 | void leader_end_user(void) { | 253 | void leader_end_user(void) { |
| 259 | if (leader_sequence_one_key(KC_1)) { | 254 | if (leader_sequence_one_key(KC_1)) { |
| 260 | // ¯\_(ツ)_/¯ | 255 | send_unicode_string("¯\\_(ツ)_/¯"); |
| 261 | unicode_input_start(); register_hex(0xaf); unicode_input_finish(); | ||
| 262 | register_code (KC_RALT); TAP_ONCE (KC_MINS); unregister_code (KC_RALT); | ||
| 263 | register_code (KC_RSFT); TAP_ONCE (KC_8); unregister_code (KC_RSFT); | ||
| 264 | unicode_input_start (); register_hex(0x30c4); unicode_input_finish(); | ||
| 265 | register_code (KC_RSFT); TAP_ONCE (KC_9); TAP_ONCE(KC_7); unregister_code (KC_RSFT); | ||
| 266 | unicode_input_start (); register_hex(0xaf); unicode_input_finish(); | ||
| 267 | } | 256 | } |
| 268 | 257 | ||
| 269 | if (leader_sequence_one_key(KC_2)) { | 258 | if (leader_sequence_one_key(KC_2)) { |
| 270 | // 凸(ツ)凸 | 259 | send_unicode_string("凸(ツ)凸"); |
| 271 | unicode_input_start(); register_hex(0x51F8); unicode_input_finish(); | ||
| 272 | register_code (KC_RSFT); TAP_ONCE (KC_8); unregister_code (KC_RSFT); | ||
| 273 | unicode_input_start (); register_hex(0x30c4); unicode_input_finish(); | ||
| 274 | register_code (KC_RSFT); TAP_ONCE (KC_9); unregister_code (KC_RSFT); | ||
| 275 | unicode_input_start (); register_hex(0x51F8); unicode_input_finish(); | ||
| 276 | } | 260 | } |
| 277 | } | 261 | } |
| 278 | 262 | ||
diff --git a/keyboards/planck/keymaps/rootiest/keymap.c b/keyboards/planck/keymaps/rootiest/keymap.c index d6e8c7ef0f..a8ff2dd8d9 100644 --- a/keyboards/planck/keymaps/rootiest/keymap.c +++ b/keyboards/planck/keymaps/rootiest/keymap.c | |||
| @@ -1328,33 +1328,25 @@ void send_degree_symbol(tap_dance_state_t* state, void* user_data) { | |||
| 1328 | switch (state->count) { | 1328 | switch (state->count) { |
| 1329 | case 4: | 1329 | case 4: |
| 1330 | // ℃ | 1330 | // ℃ |
| 1331 | unicode_input_start(); | 1331 | register_unicode(0x2103); |
| 1332 | register_hex(0x2103); | ||
| 1333 | unicode_input_finish(); | ||
| 1334 | print("You pressed the Degrees key 4 times!\n"); | 1332 | print("You pressed the Degrees key 4 times!\n"); |
| 1335 | reset_tap_dance(state); | 1333 | reset_tap_dance(state); |
| 1336 | break; | 1334 | break; |
| 1337 | case 3: | 1335 | case 3: |
| 1338 | //℉ | 1336 | //℉ |
| 1339 | unicode_input_start(); | 1337 | register_unicode(0x2109); |
| 1340 | register_hex(0x2109); | ||
| 1341 | unicode_input_finish(); | ||
| 1342 | print("You pressed the Degrees key 3 times!\n"); | 1338 | print("You pressed the Degrees key 3 times!\n"); |
| 1343 | reset_tap_dance(state); | 1339 | reset_tap_dance(state); |
| 1344 | break; | 1340 | break; |
| 1345 | case 2: | 1341 | case 2: |
| 1346 | // € | 1342 | // € |
| 1347 | unicode_input_start(); | 1343 | register_unicode(0x20AC); |
| 1348 | register_hex(0x20AC); | ||
| 1349 | unicode_input_finish(); | ||
| 1350 | print("You pressed the Degrees key 2 times!\n"); | 1344 | print("You pressed the Degrees key 2 times!\n"); |
| 1351 | reset_tap_dance(state); | 1345 | reset_tap_dance(state); |
| 1352 | break; | 1346 | break; |
| 1353 | case 1: | 1347 | case 1: |
| 1354 | // ° | 1348 | // ° |
| 1355 | unicode_input_start(); | 1349 | register_unicode(0x00B0); |
| 1356 | register_hex(0x00B0); | ||
| 1357 | unicode_input_finish(); | ||
| 1358 | print("You pressed the Degrees key 1 time!\n"); | 1350 | print("You pressed the Degrees key 1 time!\n"); |
| 1359 | reset_tap_dance(state); | 1351 | reset_tap_dance(state); |
| 1360 | break; | 1352 | break; |
diff --git a/users/romus/romus.c b/users/romus/romus.c index 7d59f28eec..e16dd3b8a0 100644 --- a/users/romus/romus.c +++ b/users/romus/romus.c | |||
| @@ -291,13 +291,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 291 | case TUR_A: | 291 | case TUR_A: |
| 292 | if (record->event.pressed) { | 292 | if (record->event.pressed) { |
| 293 | if ( is_capital ) { | 293 | if ( is_capital ) { |
| 294 | unicode_input_start(); | 294 | register_unicode(0x00c2); |
| 295 | register_hex(0x00c2); | ||
| 296 | unicode_input_finish(); | ||
| 297 | } else { | 295 | } else { |
| 298 | unicode_input_start(); | 296 | register_unicode(0x00e2); |
| 299 | register_hex(0x00e2); | ||
| 300 | unicode_input_finish(); | ||
| 301 | } | 297 | } |
| 302 | } | 298 | } |
| 303 | return false; | 299 | return false; |
| @@ -305,13 +301,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 305 | case TUR_O: | 301 | case TUR_O: |
| 306 | if (record->event.pressed) { | 302 | if (record->event.pressed) { |
| 307 | if ( is_capital ) { | 303 | if ( is_capital ) { |
| 308 | unicode_input_start(); | 304 | register_unicode(0x00d6); |
| 309 | register_hex(0x00d6); | ||
| 310 | unicode_input_finish(); | ||
| 311 | } else { | 305 | } else { |
| 312 | unicode_input_start(); | 306 | register_unicode(0x00f6); |
| 313 | register_hex(0x00f6); | ||
| 314 | unicode_input_finish(); | ||
| 315 | } | 307 | } |
| 316 | } | 308 | } |
| 317 | return false; | 309 | return false; |
| @@ -319,13 +311,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 319 | case TUR_U: | 311 | case TUR_U: |
| 320 | if (record->event.pressed) { | 312 | if (record->event.pressed) { |
| 321 | if ( is_capital ) { | 313 | if ( is_capital ) { |
| 322 | unicode_input_start(); | 314 | register_unicode(0x00dc); |
| 323 | register_hex(0x00dc); | ||
| 324 | unicode_input_finish(); | ||
| 325 | } else { | 315 | } else { |
| 326 | unicode_input_start(); | 316 | register_unicode(0x00fc); |
| 327 | register_hex(0x00fc); | ||
| 328 | unicode_input_finish(); | ||
| 329 | } | 317 | } |
| 330 | } | 318 | } |
| 331 | return false; | 319 | return false; |
| @@ -333,13 +321,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 333 | case TUR_I: | 321 | case TUR_I: |
| 334 | if (record->event.pressed) { | 322 | if (record->event.pressed) { |
| 335 | if ( is_capital ) { | 323 | if ( is_capital ) { |
| 336 | unicode_input_start(); | 324 | register_unicode(0x0130); |
| 337 | register_hex(0x0130); | ||
| 338 | unicode_input_finish(); | ||
| 339 | } else { | 325 | } else { |
| 340 | unicode_input_start(); | 326 | register_unicode(0x0131); |
| 341 | register_hex(0x0131); | ||
| 342 | unicode_input_finish(); | ||
| 343 | } | 327 | } |
| 344 | } | 328 | } |
| 345 | return false; | 329 | return false; |
| @@ -347,13 +331,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 347 | case TUR_G: | 331 | case TUR_G: |
| 348 | if (record->event.pressed) { | 332 | if (record->event.pressed) { |
| 349 | if ( is_capital ) { | 333 | if ( is_capital ) { |
| 350 | unicode_input_start(); | 334 | register_unicode(0x011e); |
| 351 | register_hex(0x011e); | ||
| 352 | unicode_input_finish(); | ||
| 353 | } else { | 335 | } else { |
| 354 | unicode_input_start(); | 336 | register_unicode(0x011f); |
| 355 | register_hex(0x011f); | ||
| 356 | unicode_input_finish(); | ||
| 357 | } | 337 | } |
| 358 | } | 338 | } |
| 359 | return false; | 339 | return false; |
| @@ -361,13 +341,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 361 | case TUR_C: | 341 | case TUR_C: |
| 362 | if (record->event.pressed) { | 342 | if (record->event.pressed) { |
| 363 | if ( is_capital ) { | 343 | if ( is_capital ) { |
| 364 | unicode_input_start(); | 344 | register_unicode(0x00c7); |
| 365 | register_hex(0x00c7); | ||
| 366 | unicode_input_finish(); | ||
| 367 | } else { | 345 | } else { |
| 368 | unicode_input_start(); | 346 | register_unicode(0x00e7); |
| 369 | register_hex(0x00e7); | ||
| 370 | unicode_input_finish(); | ||
| 371 | } | 347 | } |
| 372 | } | 348 | } |
| 373 | return false; | 349 | return false; |
| @@ -375,13 +351,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 375 | case TUR_S: | 351 | case TUR_S: |
| 376 | if (record->event.pressed) { | 352 | if (record->event.pressed) { |
| 377 | if ( is_capital ) { | 353 | if ( is_capital ) { |
| 378 | unicode_input_start(); | 354 | register_unicode(0x015e); |
| 379 | register_hex(0x015e); | ||
| 380 | unicode_input_finish(); | ||
| 381 | } else { | 355 | } else { |
| 382 | unicode_input_start(); | 356 | register_unicode(0x015f); |
| 383 | register_hex(0x015f); | ||
| 384 | unicode_input_finish(); | ||
| 385 | } | 357 | } |
| 386 | } | 358 | } |
| 387 | return false; | 359 | return false; |
diff --git a/users/rupa/unicode.c b/users/rupa/unicode.c index f99e6d0832..56b4509813 100644 --- a/users/rupa/unicode.c +++ b/users/rupa/unicode.c | |||
| @@ -125,12 +125,14 @@ bool u_xp(bool is_shifted, const char *shifted, const char *plain) { | |||
| 125 | }; | 125 | }; |
| 126 | 126 | ||
| 127 | void zalgo(void) { | 127 | void zalgo(void) { |
| 128 | unicode_input_start(); | ||
| 128 | int number = (rand() % (8 + 1 - 2)) + 2; | 129 | int number = (rand() % (8 + 1 - 2)) + 2; |
| 129 | unsigned int index; | 130 | unsigned int index; |
| 130 | for (index=0; index<number; index++) { | 131 | for (index=0; index<number; index++) { |
| 131 | uint16_t hex = (rand() % (0x036F + 1 - 0x0300)) + 0x0300; | 132 | uint16_t hex = (rand() % (0x036F + 1 - 0x0300)) + 0x0300; |
| 132 | register_hex(hex); | 133 | register_hex(hex); |
| 133 | } | 134 | } |
| 135 | unicode_input_finish(); | ||
| 134 | } | 136 | } |
| 135 | 137 | ||
| 136 | bool combined_text(uint16_t keycode) { | 138 | bool combined_text(uint16_t keycode) { |
| @@ -138,16 +140,16 @@ bool combined_text(uint16_t keycode) { | |||
| 138 | return false; | 140 | return false; |
| 139 | } | 141 | } |
| 140 | tap_code(keycode); | 142 | tap_code(keycode); |
| 141 | unicode_input_start(); | 143 | |
| 142 | switch (combined_mode) { | 144 | switch (combined_mode) { |
| 143 | case CM_CIRCLE: | 145 | case CM_CIRCLE: |
| 144 | register_hex(0x20DD); | 146 | register_unicode(0x20DD); |
| 145 | break; | 147 | break; |
| 146 | case CM_NO: | 148 | case CM_NO: |
| 147 | register_hex(0x20E0); | 149 | register_unicode(0x20E0); |
| 148 | break; | 150 | break; |
| 149 | case CM_KEYCAP: | 151 | case CM_KEYCAP: |
| 150 | register_hex(0x20E3); | 152 | register_unicode(0x20E3); |
| 151 | break; | 153 | break; |
| 152 | case CM_ZALGO: | 154 | case CM_ZALGO: |
| 153 | zalgo(); | 155 | zalgo(); |
| @@ -155,7 +157,6 @@ bool combined_text(uint16_t keycode) { | |||
| 155 | default: | 157 | default: |
| 156 | break; | 158 | break; |
| 157 | } | 159 | } |
| 158 | unicode_input_finish(); | ||
| 159 | return true; | 160 | return true; |
| 160 | } | 161 | } |
| 161 | 162 | ||
diff --git a/users/spidey3/spidey3.c b/users/spidey3/spidey3.c index 0f3c08fca6..b177f9f652 100644 --- a/users/spidey3/spidey3.c +++ b/users/spidey3/spidey3.c | |||
| @@ -73,19 +73,13 @@ static uint32_t math_glyph_exceptions(const uint16_t keycode, const bool shifted | |||
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | bool process_record_glyph_replacement(uint16_t keycode, keyrecord_t *record, uint32_t baseAlphaLower, uint32_t baseAlphaUpper, uint32_t zeroGlyph, uint32_t baseNumberOne, uint32_t spaceGlyph, uint32_t (*exceptions)(const uint16_t keycode, const bool shifted), uint8_t temp_mod, uint8_t temp_osm) { | 75 | bool process_record_glyph_replacement(uint16_t keycode, keyrecord_t *record, uint32_t baseAlphaLower, uint32_t baseAlphaUpper, uint32_t zeroGlyph, uint32_t baseNumberOne, uint32_t spaceGlyph, uint32_t (*exceptions)(const uint16_t keycode, const bool shifted), uint8_t temp_mod, uint8_t temp_osm) { |
| 76 | void _register(uint32_t codepoint) { | ||
| 77 | unicode_input_start(); | ||
| 78 | register_hex32(codepoint); | ||
| 79 | unicode_input_finish(); | ||
| 80 | } | ||
| 81 | |||
| 82 | if ((((temp_mod | temp_osm) & (MOD_MASK_CTRL | MOD_MASK_ALT | MOD_MASK_GUI))) == 0) { | 76 | if ((((temp_mod | temp_osm) & (MOD_MASK_CTRL | MOD_MASK_ALT | MOD_MASK_GUI))) == 0) { |
| 83 | bool shifted = ((temp_mod | temp_osm) & MOD_MASK_SHIFT); | 77 | bool shifted = ((temp_mod | temp_osm) & MOD_MASK_SHIFT); |
| 84 | if (exceptions) { | 78 | if (exceptions) { |
| 85 | uint32_t res = exceptions(keycode, shifted); | 79 | uint32_t res = exceptions(keycode, shifted); |
| 86 | if (res) { | 80 | if (res) { |
| 87 | if (record->event.pressed) { | 81 | if (record->event.pressed) { |
| 88 | _register(res); | 82 | register_unicode(res); |
| 89 | } | 83 | } |
| 90 | return false; | 84 | return false; |
| 91 | } | 85 | } |
| @@ -100,7 +94,7 @@ bool process_record_glyph_replacement(uint16_t keycode, keyrecord_t *record, uin | |||
| 100 | 94 | ||
| 101 | bool caps = host_keyboard_led_state().caps_lock; | 95 | bool caps = host_keyboard_led_state().caps_lock; |
| 102 | uint32_t base = ((shifted == caps) ? baseAlphaLower : baseAlphaUpper); | 96 | uint32_t base = ((shifted == caps) ? baseAlphaLower : baseAlphaUpper); |
| 103 | _register(base + (keycode - KC_A)); | 97 | register_unicode(base + (keycode - KC_A)); |
| 104 | set_mods(temp_mod); | 98 | set_mods(temp_mod); |
| 105 | } | 99 | } |
| 106 | return false; | 100 | return false; |
| @@ -109,7 +103,7 @@ bool process_record_glyph_replacement(uint16_t keycode, keyrecord_t *record, uin | |||
| 109 | return true; | 103 | return true; |
| 110 | } | 104 | } |
| 111 | if (record->event.pressed) { | 105 | if (record->event.pressed) { |
| 112 | _register(zeroGlyph); | 106 | register_unicode(zeroGlyph); |
| 113 | } | 107 | } |
| 114 | return false; | 108 | return false; |
| 115 | case KC_1 ... KC_9: | 109 | case KC_1 ... KC_9: |
| @@ -117,12 +111,12 @@ bool process_record_glyph_replacement(uint16_t keycode, keyrecord_t *record, uin | |||
| 117 | return true; | 111 | return true; |
| 118 | } | 112 | } |
| 119 | if (record->event.pressed) { | 113 | if (record->event.pressed) { |
| 120 | _register(baseNumberOne + (keycode - KC_1)); | 114 | register_unicode(baseNumberOne + (keycode - KC_1)); |
| 121 | } | 115 | } |
| 122 | return false; | 116 | return false; |
| 123 | case KC_SPACE: | 117 | case KC_SPACE: |
| 124 | if (record->event.pressed) { | 118 | if (record->event.pressed) { |
| 125 | _register(spaceGlyph); // em space | 119 | register_unicode(spaceGlyph); // em space |
| 126 | } | 120 | } |
| 127 | return false; | 121 | return false; |
| 128 | } | 122 | } |
