aboutsummaryrefslogtreecommitdiff
path: root/users/bocaj/send_unicode.c
diff options
context:
space:
mode:
Diffstat (limited to 'users/bocaj/send_unicode.c')
-rw-r--r--users/bocaj/send_unicode.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/users/bocaj/send_unicode.c b/users/bocaj/send_unicode.c
new file mode 100644
index 000000000..b1290f631
--- /dev/null
+++ b/users/bocaj/send_unicode.c
@@ -0,0 +1,106 @@
1// Written by konstantin: vomindoraan
2#include "send_unicode.h"
3#include <ctype.h>
4#include <string.h>
5
6__attribute__((weak))
7void send_unicode_hex_string(const char* str) {
8 if (!str) { return; } // Safety net
9
10 while (*str) {
11 // Find the next code point (token) in the string
12 for (; *str == ' '; str++);
13 size_t n = strcspn(str, " "); // Length of the current token
14 char code_point[n+1];
15 strncpy(code_point, str, n);
16 code_point[n] = '\0'; // Make sure it's null-terminated
17
18 // Normalize the code point: make all hex digits lowercase
19 for (char *p = code_point; *p; p++) {
20 *p = tolower((unsigned char)*p);
21 }
22
23 // Send the code point as a Unicode input string
24 unicode_input_start();
25 send_string(code_point);
26 unicode_input_finish();
27
28 str += n; // Move to the first ' ' (or '\0') after the current token
29 }
30}
31
32// (ノಠ痊ಠ)ノ彡┻━┻
33// send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B");
34
35//Old code
36// (╯°□°)╯ ︵ ┻━┻
37 #if 0
38 register_code(KC_RSFT);
39 tap(KC_9);
40 unregister_code(KC_RSFT);
41 process_unicode((0x256F | QK_UNICODE), record); // Arm
42 process_unicode((0x00B0 | QK_UNICODE), record); // Eye
43 process_unicode((0x25A1 | QK_UNICODE), record); // Mouth
44 process_unicode((0x00B0 | QK_UNICODE), record); // Eye
45 register_code(KC_RSFT);
46 tap(KC_0);
47 unregister_code(KC_RSFT);
48 process_unicode((0x256F | QK_UNICODE), record); // Arm
49 tap(KC_SPC);
50 process_unicode((0x0361 | QK_UNICODE), record); // Flippy
51 tap(KC_SPC);
52 process_unicode((0x253B | QK_UNICODE), record); // Table
53 process_unicode((0x2501 | QK_UNICODE), record); // Table
54 process_unicode((0x253B | QK_UNICODE), record); // Table
55 #endif
56
57
58// If you need a good converter: https://r12a.github.io/app-conversion/
59uint8_t saved_mods;
60
61void unicode_input_start (void) {
62 // save current mods
63 saved_mods = get_mods(); // Save current mods
64 clear_mods(); // Unregister mods to start from a clean state
65
66 switch(get_unicode_input_mode()) {
67 case UC_OSX:
68 register_code(KC_LALT);
69 break;
70 case UC_LNX:
71 register_code(KC_LCTL);
72 register_code(KC_LSFT);
73 register_code(KC_U);
74 unregister_code(KC_U);
75 unregister_code(KC_LSFT);
76 unregister_code(KC_LCTL);
77 break;
78 case UC_WIN:
79 register_code(KC_LALT);
80 register_code(KC_PPLS);
81 unregister_code(KC_PPLS);
82 break;
83 case UC_WINC:
84 register_code(KC_RALT);
85 unregister_code(KC_RALT);
86 register_code(KC_U);
87 unregister_code(KC_U);
88 break;
89 }
90 wait_ms(UNICODE_TYPE_DELAY);
91}
92
93void unicode_input_finish (void) {
94 switch(get_unicode_input_mode()) {
95 case UC_OSX:
96 case UC_WIN:
97 unregister_code(KC_LALT);
98 break;
99 case UC_LNX:
100 register_code(KC_SPC);
101 unregister_code(KC_SPC);
102 break;
103 }
104
105 set_mods(saved_mods); // Reregister previously set mods
106}