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

Fixed info.json issue, some key got wrong pos for Gas75 #17070

Merged
merged 3 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions keyboards/ml/gas75/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
{"label":"[{", "x":11.5, "y":2.25},
{"label":"]}", "x":12.5, "y":2.25},
{"label":"\\|", "x":13.5, "y":2.25, "w":1.5},
{"label":"PgUp", "x":12.5, "y":2.25},
{"label":"PgUp", "x":15.25, "y":2.25},

{"label":"Caps Lock", "x":0, "y":3.25, "w":1.75},
{"label":"A", "x":1.75, "y":3.25},
Expand All @@ -68,7 +68,7 @@
{"label":";:", "x":10.75, "y":3.25},
{"label":"'\"", "x":11.75, "y":3.25},
{"label":"Enter", "x":12.75, "y":3.25, "w":2.25},
{"label":"PgDn", "x":12.5, "y":3.25},
{"label":"PgDn", "x":15.25, "y":3.25},

{"label":"Shift", "x":0, "y":4.25, "w":2.25},
{"label":"Z", "x":2.25, "y":4.25},
Expand Down
64 changes: 42 additions & 22 deletions keyboards/ml/gas75/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ 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 */
[_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_MUTE, _______,
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_PGUP,
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_PGDN,
Expand All @@ -110,12 +110,12 @@ 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 */
[_FN] = LAYOUT(
QK_BOOT, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOG, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_HUI,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_HUD,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
QK_BOOT, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_RMOD, RGB_TOG, RGB_MOD,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_HUI,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_HUD,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_VAI,
_______, _______, _______, _______, _______, _______, RGB_SPD, RGB_VAD, RGB_SPI
_______, _______, _______, _______, _______, _______, RGB_SPD, RGB_VAD, RGB_SPI
),
};

Expand Down Expand Up @@ -159,23 +159,43 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}

#ifdef ENCODER_ENABLE
bool encoder_update_user(uint8_t index, bool clockwise) {
if (index == 0) {
if (layer_state_is(_BASE)) {
if (clockwise) {
tap_code(KC_VOLU);
} else {
tap_code(KC_VOLD);
}
} else if (layer_state_is(_FN)) {
if (clockwise) {
rgb_matrix_step();
} else {
rgb_matrix_step_reverse();
}

#define ENCODERS 1
drashna marked this conversation as resolved.
Show resolved Hide resolved
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);
}
}
return true;
}
}

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;
}
#endif

Expand Down