qmk-keychron-q3-colemak-dh/users/drashna/send_unicode.c
Drashna Jaelre ecd21b44a8 Update to drashna userspace and keymaps (#4459)
* Fix reversed bool check in layer_state_set

* Add Quefrency 65 for a friend

* Add Ergodox EZ Glow keymap

* Add RGB Matrix Code

* Further changes to rgb matrix ErgoDox EZ

* Update bjohnson keymaps

* Fix CRKBD display

* Overhaul to corne keyboard

* Narrow scope for keylogger

* Minor layout tweaks to Corne Keyboard

* additional CRKBD tweaks

* Minor tweaks to CRKBD

* Add all characters for keylogger

* Ergodox EZ Glow overhaul

* Fix Ergodox EZ Glow layer colors

* Increase Tapping Term for Corne Keyboard

* Fix unicode-ish

* Revert some changes

* Add layer specific lighting effects

* Some minor tweaks to ergodox glow config

* revert changes to ergodox files

* Update Glow readme

* Add more tapping term defines

* Fix changes

* Fix ergodox keymap

* Hopefully fix sleeping

* Disable layer indications if rgb matrix is disabled

* Add support for sleeping and rgb layer change toggle to ergodox ez glow

* Make RGB Layer Indication Great Again

* Make Unicode Great Again

* Remove placeholder define

Co-Authored-By: drashna <drashna@live.com>

* Remove placeholder define

Co-Authored-By: drashna <drashna@live.com>

* Remove old EEPROM Reset keycode
2018-11-26 16:45:24 -08:00

113 lines
3.0 KiB
C

// Written by konstantin: vomindoraan
#include "send_unicode.h"
#include <ctype.h>
#include <string.h>
__attribute__((weak))
void send_unicode_hex_string(const char* str) {
if (!str) { return; } // Safety net
while (*str) {
// Find the next code point (token) in the string
for (; *str == ' '; str++);
size_t n = strcspn(str, " "); // Length of the current token
char code_point[n+1];
strncpy(code_point, str, n);
code_point[n] = '\0'; // Make sure it's null-terminated
// Normalize the code point: make all hex digits lowercase
for (char *p = code_point; *p; p++) {
*p = tolower((unsigned char)*p);
}
// Send the code point as a Unicode input string
unicode_input_start();
send_string(code_point);
unicode_input_finish();
str += n; // Move to the first ' ' (or '\0') after the current token
}
}
// (ノಠ痊ಠ)ノ彡┻━┻
// send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B");
//Old code
// (╯°□°)╯ ︵ ┻━┻
#if 0
register_code(KC_RSFT);
tap(KC_9);
unregister_code(KC_RSFT);
process_unicode((0x256F | QK_UNICODE), record); // Arm
process_unicode((0x00B0 | QK_UNICODE), record); // Eye
process_unicode((0x25A1 | QK_UNICODE), record); // Mouth
process_unicode((0x00B0 | QK_UNICODE), record); // Eye
register_code(KC_RSFT);
tap(KC_0);
unregister_code(KC_RSFT);
process_unicode((0x256F | QK_UNICODE), record); // Arm
tap(KC_SPC);
process_unicode((0x0361 | QK_UNICODE), record); // Flippy
tap(KC_SPC);
process_unicode((0x253B | QK_UNICODE), record); // Table
process_unicode((0x2501 | QK_UNICODE), record); // Table
process_unicode((0x253B | QK_UNICODE), record); // Table
#endif
// If you need a good converter: https://r12a.github.io/app-conversion/
uint8_t saved_mods;
void unicode_input_start (void) {
// save current mods
saved_mods = get_mods(); // Save current mods
clear_mods(); // Unregister mods to start from a clean state
switch(get_unicode_input_mode()) {
case UC_OSX:
register_code(KC_LALT);
break;
case UC_OSX_RALT:
register_code(KC_RALT);
break;
case UC_LNX:
register_code(KC_LCTL);
register_code(KC_LSFT);
register_code(KC_U);
unregister_code(KC_U);
unregister_code(KC_LSFT);
unregister_code(KC_LCTL);
break;
case UC_WIN:
register_code(KC_LALT);
register_code(KC_PPLS);
unregister_code(KC_PPLS);
break;
case UC_WINC:
register_code(KC_RALT);
unregister_code(KC_RALT);
register_code(KC_U);
unregister_code(KC_U);
break;
}
wait_ms(UNICODE_TYPE_DELAY);
}
void unicode_input_finish (void) {
switch(get_unicode_input_mode()) {
case UC_OSX:
case UC_WIN:
unregister_code(KC_LALT);
break;
case UC_OSX_RALT:
unregister_code(KC_RALT);
break;
case UC_LNX:
register_code(KC_SPC);
unregister_code(KC_SPC);
break;
}
set_mods(saved_mods); // Reregister previously set mods
}