Migrate fn_actions for default keymaps (#4935)
* Migrate fn_actions for default keymaps * Rename the Grave/Escape Shift masks * No need for shift_esc_shift_mask * Change breaks to return false * Right align pointers * Add default case * Separate cases with empty lines
This commit is contained in:
		
							parent
							
								
									d5bc7fc157
								
							
						
					
					
						commit
						9e4ac6cf29
					
				
					 42 changed files with 373 additions and 654 deletions
				
			
		| 
						 | 
				
			
			@ -1,12 +1,18 @@
 | 
			
		|||
#include QMK_KEYBOARD_H
 | 
			
		||||
 | 
			
		||||
enum custom_keycodes {
 | 
			
		||||
	SONG_SU = SAFE_RANGE,
 | 
			
		||||
	SONG_SC,
 | 
			
		||||
	SONG_GB
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 | 
			
		||||
	[0] = LAYOUT(
 | 
			
		||||
		RGB_TOG,        RGB_SAI,        RGB_VAI, \
 | 
			
		||||
		        RGB_HUD,        RGB_HUI,         \
 | 
			
		||||
		RGB_MOD,        RGB_SAD,        RGB_VAD, \
 | 
			
		||||
		BL_STEP,                                 \
 | 
			
		||||
		F(0),   F(1),   F(2)                     \
 | 
			
		||||
		SONG_SU,SONG_SC,SONG_GB                  \
 | 
			
		||||
	)
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -23,28 +29,6 @@ float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
 | 
			
		|||
float tone_goodbye[][2] = SONG(GOODBYE_SOUND);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
const uint16_t PROGMEM fn_actions[] = {
 | 
			
		||||
	[0] = ACTION_FUNCTION(0),
 | 
			
		||||
	[1] = ACTION_FUNCTION(1),
 | 
			
		||||
	[2] = ACTION_FUNCTION(2)
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
 | 
			
		||||
	if (record->event.pressed) {
 | 
			
		||||
		switch (id) {
 | 
			
		||||
			case 0:
 | 
			
		||||
				PLAY_SONG(tone_startup);
 | 
			
		||||
				break;
 | 
			
		||||
			case 1:
 | 
			
		||||
				PLAY_SONG(music_scale);
 | 
			
		||||
				break;
 | 
			
		||||
			case 2:
 | 
			
		||||
				PLAY_SONG(tone_goodbye);
 | 
			
		||||
				break;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
void matrix_init_user(void) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -53,7 +37,31 @@ void matrix_scan_user(void) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
 | 
			
		||||
  return true;
 | 
			
		||||
  switch (keycode) {
 | 
			
		||||
    case SONG_SU:
 | 
			
		||||
      if (record->event.pressed) {
 | 
			
		||||
        PLAY_SONG(tone_startup);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      return false;
 | 
			
		||||
 | 
			
		||||
    case SONG_SC:
 | 
			
		||||
      if (record->event.pressed) {
 | 
			
		||||
        PLAY_SONG(music_scale);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      return false;
 | 
			
		||||
 | 
			
		||||
    case SONG_GB:
 | 
			
		||||
      if (record->event.pressed) {
 | 
			
		||||
        PLAY_SONG(tone_goodbye);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      return false;
 | 
			
		||||
 | 
			
		||||
    default:
 | 
			
		||||
      return true;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void led_set_user(uint8_t usb_led) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue