Convert Encoder callbacks to be boolean functions (#12805)
Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
This commit is contained in:
@@ -21,13 +21,13 @@ 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) {
|
||||
/* Top-left encoder (volume) */
|
||||
case 0:
|
||||
tap_code(clockwise ? KC_VOLU : KC_VOLD);
|
||||
break;
|
||||
|
||||
|
||||
/* Top-right encoder (backlight brightness) */
|
||||
case 1:
|
||||
if (clockwise) {
|
||||
@@ -41,4 +41,5 @@ void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -253,7 +253,7 @@ const uint16_t PROGMEM encoders[][2][2] = {
|
||||
[LR_EDIT] = {{ KC_COMM, KC_DOT }, { KC_MINS, KC_EQL }},
|
||||
};
|
||||
|
||||
void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
bool encoder_update_user(uint8_t index, bool clockwise) {
|
||||
uint8_t layer = get_highest_layer(layer_state);
|
||||
|
||||
switch (layer) {
|
||||
@@ -285,6 +285,7 @@ void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
tap_code16(pgm_read_word(&encoders[layer][index][clockwise]));
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -39,7 +39,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) {
|
||||
if (clockwise) {
|
||||
tap_code(KC_MS_WH_UP);
|
||||
@@ -54,4 +54,5 @@ void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
tap_code(KC_VOLD);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -45,7 +45,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 == _LEFT) {
|
||||
if (clockwise) {
|
||||
tap_code(KC_VOLU);
|
||||
@@ -67,4 +67,5 @@ void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
tap_code(KC_PGUP);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -123,7 +123,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) {
|
||||
if (clockwise) {
|
||||
tap_code(KC_VOLD);
|
||||
@@ -131,6 +131,7 @@ void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
tap_code(KC_VOLU);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Tapdance! Hold to use as a modifier to the _MOD layout, tap to change it between _BASE and _MACRO
|
||||
|
@@ -45,7 +45,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 == _LEFT) {
|
||||
if (clockwise) {
|
||||
tap_code(KC_VOLD);
|
||||
@@ -67,4 +67,5 @@ void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
tap_code(KC_PGDN);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -67,7 +67,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) {
|
||||
if (clockwise) {
|
||||
tap_code(KC_RGHT);
|
||||
@@ -82,4 +82,5 @@ void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
SEND_STRING(SS_LCTRL("3")); // audacity zoom out
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -26,18 +26,18 @@ enum custom_keycodes { // Make sure have the awesome keycode ready
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = LAYOUT(
|
||||
KC_MS_BTN1, KC_MS_BTN2, KC_MS_BTN3,
|
||||
KC_WH_U, ALT_TAB, KC_WH_L,
|
||||
KC_WH_D, TT(1), KC_WH_R
|
||||
KC_MS_BTN1, KC_MS_BTN2, KC_MS_BTN3,
|
||||
KC_WH_U, ALT_TAB, KC_WH_L,
|
||||
KC_WH_D, TT(1), KC_WH_R
|
||||
),
|
||||
[1] = LAYOUT(
|
||||
RESET, KC_ACL0, KC_ACL1,
|
||||
KC_VOLU, KC_ACL2, KC_BRIU,
|
||||
KC_VOLD, TO(1), KC_BRID
|
||||
RESET, KC_ACL0, KC_ACL1,
|
||||
KC_VOLU, KC_ACL2, KC_BRIU,
|
||||
KC_VOLD, TO(1), KC_BRID
|
||||
),
|
||||
};
|
||||
|
||||
void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
bool encoder_update_user(uint8_t index, bool clockwise) {
|
||||
if (index == 0) {
|
||||
if (clockwise) {
|
||||
tap_code(KC_MS_LEFT);
|
||||
@@ -52,6 +52,7 @@ void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
tap_code(KC_MS_D);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
switch (keycode) { // This will do most of the grunt work with the keycodes.
|
||||
|
@@ -38,7 +38,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
KC_MPRV, KC_END , KC_MNXT
|
||||
),
|
||||
};
|
||||
void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
bool encoder_update_user(uint8_t index, bool clockwise) {
|
||||
if (index == 0) {
|
||||
if (clockwise) {
|
||||
tap_code(KC_VOLD);
|
||||
@@ -63,4 +63,5 @@ void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -14,7 +14,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 == _LEFT) {
|
||||
if (clockwise) {
|
||||
rgblight_increase_hue();
|
||||
@@ -36,4 +36,5 @@ void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
rgblight_decrease_val();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -41,7 +41,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 == _LEFT) {
|
||||
if (clockwise) {
|
||||
tap_code(KC_VOLU);
|
||||
@@ -63,4 +63,5 @@ void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
tap_code(KC_PGUP);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -35,7 +35,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) {
|
||||
if (clockwise) {
|
||||
// Tab right
|
||||
@@ -54,4 +54,5 @@ void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
tap_code16(LGUI(KC_LBRC));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -106,7 +106,7 @@ void keyboard_post_init_user(void) {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
bool encoder_update_user(uint8_t index, bool clockwise) {
|
||||
if(base_mode == true) {
|
||||
if (index == 0) {
|
||||
if (clockwise) {
|
||||
@@ -169,4 +169,5 @@ void encoder_update_user(uint8_t index, bool clockwise) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user