fix(underglow): Handle cycling effects on splits.
* Convert relative effect cycling to absolute effect selection.
This commit is contained in:
parent
0febaa142a
commit
d486304f79
4 changed files with 29 additions and 4 deletions
|
@ -17,7 +17,8 @@
|
|||
#define RGB_SPD_CMD 10
|
||||
#define RGB_EFF_CMD 11
|
||||
#define RGB_EFR_CMD 12
|
||||
#define RGB_COLOR_HSB_CMD 13
|
||||
#define RGB_EFS_CMD 13
|
||||
#define RGB_COLOR_HSB_CMD 14
|
||||
|
||||
#define RGB_TOG RGB_TOG_CMD 0
|
||||
#define RGB_ON RGB_ON_CMD 0
|
||||
|
|
|
@ -17,6 +17,8 @@ int zmk_rgb_underglow_get_state(bool *state);
|
|||
int zmk_rgb_underglow_on();
|
||||
int zmk_rgb_underglow_off();
|
||||
int zmk_rgb_underglow_cycle_effect(int direction);
|
||||
int zmk_rgb_underglow_calc_effect(int direction);
|
||||
int zmk_rgb_underglow_select_effect(int effect);
|
||||
struct zmk_led_hsb zmk_rgb_underglow_calc_hue(int direction);
|
||||
struct zmk_led_hsb zmk_rgb_underglow_calc_sat(int direction);
|
||||
struct zmk_led_hsb zmk_rgb_underglow_calc_brt(int direction);
|
||||
|
|
|
@ -77,6 +77,16 @@ on_keymap_binding_convert_central_state_dependent_params(struct zmk_behavior_bin
|
|||
binding->param2 = RGB_COLOR_HSB_VAL(color.h, color.s, color.b);
|
||||
break;
|
||||
}
|
||||
case RGB_EFR_CMD: {
|
||||
binding->param1 = RGB_EFS_CMD;
|
||||
binding->param2 = zmk_rgb_underglow_calc_effect(-1);
|
||||
break;
|
||||
}
|
||||
case RGB_EFF_CMD: {
|
||||
binding->param1 = RGB_EFS_CMD;
|
||||
binding->param2 = zmk_rgb_underglow_calc_effect(1);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
@ -111,6 +121,8 @@ static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding,
|
|||
return zmk_rgb_underglow_change_spd(1);
|
||||
case RGB_SPD_CMD:
|
||||
return zmk_rgb_underglow_change_spd(-1);
|
||||
case RGB_EFS_CMD:
|
||||
return zmk_rgb_underglow_select_effect(binding->param2);
|
||||
case RGB_EFF_CMD:
|
||||
return zmk_rgb_underglow_cycle_effect(1);
|
||||
case RGB_EFR_CMD:
|
||||
|
|
|
@ -332,18 +332,28 @@ int zmk_rgb_underglow_off() {
|
|||
return zmk_rgb_underglow_save_state();
|
||||
}
|
||||
|
||||
int zmk_rgb_underglow_cycle_effect(int direction) {
|
||||
int zmk_rgb_underglow_calc_effect(int direction) {
|
||||
return (state.current_effect + UNDERGLOW_EFFECT_NUMBER + direction) % UNDERGLOW_EFFECT_NUMBER;
|
||||
}
|
||||
|
||||
int zmk_rgb_underglow_select_effect(int effect) {
|
||||
if (!led_strip)
|
||||
return -ENODEV;
|
||||
|
||||
state.current_effect += UNDERGLOW_EFFECT_NUMBER + direction;
|
||||
state.current_effect %= UNDERGLOW_EFFECT_NUMBER;
|
||||
if (effect < 0 || effect >= UNDERGLOW_EFFECT_NUMBER) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
state.current_effect = effect;
|
||||
state.animation_step = 0;
|
||||
|
||||
return zmk_rgb_underglow_save_state();
|
||||
}
|
||||
|
||||
int zmk_rgb_underglow_cycle_effect(int direction) {
|
||||
return zmk_rgb_underglow_select_effect(zmk_rgb_underglow_calc_effect(direction));
|
||||
}
|
||||
|
||||
int zmk_rgb_underglow_toggle() {
|
||||
return state.on ? zmk_rgb_underglow_off() : zmk_rgb_underglow_on();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue