Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated callbacks for encoders and dip switches #13404

Merged
merged 4 commits into from
Jul 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions docs/ja/feature_encoders.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,18 @@ ENCODER_ENABLE = yes
コールバック関数を `<keyboard>.c` に記述することができます:

```c
void encoder_update_kb(uint8_t index, bool clockwise) {
encoder_update_user(index, clockwise);
bool encoder_update_kb(uint8_t index, bool clockwise) {
if (!encoder_update_user(index, clockwise)) {
return false;
}

}
```

あるいは `keymap.c` に記述することもできます:

```c
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) {
tap_code(KC_PGDN);
Expand All @@ -73,6 +76,7 @@ void encoder_update_user(uint8_t index, bool clockwise) {
tap_code(KC_UP);
}
}
return true;
}
```

Expand Down
25 changes: 12 additions & 13 deletions keyboards/gmmk/pro/ansi/keymaps/willwm/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#include QMK_KEYBOARD_H

// clang-format off
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

// ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Del Rotary(Mute)
// ~ 1 2 3 4 5 6 7 8 9 0 - (=) BackSpc Home
// Tab Q W E R T Y U I O P [ ] \ PgUp
// Caps A S D F G H J K L ; " Enter PgDn
// Sh_L Z X C V B N M , . ? Sh_R Up End
// Ct_L Win_L Alt_L SPACE Alt_R FN Ct_R Left Down Right


// ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Del Rotary(Mute)
// ~ 1 2 3 4 5 6 7 8 9 0 - (=) BackSpc Home
// Tab Q W E R T Y U I O P [ ] \ PgUp
// Caps A S D F G H J K L ; " Enter PgDn
// Sh_L Z X C V B N M , . ? Sh_R Up End
// Ct_L Win_L Alt_L SPACE Alt_R FN Ct_R Left Down Right
[0] = LAYOUT(
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, KC_MUTE,
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_HOME,
Expand Down Expand Up @@ -61,14 +60,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______
),

};
// clang-format on


void encoder_update_user(uint8_t index, bool clockwise) {
bool encoder_update_user(uint8_t index, bool clockwise) {
if (clockwise) {
tap_code(KC_VOLU);
tap_code(KC_VOLU);
} else {
tap_code(KC_VOLD);
tap_code(KC_VOLD);
}
return true;
}
2 changes: 0 additions & 2 deletions keyboards/handwired/daishi/daishi.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include "quantum.h"

#define encoder_update(clockwise) encoder_update_user(uint8_t index, clockwise)

// The first section contains all of the arguments
// The second converts the arguments into a two-dimensional array
#define LAYOUT( \
Expand Down
4 changes: 2 additions & 2 deletions keyboards/handwired/daishi/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true;
};

