Skip to content

Commit

Permalink
GMMK Pro: fix unintended volume encoder taps (#17129)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrebrait authored Sep 24, 2022
1 parent 94d5fe6 commit 32204f4
Show file tree
Hide file tree
Showing 25 changed files with 83 additions and 125 deletions.
3 changes: 2 additions & 1 deletion keyboards/gmmk/pro/rev1/ansi/keymaps/alexmarmon/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
} else {
tap_code(KC_VOLD);
}
return true;
//return true; //set to return false to counteract enabled encoder in pro.c
return false;
}
2 changes: 1 addition & 1 deletion keyboards/gmmk/pro/rev1/ansi/keymaps/andrebrait/config.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2021 Andre Brait
/* Copyright 2022 Andre Brait
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
11 changes: 0 additions & 11 deletions keyboards/gmmk/pro/rev1/ansi/keymaps/andrebrait/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
};
// clang-format on

#ifdef ENCODER_ENABLE
bool encoder_update_user(uint8_t index, bool clockwise) {
if (clockwise) {
tap_code(KC_VOLU);
} else {
tap_code(KC_VOLD);
}
return true;
}
#endif // ENCODER_ENABLE

#ifdef RGB_MATRIX_ENABLE

#define RGB_CONFIRMATION_BLINKING_TIME 2000 // 2 seconds
Expand Down
2 changes: 0 additions & 2 deletions keyboards/gmmk/pro/rev1/ansi/keymaps/andrebrait/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ The differences are as follows:
- Dedicated MacOS and Windows/Linux layers
- Switching between them by pressing Fn + CAPS LOCK
- Disabled Mouse Keys (to fix issues with KVM switches and also because they're not used here anyway)
- Short DEBOUNCE time (5 ms)
- Per-key debounce algorithm (sym_defer_pk)
- RGB turns off after 20 minutes of inactivity
- RGB turns off when USB is suspended
- Layer 0:
Expand Down
2 changes: 0 additions & 2 deletions keyboards/gmmk/pro/rev1/ansi/keymaps/andrebrait/rules.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Enable additional features.

DEBOUNCE_TYPE = sym_defer_pk

# Disabling MouseKey because it breaks my KVM switch
MOUSEKEY_ENABLE = no
3 changes: 2 additions & 1 deletion keyboards/gmmk/pro/rev1/ansi/keymaps/byungyoonc/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
tap_code16(KC_VOLD);
}
}
return true;
//return true; //set to return false to counteract enabled encoder in pro.c
return false;
}
#endif // ENCODER_ENABLE

Expand Down
5 changes: 3 additions & 2 deletions keyboards/gmmk/pro/rev1/ansi/keymaps/cedrikl/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
} else {
tap_code(KC_VOLD);
}
return true;
//return true; //set to return false to counteract enabled encoder in pro.c
return false;
}
#endif // ENCODER_ENABLE

Expand All @@ -77,7 +78,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
//void set_layer_rgb(uint8_t led_min, uint8_t led_max, int layer) {
// const ledmap *l = &(ledmaps[layer]);
//
//
//
//
// for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) {
// HSV hsv = {
Expand Down
3 changes: 2 additions & 1 deletion keyboards/gmmk/pro/rev1/ansi/keymaps/coryginsberg/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,6 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
else {
tap_code(KC_VOLD);
}
return true;
//return true; //set to return false to counteract enabled encoder in pro.c
return false;
}
11 changes: 0 additions & 11 deletions keyboards/gmmk/pro/rev1/ansi/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

};
// clang-format on

#ifdef ENCODER_ENABLE
bool encoder_update_user(uint8_t index, bool clockwise) {
if (clockwise) {
tap_code(KC_VOLU);
} else {
tap_code(KC_VOLD);
}
return false;
}
#endif // ENCODER_ENABLE
3 changes: 2 additions & 1 deletion keyboards/gmmk/pro/rev1/ansi/keymaps/gigahawk/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
} else {
tap_code(KC_VOLD);
}
return true;
//return true; //set to return false to counteract enabled encoder in pro.c
return false;
}

void rgb_matrix_indicators_user(void) {
Expand Down
3 changes: 2 additions & 1 deletion keyboards/gmmk/pro/rev1/ansi/keymaps/hachetman/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
} else {
tap_code(KC_VOLD);
}
return true;
//return true; //set to return false to counteract enabled encoder in pro.c
return false;
}
#endif // ENCODER_ENABLE

Expand Down
3 changes: 2 additions & 1 deletion keyboards/gmmk/pro/rev1/ansi/keymaps/jackkenney/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
else {
tap_code(KC_VOLD);
}
return true;
//return true; //set to return false to counteract enabled encoder in pro.c
return false;
}
3 changes: 2 additions & 1 deletion keyboards/gmmk/pro/rev1/ansi/keymaps/jonavin/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
break;
}
}
return true;
//return true; //set to return false to counteract enabled encoder in pro.c
return false;
}
#endif // ENCODER_ENABLE && !ENCODER_DEFAULTACTIONS_ENABLE

Expand Down
3 changes: 2 additions & 1 deletion keyboards/gmmk/pro/rev1/ansi/keymaps/macos/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
} else {
tap_code(KC_VOLD);
}
return true;
//return true; //set to return false to counteract enabled encoder in pro.c
return false;
}
#endif //ENCODER_ENABLE

Expand Down
3 changes: 2 additions & 1 deletion keyboards/gmmk/pro/rev1/ansi/keymaps/mattgauf/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
}
}
}
return true;
//return true; //set to return false to counteract enabled encoder in pro.c
return false;
}


Expand Down
3 changes: 2 additions & 1 deletion keyboards/gmmk/pro/rev1/ansi/keymaps/mike1808/encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
(*encoder_mapping[state][1])();
}

return true;
//return true; //set to return false to counteract enabled encoder in pro.c
return false;
}

void handle_rgb_key(bool pressed) {
Expand Down
75 changes: 38 additions & 37 deletions keyboards/gmmk/pro/rev1/ansi/keymaps/paddlegame/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,20 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
),

[_MO2] = LAYOUT(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, TG(_MO2), _______, _______, _______, _______
),

[_MO3] = LAYOUT(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______
),

Expand Down Expand Up @@ -128,17 +128,18 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
}
}
break;

case _BASE:
default:
if ( clockwise ) {
tap_code(KC_VOLU);
} else {
tap_code(KC_VOLD);
}
break;
break;
}
return true;
//return true; //set to return false to counteract enabled encoder in pro.c
return false;
}
#endif

Expand All @@ -149,15 +150,15 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
ball[i].up = false;
ball[i].y = 0;
ball[i].x = rand() % 16;

// Set initial ball state
if (ball[i].x < 8) {
ball[i].left = false;
} else {
ball[i].x -= 4;
ball[i].left = true;
}

// 1/4 chance of being an enemy ball after level 6
if (level_number > 3) {
ball[i].enemy = ((rand() % 4) == 0);
Expand All @@ -172,7 +173,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
}
damage_timer = timer_read();
damage_count = 10;

// Reset board
init_ball(0);
ball[1].on = false;
Expand All @@ -189,7 +190,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
rgb_value.g = 0x00;
rgb_value.b = 0x00;
}

if (rgb_value.r == 0xff && rgb_value.g < 0xff) {
if (rgb_value.b > 0) { --rgb_value.b; }
else { ++rgb_value.g; }
Expand All @@ -212,25 +213,25 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
for (uint8_t i=0; i<ARRAY_SIZE(LED_GREEN); i++) {
rgb_matrix_set_color(LED_GREEN[i], RGB_GREEN);
}

rgb_matrix_set_color(LED_ESC, RGB_RED);

rgb_matrix_set_color(LED_LWIN, RGB_BLUE);
break;

case _MO2:
// Paddle game
if (!game_start) {
srand((unsigned int)timer_read());

// Store user light settings
last_hsv = rgb_matrix_get_hsv();
rgb_matrix_sethsv_noeeprom(0, 0, 0);

rgb_value.r = 0xff;
rgb_value.g = 0x00;
rgb_value.b = 0x00;

paddle_pos_full = 8;
paddle_lives = 4;
bounce_count = 0;
Expand All @@ -243,17 +244,17 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

game_start = true;
}

// Set level indicator
if (level_number < 12) {
rgb_matrix_set_color(GAME_R0[level_number], RGB_BLUE);
}

// Set life bar
for (uint8_t i=0; i < paddle_lives ; i++) {
rgb_matrix_set_color(GAME_LIVES[i], RGB_GREEN);
}

uint8_t paddle_pos = paddle_pos_full >> 1;

if (damage_count > 0) {
Expand All @@ -270,14 +271,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
if (damage_count == 0) {
ball_timer = timer_read();
}


} else if (paddle_lives == 0) {
// Game over
for (uint8_t i=0; i<ARRAY_SIZE(LED_GAME_OVER); i++) {
rgb_matrix_set_color(LED_GAME_OVER[i], RGB_RED);
}

} else if (level_number >= 12) {
// You win
if (rgb_value.r == 0xff && rgb_value.g < 0xff) {
Expand All @@ -290,23 +291,23 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
if (rgb_value.g > 0) { --rgb_value.g; }
else { ++rgb_value.r; }
}

for (uint8_t i=0; i < 3 ; i++) {
rgb_matrix_set_color(GAME_PADDLE[paddle_pos + i], rgb_value.r, rgb_value.g, rgb_value.b);
}
rgb_matrix_set_color(GAME_SMILE1[paddle_pos], rgb_value.r, rgb_value.g, rgb_value.b);
rgb_matrix_set_color(GAME_SMILE1[paddle_pos + 3], rgb_value.r, rgb_value.g, rgb_value.b);
rgb_matrix_set_color(GAME_SMILE2[paddle_pos], rgb_value.r, rgb_value.g, rgb_value.b);
rgb_matrix_set_color(GAME_SMILE2[paddle_pos + 3], rgb_value.r, rgb_value.g, rgb_value.b);

} else {
// normal game loop

// Set paddle position
for (uint8_t i=0; i < 3 ; i++) {
rgb_matrix_set_color(GAME_PADDLE[paddle_pos + i], RGB_GREEN);
}

// Ball movement logic happens at intervals
if (timer_elapsed(ball_timer) > GAME_TIMER[level_number]) {
for (int i=0; i<2; ++i) {
Expand All @@ -331,7 +332,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
if (ball[i].y > 4) {
// Remove a life if ball isn't returned and isn't enemy
if (!ball[i].enemy) {
hurt_paddle();
hurt_paddle();
i = 2;
} else {
ball[i].on = false;
Expand All @@ -351,7 +352,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
}
ball_timer = timer_read();
}

// Other ball stuff
for (int i=0; i<2; ++i) {
if (ball[i].on) {
Expand Down Expand Up @@ -410,20 +411,20 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
break;
}
}
}
}
}


break;

default:
fn_active = false;
if (game_start) {
// Reset lighting settings
game_start = false;
rgb_matrix_sethsv_noeeprom(last_hsv.h, last_hsv.s, last_hsv.v);
}
break;
break;
}

if (IS_HOST_LED_ON(USB_LED_CAPS_LOCK)) {
Expand Down
Loading

0 comments on commit 32204f4

Please sign in to comment.