Skip to content

Commit

Permalink
keycapsss/plaid_pad: switch to encoder map (qmk#22474)
Browse files Browse the repository at this point in the history
  • Loading branch information
fauxpark authored and mechlovin committed Jan 17, 2024
1 parent baf9750 commit 37da07a
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 174 deletions.
42 changes: 8 additions & 34 deletions keyboards/keycapsss/plaid_pad/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ bool oled_task_user(void) {
#endif


#ifdef ENCODER_ENABLE
#ifdef ENCODER_MAP_ENABLE

bool encoder_update_user(uint8_t index, bool clockwise) {
/*
Rev1.1 Rev1
,-----------------------, ,-----------------------,
Expand All @@ -57,37 +56,12 @@ Rev1.1 Rev1
| | | | E1 | | | | | |
`-----------------------' `-----------------------'
*/

// First encoder (E1)
if (index == 0) {
if (clockwise) {
tap_code(KC_F17);
} else {
tap_code(KC_F18);
}
// Second encoder (E2)
} else if (index == 1) {
if (clockwise) {
tap_code(KC_F19);
} else {
tap_code(KC_F20);
}
// Third encoder (E3)
} else if (index == 2) {
if (clockwise) {
tap_code(KC_F21);
} else {
tap_code(KC_F22);
}
// Forth encoder (E4)
} else if (index == 3) {
if (clockwise) {
tap_code(KC_F23);
} else {
tap_code(KC_F24);
}
}
return true;
}
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
#ifdef KEYBOARD_keycapsss_plaid_pad_rev1
{ ENCODER_CCW_CW(KC_F18, KC_F17), ENCODER_CCW_CW(KC_F20, KC_F19) }
#else
{ ENCODER_CCW_CW(KC_F18, KC_F17), ENCODER_CCW_CW(KC_F20, KC_F19), ENCODER_CCW_CW(KC_F22, KC_F21), ENCODER_CCW_CW(KC_F24, KC_F23) }
#endif
};

#endif
1 change: 1 addition & 0 deletions keyboards/keycapsss/plaid_pad/keymaps/default/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ENCODER_MAP_ENABLE = yes
102 changes: 12 additions & 90 deletions keyboards/keycapsss/plaid_pad/keymaps/oled/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ bool oled_task_user(void) {

#endif

#ifdef ENCODER_ENABLE
bool encoder_update_user(uint8_t index, bool clockwise) {
#ifdef ENCODER_MAP_ENABLE
/*
,-----------------------,
| E1 | E2 | E3 | E4 |
Expand All @@ -138,93 +137,16 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
| | | | E1 |
`-----------------------'
*/
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
#ifdef KEYBOARD_keycapsss_plaid_pad_rev1
[_NUMPAD] = { ENCODER_CCW_CW(KC_F18, KC_F17), ENCODER_CCW_CW(KC_F20, KC_F19) },
[_NAVIGATION] = { ENCODER_CCW_CW(C(S(KC_TAB)), C(KC_TAB)), ENCODER_CCW_CW(KC_PGUP, KC_PGDN) },
[_MEDIA] = { ENCODER_CCW_CW(KC_F18, KC_F17), ENCODER_CCW_CW(KC_F20, KC_F19) }
#else
[_NUMPAD] = { ENCODER_CCW_CW(KC_F18, KC_F17), ENCODER_CCW_CW(KC_F20, KC_F19), ENCODER_CCW_CW(KC_F22, KC_F21), ENCODER_CCW_CW(KC_F24, KC_F23) },
[_NAVIGATION] = { ENCODER_CCW_CW(C(S(KC_TAB)), C(KC_TAB)), ENCODER_CCW_CW(KC_PGUP, KC_PGDN), ENCODER_CCW_CW(KC_WH_U, KC_WH_D), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
[_MEDIA] = { ENCODER_CCW_CW(KC_F18, KC_F17), ENCODER_CCW_CW(KC_F20, KC_F19), ENCODER_CCW_CW(KC_BRID, KC_BRIU), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }
#endif
};

// First encoder (E1)
if (index == 0) {
switch (get_highest_layer(layer_state)) {
case _NAVIGATION:
// Browser tab switching
if (clockwise) {
tap_code16(LCTL(KC_TAB));
} else {
tap_code16(LCTL(LSFT(KC_TAB)));
}
break;
default:
if (clockwise) {
tap_code(KC_F17);
} else {
tap_code(KC_F18);
}
break;
}
// Second encoder (E2)
} else if (index == 1) {
switch (get_highest_layer(layer_state)) {
case _NAVIGATION:
// Page Down/Up
if (clockwise) {
tap_code16(KC_PGDN);
} else {
tap_code16(KC_PGUP);
}
break;
default:
if (clockwise) {
tap_code(KC_F19);
} else {
tap_code(KC_F20);
}
break;
}
// Third encoder (E3)
} else if (index == 2) {
switch (get_highest_layer(layer_state)) {
case _NAVIGATION:
// Mouse wheel up/down
if (clockwise) {
tap_code(KC_MS_WH_DOWN);
} else {
tap_code(KC_MS_WH_UP);
}
break;
case _MEDIA:
// BRIGHTNESS Up/Down
if (clockwise) {
tap_code16(KC_BRIGHTNESS_UP);
} else {
tap_code16(KC_BRIGHTNESS_DOWN);
}
break;
default:
if (clockwise) {
tap_code(KC_F21);
} else {
tap_code(KC_F22);
}
break;
}
// Forth encoder (E4)
} else if (index == 3) {
switch (get_highest_layer(layer_state)) {
case _NAVIGATION:
case _MEDIA:
// Volume Up/Down
if (clockwise) {
tap_code16(KC_AUDIO_VOL_UP);
} else {
tap_code16(KC_AUDIO_VOL_DOWN);
}
break;
default:
if (clockwise) {
tap_code(KC_F23);
} else {
tap_code(KC_F24);
}
break;
}
}
return true;
}
#endif
1 change: 1 addition & 0 deletions keyboards/keycapsss/plaid_pad/keymaps/oled/rules.mk
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
OLED_ENABLE = yes
COMBO_ENABLE = yes
ENCODER_MAP_ENABLE = yes
61 changes: 11 additions & 50 deletions keyboards/keycapsss/plaid_pad/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,12 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* | 0 | . | = | + |
* `-----------------------'
*/
[0] = LAYOUT_ortho_4x4(
LAYOUT_ortho_4x4(
KC_P7, KC_P8, KC_P9, KC_PSLS,
KC_P4, KC_P5, KC_P6, KC_PAST,
KC_P1, KC_P2, KC_P3, KC_PMNS,
KC_P0, KC_PDOT, KC_PEQL, KC_PPLS ),
[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, 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, KC_TRNS ),
[3] = 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, KC_TRNS ),
KC_P0, KC_PDOT, KC_PEQL, KC_PPLS
),
};


Expand All @@ -69,8 +55,7 @@ bool oled_task_user(void) {
#endif


#ifdef ENCODER_ENABLE
bool encoder_update_user(uint8_t index, bool clockwise) {
#ifdef ENCODER_MAP_ENABLE
/*
Rev1.1 Rev1
,-----------------------, ,-----------------------,
Expand All @@ -84,35 +69,11 @@ Rev1.1 Rev1
`-----------------------' `-----------------------'
*/

// First encoder (E1)
if (index == 0) {
if (clockwise) {
tap_code(KC_F17);
} else {
tap_code(KC_F18);
}
// Second encoder (E2)
} else if (index == 1) {
if (clockwise) {
tap_code(KC_F19);
} else {
tap_code(KC_F20);
}
// Third encoder (E3)
} else if (index == 2) {
if (clockwise) {
tap_code(KC_F21);
} else {
tap_code(KC_F22);
}
// Forth encoder (E4)
} else if (index == 3) {
if (clockwise) {
tap_code(KC_F23);
} else {
tap_code(KC_F24);
}
}
return true;
}
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
#ifdef KEYBOARD_keycapsss_plaid_pad_rev1
{ ENCODER_CCW_CW(KC_F18, KC_F17), ENCODER_CCW_CW(KC_F20, KC_F19) }
#else
{ ENCODER_CCW_CW(KC_F18, KC_F17), ENCODER_CCW_CW(KC_F20, KC_F19), ENCODER_CCW_CW(KC_F22, KC_F21), ENCODER_CCW_CW(KC_F24, KC_F23) }
#endif
};
#endif
1 change: 1 addition & 0 deletions keyboards/keycapsss/plaid_pad/keymaps/via/rules.mk
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
VIA_ENABLE = yes
LTO_ENABLE = yes
ENCODER_MAP_ENABLE = yes

0 comments on commit 37da07a

Please sign in to comment.