bool encoder_update(bool clockwise) {
if (clockwise) {
bool encoder_update_user(uint8_t index, bool clockwise) {
if (clockwise) {
tap_code(KC_VOLU);
} else {
tap_code(KC_VOLD);
Expand Down
11 changes: 5 additions & 6 deletions keyboards/hub20/keymaps/left_hand_numpad/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
*/
#include QMK_KEYBOARD_H



// #define LED_MERGE_NUMPAD_LEFT_HANDED_PLUS TRUE
// #define LED_MERGE_NUMPAD_LEFT_HANDED_ENTER TRUE
// #define LED_MERGE_NUMPAD_LEFT_HANDED_ZERO TRUE

#define MO_NLCK LT(1, KC_NLCK) // Numlock on tap, layer change on hold

#define MO_NLCK LT(1, KC_NLCK) // Numlock on tap, layer change on hold

// clang-format off
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT_left_handed(
KC_MUTE, KC_MPLY,
Expand All @@ -42,8 +40,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_______, _______
)
};
// clang-format of

void encoder_update_user(uint8_t index, bool clockwise) {
bool encoder_update_user(uint8_t index, bool clockwise) {
if (index == 0) { /* Left Encoder */
if (clockwise) {
tap_code(KC_VOLU);
Expand All @@ -57,5 +56,5 @@ void encoder_update_user(uint8_t index, bool clockwise) {
tap_code(KC_MPRV);
}
}
return true;
}

14 changes: 5 additions & 9 deletions keyboards/hub20/keymaps/right_hand_numpad/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
*/
#include QMK_KEYBOARD_H



// #define LED_MERGE_NUMPAD_RIGHT_HANDED_PLUS TRUE
// #define LED_MERGE_NUMPAD_RIGHT_HANDED_ENTER TRUE
// #define LED_MERGE_NUMPAD_RIGHT_HANDED_ZERO TRUE

#define MO_NLCK LT(1, KC_NLCK) // Numlock on tap, layer change on hold

#define MO_NLCK LT(1, KC_NLCK) // Numlock on tap, layer change on hold

// clang-format off
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

//NOT TESTED, WAITING ENDORSEMENT FROM MANUFACTURER
Expand All @@ -44,11 +42,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_______, _______, _______
)
};
// clang-format on




void encoder_update_user(uint8_t index, bool clockwise) {
bool encoder_update_user(uint8_t index, bool clockwise) {
if (index == 0) { /* Left Encoder */
if (clockwise) {
tap_code(KC_VOLU);
Expand All @@ -62,5 +58,5 @@ void encoder_update_user(uint8_t index, bool clockwise) {
tap_code(KC_MPRV);
}
}
return true;
}

84 changes: 43 additions & 41 deletions keyboards/manyboard/macro/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,59 +15,61 @@
*/
#include QMK_KEYBOARD_H


// clang-format off
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT_ortho_4x4(
KC_F1, KC_F2, KC_F3, KC_F4,
KC_F5, KC_F6, KC_F7, KC_F8,
KC_F9, KC_F10, KC_F11, KC_F12,
[0] = LAYOUT_ortho_4x4(
KC_F1, KC_F2, KC_F3, KC_F4,
KC_F5, KC_F6, KC_F7, KC_F8,
KC_F9, KC_F10, KC_F11, KC_F12,
KC_F13, KC_F14, KC_F15, TO(1)
),
[1] = LAYOUT_ortho_4x4(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
[1] = LAYOUT_ortho_4x4(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, TO(2)
),
[2] = LAYOUT_ortho_4x4(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
[2] = LAYOUT_ortho_4x4(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, TO(0)
),
};
// clang-format on

layer_state_t layer_state_set_user(layer_state_t state) {
switch (get_highest_layer(state)) {
case 0:
sethsv(HSV_WHITE, (LED_TYPE *)&led[0]);
rgblight_set();
break;
case 1:
sethsv(HSV_GREEN, (LED_TYPE *)&led[0]);
rgblight_set();
break;
case 2:
sethsv(HSV_BLUE, (LED_TYPE *)&led[0]);
rgblight_set();
break;
}
return state;
case 0:
sethsv(HSV_WHITE, (LED_TYPE *)&led[0]);
rgblight_set();
break;
case 1:
sethsv(HSV_GREEN, (LED_TYPE *)&led[0]);
rgblight_set();
break;
case 2:
sethsv(HSV_BLUE, (LED_TYPE *)&led[0]);
rgblight_set();
break;
}
return state;
}

void encoder_update_user(uint8_t index, bool clockwise) {
/* With an if statement we can check which encoder was turned. */
if (index == 0) { /* First encoder */
/* And with another if statement we can check the direction. */
if (clockwise) {
/* This is where the actual magic happens: this bit of code taps on the
Page Down key. You can do anything QMK allows you to do here.
You'll want to replace these lines with the things you want your
encoders to do. */
tap_code(KC_AUDIO_VOL_UP);
} else {
/* And likewise for the other direction, this time Vol Down is pressed. */
tap_code(KC_AUDIO_VOL_DOWN);
bool encoder_update_user(uint8_t index, bool clockwise) {
/* With an if statement we can check which encoder was turned. */
if (index == 0) { /* First encoder */
/* And with another if statement we can check the direction. */
if (clockwise) {
/* This is where the actual magic happens: this bit of code taps on the
Page Down key. You can do anything QMK allows you to do here.
You'll want to replace these lines with the things you want your
encoders to do. */
tap_code(KC_AUDIO_VOL_UP);
} else {
/* And likewise for the other direction, this time Vol Down is pressed. */
tap_code(KC_AUDIO_VOL_DOWN);
}
}
}
return true;
}
85 changes: 44 additions & 41 deletions keyboards/manyboard/macro/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,58 +15,61 @@
*/
#include QMK_KEYBOARD_H


// clang-format off
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT_ortho_4x4(
KC_F1, KC_F2, KC_F3, KC_F4,
KC_F5, KC_F6, KC_F7, KC_F8,
KC_F9, KC_F10, KC_F11, KC_F12,
[0] = LAYOUT_ortho_4x4(
KC_F1, KC_F2, KC_F3, KC_F4,
KC_F5, KC_F6, KC_F7, KC_F8,
KC_F9, KC_F10, KC_F11, KC_F12,
KC_F13, KC_F14, KC_F15, TO(1)
),
[1] = LAYOUT_ortho_4x4(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
[1] = LAYOUT_ortho_4x4(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, TO(2)
),
[2] = LAYOUT_ortho_4x4(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
[2] = LAYOUT_ortho_4x4(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, TO(0)
),
};
// clang-format on

layer_state_t layer_state_set_user(layer_state_t state) {
switch (get_highest_layer(state)) {
case 0:
sethsv(HSV_WHITE, (LED_TYPE *)&led[0]);
rgblight_set();
break;
case 1:
sethsv(HSV_GREEN, (LED_TYPE *)&led[0]);
rgblight_set();
break;
case 2:
sethsv(HSV_BLUE, (LED_TYPE *)&led[0]);
rgblight_set();
break;
}
return state;
case 0:
sethsv(HSV_WHITE, (LED_TYPE *)&led[0]);
rgblight_set();
break;
case 1:
sethsv(HSV_GREEN, (LED_TYPE *)&led[0]);
rgblight_set();
break;
case 2:
sethsv(HSV_BLUE, (LED_TYPE *)&led[0]);
rgblight_set();
break;
}
return state;
}

void encoder_update_user(uint8_t index, bool clockwise) {
/* With an if statement we can check which encoder was turned. */
if (index == 0) { /* First encoder */
/* And with another if statement we can check the direction. */
if (clockwise) {
/* This is where the actual magic happens: this bit of code taps on the
Page Down key. You can do anything QMK allows you to do here.
You'll want to replace these lines with the things you want your
encoders to do. */
tap_code(KC_AUDIO_VOL_UP);
} else {
/* And likewise for the other direction, this time Vol Down is pressed. */
tap_code(KC_AUDIO_VOL_DOWN);
bool encoder_update_user(uint8_t index, bool clockwise) {
/* With an if statement we can check which encoder was turned. */
if (index == 0) { /* First encoder */
/* And with another if statement we can check the direction. */
if (clockwise) {
/* This is where the actual magic happens: this bit of code taps on the
Page Down key. You can do anything QMK allows you to do here.
You'll want to replace these lines with the things you want your
encoders to do. */
tap_code(KC_AUDIO_VOL_UP);
} else {
/* And likewise for the other direction, this time Vol Down is pressed. */
tap_code(KC_AUDIO_VOL_DOWN);
}
}
}
return true;
}
Loading