From 66b744b63b6328a206f9ab463b4acb44002e4bb0 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 27 Aug 2023 16:51:19 +1000 Subject: [PATCH] Clean up Unicode API usage in user keymaps (#21849) --- .../keymaps/not-quite-neo/keymap.c | 20 +------ keyboards/planck/keymaps/rootiest/keymap.c | 16 ++---- users/romus/romus.c | 56 +++++-------------- users/rupa/unicode.c | 11 ++-- 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 a345e075d9b..a49fe882ea7 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 #endif #define LEADER_TIMEOUT 300 -#define TAP_ONCE(code) \ - register_code (code); \ - unregister_code (code) - - // Automatic number generation of important keywords enum my_keycodes{ // Layer numbers follow the neo2 terminology, i.e. base layer = layer 1 @@ -257,22 +252,11 @@ L06 -> : UNSPECIFIED void leader_end_user(void) { if (leader_sequence_one_key(KC_1)) { - // ¯\_(ツ)_/¯ - unicode_input_start(); register_hex(0xaf); unicode_input_finish(); - register_code (KC_RALT); TAP_ONCE (KC_MINS); unregister_code (KC_RALT); - register_code (KC_RSFT); TAP_ONCE (KC_8); unregister_code (KC_RSFT); - unicode_input_start (); register_hex(0x30c4); unicode_input_finish(); - register_code (KC_RSFT); TAP_ONCE (KC_9); TAP_ONCE(KC_7); unregister_code (KC_RSFT); - unicode_input_start (); register_hex(0xaf); unicode_input_finish(); + send_unicode_string("¯\\_(ツ)_/¯"); } if (leader_sequence_one_key(KC_2)) { - // 凸(ツ)凸 - unicode_input_start(); register_hex(0x51F8); unicode_input_finish(); - register_code (KC_RSFT); TAP_ONCE (KC_8); unregister_code (KC_RSFT); - unicode_input_start (); register_hex(0x30c4); unicode_input_finish(); - register_code (KC_RSFT); TAP_ONCE (KC_9); unregister_code (KC_RSFT); - unicode_input_start (); register_hex(0x51F8); unicode_input_finish(); + send_unicode_string("凸(ツ)凸"); } } diff --git a/keyboards/planck/keymaps/rootiest/keymap.c b/keyboards/planck/keymaps/rootiest/keymap.c index d6e8c7ef0ff..a8ff2dd8d92 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) { switch (state->count) { case 4: // ℃ - unicode_input_start(); - register_hex(0x2103); - unicode_input_finish(); + register_unicode(0x2103); print("You pressed the Degrees key 4 times!\n"); reset_tap_dance(state); break; case 3: //℉ - unicode_input_start(); - register_hex(0x2109); - unicode_input_finish(); + register_unicode(0x2109); print("You pressed the Degrees key 3 times!\n"); reset_tap_dance(state); break; case 2: // € - unicode_input_start(); - register_hex(0x20AC); - unicode_input_finish(); + register_unicode(0x20AC); print("You pressed the Degrees key 2 times!\n"); reset_tap_dance(state); break; case 1: // ° - unicode_input_start(); - register_hex(0x00B0); - unicode_input_finish(); + register_unicode(0x00B0); print("You pressed the Degrees key 1 time!\n"); reset_tap_dance(state); break; diff --git a/users/romus/romus.c b/users/romus/romus.c index 7d59f28eec7..e16dd3b8a0e 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) { case TUR_A: if (record->event.pressed) { if ( is_capital ) { - unicode_input_start(); - register_hex(0x00c2); - unicode_input_finish(); + register_unicode(0x00c2); } else { - unicode_input_start(); - register_hex(0x00e2); - unicode_input_finish(); + register_unicode(0x00e2); } } return false; @@ -305,13 +301,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case TUR_O: if (record->event.pressed) { if ( is_capital ) { - unicode_input_start(); - register_hex(0x00d6); - unicode_input_finish(); + register_unicode(0x00d6); } else { - unicode_input_start(); - register_hex(0x00f6); - unicode_input_finish(); + register_unicode(0x00f6); } } return false; @@ -319,13 +311,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case TUR_U: if (record->event.pressed) { if ( is_capital ) { - unicode_input_start(); - register_hex(0x00dc); - unicode_input_finish(); + register_unicode(0x00dc); } else { - unicode_input_start(); - register_hex(0x00fc); - unicode_input_finish(); + register_unicode(0x00fc); } } return false; @@ -333,13 +321,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case TUR_I: if (record->event.pressed) { if ( is_capital ) { - unicode_input_start(); - register_hex(0x0130); - unicode_input_finish(); + register_unicode(0x0130); } else { - unicode_input_start(); - register_hex(0x0131); - unicode_input_finish(); + register_unicode(0x0131); } } return false; @@ -347,13 +331,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case TUR_G: if (record->event.pressed) { if ( is_capital ) { - unicode_input_start(); - register_hex(0x011e); - unicode_input_finish(); + register_unicode(0x011e); } else { - unicode_input_start(); - register_hex(0x011f); - unicode_input_finish(); + register_unicode(0x011f); } } return false; @@ -361,13 +341,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case TUR_C: if (record->event.pressed) { if ( is_capital ) { - unicode_input_start(); - register_hex(0x00c7); - unicode_input_finish(); + register_unicode(0x00c7); } else { - unicode_input_start(); - register_hex(0x00e7); - unicode_input_finish(); + register_unicode(0x00e7); } } return false; @@ -375,13 +351,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case TUR_S: if (record->event.pressed) { if ( is_capital ) { - unicode_input_start(); - register_hex(0x015e); - unicode_input_finish(); + register_unicode(0x015e); } else { - unicode_input_start(); - register_hex(0x015f); - unicode_input_finish(); + register_unicode(0x015f); } } return false; diff --git a/users/rupa/unicode.c b/users/rupa/unicode.c index f99e6d08325..56b4509813e 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) { }; void zalgo(void) { + unicode_input_start(); int number = (rand() % (8 + 1 - 2)) + 2; unsigned int index; for (index=0; indexevent.pressed) { - _register(res); + register_unicode(res); } return false; } @@ -100,7 +94,7 @@ bool process_record_glyph_replacement(uint16_t keycode, keyrecord_t *record, uin bool caps = host_keyboard_led_state().caps_lock; uint32_t base = ((shifted == caps) ? baseAlphaLower : baseAlphaUpper); - _register(base + (keycode - KC_A)); + register_unicode(base + (keycode - KC_A)); set_mods(temp_mod); } return false; @@ -109,7 +103,7 @@ bool process_record_glyph_replacement(uint16_t keycode, keyrecord_t *record, uin return true; } if (record->event.pressed) { - _register(zeroGlyph); + register_unicode(zeroGlyph); } return false; case KC_1 ... KC_9: @@ -117,12 +111,12 @@ bool process_record_glyph_replacement(uint16_t keycode, keyrecord_t *record, uin return true; } if (record->event.pressed) { - _register(baseNumberOne + (keycode - KC_1)); + register_unicode(baseNumberOne + (keycode - KC_1)); } return false; case KC_SPACE: if (record->event.pressed) { - _register(spaceGlyph); // em space + register_unicode(spaceGlyph); // em space } return false; }