diff options
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/keymap_common.c | 5 | ||||
| -rw-r--r-- | quantum/keymap_common.h | 5 | ||||
| -rw-r--r-- | quantum/quantum.c | 88 | ||||
| -rw-r--r-- | quantum/quantum.h | 3 | ||||
| -rw-r--r-- | quantum/quantum.mk | 6 |
5 files changed, 93 insertions, 14 deletions
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 0184770c4..2aae13e67 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c | |||
| @@ -282,11 +282,6 @@ static action_t keycode_to_action(uint16_t keycode) | |||
| 282 | action.code = ACTION_MODS_ONESHOT(mod); | 282 | action.code = ACTION_MODS_ONESHOT(mod); |
| 283 | } | 283 | } |
| 284 | break; | 284 | break; |
| 285 | #ifdef MIDI_ENABLE | ||
| 286 | case 0x6000 ... 0x6FFF: | ||
| 287 | action.code = ACTION_FUNCTION_OPT(keycode & 0xFF, (keycode & 0x0F00) >> 8); | ||
| 288 | break; | ||
| 289 | #endif | ||
| 290 | case 0x7000 ... 0x7FFF: | 285 | case 0x7000 ... 0x7FFF: |
| 291 | action.code = ACTION_MODS_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); | 286 | action.code = ACTION_MODS_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); |
| 292 | break; | 287 | break; |
diff --git a/quantum/keymap_common.h b/quantum/keymap_common.h index 0074ab164..07020150a 100644 --- a/quantum/keymap_common.h +++ b/quantum/keymap_common.h | |||
| @@ -195,6 +195,7 @@ extern const uint16_t fn_actions[]; | |||
| 195 | 195 | ||
| 196 | 196 | ||
| 197 | 197 | ||
| 198 | |||
| 198 | // MAGIC keycodes | 199 | // MAGIC keycodes |
| 199 | #define MAGIC_SWAP_CONTROL_CAPSLOCK 0x5002 | 200 | #define MAGIC_SWAP_CONTROL_CAPSLOCK 0x5002 |
| 200 | #define MAGIC_UNSWAP_CONTROL_CAPSLOCK 0x5003 | 201 | #define MAGIC_UNSWAP_CONTROL_CAPSLOCK 0x5003 |
| @@ -232,6 +233,10 @@ extern const uint16_t fn_actions[]; | |||
| 232 | #define MUV_IN 0x5024 | 233 | #define MUV_IN 0x5024 |
| 233 | #define MUV_DE 0x5025 | 234 | #define MUV_DE 0x5025 |
| 234 | 235 | ||
| 236 | // Midi mode on/off | ||
| 237 | #define MI_ON 0x5026 | ||
| 238 | #define MI_OFF 0x5027 | ||
| 239 | |||
| 235 | // GOTO layer - 16 layers max | 240 | // GOTO layer - 16 layers max |
| 236 | // when: | 241 | // when: |
| 237 | // ON_PRESS = 1 | 242 | // ON_PRESS = 1 |
diff --git a/quantum/quantum.c b/quantum/quantum.c index dd5d84f82..5a978d332 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -19,11 +19,15 @@ void leader_end(void) {} | |||
| 19 | 19 | ||
| 20 | #ifdef AUDIO_ENABLE | 20 | #ifdef AUDIO_ENABLE |
| 21 | uint8_t starting_note = 0x0C; | 21 | uint8_t starting_note = 0x0C; |
| 22 | int offset = 0; | 22 | int offset = 7; |
| 23 | bool music_activated = false; | 23 | bool music_activated = false; |
| 24 | float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); | 24 | float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); |
| 25 | #endif | 25 | #endif |
| 26 | 26 | ||
| 27 | #ifdef MIDI_ENABLE | ||
| 28 | bool midi_activated = false; | ||
| 29 | #endif | ||
| 30 | |||
| 27 | // Leader key stuff | 31 | // Leader key stuff |
| 28 | bool leading = false; | 32 | bool leading = false; |
| 29 | uint16_t leader_time = 0; | 33 | uint16_t leader_time = 0; |
| @@ -98,6 +102,82 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 98 | // return false; | 102 | // return false; |
| 99 | // } | 103 | // } |
| 100 | 104 | ||
| 105 | #ifdef MIDI_ENABLE | ||
| 106 | if (keycode == MI_ON && record->event.pressed) { | ||
| 107 | midi_activated = true; | ||
| 108 | PLAY_NOTE_ARRAY(music_scale, false, 0); | ||
| 109 | return false; | ||
| 110 | } | ||
| 111 | |||
| 112 | if (keycode == MI_OFF && record->event.pressed) { | ||
| 113 | midi_activated = false; | ||
| 114 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 115 | return false; | ||
| 116 | } | ||
| 117 | |||
| 118 | if (midi_activated) { | ||
| 119 | if (record->event.key.col == (MATRIX_COLS - 1) && record->event.key.row == (MATRIX_ROWS - 1)) { | ||
| 120 | if (record->event.pressed) { | ||
| 121 | starting_note++; // Change key | ||
| 122 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 123 | // midi_send_cc(&midi_device, 1, 0x7B, 0); | ||
| 124 | // midi_send_cc(&midi_device, 2, 0x7B, 0); | ||
| 125 | // midi_send_cc(&midi_device, 3, 0x7B, 0); | ||
| 126 | // midi_send_cc(&midi_device, 4, 0x7B, 0); | ||
| 127 | } | ||
| 128 | return false; | ||
| 129 | } | ||
| 130 | if (record->event.key.col == (MATRIX_COLS - 2) && record->event.key.row == (MATRIX_ROWS - 1)) { | ||
| 131 | if (record->event.pressed) { | ||
| 132 | starting_note--; // Change key | ||
| 133 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 134 | // midi_send_cc(&midi_device, 1, 0x7B, 0); | ||
| 135 | // midi_send_cc(&midi_device, 2, 0x7B, 0); | ||
| 136 | // midi_send_cc(&midi_device, 3, 0x7B, 0); | ||
| 137 | // midi_send_cc(&midi_device, 4, 0x7B, 0); | ||
| 138 | } | ||
| 139 | return false; | ||
| 140 | } | ||
| 141 | if (record->event.key.col == (MATRIX_COLS - 3) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { | ||
| 142 | offset++; // Change scale | ||
| 143 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 144 | // midi_send_cc(&midi_device, 1, 0x7B, 0); | ||
| 145 | // midi_send_cc(&midi_device, 2, 0x7B, 0); | ||
| 146 | // midi_send_cc(&midi_device, 3, 0x7B, 0); | ||
| 147 | // midi_send_cc(&midi_device, 4, 0x7B, 0); | ||
| 148 | return false; | ||
| 149 | } | ||
| 150 | if (record->event.key.col == (MATRIX_COLS - 4) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { | ||
| 151 | offset--; // Change scale | ||
| 152 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 153 | // midi_send_cc(&midi_device, 1, 0x7B, 0); | ||
| 154 | // midi_send_cc(&midi_device, 2, 0x7B, 0); | ||
| 155 | // midi_send_cc(&midi_device, 3, 0x7B, 0); | ||
| 156 | // midi_send_cc(&midi_device, 4, 0x7B, 0); | ||
| 157 | return false; | ||
| 158 | } | ||
| 159 | // basic | ||
| 160 | // uint8_t note = (starting_note + SCALE[record->event.key.col + offset])+12*(MATRIX_ROWS - record->event.key.row); | ||
| 161 | // advanced | ||
| 162 | // uint8_t note = (starting_note + record->event.key.col + offset)+12*(MATRIX_ROWS - record->event.key.row); | ||
| 163 | // guitar | ||
| 164 | uint8_t note = (starting_note + record->event.key.col + offset)+5*(MATRIX_ROWS - record->event.key.row); | ||
| 165 | // violin | ||
| 166 | // uint8_t note = (starting_note + record->event.key.col + offset)+7*(MATRIX_ROWS - record->event.key.row); | ||
| 167 | |||
| 168 | if (record->event.pressed) { | ||
| 169 | // midi_send_noteon(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127); | ||
| 170 | midi_send_noteon(&midi_device, 0, note, 127); | ||
| 171 | } else { | ||
| 172 | // midi_send_noteoff(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127); | ||
| 173 | midi_send_noteoff(&midi_device, 0, note, 127); | ||
| 174 | } | ||
| 175 | |||
| 176 | if (keycode < 0xFF) // ignores all normal keycodes, but lets RAISE, LOWER, etc through | ||
| 177 | return false; | ||
| 178 | } | ||
| 179 | #endif | ||
| 180 | |||
| 101 | #ifdef AUDIO_ENABLE | 181 | #ifdef AUDIO_ENABLE |
| 102 | if (keycode == AU_ON && record->event.pressed) { | 182 | if (keycode == AU_ON && record->event.pressed) { |
| 103 | audio_on(); | 183 | audio_on(); |
| @@ -169,7 +249,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 169 | return false; | 249 | return false; |
| 170 | } | 250 | } |
| 171 | 251 | ||
| 172 | float freq = ((float)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)); | 252 | 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)); |
| 173 | if (record->event.pressed) { | 253 | if (record->event.pressed) { |
| 174 | play_note(freq, 0xF); | 254 | play_note(freq, 0xF); |
| 175 | if (music_sequence_recording) { | 255 | if (music_sequence_recording) { |
| @@ -185,8 +265,6 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 185 | } | 265 | } |
| 186 | #endif | 266 | #endif |
| 187 | 267 | ||
| 188 | |||
| 189 | |||
| 190 | #ifndef DISABLE_LEADER | 268 | #ifndef DISABLE_LEADER |
| 191 | // Leader key set-up | 269 | // Leader key set-up |
| 192 | if (record->event.pressed) { | 270 | if (record->event.pressed) { |
| @@ -267,6 +345,6 @@ void matrix_scan_quantum() { | |||
| 267 | } | 345 | } |
| 268 | 346 | ||
| 269 | #endif | 347 | #endif |
| 270 | 348 | ||
| 271 | matrix_scan_kb(); | 349 | matrix_scan_kb(); |
| 272 | } \ No newline at end of file | 350 | } \ No newline at end of file |
diff --git a/quantum/quantum.h b/quantum/quantum.h index db726ad42..bfecdb262 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
| @@ -13,7 +13,8 @@ | |||
| 13 | #include "audio.h" | 13 | #include "audio.h" |
| 14 | #endif | 14 | #endif |
| 15 | #ifdef MIDI_ENABLE | 15 | #ifdef MIDI_ENABLE |
| 16 | #include <keymap_midi.h> | 16 | // #include <keymap_midi.h> |
| 17 | #include <lufa.h> | ||
| 17 | #endif | 18 | #endif |
| 18 | #include "action_layer.h" | 19 | #include "action_layer.h" |
| 19 | #include "eeconfig.h" | 20 | #include "eeconfig.h" |
diff --git a/quantum/quantum.mk b/quantum/quantum.mk index b45ad850a..e7ccfd659 100644 --- a/quantum/quantum.mk +++ b/quantum/quantum.mk | |||
| @@ -24,9 +24,9 @@ ifndef CUSTOM_MATRIX | |||
| 24 | SRC += $(QUANTUM_DIR)/matrix.c | 24 | SRC += $(QUANTUM_DIR)/matrix.c |
| 25 | endif | 25 | endif |
| 26 | 26 | ||
| 27 | ifeq ($(strip $(MIDI_ENABLE)), yes) | 27 | #ifeq ($(strip $(MIDI_ENABLE)), yes) |
| 28 | SRC += $(QUANTUM_DIR)/keymap_midi.c | 28 | # SRC += $(QUANTUM_DIR)/keymap_midi.c |
| 29 | endif | 29 | #endif |
| 30 | 30 | ||
| 31 | ifeq ($(strip $(AUDIO_ENABLE)), yes) | 31 | ifeq ($(strip $(AUDIO_ENABLE)), yes) |
| 32 | SRC += $(QUANTUM_DIR)/audio/audio.c | 32 | SRC += $(QUANTUM_DIR)/audio/audio.c |
