maxr1998/pulse4k: Move Combo code to keymap level (#16301)
* maxr1998/pulse4k: Move Combo code to keymap level * Reorder code
This commit is contained in:
		
							parent
							
								
									63c310f6fd
								
							
						
					
					
						commit
						2bc4a216df
					
				
					 6 changed files with 85 additions and 34 deletions
				
			
		| 
						 | 
				
			
			@ -21,6 +21,10 @@ enum layers {
 | 
			
		|||
    DEFAULT
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum combo_events {
 | 
			
		||||
    LED_ADJUST
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const uint16_t PROGMEM led_adjust_combo[] = {KC_LEFT, KC_RGHT, COMBO_END};
 | 
			
		||||
 | 
			
		||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 | 
			
		||||
| 
						 | 
				
			
			@ -29,3 +33,39 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 | 
			
		|||
        KC_LEFT, KC_DOWN, KC_RGHT
 | 
			
		||||
    )
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
combo_t key_combos[COMBO_COUNT] = {
 | 
			
		||||
    [LED_ADJUST] = COMBO_ACTION(led_adjust_combo)
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
bool led_adjust_active = false;
 | 
			
		||||
 | 
			
		||||
void process_combo_event(uint16_t combo_index, bool pressed) {
 | 
			
		||||
    if (combo_index == LED_ADJUST) {
 | 
			
		||||
        led_adjust_active = pressed;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool encoder_update_user(uint8_t index, bool clockwise) {
 | 
			
		||||
    if (index == 0) {
 | 
			
		||||
        if (led_adjust_active) {
 | 
			
		||||
            if (clockwise) {
 | 
			
		||||
                rgblight_increase_val();
 | 
			
		||||
            } else {
 | 
			
		||||
                rgblight_decrease_val();
 | 
			
		||||
            }
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    } else if (index == 1) {
 | 
			
		||||
        if (led_adjust_active) {
 | 
			
		||||
            if (clockwise) {
 | 
			
		||||
                rgblight_increase_hue();
 | 
			
		||||
            } else {
 | 
			
		||||
                rgblight_decrease_hue();
 | 
			
		||||
            }
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										1
									
								
								keyboards/maxr1998/pulse4k/keymaps/default/rules.mk
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								keyboards/maxr1998/pulse4k/keymaps/default/rules.mk
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
COMBO_ENABLE = yes
 | 
			
		||||
| 
						 | 
				
			
			@ -21,6 +21,10 @@ enum layers {
 | 
			
		|||
    DEFAULT
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum combo_events {
 | 
			
		||||
    LED_ADJUST
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const uint16_t PROGMEM led_adjust_combo[] = {KC_F22, KC_F24, COMBO_END};
 | 
			
		||||
 | 
			
		||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 | 
			
		||||
| 
						 | 
				
			
			@ -30,6 +34,42 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 | 
			
		|||
    )
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
combo_t key_combos[COMBO_COUNT] = {
 | 
			
		||||
    [LED_ADJUST] = COMBO_ACTION(led_adjust_combo)
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
bool led_adjust_active = false;
 | 
			
		||||
 | 
			
		||||
void process_combo_event(uint16_t combo_index, bool pressed) {
 | 
			
		||||
    if (combo_index == LED_ADJUST) {
 | 
			
		||||
        led_adjust_active = pressed;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool encoder_update_user(uint8_t index, bool clockwise) {
 | 
			
		||||
    if (index == 0) {
 | 
			
		||||
        if (led_adjust_active) {
 | 
			
		||||
            if (clockwise) {
 | 
			
		||||
                rgblight_increase_val();
 | 
			
		||||
            } else {
 | 
			
		||||
                rgblight_decrease_val();
 | 
			
		||||
            }
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    } else if (index == 1) {
 | 
			
		||||
        if (led_adjust_active) {
 | 
			
		||||
            if (clockwise) {
 | 
			
		||||
                rgblight_increase_hue();
 | 
			
		||||
            } else {
 | 
			
		||||
                rgblight_decrease_hue();
 | 
			
		||||
            }
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void encoder_one_update(bool clockwise) {
 | 
			
		||||
    tap_code(!clockwise ? KC_F18 : KC_F19);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										1
									
								
								keyboards/maxr1998/pulse4k/keymaps/maxr1998/rules.mk
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								keyboards/maxr1998/pulse4k/keymaps/maxr1998/rules.mk
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
COMBO_ENABLE = yes
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue