Update existing keymaps
Update existing keymaps to enable MIDI_BASIC functionality. Also added an option MIDI_ENABLE_STRICT to be strict about keycode use (which also reduces memory footprint at runtime)
This commit is contained in:
		
							parent
							
								
									ea14ed122f
								
							
						
					
					
						commit
						a64ae10662
					
				
					 23 changed files with 472 additions and 19 deletions
				
			
		| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#include "process_audio.h"
 | 
			
		||||
#include "audio.h"
 | 
			
		||||
#include "process_audio.h"
 | 
			
		||||
 | 
			
		||||
static float compute_freq_for_midi_note(uint8_t note)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -43,7 +43,7 @@ bool process_audio(uint16_t keycode, keyrecord_t *record) {
 | 
			
		|||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return true
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void process_audio_noteon(uint8_t note) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -42,7 +42,7 @@ static void music_noteoff(uint8_t note) {
 | 
			
		|||
    #endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void music_all_notes_off(void) {
 | 
			
		||||
void music_all_notes_off(void) {
 | 
			
		||||
    #ifdef AUDIO_ENABLE
 | 
			
		||||
    process_audio_stop_all_notes();
 | 
			
		||||
    #endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,6 +14,7 @@ void music_off(void);
 | 
			
		|||
 | 
			
		||||
void music_on_user(void);
 | 
			
		||||
void music_scale_user(void);
 | 
			
		||||
void music_all_notes_off(void);
 | 
			
		||||
 | 
			
		||||
void matrix_scan_music(void);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -95,8 +95,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
 | 
			
		|||
 | 
			
		||||
void reset_keyboard(void) {
 | 
			
		||||
  clear_keyboard();
 | 
			
		||||
#ifdef AUDIO_ENABLE
 | 
			
		||||
  stop_all_notes();
 | 
			
		||||
#if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_ENABLE_BASIC))
 | 
			
		||||
  music_all_notes_off();
 | 
			
		||||
  shutdown_user();
 | 
			
		||||
#endif
 | 
			
		||||
  wait_ms(250);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,8 +1,11 @@
 | 
			
		|||
 | 
			
		||||
#ifndef QUANTUM_KEYCODES_H
 | 
			
		||||
#define QUANTUM_KEYCODES_H
 | 
			
		||||
 | 
			
		||||
#if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED)
 | 
			
		||||
#ifndef MIDI_ENABLE_STRICT
 | 
			
		||||
#define MIDI_ENABLE_STRICT 0
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if !MIDI_ENABLE_STRICT || (defined(MIDI_ENABLE) && defined(MIDI_ADVANCED))
 | 
			
		||||
#ifndef MIDI_TONE_KEYCODE_OCTAVES
 | 
			
		||||
#define MIDI_TONE_KEYCODE_OCTAVES 3
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -113,18 +116,16 @@ enum quantum_keycodes {
 | 
			
		|||
    MUV_IN,
 | 
			
		||||
    MUV_DE,
 | 
			
		||||
 | 
			
		||||
#ifdef MIDI_ENABLE
 | 
			
		||||
    // Midi
 | 
			
		||||
 | 
			
		||||
#ifdef MIDI_BASIC
 | 
			
		||||
#if !MIDI_ENABLE_STRICT || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
 | 
			
		||||
    MI_ON,  // send midi notes when music mode is enabled
 | 
			
		||||
    MI_OFF, // don't send midi notes when music mode is enabled
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef MIDI_ADVANCED
 | 
			
		||||
#if !MIDI_ENABLE_STRICT || (defined(MIDI_ENABLE) && defined(MIDI_ADVANCED))
 | 
			
		||||
    MIDI_TONE_MIN,
 | 
			
		||||
 | 
			
		||||
#if MIDI_TONE_KEYCODE_OCTAVES > 0
 | 
			
		||||
#if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 0
 | 
			
		||||
    MI_C = MIDI_TONE_MIN,
 | 
			
		||||
    MI_Cs,
 | 
			
		||||
    MI_Db = MI_Cs,
 | 
			
		||||
| 
						 | 
				
			
			@ -144,7 +145,7 @@ enum quantum_keycodes {
 | 
			
		|||
    MI_B,
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if MIDI_TONE_KEYCODE_OCTAVES > 1
 | 
			
		||||
#if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 1
 | 
			
		||||
    MI_C_1,
 | 
			
		||||
    MI_Cs_1,
 | 
			
		||||
    MI_Db_1 = MI_Cs_1,
 | 
			
		||||
| 
						 | 
				
			
			@ -164,7 +165,7 @@ enum quantum_keycodes {
 | 
			
		|||
    MI_B_1,
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if MIDI_TONE_KEYCODE_OCTAVES > 2
 | 
			
		||||
#if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 2
 | 
			
		||||
    MI_C_2,
 | 
			
		||||
    MI_Cs_2,
 | 
			
		||||
    MI_Db_2 = MI_Cs_2,
 | 
			
		||||
| 
						 | 
				
			
			@ -184,7 +185,7 @@ enum quantum_keycodes {
 | 
			
		|||
    MI_B_2,
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if MIDI_TONE_KEYCODE_OCTAVES > 3
 | 
			
		||||
#if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 3
 | 
			
		||||
    MI_C_3,
 | 
			
		||||
    MI_Cs_3,
 | 
			
		||||
    MI_Db_3 = MI_Cs_3,
 | 
			
		||||
| 
						 | 
				
			
			@ -204,7 +205,7 @@ enum quantum_keycodes {
 | 
			
		|||
    MI_B_3,
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if MIDI_TONE_KEYCODE_OCTAVES > 4
 | 
			
		||||
#if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 4
 | 
			
		||||
    MI_C_4,
 | 
			
		||||
    MI_Cs_4,
 | 
			
		||||
    MI_Db_4 = MI_Cs_4,
 | 
			
		||||
| 
						 | 
				
			
			@ -224,7 +225,7 @@ enum quantum_keycodes {
 | 
			
		|||
    MI_B_4,
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if MIDI_TONE_KEYCODE_OCTAVES > 5
 | 
			
		||||
#if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 5
 | 
			
		||||
    MI_C_5,
 | 
			
		||||
    MI_Cs_5,
 | 
			
		||||
    MI_Db_5 = MI_Cs_5,
 | 
			
		||||
| 
						 | 
				
			
			@ -244,7 +245,7 @@ enum quantum_keycodes {
 | 
			
		|||
    MI_B_5,
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if MIDI_TONE_KEYCODE_OCTAVES > 5
 | 
			
		||||
#if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 5
 | 
			
		||||
    MIDI_TONE_MAX = MI_B_5,
 | 
			
		||||
#elif MIDI_TONE_KEYCODE_OCTAVES > 4
 | 
			
		||||
    MIDI_TONE_MAX = MI_B_4,
 | 
			
		||||
| 
						 | 
				
			
			@ -339,7 +340,6 @@ enum quantum_keycodes {
 | 
			
		|||
    MI_MODSD, // decrease modulation speed
 | 
			
		||||
    MI_MODSU, // increase modulation speed
 | 
			
		||||
#endif // MIDI_ADVANCED
 | 
			
		||||
#endif // MIDI_ENABLE
 | 
			
		||||
 | 
			
		||||
    // Backlight functionality
 | 
			
		||||
    BL_0,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -163,6 +163,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		|||
 * MIDI options
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/* Prevent use of disabled MIDI features in the keymap */
 | 
			
		||||
//#define MIDI_ENABLE_STRICT 1
 | 
			
		||||
 | 
			
		||||
/* enable basic MIDI features:
 | 
			
		||||
   - MIDI notes can be sent when in Music mode is on
 | 
			
		||||
*/
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue