summaryrefslogtreecommitdiff
path: root/quantum/quantum.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/quantum.c')
-rw-r--r--quantum/quantum.c79
1 files changed, 72 insertions, 7 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c
index e4d7b91852..1e91ac04a4 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -23,6 +23,18 @@ int offset = 7;
#ifdef AUDIO_ENABLE
bool music_activated = false;
+ float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
+
+ // music sequencer
+ static bool music_sequence_recording = false;
+ static bool music_sequence_playing = false;
+ static float music_sequence[16] = {0};
+ static uint8_t music_sequence_count = 0;
+ static uint8_t music_sequence_position = 0;
+
+ static uint16_t music_sequence_timer = 0;
+ static uint16_t music_sequence_interval = 100;
+
#endif
#ifdef MIDI_ENABLE
@@ -44,6 +56,10 @@ uint8_t chord_keys[CHORDING_MAX] = {0};
uint8_t chord_key_count = 0;
uint8_t chord_key_down = 0;
+#ifdef UNICODE_ENABLE
+ static uint8_t input_mode;
+#endif
+
bool keys_chord(uint8_t keys[]) {
uint8_t keys_size = sizeof(keys)/sizeof(keys[0]);
bool pass = true;
@@ -66,14 +82,25 @@ bool keys_chord(uint8_t keys[]) {
return (pass && (in == keys_size));
}
-static bool music_sequence_recording = false;
-static bool music_sequence_playing = false;
-static float music_sequence[16] = {0};
-static uint8_t music_sequence_count = 0;
-static uint8_t music_sequence_position = 0;
+#ifdef UNICODE_ENABLE
+
+uint16_t hex_to_keycode(uint8_t hex)
+{
+ if (hex == 0x0) {
+ return KC_0;
+ } else if (hex < 0xA) {
+ return KC_1 + (hex - 0x1);
+ } else {
+ return KC_A + (hex - 0xA);
+ }
+}
+
+void set_unicode_mode(uint8_t os_target)
+{
+ input_mode = os_target;
+}
-static uint16_t music_sequence_timer = 0;
-static uint16_t music_sequence_interval = 100;
+#endif
bool process_record_quantum(keyrecord_t *record) {
@@ -347,6 +374,44 @@ bool process_record_quantum(keyrecord_t *record) {
#endif
+#ifdef UNICODE_ENABLE
+
+ if (keycode > UNICODE(0) && record->event.pressed) {
+ uint16_t unicode = keycode & 0x7FFF;
+ switch(input_mode) {
+ case UC_OSX:
+ register_code(KC_LALT);
+ break;
+ case UC_LNX:
+ register_code(KC_LCTL);
+ register_code(KC_LSFT);
+ register_code(KC_U);
+ unregister_code(KC_U);
+ break;
+ case UC_WIN:
+ register_code(KC_LALT);
+ register_code(KC_PPLS);
+ unregister_code(KC_PPLS);
+ break;
+ }
+ for(int i = 3; i >= 0; i--) {
+ uint8_t digit = ((unicode >> (i*4)) & 0xF);
+ register_code(hex_to_keycode(digit));
+ unregister_code(hex_to_keycode(digit));
+ }
+ switch(input_mode) {
+ case UC_OSX:
+ case UC_WIN:
+ unregister_code(KC_LALT);
+ break;
+ case UC_LNX:
+ unregister_code(KC_LCTL);
+ unregister_code(KC_LSFT);
+ break;
+ }
+ }
+
+#endif
return process_action_kb(record);
}