Convert Encoder callbacks to be boolean functions (#12805)
Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
This commit is contained in:
parent
76c23b15ab
commit
a0fed0ea17
437 changed files with 2542 additions and 2135 deletions
|
@ -24,7 +24,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
),
|
||||
};
|
||||
|
||||
void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
bool encoder_update_user(uint8_t index, bool clockwise) {
|
||||
switch(index) {
|
||||
case 0:
|
||||
if (clockwise) {
|
||||
|
@ -48,4 +48,5 @@ void encoder_update_user(uint8_t index, bool clockwise) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -24,24 +24,25 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
),
|
||||
};
|
||||
|
||||
void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
bool encoder_update_user(uint8_t index, bool clockwise) {
|
||||
if (index == 0) { /* First encoder */
|
||||
if (clockwise) {
|
||||
rgblight_increase_hue(); //Cycle through the RGB hue
|
||||
} else {
|
||||
rgblight_decrease_hue();
|
||||
}
|
||||
} else if (index == 1) { /* Second encoder */
|
||||
} else if (index == 1) { /* Second encoder */
|
||||
if (clockwise) {
|
||||
tap_code(KC_VOLU); //Example of using tap_code which lets you use keycodes outside of the keymap
|
||||
} else {
|
||||
tap_code(KC_VOLD);
|
||||
}
|
||||
} else if (index == 2) { /* Third encoder */
|
||||
} else if (index == 2) { /* Third encoder */
|
||||
if (clockwise) {
|
||||
rgblight_increase_val(); //Change brightness on the RGB LEDs
|
||||
} else {
|
||||
rgblight_decrease_val();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
)
|
||||
};
|
||||
|
||||
void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
bool encoder_update_user(uint8_t index, bool clockwise) {
|
||||
if (index == 0) { /* First encoder */
|
||||
switch (currentLayer) { //break each encoder update into a switch statement for the current layer
|
||||
case _BL:
|
||||
|
@ -124,6 +124,7 @@ void encoder_update_user(uint8_t index, bool clockwise) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
layer_state_t layer_state_set_user(layer_state_t state) { //This will run every time the layer is updated
|
||||
|
|
|
@ -61,7 +61,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
|||
return true;
|
||||
};
|
||||
|
||||
void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
bool encoder_update_user(uint8_t index, bool clockwise) {
|
||||
if (index == 0) { /* First encoder */
|
||||
switch (get_highest_layer(layer_state)) { //break each encoder update into a switch statement for the current layer
|
||||
case _NUMPAD:
|
||||
|
@ -135,6 +135,7 @@ void encoder_update_user(uint8_t index, bool clockwise) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
layer_state_t layer_state_set_user(layer_state_t state) { //This will run every time the layer is updated
|
||||
|
|
|
@ -37,8 +37,8 @@ enum custom_keycodes {
|
|||
// clang-format off
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[_MACRO] = LAYOUT(
|
||||
A(S(KC_N)), HELLO, CH_SUSP, TO(_MACRO),
|
||||
KC_MPRV, KC_MPLY, KC_MNXT, TO(_NUMPAD),
|
||||
A(S(KC_N)), HELLO, CH_SUSP, TO(_MACRO),
|
||||
KC_MPRV, KC_MPLY, KC_MNXT, TO(_NUMPAD),
|
||||
C(A(KC_COMM)), KC_F5, C(A(KC_DOT)), TO(_RGB),
|
||||
MO(_FN), CH_ASST, CH_CPNL),
|
||||
|
||||
|
@ -60,7 +60,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
KC_NO, KC_NO, KC_NO, KC_TRNS,
|
||||
KC_NO, KC_NO, KC_NO),
|
||||
};
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
|
||||
typedef enum layer_ack {
|
||||
ACK_NO = 0,
|
||||
|
@ -79,20 +79,20 @@ const rgblight_segment_t PROGMEM _no_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, 3, H
|
|||
const rgblight_segment_t PROGMEM _yes_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, 3, HSV_GREEN});
|
||||
const rgblight_segment_t PROGMEM _meh_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, 3, HSV_YELLOW});
|
||||
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
const rgblight_segment_t *const PROGMEM _rgb_layers[] = {
|
||||
[LAYER_OFFSET + 0] = _macro_layer,
|
||||
[LAYER_OFFSET + 1] = _numpad_layer,
|
||||
[LAYER_OFFSET + 2] = _rgb_layer,
|
||||
[LAYER_OFFSET + 3] = _fn_layer,
|
||||
|
||||
|
||||
[ACK_OFFSET + ACK_NO] = _no_layer,
|
||||
[ACK_OFFSET + ACK_YES] = _yes_layer,
|
||||
[ACK_OFFSET + ACK_MEH] = _meh_layer,
|
||||
|
||||
[ACK_OFFSET + ACK_MEH + 1] = NULL
|
||||
};
|
||||
// clang-format off
|
||||
// clang-format off
|
||||
|
||||
const uint8_t PROGMEM _n_rgb_layers = sizeof(_rgb_layers) / sizeof(_rgb_layers[0]) - 1;
|
||||
|
||||
|
@ -200,7 +200,7 @@ void post_process_record_user(uint16_t keycode, keyrecord_t *record) {
|
|||
}
|
||||
}
|
||||
|
||||
void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
bool encoder_update_user(uint8_t index, bool clockwise) {
|
||||
switch (get_highest_layer(layer_state)) {
|
||||
case _RGB:
|
||||
if (index == 0) {
|
||||
|
@ -234,4 +234,5 @@ void encoder_update_user(uint8_t index, bool clockwise) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -45,24 +45,25 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
)
|
||||
};
|
||||
|
||||
void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
bool encoder_update_user(uint8_t index, bool clockwise) {
|
||||
if (index == 0) { /* First encoder */
|
||||
if (clockwise) {
|
||||
rgblight_increase_hue(); //Cycle through the RGB hue
|
||||
} else {
|
||||
rgblight_decrease_hue();
|
||||
}
|
||||
} else if (index == 1) { /* Second encoder */
|
||||
} else if (index == 1) { /* Second encoder */
|
||||
if (clockwise) {
|
||||
rgblight_increase_sat();
|
||||
} else {
|
||||
rgblight_decrease_sat();
|
||||
}
|
||||
} else if (index == 2) { /* Third encoder */
|
||||
} else if (index == 2) { /* Third encoder */
|
||||
if (clockwise) {
|
||||
rgblight_increase_val(); //Change brightness on the RGB LEDs
|
||||
} else {
|
||||
rgblight_decrease_val();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue