aboutsummaryrefslogtreecommitdiff
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 e4d7b9185..1e91ac04a 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -23,6 +23,18 @@ int offset = 7;
23 23
24#ifdef AUDIO_ENABLE 24#ifdef AUDIO_ENABLE
25 bool music_activated = false; 25 bool music_activated = false;
26 float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
27
28 // music sequencer
29 static bool music_sequence_recording = false;
30 static bool music_sequence_playing = false;
31 static float music_sequence[16] = {0};
32 static uint8_t music_sequence_count = 0;
33 static uint8_t music_sequence_position = 0;
34
35 static uint16_t music_sequence_timer = 0;
36 static uint16_t music_sequence_interval = 100;
37
26#endif 38#endif
27 39
28#ifdef MIDI_ENABLE 40#ifdef MIDI_ENABLE
@@ -44,6 +56,10 @@ uint8_t chord_keys[CHORDING_MAX] = {0};
44uint8_t chord_key_count = 0; 56uint8_t chord_key_count = 0;
45uint8_t chord_key_down = 0; 57uint8_t chord_key_down = 0;
46 58
59#ifdef UNICODE_ENABLE
60 static uint8_t input_mode;
61#endif
62
47bool keys_chord(uint8_t keys[]) { 63bool keys_chord(uint8_t keys[]) {
48 uint8_t keys_size = sizeof(keys)/sizeof(keys[0]); 64 uint8_t keys_size = sizeof(keys)/sizeof(keys[0]);
49 bool pass = true; 65 bool pass = true;
@@ -66,14 +82,25 @@ bool keys_chord(uint8_t keys[]) {
66 return (pass && (in == keys_size)); 82 return (pass && (in == keys_size));
67} 83}
68 84
69static bool music_sequence_recording = false; 85#ifdef UNICODE_ENABLE
70static bool music_sequence_playing = false; 86
71static float music_sequence[16] = {0}; 87uint16_t hex_to_keycode(uint8_t hex)
72static uint8_t music_sequence_count = 0; 88{
73static uint8_t music_sequence_position = 0; 89 if (hex == 0x0) {
90 return KC_0;
91 } else if (hex < 0xA) {
92 return KC_1 + (hex - 0x1);
93 } else {
94 return KC_A + (hex - 0xA);
95 }
96}
97
98void set_unicode_mode(uint8_t os_target)
99{
100 input_mode = os_target;
101}
74 102
75static uint16_t music_sequence_timer = 0; 103#endif
76static uint16_t music_sequence_interval = 100;
77 104
78bool process_record_quantum(keyrecord_t *record) { 105bool process_record_quantum(keyrecord_t *record) {
79 106
@@ -347,6 +374,44 @@ bool process_record_quantum(keyrecord_t *record) {
347 374
348#endif 375#endif
349 376
377#ifdef UNICODE_ENABLE
378
379 if (keycode > UNICODE(0) && record->event.pressed) {
380 uint16_t unicode = keycode & 0x7FFF;
381 switch(input_mode) {
382 case UC_OSX:
383 register_code(KC_LALT);
384 break;
385 case UC_LNX:
386 register_code(KC_LCTL);
387 register_code(KC_LSFT);
388 register_code(KC_U);
389 unregister_code(KC_U);
390 break;
391 case UC_WIN:
392 register_code(KC_LALT);
393 register_code(KC_PPLS);
394 unregister_code(KC_PPLS);
395 break;
396 }
397 for(int i = 3; i >= 0; i--) {
398 uint8_t digit = ((unicode >> (i*4)) & 0xF);
399 register_code(hex_to_keycode(digit));
400 unregister_code(hex_to_keycode(digit));
401 }
402 switch(input_mode) {
403 case UC_OSX:
404 case UC_WIN:
405 unregister_code(KC_LALT);
406 break;
407 case UC_LNX:
408 unregister_code(KC_LCTL);
409 unregister_code(KC_LSFT);
410 break;
411 }
412 }
413
414#endif
350 415
351 return process_action_kb(record); 416 return process_action_kb(record);
352} 417}