diff options
Diffstat (limited to 'quantum/process_keycode')
| -rw-r--r-- | quantum/process_keycode/process_chording.c | 60 | ||||
| -rw-r--r-- | quantum/process_keycode/process_chording.h | 16 | ||||
| -rw-r--r-- | quantum/process_keycode/process_leader.c | 38 | ||||
| -rw-r--r-- | quantum/process_keycode/process_leader.h | 23 | ||||
| -rw-r--r-- | quantum/process_keycode/process_midi.c | 66 | ||||
| -rw-r--r-- | quantum/process_keycode/process_midi.h | 207 | ||||
| -rw-r--r-- | quantum/process_keycode/process_music.c | 171 | ||||
| -rw-r--r-- | quantum/process_keycode/process_music.h | 27 | ||||
| -rw-r--r-- | quantum/process_keycode/process_tap_dance.c | 90 | ||||
| -rw-r--r-- | quantum/process_keycode/process_tap_dance.h | 62 | ||||
| -rw-r--r-- | quantum/process_keycode/process_unicode.c | 57 | ||||
| -rw-r--r-- | quantum/process_keycode/process_unicode.h | 122 |
12 files changed, 939 insertions, 0 deletions
diff --git a/quantum/process_keycode/process_chording.c b/quantum/process_keycode/process_chording.c new file mode 100644 index 000000000..d7814629f --- /dev/null +++ b/quantum/process_keycode/process_chording.c | |||
| @@ -0,0 +1,60 @@ | |||
| 1 | #include "process_chording.h" | ||
| 2 | |||
| 3 | bool keys_chord(uint8_t keys[]) { | ||
| 4 | uint8_t keys_size = sizeof(keys)/sizeof(keys[0]); | ||
| 5 | bool pass = true; | ||
| 6 | uint8_t in = 0; | ||
| 7 | for (uint8_t i = 0; i < chord_key_count; i++) { | ||
| 8 | bool found = false; | ||
| 9 | for (uint8_t j = 0; j < keys_size; j++) { | ||
| 10 | if (chord_keys[i] == (keys[j] & 0xFF)) { | ||
| 11 | in++; // detects key in chord | ||
| 12 | found = true; | ||
| 13 | break; | ||
| 14 | } | ||
| 15 | } | ||
| 16 | if (found) | ||
| 17 | continue; | ||
| 18 | if (chord_keys[i] != 0) { | ||
| 19 | pass = false; // makes sure rest are blank | ||
| 20 | } | ||
| 21 | } | ||
| 22 | return (pass && (in == keys_size)); | ||
| 23 | } | ||
| 24 | |||
| 25 | bool process_chording(uint16_t keycode, keyrecord_t *record) { | ||
| 26 | if (keycode >= QK_CHORDING && keycode <= QK_CHORDING_MAX) { | ||
| 27 | if (record->event.pressed) { | ||
| 28 | if (!chording) { | ||
| 29 | chording = true; | ||
| 30 | for (uint8_t i = 0; i < CHORDING_MAX; i++) | ||
| 31 | chord_keys[i] = 0; | ||
| 32 | chord_key_count = 0; | ||
| 33 | chord_key_down = 0; | ||
| 34 | } | ||
| 35 | chord_keys[chord_key_count] = (keycode & 0xFF); | ||
| 36 | chord_key_count++; | ||
| 37 | chord_key_down++; | ||
| 38 | return false; | ||
| 39 | } else { | ||
| 40 | if (chording) { | ||
| 41 | chord_key_down--; | ||
| 42 | if (chord_key_down == 0) { | ||
| 43 | chording = false; | ||
| 44 | // Chord Dictionary | ||
| 45 | if (keys_chord((uint8_t[]){KC_ENTER, KC_SPACE})) { | ||
| 46 | register_code(KC_A); | ||
| 47 | unregister_code(KC_A); | ||
| 48 | return false; | ||
| 49 | } | ||
| 50 | for (uint8_t i = 0; i < chord_key_count; i++) { | ||
| 51 | register_code(chord_keys[i]); | ||
| 52 | unregister_code(chord_keys[i]); | ||
| 53 | return false; | ||
| 54 | } | ||
| 55 | } | ||
| 56 | } | ||
| 57 | } | ||
| 58 | } | ||
| 59 | return true; | ||
| 60 | } \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_chording.h b/quantum/process_keycode/process_chording.h new file mode 100644 index 000000000..49c97db3b --- /dev/null +++ b/quantum/process_keycode/process_chording.h | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | #ifndef PROCESS_CHORDING_H | ||
| 2 | #define PROCESS_CHORDING_H | ||
| 3 | |||
| 4 | #include "quantum.h" | ||
| 5 | |||
| 6 | // Chording stuff | ||
| 7 | #define CHORDING_MAX 4 | ||
| 8 | bool chording = false; | ||
| 9 | |||
| 10 | uint8_t chord_keys[CHORDING_MAX] = {0}; | ||
| 11 | uint8_t chord_key_count = 0; | ||
| 12 | uint8_t chord_key_down = 0; | ||
| 13 | |||
| 14 | bool process_chording(uint16_t keycode, keyrecord_t *record); | ||
| 15 | |||
| 16 | #endif \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c new file mode 100644 index 000000000..e53d221e7 --- /dev/null +++ b/quantum/process_keycode/process_leader.c | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | #include "process_leader.h" | ||
| 2 | |||
| 3 | __attribute__ ((weak)) | ||
| 4 | void leader_start(void) {} | ||
| 5 | |||
| 6 | __attribute__ ((weak)) | ||
| 7 | void leader_end(void) {} | ||
| 8 | |||
| 9 | // Leader key stuff | ||
| 10 | bool leading = false; | ||
| 11 | uint16_t leader_time = 0; | ||
| 12 | |||
| 13 | uint16_t leader_sequence[5] = {0, 0, 0, 0, 0}; | ||
| 14 | uint8_t leader_sequence_size = 0; | ||
| 15 | |||
| 16 | bool process_leader(uint16_t keycode, keyrecord_t *record) { | ||
| 17 | // Leader key set-up | ||
| 18 | if (record->event.pressed) { | ||
| 19 | if (!leading && keycode == KC_LEAD) { | ||
| 20 | leader_start(); | ||
| 21 | leading = true; | ||
| 22 | leader_time = timer_read(); | ||
| 23 | leader_sequence_size = 0; | ||
| 24 | leader_sequence[0] = 0; | ||
| 25 | leader_sequence[1] = 0; | ||
| 26 | leader_sequence[2] = 0; | ||
| 27 | leader_sequence[3] = 0; | ||
| 28 | leader_sequence[4] = 0; | ||
| 29 | return false; | ||
| 30 | } | ||
| 31 | if (leading && timer_elapsed(leader_time) < LEADER_TIMEOUT) { | ||
| 32 | leader_sequence[leader_sequence_size] = keycode; | ||
| 33 | leader_sequence_size++; | ||
| 34 | return false; | ||
| 35 | } | ||
| 36 | } | ||
| 37 | return true; | ||
| 38 | } \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_leader.h b/quantum/process_keycode/process_leader.h new file mode 100644 index 000000000..c83db8abb --- /dev/null +++ b/quantum/process_keycode/process_leader.h | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | #ifndef PROCESS_LEADER_H | ||
| 2 | #define PROCESS_LEADER_H | ||
| 3 | |||
| 4 | #include "quantum.h" | ||
| 5 | |||
| 6 | bool process_leader(uint16_t keycode, keyrecord_t *record); | ||
| 7 | |||
| 8 | void leader_start(void); | ||
| 9 | void leader_end(void); | ||
| 10 | |||
| 11 | #ifndef LEADER_TIMEOUT | ||
| 12 | #define LEADER_TIMEOUT 200 | ||
| 13 | #endif | ||
| 14 | #define SEQ_ONE_KEY(key) if (leader_sequence[0] == (key) && leader_sequence[1] == 0 && leader_sequence[2] == 0 && leader_sequence[3] == 0 && leader_sequence[4] == 0) | ||
| 15 | #define SEQ_TWO_KEYS(key1, key2) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == 0 && leader_sequence[3] == 0 && leader_sequence[4] == 0) | ||
| 16 | #define SEQ_THREE_KEYS(key1, key2, key3) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == (key3) && leader_sequence[3] == 0 && leader_sequence[4] == 0) | ||
| 17 | #define SEQ_FOUR_KEYS(key1, key2, key3, key4) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == (key3) && leader_sequence[3] == (key4) && leader_sequence[4] == 0) | ||
| 18 | #define SEQ_FIVE_KEYS(key1, key2, key3, key4, key5) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == (key3) && leader_sequence[3] == (key4) && leader_sequence[4] == (key5)) | ||
| 19 | |||
| 20 | #define LEADER_EXTERNS() extern bool leading; extern uint16_t leader_time; extern uint16_t leader_sequence[5]; extern uint8_t leader_sequence_size | ||
| 21 | #define LEADER_DICTIONARY() if (leading && timer_elapsed(leader_time) > LEADER_TIMEOUT) | ||
| 22 | |||
| 23 | #endif \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_midi.c b/quantum/process_keycode/process_midi.c new file mode 100644 index 000000000..d6ab9c626 --- /dev/null +++ b/quantum/process_keycode/process_midi.c | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | #include "process_midi.h" | ||
| 2 | |||
| 3 | bool midi_activated = false; | ||
| 4 | uint8_t starting_note = 0x0C; | ||
| 5 | int offset = 7; | ||
| 6 | |||
| 7 | bool process_midi(uint16_t keycode, keyrecord_t *record) { | ||
| 8 | if (keycode == MI_ON && record->event.pressed) { | ||
| 9 | midi_activated = true; | ||
| 10 | music_scale_user(); | ||
| 11 | return false; | ||
| 12 | } | ||
| 13 | |||
| 14 | if (keycode == MI_OFF && record->event.pressed) { | ||
| 15 | midi_activated = false; | ||
| 16 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 17 | return false; | ||
| 18 | } | ||
| 19 | |||
| 20 | if (midi_activated) { | ||
| 21 | if (record->event.key.col == (MATRIX_COLS - 1) && record->event.key.row == (MATRIX_ROWS - 1)) { | ||
| 22 | if (record->event.pressed) { | ||
| 23 | starting_note++; // Change key | ||
| 24 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 25 | } | ||
| 26 | return false; | ||
| 27 | } | ||
| 28 | if (record->event.key.col == (MATRIX_COLS - 2) && record->event.key.row == (MATRIX_ROWS - 1)) { | ||
| 29 | if (record->event.pressed) { | ||
| 30 | starting_note--; // Change key | ||
| 31 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 32 | } | ||
| 33 | return false; | ||
| 34 | } | ||
| 35 | if (record->event.key.col == (MATRIX_COLS - 3) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { | ||
| 36 | offset++; // Change scale | ||
| 37 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 38 | return false; | ||
| 39 | } | ||
| 40 | if (record->event.key.col == (MATRIX_COLS - 4) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { | ||
| 41 | offset--; // Change scale | ||
| 42 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 43 | return false; | ||
| 44 | } | ||
| 45 | // basic | ||
| 46 | // uint8_t note = (starting_note + SCALE[record->event.key.col + offset])+12*(MATRIX_ROWS - record->event.key.row); | ||
| 47 | // advanced | ||
| 48 | // uint8_t note = (starting_note + record->event.key.col + offset)+12*(MATRIX_ROWS - record->event.key.row); | ||
| 49 | // guitar | ||
| 50 | uint8_t note = (starting_note + record->event.key.col + offset)+5*(MATRIX_ROWS - record->event.key.row); | ||
| 51 | // violin | ||
| 52 | // uint8_t note = (starting_note + record->event.key.col + offset)+7*(MATRIX_ROWS - record->event.key.row); | ||
| 53 | |||
| 54 | if (record->event.pressed) { | ||
| 55 | // midi_send_noteon(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127); | ||
| 56 | midi_send_noteon(&midi_device, 0, note, 127); | ||
| 57 | } else { | ||
| 58 | // midi_send_noteoff(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127); | ||
| 59 | midi_send_noteoff(&midi_device, 0, note, 127); | ||
| 60 | } | ||
| 61 | |||
| 62 | if (keycode < 0xFF) // ignores all normal keycodes, but lets RAISE, LOWER, etc through | ||
| 63 | return false; | ||
| 64 | } | ||
| 65 | return true; | ||
| 66 | } \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_midi.h b/quantum/process_keycode/process_midi.h new file mode 100644 index 000000000..acd4fc1b1 --- /dev/null +++ b/quantum/process_keycode/process_midi.h | |||
| @@ -0,0 +1,207 @@ | |||
| 1 | #ifndef PROCESS_MIDI_H | ||
| 2 | #define PROCESS_MIDI_H | ||
| 3 | |||
| 4 | #include "quantum.h" | ||
| 5 | |||
| 6 | bool process_midi(uint16_t keycode, keyrecord_t *record); | ||
| 7 | |||
| 8 | #define MIDI(n) ((n) | 0x6000) | ||
| 9 | #define MIDI12 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000 | ||
| 10 | |||
| 11 | #define CHNL(note, channel) (note + (channel << 8)) | ||
| 12 | |||
| 13 | #define SCALE (int8_t []){ 0 + (12*0), 2 + (12*0), 4 + (12*0), 5 + (12*0), 7 + (12*0), 9 + (12*0), 11 + (12*0), \ | ||
| 14 | 0 + (12*1), 2 + (12*1), 4 + (12*1), 5 + (12*1), 7 + (12*1), 9 + (12*1), 11 + (12*1), \ | ||
| 15 | 0 + (12*2), 2 + (12*2), 4 + (12*2), 5 + (12*2), 7 + (12*2), 9 + (12*2), 11 + (12*2), \ | ||
| 16 | 0 + (12*3), 2 + (12*3), 4 + (12*3), 5 + (12*3), 7 + (12*3), 9 + (12*3), 11 + (12*3), \ | ||
| 17 | 0 + (12*4), 2 + (12*4), 4 + (12*4), 5 + (12*4), 7 + (12*4), 9 + (12*4), 11 + (12*4), } | ||
| 18 | |||
| 19 | #define N_CN1 (0x600C + (12 * -1) + 0 ) | ||
| 20 | #define N_CN1S (0x600C + (12 * -1) + 1 ) | ||
| 21 | #define N_DN1F (0x600C + (12 * -1) + 1 ) | ||
| 22 | #define N_DN1 (0x600C + (12 * -1) + 2 ) | ||
| 23 | #define N_DN1S (0x600C + (12 * -1) + 3 ) | ||
| 24 | #define N_EN1F (0x600C + (12 * -1) + 3 ) | ||
| 25 | #define N_EN1 (0x600C + (12 * -1) + 4 ) | ||
| 26 | #define N_FN1 (0x600C + (12 * -1) + 5 ) | ||
| 27 | #define N_FN1S (0x600C + (12 * -1) + 6 ) | ||
| 28 | #define N_GN1F (0x600C + (12 * -1) + 6 ) | ||
| 29 | #define N_GN1 (0x600C + (12 * -1) + 7 ) | ||
| 30 | #define N_GN1S (0x600C + (12 * -1) + 8 ) | ||
| 31 | #define N_AN1F (0x600C + (12 * -1) + 8 ) | ||
| 32 | #define N_AN1 (0x600C + (12 * -1) + 9 ) | ||
| 33 | #define N_AN1S (0x600C + (12 * -1) + 10) | ||
| 34 | #define N_BN1F (0x600C + (12 * -1) + 10) | ||
| 35 | #define N_BN1 (0x600C + (12 * -1) + 11) | ||
| 36 | #define N_C0 (0x600C + (12 * 0) + 0 ) | ||
| 37 | #define N_C0S (0x600C + (12 * 0) + 1 ) | ||
| 38 | #define N_D0F (0x600C + (12 * 0) + 1 ) | ||
| 39 | #define N_D0 (0x600C + (12 * 0) + 2 ) | ||
| 40 | #define N_D0S (0x600C + (12 * 0) + 3 ) | ||
| 41 | #define N_E0F (0x600C + (12 * 0) + 3 ) | ||
| 42 | #define N_E0 (0x600C + (12 * 0) + 4 ) | ||
| 43 | #define N_F0 (0x600C + (12 * 0) + 5 ) | ||
| 44 | #define N_F0S (0x600C + (12 * 0) + 6 ) | ||
| 45 | #define N_G0F (0x600C + (12 * 0) + 6 ) | ||
| 46 | #define N_G0 (0x600C + (12 * 0) + 7 ) | ||
| 47 | #define N_G0S (0x600C + (12 * 0) + 8 ) | ||
| 48 | #define N_A0F (0x600C + (12 * 0) + 8 ) | ||
| 49 | #define N_A0 (0x600C + (12 * 0) + 9 ) | ||
| 50 | #define N_A0S (0x600C + (12 * 0) + 10) | ||
| 51 | #define N_B0F (0x600C + (12 * 0) + 10) | ||
| 52 | #define N_B0 (0x600C + (12 * 0) + 11) | ||
| 53 | #define N_C1 (0x600C + (12 * 1) + 0 ) | ||
| 54 | #define N_C1S (0x600C + (12 * 1) + 1 ) | ||
| 55 | #define N_D1F (0x600C + (12 * 1) + 1 ) | ||
| 56 | #define N_D1 (0x600C + (12 * 1) + 2 ) | ||
| 57 | #define N_D1S (0x600C + (12 * 1) + 3 ) | ||
| 58 | #define N_E1F (0x600C + (12 * 1) + 3 ) | ||
| 59 | #define N_E1 (0x600C + (12 * 1) + 4 ) | ||
| 60 | #define N_F1 (0x600C + (12 * 1) + 5 ) | ||
| 61 | #define N_F1S (0x600C + (12 * 1) + 6 ) | ||
| 62 | #define N_G1F (0x600C + (12 * 1) + 6 ) | ||
| 63 | #define N_G1 (0x600C + (12 * 1) + 7 ) | ||
| 64 | #define N_G1S (0x600C + (12 * 1) + 8 ) | ||
| 65 | #define N_A1F (0x600C + (12 * 1) + 8 ) | ||
| 66 | #define N_A1 (0x600C + (12 * 1) + 9 ) | ||
| 67 | #define N_A1S (0x600C + (12 * 1) + 10) | ||
| 68 | #define N_B1F (0x600C + (12 * 1) + 10) | ||
| 69 | #define N_B1 (0x600C + (12 * 1) + 11) | ||
| 70 | #define N_C2 (0x600C + (12 * 2) + 0 ) | ||
| 71 | #define N_C2S (0x600C + (12 * 2) + 1 ) | ||
| 72 | #define N_D2F (0x600C + (12 * 2) + 1 ) | ||
| 73 | #define N_D2 (0x600C + (12 * 2) + 2 ) | ||
| 74 | #define N_D2S (0x600C + (12 * 2) + 3 ) | ||
| 75 | #define N_E2F (0x600C + (12 * 2) + 3 ) | ||
| 76 | #define N_E2 (0x600C + (12 * 2) + 4 ) | ||
| 77 | #define N_F2 (0x600C + (12 * 2) + 5 ) | ||
| 78 | #define N_F2S (0x600C + (12 * 2) + 6 ) | ||
| 79 | #define N_G2F (0x600C + (12 * 2) + 6 ) | ||
| 80 | #define N_G2 (0x600C + (12 * 2) + 7 ) | ||
| 81 | #define N_G2S (0x600C + (12 * 2) + 8 ) | ||
| 82 | #define N_A2F (0x600C + (12 * 2) + 8 ) | ||
| 83 | #define N_A2 (0x600C + (12 * 2) + 9 ) | ||
| 84 | #define N_A2S (0x600C + (12 * 2) + 10) | ||
| 85 | #define N_B2F (0x600C + (12 * 2) + 10) | ||
| 86 | #define N_B2 (0x600C + (12 * 2) + 11) | ||
| 87 | #define N_C3 (0x600C + (12 * 3) + 0 ) | ||
| 88 | #define N_C3S (0x600C + (12 * 3) + 1 ) | ||
| 89 | #define N_D3F (0x600C + (12 * 3) + 1 ) | ||
| 90 | #define N_D3 (0x600C + (12 * 3) + 2 ) | ||
| 91 | #define N_D3S (0x600C + (12 * 3) + 3 ) | ||
| 92 | #define N_E3F (0x600C + (12 * 3) + 3 ) | ||
| 93 | #define N_E3 (0x600C + (12 * 3) + 4 ) | ||
| 94 | #define N_F3 (0x600C + (12 * 3) + 5 ) | ||
| 95 | #define N_F3S (0x600C + (12 * 3) + 6 ) | ||
| 96 | #define N_G3F (0x600C + (12 * 3) + 6 ) | ||
| 97 | #define N_G3 (0x600C + (12 * 3) + 7 ) | ||
| 98 | #define N_G3S (0x600C + (12 * 3) + 8 ) | ||
| 99 | #define N_A3F (0x600C + (12 * 3) + 8 ) | ||
| 100 | #define N_A3 (0x600C + (12 * 3) + 9 ) | ||
| 101 | #define N_A3S (0x600C + (12 * 3) + 10) | ||
| 102 | #define N_B3F (0x600C + (12 * 3) + 10) | ||
| 103 | #define N_B3 (0x600C + (12 * 3) + 11) | ||
| 104 | #define N_C4 (0x600C + (12 * 4) + 0 ) | ||
| 105 | #define N_C4S (0x600C + (12 * 4) + 1 ) | ||
| 106 | #define N_D4F (0x600C + (12 * 4) + 1 ) | ||
| 107 | #define N_D4 (0x600C + (12 * 4) + 2 ) | ||
| 108 | #define N_D4S (0x600C + (12 * 4) + 3 ) | ||
| 109 | #define N_E4F (0x600C + (12 * 4) + 3 ) | ||
| 110 | #define N_E4 (0x600C + (12 * 4) + 4 ) | ||
| 111 | #define N_F4 (0x600C + (12 * 4) + 5 ) | ||
| 112 | #define N_F4S (0x600C + (12 * 4) + 6 ) | ||
| 113 | #define N_G4F (0x600C + (12 * 4) + 6 ) | ||
| 114 | #define N_G4 (0x600C + (12 * 4) + 7 ) | ||
| 115 | #define N_G4S (0x600C + (12 * 4) + 8 ) | ||
| 116 | #define N_A4F (0x600C + (12 * 4) + 8 ) | ||
| 117 | #define N_A4 (0x600C + (12 * 4) + 9 ) | ||
| 118 | #define N_A4S (0x600C + (12 * 4) + 10) | ||
| 119 | #define N_B4F (0x600C + (12 * 4) + 10) | ||
| 120 | #define N_B4 (0x600C + (12 * 4) + 11) | ||
| 121 | #define N_C5 (0x600C + (12 * 5) + 0 ) | ||
| 122 | #define N_C5S (0x600C + (12 * 5) + 1 ) | ||
| 123 | #define N_D5F (0x600C + (12 * 5) + 1 ) | ||
| 124 | #define N_D5 (0x600C + (12 * 5) + 2 ) | ||
| 125 | #define N_D5S (0x600C + (12 * 5) + 3 ) | ||
| 126 | #define N_E5F (0x600C + (12 * 5) + 3 ) | ||
| 127 | #define N_E5 (0x600C + (12 * 5) + 4 ) | ||
| 128 | #define N_F5 (0x600C + (12 * 5) + 5 ) | ||
| 129 | #define N_F5S (0x600C + (12 * 5) + 6 ) | ||
| 130 | #define N_G5F (0x600C + (12 * 5) + 6 ) | ||
| 131 | #define N_G5 (0x600C + (12 * 5) + 7 ) | ||
| 132 | #define N_G5S (0x600C + (12 * 5) + 8 ) | ||
| 133 | #define N_A5F (0x600C + (12 * 5) + 8 ) | ||
| 134 | #define N_A5 (0x600C + (12 * 5) + 9 ) | ||
| 135 | #define N_A5S (0x600C + (12 * 5) + 10) | ||
| 136 | #define N_B5F (0x600C + (12 * 5) + 10) | ||
| 137 | #define N_B5 (0x600C + (12 * 5) + 11) | ||
| 138 | #define N_C6 (0x600C + (12 * 6) + 0 ) | ||
| 139 | #define N_C6S (0x600C + (12 * 6) + 1 ) | ||
| 140 | #define N_D6F (0x600C + (12 * 6) + 1 ) | ||
| 141 | #define N_D6 (0x600C + (12 * 6) + 2 ) | ||
| 142 | #define N_D6S (0x600C + (12 * 6) + 3 ) | ||
| 143 | #define N_E6F (0x600C + (12 * 6) + 3 ) | ||
| 144 | #define N_E6 (0x600C + (12 * 6) + 4 ) | ||
| 145 | #define N_F6 (0x600C + (12 * 6) + 5 ) | ||
| 146 | #define N_F6S (0x600C + (12 * 6) + 6 ) | ||
| 147 | #define N_G6F (0x600C + (12 * 6) + 6 ) | ||
| 148 | #define N_G6 (0x600C + (12 * 6) + 7 ) | ||
| 149 | #define N_G6S (0x600C + (12 * 6) + 8 ) | ||
| 150 | #define N_A6F (0x600C + (12 * 6) + 8 ) | ||
| 151 | #define N_A6 (0x600C + (12 * 6) + 9 ) | ||
| 152 | #define N_A6S (0x600C + (12 * 6) + 10) | ||
| 153 | #define N_B6F (0x600C + (12 * 6) + 10) | ||
| 154 | #define N_B6 (0x600C + (12 * 6) + 11) | ||
| 155 | #define N_C7 (0x600C + (12 * 7) + 0 ) | ||
| 156 | #define N_C7S (0x600C + (12 * 7) + 1 ) | ||
| 157 | #define N_D7F (0x600C + (12 * 7) + 1 ) | ||
| 158 | #define N_D7 (0x600C + (12 * 7) + 2 ) | ||
| 159 | #define N_D7S (0x600C + (12 * 7) + 3 ) | ||
| 160 | #define N_E7F (0x600C + (12 * 7) + 3 ) | ||
| 161 | #define N_E7 (0x600C + (12 * 7) + 4 ) | ||
| 162 | #define N_F7 (0x600C + (12 * 7) + 5 ) | ||
| 163 | #define N_F7S (0x600C + (12 * 7) + 6 ) | ||
| 164 | #define N_G7F (0x600C + (12 * 7) + 6 ) | ||
| 165 | #define N_G7 (0x600C + (12 * 7) + 7 ) | ||
| 166 | #define N_G7S (0x600C + (12 * 7) + 8 ) | ||
| 167 | #define N_A7F (0x600C + (12 * 7) + 8 ) | ||
| 168 | #define N_A7 (0x600C + (12 * 7) + 9 ) | ||
| 169 | #define N_A7S (0x600C + (12 * 7) + 10) | ||
| 170 | #define N_B7F (0x600C + (12 * 7) + 10) | ||
| 171 | #define N_B7 (0x600C + (12 * 7) + 11) | ||
| 172 | #define N_C8 (0x600C + (12 * 8) + 0 ) | ||
| 173 | #define N_C8S (0x600C + (12 * 8) + 1 ) | ||
| 174 | #define N_D8F (0x600C + (12 * 8) + 1 ) | ||
| 175 | #define N_D8 (0x600C + (12 * 8) + 2 ) | ||
| 176 | #define N_D8S (0x600C + (12 * 8) + 3 ) | ||
| 177 | #define N_E8F (0x600C + (12 * 8) + 3 ) | ||
| 178 | #define N_E8 (0x600C + (12 * 8) + 4 ) | ||
| 179 | #define N_F8 (0x600C + (12 * 8) + 5 ) | ||
| 180 | #define N_F8S (0x600C + (12 * 8) + 6 ) | ||
| 181 | #define N_G8F (0x600C + (12 * 8) + 6 ) | ||
| 182 | #define N_G8 (0x600C + (12 * 8) + 7 ) | ||
| 183 | #define N_G8S (0x600C + (12 * 8) + 8 ) | ||
| 184 | #define N_A8F (0x600C + (12 * 8) + 8 ) | ||
| 185 | #define N_A8 (0x600C + (12 * 8) + 9 ) | ||
| 186 | #define N_A8S (0x600C + (12 * 8) + 10) | ||
| 187 | #define N_B8F (0x600C + (12 * 8) + 10) | ||
| 188 | #define N_B8 (0x600C + (12 * 8) + 11) | ||
| 189 | #define N_C8 (0x600C + (12 * 8) + 0 ) | ||
| 190 | #define N_C8S (0x600C + (12 * 8) + 1 ) | ||
| 191 | #define N_D8F (0x600C + (12 * 8) + 1 ) | ||
| 192 | #define N_D8 (0x600C + (12 * 8) + 2 ) | ||
| 193 | #define N_D8S (0x600C + (12 * 8) + 3 ) | ||
| 194 | #define N_E8F (0x600C + (12 * 8) + 3 ) | ||
| 195 | #define N_E8 (0x600C + (12 * 8) + 4 ) | ||
| 196 | #define N_F8 (0x600C + (12 * 8) + 5 ) | ||
| 197 | #define N_F8S (0x600C + (12 * 8) + 6 ) | ||
| 198 | #define N_G8F (0x600C + (12 * 8) + 6 ) | ||
| 199 | #define N_G8 (0x600C + (12 * 8) + 7 ) | ||
| 200 | #define N_G8S (0x600C + (12 * 8) + 8 ) | ||
| 201 | #define N_A8F (0x600C + (12 * 8) + 8 ) | ||
| 202 | #define N_A8 (0x600C + (12 * 8) + 9 ) | ||
| 203 | #define N_A8S (0x600C + (12 * 8) + 10) | ||
| 204 | #define N_B8F (0x600C + (12 * 8) + 10) | ||
| 205 | #define N_B8 (0x600C + (12 * 8) + 11) | ||
| 206 | |||
| 207 | #endif \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_music.c b/quantum/process_keycode/process_music.c new file mode 100644 index 000000000..c8f3ddb90 --- /dev/null +++ b/quantum/process_keycode/process_music.c | |||
| @@ -0,0 +1,171 @@ | |||
| 1 | #include "process_music.h" | ||
| 2 | |||
| 3 | bool music_activated = false; | ||
| 4 | uint8_t starting_note = 0x0C; | ||
| 5 | int offset = 7; | ||
| 6 | |||
| 7 | // music sequencer | ||
| 8 | static bool music_sequence_recording = false; | ||
| 9 | static bool music_sequence_playing = false; | ||
| 10 | static float music_sequence[16] = {0}; | ||
| 11 | static uint8_t music_sequence_count = 0; | ||
| 12 | static uint8_t music_sequence_position = 0; | ||
| 13 | |||
| 14 | static uint16_t music_sequence_timer = 0; | ||
| 15 | static uint16_t music_sequence_interval = 100; | ||
| 16 | |||
| 17 | bool process_music(uint16_t keycode, keyrecord_t *record) { | ||
| 18 | |||
| 19 | if (keycode == AU_ON && record->event.pressed) { | ||
| 20 | audio_on(); | ||
| 21 | return false; | ||
| 22 | } | ||
| 23 | |||
| 24 | if (keycode == AU_OFF && record->event.pressed) { | ||
| 25 | audio_off(); | ||
| 26 | return false; | ||
| 27 | } | ||
| 28 | |||
| 29 | if (keycode == AU_TOG && record->event.pressed) { | ||
| 30 | if (is_audio_on()) | ||
| 31 | { | ||
| 32 | audio_off(); | ||
| 33 | } | ||
| 34 | else | ||
| 35 | { | ||
| 36 | audio_on(); | ||
| 37 | } | ||
| 38 | return false; | ||
| 39 | } | ||
| 40 | |||
| 41 | if (keycode == MU_ON && record->event.pressed) { | ||
| 42 | music_on(); | ||
| 43 | return false; | ||
| 44 | } | ||
| 45 | |||
| 46 | if (keycode == MU_OFF && record->event.pressed) { | ||
| 47 | music_off(); | ||
| 48 | return false; | ||
| 49 | } | ||
| 50 | |||
| 51 | if (keycode == MU_TOG && record->event.pressed) { | ||
| 52 | if (music_activated) | ||
| 53 | { | ||
| 54 | music_off(); | ||
| 55 | } | ||
| 56 | else | ||
| 57 | { | ||
| 58 | music_on(); | ||
| 59 | } | ||
| 60 | return false; | ||
| 61 | } | ||
| 62 | |||
| 63 | if (keycode == MUV_IN && record->event.pressed) { | ||
| 64 | voice_iterate(); | ||
| 65 | music_scale_user(); | ||
| 66 | return false; | ||
| 67 | } | ||
| 68 | |||
| 69 | if (keycode == MUV_DE && record->event.pressed) { | ||
| 70 | voice_deiterate(); | ||
| 71 | music_scale_user(); | ||
| 72 | return false; | ||
| 73 | } | ||
| 74 | |||
| 75 | if (music_activated) { | ||
| 76 | |||
| 77 | if (keycode == KC_LCTL && record->event.pressed) { // Start recording | ||
| 78 | stop_all_notes(); | ||
| 79 | music_sequence_recording = true; | ||
| 80 | music_sequence_playing = false; | ||
| 81 | music_sequence_count = 0; | ||
| 82 | return false; | ||
| 83 | } | ||
| 84 | |||
| 85 | if (keycode == KC_LALT && record->event.pressed) { // Stop recording/playing | ||
| 86 | stop_all_notes(); | ||
| 87 | music_sequence_recording = false; | ||
| 88 | music_sequence_playing = false; | ||
| 89 | return false; | ||
| 90 | } | ||
| 91 | |||
| 92 | if (keycode == KC_LGUI && record->event.pressed) { // Start playing | ||
| 93 | stop_all_notes(); | ||
| 94 | music_sequence_recording = false; | ||
| 95 | music_sequence_playing = true; | ||
| 96 | music_sequence_position = 0; | ||
| 97 | music_sequence_timer = 0; | ||
| 98 | return false; | ||
| 99 | } | ||
| 100 | |||
| 101 | if (keycode == KC_UP) { | ||
| 102 | if (record->event.pressed) | ||
| 103 | music_sequence_interval-=10; | ||
| 104 | return false; | ||
| 105 | } | ||
| 106 | |||
| 107 | if (keycode == KC_DOWN) { | ||
| 108 | if (record->event.pressed) | ||
| 109 | music_sequence_interval+=10; | ||
| 110 | return false; | ||
| 111 | } | ||
| 112 | |||
| 113 | float freq = ((float)220.0)*pow(2.0, -5.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)); | ||
| 114 | if (record->event.pressed) { | ||
| 115 | play_note(freq, 0xF); | ||
| 116 | if (music_sequence_recording) { | ||
| 117 | music_sequence[music_sequence_count] = freq; | ||
| 118 | music_sequence_count++; | ||
| 119 | } | ||
| 120 | } else { | ||
| 121 | stop_note(freq); | ||
| 122 | } | ||
| 123 | |||
| 124 | if (keycode < 0xFF) // ignores all normal keycodes, but lets RAISE, LOWER, etc through | ||
| 125 | return false; | ||
| 126 | } | ||
| 127 | return true; | ||
| 128 | } | ||
| 129 | |||
| 130 | bool is_music_on(void) { | ||
| 131 | return (music_activated != 0); | ||
| 132 | } | ||
| 133 | |||
| 134 | void music_toggle(void) { | ||
| 135 | if (!music_activated) { | ||
| 136 | music_on(); | ||
| 137 | } else { | ||
| 138 | music_off(); | ||
| 139 | } | ||
| 140 | } | ||
| 141 | |||
| 142 | void music_on(void) { | ||
| 143 | music_activated = 1; | ||
| 144 | music_on_user(); | ||
| 145 | } | ||
| 146 | |||
| 147 | void music_off(void) { | ||
| 148 | music_activated = 0; | ||
| 149 | stop_all_notes(); | ||
| 150 | } | ||
| 151 | |||
| 152 | |||
| 153 | __attribute__ ((weak)) | ||
| 154 | void music_on_user() {} | ||
| 155 | |||
| 156 | __attribute__ ((weak)) | ||
| 157 | void audio_on_user() {} | ||
| 158 | |||
| 159 | __attribute__ ((weak)) | ||
| 160 | void music_scale_user() {} | ||
| 161 | |||
| 162 | void matrix_scan_music(void) { | ||
| 163 | if (music_sequence_playing) { | ||
| 164 | if ((music_sequence_timer == 0) || (timer_elapsed(music_sequence_timer) > music_sequence_interval)) { | ||
| 165 | music_sequence_timer = timer_read(); | ||
| 166 | stop_note(music_sequence[(music_sequence_position - 1 < 0)?(music_sequence_position - 1 + music_sequence_count):(music_sequence_position - 1)]); | ||
| 167 | play_note(music_sequence[music_sequence_position], 0xF); | ||
| 168 | music_sequence_position = (music_sequence_position + 1) % music_sequence_count; | ||
| 169 | } | ||
| 170 | } | ||
| 171 | } | ||
diff --git a/quantum/process_keycode/process_music.h b/quantum/process_keycode/process_music.h new file mode 100644 index 000000000..318b3e387 --- /dev/null +++ b/quantum/process_keycode/process_music.h | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | #ifndef PROCESS_MUSIC_H | ||
| 2 | #define PROCESS_MUSIC_H | ||
| 3 | |||
| 4 | #include "quantum.h" | ||
| 5 | |||
| 6 | bool process_music(uint16_t keycode, keyrecord_t *record); | ||
| 7 | |||
| 8 | bool is_music_on(void); | ||
| 9 | void music_toggle(void); | ||
| 10 | void music_on(void); | ||
| 11 | void music_off(void); | ||
| 12 | |||
| 13 | void audio_on_user(void); | ||
| 14 | void music_on_user(void); | ||
| 15 | void music_scale_user(void); | ||
| 16 | |||
| 17 | void matrix_scan_music(void); | ||
| 18 | |||
| 19 | #ifndef SCALE | ||
| 20 | #define SCALE (int8_t []){ 0 + (12*0), 2 + (12*0), 4 + (12*0), 5 + (12*0), 7 + (12*0), 9 + (12*0), 11 + (12*0), \ | ||
| 21 | 0 + (12*1), 2 + (12*1), 4 + (12*1), 5 + (12*1), 7 + (12*1), 9 + (12*1), 11 + (12*1), \ | ||
| 22 | 0 + (12*2), 2 + (12*2), 4 + (12*2), 5 + (12*2), 7 + (12*2), 9 + (12*2), 11 + (12*2), \ | ||
| 23 | 0 + (12*3), 2 + (12*3), 4 + (12*3), 5 + (12*3), 7 + (12*3), 9 + (12*3), 11 + (12*3), \ | ||
| 24 | 0 + (12*4), 2 + (12*4), 4 + (12*4), 5 + (12*4), 7 + (12*4), 9 + (12*4), 11 + (12*4), } | ||
| 25 | #endif | ||
| 26 | |||
| 27 | #endif \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c new file mode 100644 index 000000000..9b172e1b6 --- /dev/null +++ b/quantum/process_keycode/process_tap_dance.c | |||
| @@ -0,0 +1,90 @@ | |||
| 1 | #include "quantum.h" | ||
| 2 | |||
| 3 | static qk_tap_dance_state_t qk_tap_dance_state; | ||
| 4 | |||
| 5 | static void _process_tap_dance_action_pair (qk_tap_dance_state_t *state, | ||
| 6 | uint16_t kc1, uint16_t kc2) { | ||
| 7 | uint16_t kc; | ||
| 8 | |||
| 9 | if (state->count == 0) | ||
| 10 | return; | ||
| 11 | |||
| 12 | kc = (state->count == 1) ? kc1 : kc2; | ||
| 13 | |||
| 14 | register_code (kc); | ||
| 15 | unregister_code (kc); | ||
| 16 | |||
| 17 | if (state->count >= 2) { | ||
| 18 | reset_tap_dance (state); | ||
| 19 | } | ||
| 20 | } | ||
| 21 | |||
| 22 | static void _process_tap_dance_action_fn (qk_tap_dance_state_t *state, | ||
| 23 | qk_tap_dance_user_fn_t fn) | ||
| 24 | { | ||
| 25 | fn(state); | ||
| 26 | } | ||
| 27 | |||
| 28 | void process_tap_dance_action (uint16_t keycode) | ||
| 29 | { | ||
| 30 | uint16_t idx = keycode - QK_TAP_DANCE; | ||
| 31 | qk_tap_dance_action_t action; | ||
| 32 | |||
| 33 | action = tap_dance_actions[idx]; | ||
| 34 | |||
| 35 | switch (action.type) { | ||
| 36 | case QK_TAP_DANCE_TYPE_PAIR: | ||
| 37 | _process_tap_dance_action_pair (&qk_tap_dance_state, | ||
| 38 | action.pair.kc1, action.pair.kc2); | ||
| 39 | break; | ||
| 40 | case QK_TAP_DANCE_TYPE_FN: | ||
| 41 | _process_tap_dance_action_fn (&qk_tap_dance_state, action.fn); | ||
| 42 | break; | ||
| 43 | |||
| 44 | default: | ||
| 45 | break; | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | bool process_tap_dance(uint16_t keycode, keyrecord_t *record) { | ||
| 50 | bool r = true; | ||
| 51 | |||
| 52 | switch(keycode) { | ||
| 53 | case QK_TAP_DANCE ... QK_TAP_DANCE_MAX: | ||
| 54 | if (qk_tap_dance_state.keycode && qk_tap_dance_state.keycode != keycode) { | ||
| 55 | process_tap_dance_action (qk_tap_dance_state.keycode); | ||
| 56 | } else { | ||
| 57 | r = false; | ||
| 58 | } | ||
| 59 | |||
| 60 | if (record->event.pressed) { | ||
| 61 | qk_tap_dance_state.keycode = keycode; | ||
| 62 | qk_tap_dance_state.timer = timer_read (); | ||
| 63 | qk_tap_dance_state.count++; | ||
| 64 | } | ||
| 65 | break; | ||
| 66 | |||
| 67 | default: | ||
| 68 | if (qk_tap_dance_state.keycode) { | ||
| 69 | process_tap_dance_action (qk_tap_dance_state.keycode); | ||
| 70 | |||
| 71 | reset_tap_dance (&qk_tap_dance_state); | ||
| 72 | } | ||
| 73 | break; | ||
| 74 | } | ||
| 75 | |||
| 76 | return r; | ||
| 77 | } | ||
| 78 | |||
| 79 | void matrix_scan_tap_dance () { | ||
| 80 | if (qk_tap_dance_state.keycode && timer_elapsed (qk_tap_dance_state.timer) > TAPPING_TERM) { | ||
| 81 | process_tap_dance_action (qk_tap_dance_state.keycode); | ||
| 82 | |||
| 83 | reset_tap_dance (&qk_tap_dance_state); | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 87 | void reset_tap_dance (qk_tap_dance_state_t *state) { | ||
| 88 | state->keycode = 0; | ||
| 89 | state->count = 0; | ||
| 90 | } | ||
diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h new file mode 100644 index 000000000..b9d7c7fcf --- /dev/null +++ b/quantum/process_keycode/process_tap_dance.h | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | #ifndef PROCESS_TAP_DANCE_H | ||
| 2 | #define PROCESS_TAP_DANCE_H | ||
| 3 | |||
| 4 | #ifdef TAP_DANCE_ENABLE | ||
| 5 | |||
| 6 | #include <stdbool.h> | ||
| 7 | #include <inttypes.h> | ||
| 8 | |||
| 9 | typedef struct | ||
| 10 | { | ||
| 11 | uint8_t count; | ||
| 12 | uint16_t keycode; | ||
| 13 | uint16_t timer; | ||
| 14 | } qk_tap_dance_state_t; | ||
| 15 | |||
| 16 | #define TD(n) (QK_TAP_DANCE + n) | ||
| 17 | |||
| 18 | typedef enum | ||
| 19 | { | ||
| 20 | QK_TAP_DANCE_TYPE_PAIR, | ||
| 21 | QK_TAP_DANCE_TYPE_FN, | ||
| 22 | } qk_tap_dance_type_t; | ||
| 23 | |||
| 24 | typedef void (*qk_tap_dance_user_fn_t) (qk_tap_dance_state_t *state); | ||
| 25 | |||
| 26 | typedef struct | ||
| 27 | { | ||
| 28 | qk_tap_dance_type_t type; | ||
| 29 | union { | ||
| 30 | struct { | ||
| 31 | uint16_t kc1; | ||
| 32 | uint16_t kc2; | ||
| 33 | } pair; | ||
| 34 | qk_tap_dance_user_fn_t fn; | ||
| 35 | }; | ||
| 36 | } qk_tap_dance_action_t; | ||
| 37 | |||
| 38 | #define ACTION_TAP_DANCE_DOUBLE(kc1, kc2) { \ | ||
| 39 | .type = QK_TAP_DANCE_TYPE_PAIR, \ | ||
| 40 | .pair = { kc1, kc2 } \ | ||
| 41 | } | ||
| 42 | |||
| 43 | #define ACTION_TAP_DANCE_FN(user_fn) { \ | ||
| 44 | .type = QK_TAP_DANCE_TYPE_FN, \ | ||
| 45 | .fn = user_fn \ | ||
| 46 | } | ||
| 47 | |||
| 48 | extern const qk_tap_dance_action_t tap_dance_actions[]; | ||
| 49 | |||
| 50 | /* To be used internally */ | ||
| 51 | |||
| 52 | bool process_tap_dance(uint16_t keycode, keyrecord_t *record); | ||
| 53 | void matrix_scan_tap_dance (void); | ||
| 54 | void reset_tap_dance (qk_tap_dance_state_t *state); | ||
| 55 | |||
| 56 | #else | ||
| 57 | |||
| 58 | #define TD(n) KC_NO | ||
| 59 | |||
| 60 | #endif | ||
| 61 | |||
| 62 | #endif | ||
diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c new file mode 100644 index 000000000..ad5d7f86b --- /dev/null +++ b/quantum/process_keycode/process_unicode.c | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | #include "process_unicode.h" | ||
| 2 | |||
| 3 | static uint8_t input_mode; | ||
| 4 | |||
| 5 | uint16_t hex_to_keycode(uint8_t hex) | ||
| 6 | { | ||
| 7 | if (hex == 0x0) { | ||
| 8 | return KC_0; | ||
| 9 | } else if (hex < 0xA) { | ||
| 10 | return KC_1 + (hex - 0x1); | ||
| 11 | } else { | ||
| 12 | return KC_A + (hex - 0xA); | ||
| 13 | } | ||
| 14 | } | ||
| 15 | |||
| 16 | void set_unicode_mode(uint8_t os_target) | ||
| 17 | { | ||
| 18 | input_mode = os_target; | ||
| 19 | } | ||
| 20 | |||
| 21 | bool process_unicode(uint16_t keycode, keyrecord_t *record) { | ||
| 22 | if (keycode > QK_UNICODE && record->event.pressed) { | ||
| 23 | uint16_t unicode = keycode & 0x7FFF; | ||
| 24 | switch(input_mode) { | ||
| 25 | case UC_OSX: | ||
| 26 | register_code(KC_LALT); | ||
| 27 | break; | ||
| 28 | case UC_LNX: | ||
| 29 | register_code(KC_LCTL); | ||
| 30 | register_code(KC_LSFT); | ||
| 31 | register_code(KC_U); | ||
| 32 | unregister_code(KC_U); | ||
| 33 | break; | ||
| 34 | case UC_WIN: | ||
| 35 | register_code(KC_LALT); | ||
| 36 | register_code(KC_PPLS); | ||
| 37 | unregister_code(KC_PPLS); | ||
| 38 | break; | ||
| 39 | } | ||
| 40 | for(int i = 3; i >= 0; i--) { | ||
| 41 | uint8_t digit = ((unicode >> (i*4)) & 0xF); | ||
| 42 | register_code(hex_to_keycode(digit)); | ||
| 43 | unregister_code(hex_to_keycode(digit)); | ||
| 44 | } | ||
| 45 | switch(input_mode) { | ||
| 46 | case UC_OSX: | ||
| 47 | case UC_WIN: | ||
| 48 | unregister_code(KC_LALT); | ||
| 49 | break; | ||
| 50 | case UC_LNX: | ||
| 51 | unregister_code(KC_LCTL); | ||
| 52 | unregister_code(KC_LSFT); | ||
| 53 | break; | ||
| 54 | } | ||
| 55 | } | ||
| 56 | return true; | ||
| 57 | } \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_unicode.h b/quantum/process_keycode/process_unicode.h new file mode 100644 index 000000000..ca17f8f66 --- /dev/null +++ b/quantum/process_keycode/process_unicode.h | |||
| @@ -0,0 +1,122 @@ | |||
| 1 | #ifndef PROCESS_UNICODE_H | ||
| 2 | #define PROCESS_UNICODE_H | ||
| 3 | |||
| 4 | #include "quantum.h" | ||
| 5 | |||
| 6 | #define UC_OSX 0 | ||
| 7 | #define UC_LNX 1 | ||
| 8 | #define UC_WIN 2 | ||
| 9 | #define UC_BSD 3 | ||
| 10 | |||
| 11 | void set_unicode_input_mode(uint8_t os_target); | ||
| 12 | |||
| 13 | bool process_unicode(uint16_t keycode, keyrecord_t *record); | ||
| 14 | |||
| 15 | #define UC_BSPC UC(0x0008) | ||
| 16 | |||
| 17 | #define UC_SPC UC(0x0020) | ||
| 18 | |||
| 19 | #define UC_EXLM UC(0x0021) | ||
| 20 | #define UC_DQUT UC(0x0022) | ||
| 21 | #define UC_HASH UC(0x0023) | ||
| 22 | #define UC_DLR UC(0x0024) | ||
| 23 | #define UC_PERC UC(0x0025) | ||
| 24 | #define UC_AMPR UC(0x0026) | ||
| 25 | #define UC_QUOT UC(0x0027) | ||
| 26 | #define UC_LPRN UC(0x0028) | ||
| 27 | #define UC_RPRN UC(0x0029) | ||
| 28 | #define UC_ASTR UC(0x002A) | ||
| 29 | #define UC_PLUS UC(0x002B) | ||
| 30 | #define UC_COMM UC(0x002C) | ||
| 31 | #define UC_DASH UC(0x002D) | ||
| 32 | #define UC_DOT UC(0x002E) | ||
| 33 | #define UC_SLSH UC(0x002F) | ||
| 34 | |||
| 35 | #define UC_0 UC(0x0030) | ||
| 36 | #define UC_1 UC(0x0031) | ||
| 37 | #define UC_2 UC(0x0032) | ||
| 38 | #define UC_3 UC(0x0033) | ||
| 39 | #define UC_4 UC(0x0034) | ||
| 40 | #define UC_5 UC(0x0035) | ||
| 41 | #define UC_6 UC(0x0036) | ||
| 42 | #define UC_7 UC(0x0037) | ||
| 43 | #define UC_8 UC(0x0038) | ||
| 44 | #define UC_9 UC(0x0039) | ||
| 45 | |||
| 46 | #define UC_COLN UC(0x003A) | ||
| 47 | #define UC_SCLN UC(0x003B) | ||
| 48 | #define UC_LT UC(0x003C) | ||
| 49 | #define UC_EQL UC(0x003D) | ||
| 50 | #define UC_GT UC(0x003E) | ||
| 51 | #define UC_QUES UC(0x003F) | ||
| 52 | #define UC_AT UC(0x0040) | ||
| 53 | |||
| 54 | #define UC_A UC(0x0041) | ||
| 55 | #define UC_B UC(0x0042) | ||
| 56 | #define UC_C UC(0x0043) | ||
| 57 | #define UC_D UC(0x0044) | ||
| 58 | #define UC_E UC(0x0045) | ||
| 59 | #define UC_F UC(0x0046) | ||
| 60 | #define UC_G UC(0x0047) | ||
| 61 | #define UC_H UC(0x0048) | ||
| 62 | #define UC_I UC(0x0049) | ||
| 63 | #define UC_J UC(0x004A) | ||
| 64 | #define UC_K UC(0x004B) | ||
| 65 | #define UC_L UC(0x004C) | ||
| 66 | #define UC_M UC(0x004D) | ||
| 67 | #define UC_N UC(0x004E) | ||
| 68 | #define UC_O UC(0x004F) | ||
| 69 | #define UC_P UC(0x0050) | ||
| 70 | #define UC_Q UC(0x0051) | ||
| 71 | #define UC_R UC(0x0052) | ||
| 72 | #define UC_S UC(0x0053) | ||
| 73 | #define UC_T UC(0x0054) | ||
| 74 | #define UC_U UC(0x0055) | ||
| 75 | #define UC_V UC(0x0056) | ||
| 76 | #define UC_W UC(0x0057) | ||
| 77 | #define UC_X UC(0x0058) | ||
| 78 | #define UC_Y UC(0x0059) | ||
| 79 | #define UC_Z UC(0x005A) | ||
| 80 | |||
| 81 | #define UC_LBRC UC(0x005B) | ||
| 82 | #define UC_BSLS UC(0x005C) | ||
| 83 | #define UC_RBRC UC(0x005D) | ||
| 84 | #define UC_CIRM UC(0x005E) | ||
| 85 | #define UC_UNDR UC(0x005F) | ||
| 86 | |||
| 87 | #define UC_GRV UC(0x0060) | ||
| 88 | |||
| 89 | #define UC_a UC(0x0061) | ||
| 90 | #define UC_b UC(0x0062) | ||
| 91 | #define UC_c UC(0x0063) | ||
| 92 | #define UC_d UC(0x0064) | ||
| 93 | #define UC_e UC(0x0065) | ||
| 94 | #define UC_f UC(0x0066) | ||
| 95 | #define UC_g UC(0x0067) | ||
| 96 | #define UC_h UC(0x0068) | ||
| 97 | #define UC_i UC(0x0069) | ||
| 98 | #define UC_j UC(0x006A) | ||
| 99 | #define UC_k UC(0x006B) | ||
| 100 | #define UC_l UC(0x006C) | ||
| 101 | #define UC_m UC(0x006D) | ||
| 102 | #define UC_n UC(0x006E) | ||
| 103 | #define UC_o UC(0x006F) | ||
| 104 | #define UC_p UC(0x0070) | ||
| 105 | #define UC_q UC(0x0071) | ||
| 106 | #define UC_r UC(0x0072) | ||
| 107 | #define UC_s UC(0x0073) | ||
| 108 | #define UC_t UC(0x0074) | ||
| 109 | #define UC_u UC(0x0075) | ||
| 110 | #define UC_v UC(0x0076) | ||
| 111 | #define UC_w UC(0x0077) | ||
| 112 | #define UC_x UC(0x0078) | ||
| 113 | #define UC_y UC(0x0079) | ||
| 114 | #define UC_z UC(0x007A) | ||
| 115 | |||
| 116 | #define UC_LCBR UC(0x007B) | ||
| 117 | #define UC_PIPE UC(0x007C) | ||
| 118 | #define UC_RCBR UC(0x007D) | ||
| 119 | #define UC_TILD UC(0x007E) | ||
| 120 | #define UC_DEL UC(0x007F) | ||
| 121 | |||
| 122 | #endif \ No newline at end of file | ||
