Skip to content

Commit

Permalink
Enable encoder map for VIA keymaps
Browse files Browse the repository at this point in the history
  • Loading branch information
HorrorTroll committed Aug 14, 2022
1 parent 030ce4c commit 5602281
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 161 deletions.
4 changes: 2 additions & 2 deletions keyboards/feker/ik75/ik75.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ led_config_t g_led_config = { {
}, {
{0 , 15}, {14 , 15}, {29 , 15}, {43 , 15}, {58 , 15}, {72 , 15}, {87 , 15}, {101, 15}, {116, 15}, {130, 15}, {145, 15}, {159, 15}, {173, 15}, {195, 15}, {38 , 61}, {92 , 61},
{4 , 26}, {22 , 26}, {36 , 26}, {51 , 26}, {65 , 26}, {79 , 26}, {94 , 26}, {108, 26}, {123, 26}, {137, 26}, {152, 26}, {166, 26}, {181, 26}, {199, 26}, {173, 61}, {159, 61},
{5 , 38}, {25 , 38}, {40 , 38}, {54 , 38}, {69 , 38}, {83 , 38}, {98 , 38}, {112, 38}, {126, 38}, {141, 38}, {155, 38}, {170, 38}, {193, 38}, {206, 52}, {0 , 0}, {145, 61},
{5 , 38}, {25 , 38}, {40 , 38}, {54 , 38}, {69 , 38}, {83 , 38}, {98 , 38}, {112, 38}, {126, 38}, {141, 38}, {155, 38}, {170, 38}, {193, 38}, {206, 52}, {210, 12}, {145, 61},
{9 , 49}, {33 , 49}, {47 , 49}, {61 , 49}, {76 , 49}, {90 , 49}, {105, 49}, {119, 49}, {134, 49}, {148, 49}, {163, 49}, {182, 49}, {191, 64}, {206, 64}, {220, 64},
{14 , 0}, {28 , 0}, {53 , 0}, {63 , 0}, {74 , 0}, {88 , 0}, {102, 0}, {116, 0}, {130, 0}, {144, 0}, {158, 0}, {172, 0}, {189, 0}, {210, 0}, {224, 0}, {224, 11},
{0 , 0}, {18 , 0}, {33 , 0}, {47 , 0}, {61 , 0}, {79 , 0}, {94 , 0}, {108, 0}, {123, 0}, {141, 0}, {155, 0}, {170, 0}, {184, 0}, {202, 0}, {2 , 61}, {20 , 61},
{0 , 0}, {0 , 11}, {0 , 27}, {0 , 37}, {224, 5}, {210, 5}, {217, 0}, {224, 15}, {224, 38}, {0 , 0}, {224, 26}, {224, 49}, {224, 56}, {224, 45}, {224, 35}, {224, 24},
{0 , 0}, {0 , 11}, {0 , 27}, {0 , 37}, {224, 5}, {210, 5}, {217, 0}, {224, 15}, {224, 38}, {210, 18}, {224, 26}, {224, 49}, {224, 56}, {224, 45}, {224, 35}, {224, 24},
{0 , 48}, {0 , 56}, {0 , 64}, {14 , 64}, {28 , 64}, {49 , 64}, {67 , 64}, {84 , 64}, {98 , 64}, {112, 64}, {126, 64}, {140, 64}, {158, 64}, {172, 64}, {196, 64}, {224, 64},
}, {
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 4,
Expand Down
6 changes: 3 additions & 3 deletions keyboards/feker/ik75/ik75.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#define XXX KC_NO

/* 54 ◯ 53
/*
* ┌───┐┌───┬───┬───┬───┐┌───┬───┬───┬───┐┌───┬───┬───┬───┐┌───┐ ┌───┐
* │00 ││01 │02 │03 │04 ││05 │06 │07 │08 ││09 │0A │0B │0C ││0D │ │4F │
* └───┘└───┴───┴───┴───┘└───┴───┴───┴───┘└───┴───┴───┴───┘└───┘ └───┘
Expand All @@ -40,7 +40,7 @@
*/

#define LAYOUT( \
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K54, K4F, K53, \
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K4F, \
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1F, \
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2F, \
K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3D, K3E, \
Expand All @@ -52,5 +52,5 @@
{ K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, XXX, K2F }, \
{ K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, XXX, K3D, K3E, K3F }, \
{ K40, XXX, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4B, XXX, K4D, K4E, K4F }, \
{ K50, K51, K52, K53, K54, XXX, K56, XXX, XXX, K59, K5A, XXX, K5C, K5D, K5E, K5F } \
{ K50, K51, K52, XXX, XXX, XXX, K56, XXX, XXX, K59, K5A, XXX, K5C, K5D, K5E, K5F } \
}
4 changes: 1 addition & 3 deletions keyboards/feker/ik75/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
{"label":"F10", "x":10.75, "y":0},
{"label":"F11", "x":11.75, "y":0},
{"label":"F12", "x":12.75, "y":0},
{"label":"Delete", "x":14, "y":0, "w":2},
{"label":"Encoder CCW", "x":15, "y":0, "w":0.5},
{"label":"Delete", "x":14, "y":0},
{"label":"Mute", "x":15.5, "y":0},
{"label":"Encoder CW", "x":16.5, "y":0, "w":0.5},

{"label":"`~", "x":0, "y":1.25},
{"label":"1!", "x":1, "y":1.25},
Expand Down
96 changes: 32 additions & 64 deletions keyboards/feker/ik75/keymaps/bkzshen/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ enum layer_names {
_BASE,
_FN,
_FN1,
_FN2
_FN2,
};

// enum layer_keycodes { };
Expand Down Expand Up @@ -65,14 +65,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
└────┴────┴────┴────────────────────────┴───┴───┴───┘│ │ │ │
└───┴───┴───┘
*/
/* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */
/* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */
[_BASE] = 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_VOLD, KC_MUTE, KC_VOLU,
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,
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_END,
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,
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_END,
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGUP,
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN,
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RIGHT
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN,
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RIGHT
),

