]> git.donarmstrong.com Git - qmk_firmware.git/blob - users/drashna/send_unicode.c
Keymap: Update to drashna keymaps and userspace (#3992)
[qmk_firmware.git] / users / drashna / send_unicode.c
1 // Written by konstantin: vomindoraan
2 #include "send_unicode.h"
3 #include <ctype.h>
4 #include <string.h>
5
6 __attribute__((weak))
7 void 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/