diff options
author | Drashna Jaelre <drashna@live.com> | 2021-11-28 23:41:59 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-28 23:41:59 -0800 |
commit | 5b5b36421a7c887aad5bf5faef06dcf133d64f15 (patch) | |
tree | 166ec88bd74110261682d82cd1a4ee43ab0802be /users | |
parent | 4ee33f1ffd921d4691207c5c3ab8c12742ddc12d (diff) | |
download | qmk_firmware-5b5b36421a7c887aad5bf5faef06dcf133d64f15.tar.gz qmk_firmware-5b5b36421a7c887aad5bf5faef06dcf133d64f15.zip |
[Keymap] Unicode and cursor sync - drashna keymap (#15328)
Diffstat (limited to 'users')
-rw-r--r-- | users/drashna/config.h | 9 | ||||
-rw-r--r-- | users/drashna/oled_stuff.c | 37 | ||||
-rw-r--r-- | users/drashna/process_records.c | 25 | ||||
-rw-r--r-- | users/drashna/process_records.h | 17 | ||||
-rw-r--r-- | users/drashna/rules.mk | 12 | ||||
-rw-r--r-- | users/drashna/transport_sync.c | 3 | ||||
-rw-r--r-- | users/drashna/unicoooode.c | 282 |
7 files changed, 336 insertions, 49 deletions
diff --git a/users/drashna/config.h b/users/drashna/config.h index ebb8d7b7a..8b5d5ba93 100644 --- a/users/drashna/config.h +++ b/users/drashna/config.h | |||
@@ -41,6 +41,15 @@ | |||
41 | # endif | 41 | # endif |
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | #if defined(WPM_ENABLE) | ||
45 | // # define WPM_LAUNCH_CONTROL | ||
46 | // # define WPM_ALLOW_COUNT_REGRESSOIN | ||
47 | // # define WPM_UNFILTERED | ||
48 | # define WPM_SAMPLE_SECONDS 6 | ||
49 | # define WPM_SAMPLE_PERIODS 50 | ||
50 | # define WPM_ESTIMATED_WORD_SIZE 6 | ||
51 | #endif | ||
52 | |||
44 | #ifdef AUDIO_ENABLE | 53 | #ifdef AUDIO_ENABLE |
45 | # define AUDIO_CLICKY | 54 | # define AUDIO_CLICKY |
46 | # define AUDIO_CLICKY_FREQ_RANDOMNESS 1.5f | 55 | # define AUDIO_CLICKY_FREQ_RANDOMNESS 1.5f |
diff --git a/users/drashna/oled_stuff.c b/users/drashna/oled_stuff.c index 396e5e05b..2c92ac6e9 100644 --- a/users/drashna/oled_stuff.c +++ b/users/drashna/oled_stuff.c | |||
@@ -15,6 +15,10 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include "drashna.h" | 17 | #include "drashna.h" |
18 | #ifdef CUSTOM_UNICODE_ENABLE | ||
19 | # include "process_unicode_common.h" | ||
20 | #endif | ||
21 | #include <string.h> | ||
18 | 22 | ||
19 | extern bool host_driver_disabled; | 23 | extern bool host_driver_disabled; |
20 | 24 | ||
@@ -59,7 +63,7 @@ void add_keylog(uint16_t keycode, keyrecord_t *record) { | |||
59 | return; | 63 | return; |
60 | } | 64 | } |
61 | if (record->tap.count) { | 65 | if (record->tap.count) { |
62 | keycode = keycode & 0xFF; | 66 | keycode &= 0xFF; |
63 | } else if (keycode > 0xFF) { | 67 | } else if (keycode > 0xFF) { |
64 | return; | 68 | return; |
65 | } | 69 | } |
@@ -150,8 +154,10 @@ void render_keylock_status(uint8_t led_usb_state) { | |||
150 | oled_write_P(PSTR(OLED_RENDER_LOCK_NUML), led_usb_state & (1 << USB_LED_NUM_LOCK)); | 154 | oled_write_P(PSTR(OLED_RENDER_LOCK_NUML), led_usb_state & (1 << USB_LED_NUM_LOCK)); |
151 | oled_write_P(PSTR(" "), false); | 155 | oled_write_P(PSTR(" "), false); |
152 | oled_write_P(PSTR(OLED_RENDER_LOCK_CAPS), led_usb_state & (1 << USB_LED_CAPS_LOCK)); | 156 | oled_write_P(PSTR(OLED_RENDER_LOCK_CAPS), led_usb_state & (1 << USB_LED_CAPS_LOCK)); |
153 | // oled_write_P(PSTR(" "), false); | 157 | #if defined(OLED_DISPLAY_128X64) |
154 | // oled_write_P(PSTR(OLED_RENDER_LOCK_SCLK), led_usb_state & (1 << USB_LED_SCROLL_LOCK)); | 158 | oled_write_P(PSTR(" "), false); |
159 | oled_write_P(PSTR(OLED_RENDER_LOCK_SCLK), led_usb_state & (1 << USB_LED_SCROLL_LOCK)); | ||
160 | #endif | ||
155 | } | 161 | } |
156 | 162 | ||
157 | void render_matrix_scan_rate(void) { | 163 | void render_matrix_scan_rate(void) { |
@@ -296,7 +302,7 @@ void render_user_status(void) { | |||
296 | oled_write_P(rgb_layer_status[userspace_config.rgb_layer_change], false); | 302 | oled_write_P(rgb_layer_status[userspace_config.rgb_layer_change], false); |
297 | static const char PROGMEM cat_mode[2][3] = {{0xF8, 0xF9, 0}, {0xF6, 0xF7, 0}}; | 303 | static const char PROGMEM cat_mode[2][3] = {{0xF8, 0xF9, 0}, {0xF6, 0xF7, 0}}; |
298 | oled_write_P(cat_mode[0], host_driver_disabled); | 304 | oled_write_P(cat_mode[0], host_driver_disabled); |
299 | #if defined(UNICODE_ENABLE) | 305 | #if defined(CUSTOM_UNICODE_ENABLE) |
300 | static const char PROGMEM uc_mod_status[5][3] = {{0xEA, 0xEB, 0}, {0xEC, 0xED, 0}}; | 306 | static const char PROGMEM uc_mod_status[5][3] = {{0xEA, 0xEB, 0}, {0xEC, 0xED, 0}}; |
301 | oled_write_P(uc_mod_status[get_unicode_input_mode() == UC_MAC], false); | 307 | oled_write_P(uc_mod_status[get_unicode_input_mode() == UC_MAC], false); |
302 | #endif | 308 | #endif |
@@ -327,39 +333,28 @@ void oled_driver_render_logo(void) { | |||
327 | 333 | ||
328 | void render_wpm(uint8_t padding) { | 334 | void render_wpm(uint8_t padding) { |
329 | #ifdef WPM_ENABLE | 335 | #ifdef WPM_ENABLE |
330 | uint8_t n = get_current_wpm(); | 336 | |
331 | char wpm_counter[4]; | ||
332 | wpm_counter[3] = '\0'; | ||
333 | wpm_counter[2] = '0' + n % 10; | ||
334 | wpm_counter[1] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; | ||
335 | wpm_counter[0] = n / 10 ? '0' + n / 10 : ' '; | ||
336 | oled_write_P(PSTR(OLED_RENDER_WPM_COUNTER), false); | 337 | oled_write_P(PSTR(OLED_RENDER_WPM_COUNTER), false); |
337 | if (padding) { | 338 | if (padding) { |
338 | for (uint8_t n = padding; n > 0; n--) { | 339 | for (uint8_t n = padding; n > 0; n--) { |
339 | oled_write_P(PSTR(" "), false); | 340 | oled_write_P(PSTR(" "), false); |
340 | } | 341 | } |
341 | } | 342 | } |
342 | oled_write(wpm_counter, false); | 343 | oled_write(get_u8_str(get_current_wpm(), ' '), false); |
343 | #endif | 344 | #endif |
344 | } | 345 | } |
345 | 346 | ||
346 | #if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right) | 347 | #if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right) |
347 | extern kb_config_data_t kb_config; | 348 | extern kb_config_data_t kb_config; |
348 | void render_pointing_dpi_status(uint8_t padding) { | 349 | void render_pointing_dpi_status(uint8_t padding) { |
349 | char dpi_status[5]; | 350 | oled_write_P(PSTR("CPI:"), false); |
350 | uint16_t n = kb_config.device_cpi; | ||
351 | dpi_status[4] = '\0'; | ||
352 | dpi_status[3] = '0' + n % 10; | ||
353 | dpi_status[2] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; | ||
354 | dpi_status[1] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; | ||
355 | dpi_status[0] = n / 10 ? '0' + n / 10 : ' '; | ||
356 | oled_write_P(PSTR("DPI: "), false); | ||
357 | if (padding) { | 351 | if (padding) { |
358 | for (uint8_t n = padding; n > 0; n--) { | 352 | for (uint8_t n = padding - 1; n > 0; n--) { |
359 | oled_write_P(PSTR(" "), false); | 353 | oled_write_P(PSTR(" "), false); |
360 | } | 354 | } |
361 | } | 355 | } |
362 | oled_write(dpi_status, false); | 356 | |
357 | oled_write(get_u16_str(kb_config.device_cpi, ' '), false); | ||
363 | } | 358 | } |
364 | #endif | 359 | #endif |
365 | 360 | ||
diff --git a/users/drashna/process_records.c b/users/drashna/process_records.c index c16c70c05..de572d893 100644 --- a/users/drashna/process_records.c +++ b/users/drashna/process_records.c | |||
@@ -40,6 +40,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *re | |||
40 | #ifdef RGBLIGHT_ENABLE | 40 | #ifdef RGBLIGHT_ENABLE |
41 | && process_record_user_rgb_light(keycode, record) | 41 | && process_record_user_rgb_light(keycode, record) |
42 | #endif | 42 | #endif |
43 | #ifdef CUSTOM_UNICODE_ENABLE | ||
44 | && process_record_unicode(keycode, record) | ||
45 | #endif | ||
43 | && true)) { | 46 | && true)) { |
44 | return false; | 47 | return false; |
45 | } | 48 | } |
@@ -117,28 +120,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *re | |||
117 | } | 120 | } |
118 | } | 121 | } |
119 | break; | 122 | break; |
120 | #ifdef UNICODE_ENABLE | ||
121 | case UC_FLIP: // (ノಠ痊ಠ)ノ彡┻━┻ | ||
122 | if (record->event.pressed) { | ||
123 | send_unicode_string("(ノಠ痊ಠ)ノ彡┻━┻"); | ||
124 | } | ||
125 | break; | ||
126 | case UC_TABL: // ┬─┬ノ( º _ ºノ) | ||
127 | if (record->event.pressed) { | ||
128 | send_unicode_string("┬─┬ノ( º _ ºノ)"); | ||
129 | } | ||
130 | break; | ||
131 | case UC_SHRG: // ¯\_(ツ)_/¯ | ||
132 | if (record->event.pressed) { | ||
133 | send_unicode_string("¯\\_(ツ)_/¯"); | ||
134 | } | ||
135 | break; | ||
136 | case UC_DISA: // ಠ_ಠ | ||
137 | if (record->event.pressed) { | ||
138 | send_unicode_string("ಠ_ಠ"); | ||
139 | } | ||
140 | break; | ||
141 | #endif | ||
142 | case KC_RGB_T: // This allows me to use underglow as layer indication, or as normal | 123 | case KC_RGB_T: // This allows me to use underglow as layer indication, or as normal |
143 | #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) | 124 | #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) |
144 | if (record->event.pressed) { | 125 | if (record->event.pressed) { |
diff --git a/users/drashna/process_records.h b/users/drashna/process_records.h index 897d7bbcc..d8c198a2d 100644 --- a/users/drashna/process_records.h +++ b/users/drashna/process_records.h | |||
@@ -46,13 +46,25 @@ enum userspace_custom_keycodes { | |||
46 | UC_TABL, // ┬─┬ノ( º _ ºノ) | 46 | UC_TABL, // ┬─┬ノ( º _ ºノ) |
47 | UC_SHRG, // ¯\_(ツ)_/¯ | 47 | UC_SHRG, // ¯\_(ツ)_/¯ |
48 | UC_DISA, // ಠ_ಠ | 48 | UC_DISA, // ಠ_ಠ |
49 | UC_IRNY, | ||
50 | UC_CLUE, | ||
49 | KEYLOCK, // Locks keyboard by unmounting driver | 51 | KEYLOCK, // Locks keyboard by unmounting driver |
50 | NEW_SAFE_RANGE // use "NEWPLACEHOLDER for keymap specific codes | 52 | KC_NOMODE, |
53 | KC_WIDE, | ||
54 | KC_SCRIPT, | ||
55 | KC_BLOCKS, | ||
56 | KC_REGIONAL, | ||
57 | KC_AUSSIE, | ||
58 | KC_ZALGO, | ||
59 | NEW_SAFE_RANGE // use "NEWPLACEHOLDER for keymap specific codes | ||
51 | }; | 60 | }; |
52 | 61 | ||
53 | bool process_record_secrets(uint16_t keycode, keyrecord_t *record); | 62 | bool process_record_secrets(uint16_t keycode, keyrecord_t *record); |
54 | bool process_record_keymap(uint16_t keycode, keyrecord_t *record); | 63 | bool process_record_keymap(uint16_t keycode, keyrecord_t *record); |
55 | void post_process_record_keymap(uint16_t keycode, keyrecord_t *record); | 64 | void post_process_record_keymap(uint16_t keycode, keyrecord_t *record); |
65 | #ifdef CUSTOM_UNICODE_ENABLE | ||
66 | bool process_record_unicode(uint16_t keycode, keyrecord_t *record); | ||
67 | #endif | ||
56 | 68 | ||
57 | #define LOWER MO(_LOWER) | 69 | #define LOWER MO(_LOWER) |
58 | #define RAISE MO(_RAISE) | 70 | #define RAISE MO(_RAISE) |
@@ -125,6 +137,3 @@ void post_process_record_keymap(uint16_t keycode, keyrecord_t *record); | |||
125 | #define ALT_APP ALT_T(KC_APP) | 137 | #define ALT_APP ALT_T(KC_APP) |
126 | 138 | ||
127 | #define MG_NKRO MAGIC_TOGGLE_NKRO | 139 | #define MG_NKRO MAGIC_TOGGLE_NKRO |
128 | |||
129 | #define UC_IRNY UC(0x2E2E) | ||
130 | #define UC_CLUE UC(0x203D) | ||
diff --git a/users/drashna/rules.mk b/users/drashna/rules.mk index e9911979c..bd661e00a 100644 --- a/users/drashna/rules.mk +++ b/users/drashna/rules.mk | |||
@@ -18,8 +18,18 @@ ifneq ($(strip $(NO_SECRETS)), yes) | |||
18 | endif | 18 | endif |
19 | endif | 19 | endif |
20 | 20 | ||
21 | CUSTOM_UNICODE_ENABLE ?= yes | ||
22 | ifeq ($(strip $(CUSTOM_UNICODE_ENABLE)), yes) | ||
23 | UNICODE_ENABLE = no | ||
24 | UNICODEMAP_ENABLE = no | ||
25 | UCIS_ENABLE = no | ||
26 | UNICODE_COMMON = yes | ||
27 | OPT_DEFS += -DCUSTOM_UNICODE_ENABLE | ||
28 | SRC += unicoooode.c | ||
29 | endif | ||
30 | |||
21 | CUSTOM_TAP_DANCE ?= yes | 31 | CUSTOM_TAP_DANCE ?= yes |
22 | ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) | 32 | ifeq ($(strip $(CUSTOM_TAP_DANCE)), yes) |
23 | ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) | 33 | ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) |
24 | SRC += $(USER_PATH)/tap_dances.c | 34 | SRC += $(USER_PATH)/tap_dances.c |
25 | endif | 35 | endif |
diff --git a/users/drashna/transport_sync.c b/users/drashna/transport_sync.c index daa14bbef..cee3f04c8 100644 --- a/users/drashna/transport_sync.c +++ b/users/drashna/transport_sync.c | |||
@@ -18,7 +18,8 @@ | |||
18 | #include "transactions.h" | 18 | #include "transactions.h" |
19 | #include <string.h> | 19 | #include <string.h> |
20 | 20 | ||
21 | #ifdef UNICODE_ENABLE | 21 | #ifdef CUSTOM_UNICODE_ENABLE |
22 | #include "process_unicode_common.h" | ||
22 | extern unicode_config_t unicode_config; | 23 | extern unicode_config_t unicode_config; |
23 | #endif | 24 | #endif |
24 | #ifdef AUDIO_ENABLE | 25 | #ifdef AUDIO_ENABLE |
diff --git a/users/drashna/unicoooode.c b/users/drashna/unicoooode.c new file mode 100644 index 000000000..0e276dec1 --- /dev/null +++ b/users/drashna/unicoooode.c | |||
@@ -0,0 +1,282 @@ | |||
1 | /* Copyright 2020 @tzarc | ||
2 | * 2021 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> | ||
3 | * | ||
4 | * This program is free software: you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation, either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #include "drashna.h" | ||
19 | #include "process_unicode_common.h" | ||
20 | |||
21 | uint16_t typing_mode; | ||
22 | |||
23 | void tap_code16_nomods(uint8_t kc) { | ||
24 | uint8_t temp_mod = get_mods(); | ||
25 | clear_mods(); | ||
26 | clear_oneshot_mods(); | ||
27 | tap_code16(kc); | ||
28 | set_mods(temp_mod); | ||
29 | } | ||
30 | |||
31 | void tap_unicode_glyph_nomods(uint32_t glyph) { | ||
32 | uint8_t temp_mod = get_mods(); | ||
33 | clear_mods(); | ||
34 | clear_oneshot_mods(); | ||
35 | register_unicode(glyph); | ||
36 | set_mods(temp_mod); | ||
37 | } | ||
38 | |||
39 | typedef uint32_t (*translator_function_t)(bool is_shifted, uint32_t keycode); | ||
40 | |||
41 | #define DEFINE_UNICODE_RANGE_TRANSLATOR(translator_name, lower_alpha, upper_alpha, zero_glyph, number_one, space_glyph) \ | ||
42 | static inline uint32_t translator_name(bool is_shifted, uint32_t keycode) { \ | ||
43 | switch (keycode) { \ | ||
44 | case KC_A ... KC_Z: \ | ||
45 | return (is_shifted ? upper_alpha : lower_alpha) + keycode - KC_A; \ | ||
46 | case KC_0: \ | ||
47 | return zero_glyph; \ | ||
48 | case KC_1 ... KC_9: \ | ||
49 | return (number_one + keycode - KC_1); \ | ||
50 | case KC_SPACE: \ | ||
51 | return space_glyph; \ | ||
52 | } \ | ||
53 | return keycode; \ | ||
54 | } | ||
55 | |||
56 | #define DEFINE_UNICODE_LUT_TRANSLATOR(translator_name, ...) \ | ||
57 | static inline uint32_t translator_name(bool is_shifted, uint32_t keycode) { \ | ||
58 | static const uint32_t translation[] = {__VA_ARGS__}; \ | ||
59 | uint32_t ret = keycode; \ | ||
60 | if ((keycode - KC_A) < (sizeof(translation) / sizeof(uint32_t))) { \ | ||
61 | ret = translation[keycode - KC_A]; \ | ||
62 | } \ | ||
63 | return ret; \ | ||
64 | } | ||
65 | |||
66 | bool process_record_glyph_replacement(uint16_t keycode, keyrecord_t *record, translator_function_t translator) { | ||
67 | uint8_t temp_mod = get_mods(); | ||
68 | uint8_t temp_osm = get_oneshot_mods(); | ||
69 | bool is_shifted = (temp_mod | temp_osm) & MOD_MASK_SHIFT; | ||
70 | if (((temp_mod | temp_osm) & (MOD_MASK_CTRL | MOD_MASK_ALT | MOD_MASK_GUI)) == 0) { | ||
71 | if (KC_A <= keycode && keycode <= KC_Z) { | ||
72 | if (record->event.pressed) { | ||
73 | tap_unicode_glyph_nomods(translator(is_shifted, keycode)); | ||
74 | } | ||
75 | return false; | ||
76 | } else if (KC_1 <= keycode && keycode <= KC_0) { | ||
77 | if (is_shifted) { // skip shifted numbers, so that we can still use symbols etc. | ||
78 | return process_record_keymap(keycode, record); | ||
79 | } | ||
80 | if (record->event.pressed) { | ||
81 | register_unicode(translator(is_shifted, keycode)); | ||
82 | } | ||
83 | return false; | ||
84 | } else if (keycode == KC_SPACE) { | ||
85 | if (record->event.pressed) { | ||
86 | register_unicode(translator(is_shifted, keycode)); | ||
87 | } | ||
88 | return false; | ||
89 | } | ||
90 | } | ||
91 | return true; | ||
92 | } | ||
93 | |||
94 | DEFINE_UNICODE_RANGE_TRANSLATOR(unicode_range_translator_wide, 0xFF41, 0xFF21, 0xFF10, 0xFF11, 0x2003); | ||
95 | DEFINE_UNICODE_RANGE_TRANSLATOR(unicode_range_translator_script, 0x1D4EA, 0x1D4D0, 0x1D7CE, 0x1D7C1, 0x2002); | ||
96 | DEFINE_UNICODE_RANGE_TRANSLATOR(unicode_range_translator_boxes, 0x1F170, 0x1F170, '0', '1', 0x2002); | ||
97 | DEFINE_UNICODE_RANGE_TRANSLATOR(unicode_range_translator_regional, 0x1F1E6, 0x1F1E6, '0', '1', 0x2003); | ||
98 | |||
99 | DEFINE_UNICODE_LUT_TRANSLATOR(unicode_lut_translator_aussie, | ||
100 | 0x0250, // a | ||
101 | 'q', // b | ||
102 | 0x0254, // c | ||
103 | 'p', // d | ||
104 | 0x01DD, // e | ||
105 | 0x025F, // f | ||
106 | 0x0183, // g | ||
107 | 0x0265, // h | ||
108 | 0x1D09, // i | ||
109 | 0x027E, // j | ||
110 | 0x029E, // k | ||
111 | 'l', // l | ||
112 | 0x026F, // m | ||
113 | 'u', // n | ||
114 | 'o', // o | ||
115 | 'd', // p | ||
116 | 'b', // q | ||
117 | 0x0279, // r | ||
118 | 's', // s | ||
119 | 0x0287, // t | ||
120 | 'n', // u | ||
121 | 0x028C, // v | ||
122 | 0x028D, // w | ||
123 | 0x2717, // x | ||
124 | 0x028E, // y | ||
125 | 'z', // z | ||
126 | 0x0269, // 1 | ||
127 | 0x3139, // 2 | ||
128 | 0x0190, // 3 | ||
129 | 0x3123, // 4 | ||
130 | 0x03DB, // 5 | ||
131 | '9', // 6 | ||
132 | 0x3125, // 7 | ||
133 | '8', // 8 | ||
134 | '6', // 9 | ||
135 | '0' // 0 | ||
136 | ); | ||
137 | |||
138 | bool process_record_aussie(uint16_t keycode, keyrecord_t *record) { | ||
139 | bool is_shifted = (get_mods() | get_oneshot_mods()) & MOD_MASK_SHIFT; | ||
140 | if ((KC_A <= keycode) && (keycode <= KC_0)) { | ||
141 | if (record->event.pressed) { | ||
142 | if (!process_record_glyph_replacement(keycode, record, unicode_lut_translator_aussie)) { | ||
143 | tap_code16_nomods(KC_LEFT); | ||
144 | return false; | ||
145 | } | ||
146 | } | ||
147 | } else if (record->event.pressed && keycode == KC_SPACE) { | ||
148 | tap_code16_nomods(KC_SPACE); | ||
149 | tap_code16_nomods(KC_LEFT); | ||
150 | return false; | ||
151 | } else if (record->event.pressed && keycode == KC_ENTER) { | ||
152 | tap_code16_nomods(KC_END); | ||
153 | tap_code16_nomods(KC_ENTER); | ||
154 | return false; | ||
155 | } else if (record->event.pressed && keycode == KC_HOME) { | ||
156 | tap_code16_nomods(KC_END); | ||
157 | return false; | ||
158 | } else if (record->event.pressed && keycode == KC_END) { | ||
159 | tap_code16_nomods(KC_HOME); | ||
160 | return false; | ||
161 | } else if (record->event.pressed && keycode == KC_BSPC) { | ||
162 | tap_code16_nomods(KC_DELT); | ||
163 | return false; | ||
164 | } else if (record->event.pressed && keycode == KC_DELT) { | ||
165 | tap_code16_nomods(KC_BSPC); | ||
166 | return false; | ||
167 | } else if (record->event.pressed && keycode == KC_QUOT) { | ||
168 | tap_unicode_glyph_nomods(is_shifted ? 0x201E : 0x201A); | ||
169 | tap_code16_nomods(KC_LEFT); | ||
170 | return false; | ||
171 | } else if (record->event.pressed && keycode == KC_COMMA) { | ||
172 | tap_unicode_glyph_nomods(is_shifted ? '<' : 0x2018); | ||
173 | tap_code16_nomods(KC_LEFT); | ||
174 | return false; | ||
175 | } else if (record->event.pressed && keycode == KC_DOT) { | ||
176 | tap_unicode_glyph_nomods(is_shifted ? '>' : 0x02D9); | ||
177 | tap_code16_nomods(KC_LEFT); | ||
178 | return false; | ||
179 | } else if (record->event.pressed && keycode == KC_SLASH) { | ||
180 | tap_unicode_glyph_nomods(is_shifted ? 0x00BF : '/'); | ||
181 | tap_code16_nomods(KC_LEFT); | ||
182 | return false; | ||
183 | } | ||
184 | return true; | ||
185 | } | ||
186 | |||
187 | bool process_record_zalgo(uint16_t keycode, keyrecord_t *record) { | ||
188 | if ((KC_A <= keycode) && (keycode <= KC_0)) { | ||
189 | if (record->event.pressed) { | ||
190 | tap_code16_nomods(keycode); | ||
191 | |||
192 | int number = (rand() % (8 + 1 - 2)) + 2; | ||
193 | for (int index = 0; index < number; index++) { | ||
194 | uint16_t hex = (rand() % (0x036F + 1 - 0x0300)) + 0x0300; | ||
195 | register_unicode(hex); | ||
196 | } | ||
197 | |||
198 | return false; | ||
199 | } | ||
200 | } | ||
201 | return true; | ||
202 | } | ||
203 | |||
204 | bool process_record_unicode(uint16_t keycode, keyrecord_t *record) { | ||
205 | switch (keycode) { | ||
206 | case UC_FLIP: // (ノಠ痊ಠ)ノ彡┻━┻ | ||
207 | if (record->event.pressed) { | ||
208 | send_unicode_string("(ノಠ痊ಠ)ノ彡┻━┻"); | ||
209 | } | ||
210 | break; | ||
211 | |||
212 | case UC_TABL: // ┬─┬ノ( º _ ºノ) | ||
213 | if (record->event.pressed) { | ||
214 | send_unicode_string("┬─┬ノ( º _ ºノ)"); | ||
215 | } | ||
216 | break; | ||
217 | |||
218 | case UC_SHRG: // ¯\_(ツ)_/¯ | ||
219 | if (record->event.pressed) { | ||
220 | send_unicode_string("¯\\_(ツ)_/¯"); | ||
221 | } | ||
222 | break; | ||
223 | |||
224 | case UC_DISA: // ಠ_ಠ | ||
225 | if (record->event.pressed) { | ||
226 | send_unicode_string("ಠ_ಠ"); | ||
227 | } | ||
228 | break; | ||
229 | |||
230 | case UC_IRNY: // ⸮ | ||
231 | if (record->event.pressed) { | ||
232 | register_unicode(0x2E2E); | ||
233 | } | ||
234 | break; | ||
235 | case UC_CLUE: // ‽ | ||
236 | if (record->event.pressed) { | ||
237 | register_unicode(0x203D); | ||
238 | } | ||
239 | break; | ||
240 | case KC_NOMODE ... KC_ZALGO: | ||
241 | if (record->event.pressed) { | ||
242 | if (typing_mode != keycode) { | ||
243 | typing_mode = keycode; | ||
244 | } else { | ||
245 | typing_mode = 0; | ||
246 | } | ||
247 | } | ||
248 | break; | ||
249 | |||
250 | break; | ||
251 | } | ||
252 | if (((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) && record->tap.count) { | ||
253 | keycode &= 0xFF; | ||
254 | } | ||
255 | |||
256 | if (typing_mode == KC_WIDE) { | ||
257 | if (((KC_A <= keycode) && (keycode <= KC_0)) || keycode == KC_SPACE) { | ||
258 | return process_record_glyph_replacement(keycode, record, unicode_range_translator_wide); | ||
259 | } | ||
260 | } else if (typing_mode == KC_SCRIPT) { | ||
261 | if (((KC_A <= keycode) && (keycode <= KC_0)) || keycode == KC_SPACE) { | ||
262 | return process_record_glyph_replacement(keycode, record, unicode_range_translator_script); | ||
263 | } | ||
264 | } else if (typing_mode == KC_BLOCKS) { | ||
265 | if (((KC_A <= keycode) && (keycode <= KC_0)) || keycode == KC_SPACE) { | ||
266 | return process_record_glyph_replacement(keycode, record, unicode_range_translator_boxes); | ||
267 | } | ||
268 | } else if (typing_mode == KC_REGIONAL) { | ||
269 | if (((KC_A <= keycode) && (keycode <= KC_0)) || keycode == KC_SPACE) { | ||
270 | if (!process_record_glyph_replacement(keycode, record, unicode_range_translator_regional)) { | ||
271 | wait_us(500); | ||
272 | tap_unicode_glyph_nomods(0x200C); | ||
273 | return false; | ||
274 | } | ||
275 | } | ||
276 | } else if (typing_mode == KC_AUSSIE) { | ||
277 | return process_record_aussie(keycode, record); | ||
278 | } else if (typing_mode == KC_ZALGO) { | ||
279 | return process_record_zalgo(keycode, record); | ||
280 | } | ||
281 | return true; | ||
282 | } | ||