/*
Expand All @@ -92,14 +92,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
└────┴────┴────┴────────────────────────┴────┴────┘ │ │Vad│ │
└───┴───┴───┘
*/
/* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */
/* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */
[_FN] = LAYOUT(
QK_BOOT, KC_MYCM, KC_WHOM, KC_CALC, KC_SLCT, KC_MPRV, KC_MNXT, KC_MPLY, KC_MSTP, KC_MUTE, KC_VOLD, KC_VOLU, KC_MAIL, KC_INS, _______, RGB_TOG, _______,
NK_TOGG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SPD, RGB_SPI, _______, RGB_MOD,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, _______, _______, _______, RGB_HUI,
QK_BOOT, KC_MYCM, KC_WHOM, KC_CALC, KC_SLCT, KC_MPRV, KC_MNXT, KC_MPLY, KC_MSTP, KC_MUTE, KC_VOLD, KC_VOLU, KC_MAIL, KC_INS, RGB_TOG,
NK_TOGG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SPD, RGB_SPI, _______, RGB_MOD,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, _______, _______, _______, RGB_HUI,
_______, _______, KC_SCRL, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SAI,
_______, _______, _______, _______, _______, _______, KC_NUM, _______, _______, _______, _______, _______, RGB_VAI, RGB_SAD,
_______, GUI_TOG, _______, _______, _______, _______, _______, _______, RGB_VAD, _______
_______, _______, _______, _______, _______, _______, KC_NUM, _______, _______, _______, _______, _______, RGB_VAI, RGB_SAD,
_______, GUI_TOG, _______, _______, _______, _______, _______, _______, RGB_VAD, _______
),

/*
Expand All @@ -119,14 +119,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
└────┴────┴────┴────────────────────────┴────┴────┘ │ │ │ │
└───┴───┴───┘
*/
/* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */
/* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */
[_FN1] = LAYOUT(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______
),

/*
Expand All @@ -146,14 +146,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
└────┴────┴────┴────────────────────────┴────┴────┘ │ │ │ │
└───┴───┴───┘
*/
/* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */
/* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */
[_FN2] = LAYOUT(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______
),
};

Expand Down Expand Up @@ -214,43 +214,11 @@ void rgb_matrix_indicators_user(void) {
}
}

#ifdef ENCODER_ENABLE

#define ENCODERS 3
static uint8_t encoder_state[ENCODERS] = {0};
static keypos_t encoder_cw[ENCODERS] = {{3, 5}};
static keypos_t encoder_ccw[ENCODERS] = {{4, 5}};

void encoder_action_unregister(void) {
for (int index = 0; index < ENCODERS; ++index) {
if (encoder_state[index]) {
keyevent_t encoder_event = (keyevent_t) {
.key = encoder_state[index] >> 1 ? encoder_cw[index] : encoder_ccw[index],
.pressed = false,
.time = (timer_read() | 1)
};
encoder_state[index] = 0;
action_exec(encoder_event);
}
}
}

void encoder_action_register(uint8_t index, bool clockwise) {
keyevent_t encoder_event = (keyevent_t) {
.key = clockwise ? encoder_cw[index] : encoder_ccw[index],
.pressed = true,
.time = (timer_read() | 1)
};
encoder_state[index] = (clockwise ^ 1) | (clockwise << 1);
action_exec(encoder_event);
}

void matrix_scan_user(void) {
encoder_action_unregister();
}

bool encoder_update_user(uint8_t index, bool clockwise) {
encoder_action_register(index, clockwise);
return false;
}
#ifdef ENCODER_MAP_ENABLE
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
[_BASE] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
[_FN] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
[_FN1] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
[_FN2] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
};
#endif
3 changes: 3 additions & 0 deletions keyboards/feker/ik75/keymaps/bkzshen/rules.mk
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
VIA_ENABLE = yes

# Encoder enabled
ENCODER_MAP_ENABLE = yes
Loading

0 comments on commit 5602281

Please sign in to comment.