GMMK Pro: fix unintended volume encoder taps (#17129)

This commit is contained in:
Andre Brait 2022-09-24 18:37:04 +02:00 committed by GitHub
parent 94d5fe6f90
commit 32204f4a03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 83 additions and 125 deletions

View file

@ -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;
}

View file

@ -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

View file

@ -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

View file

@ -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:

View file

@ -1,6 +1,4 @@
# Enable additional features.
DEBOUNCE_TYPE = sym_defer_pk
# Disabling MouseKey because it breaks my KVM switch
MOUSEKEY_ENABLE = no

View file

@ -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

View file

@ -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
@ -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 = {

View file

@ -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;
}

View file

@ -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

View file

@ -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) {

View file

@ -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

View file

@ -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;
}

View file

@ -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

View file

@ -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

View file

@ -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;
}

View file

@ -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) {

View file

@ -86,20 +86,20 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
),
[_MO2] = LAYOUT(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, TG(_MO2), _______, _______, _______, _______
),
[_MO3] = LAYOUT(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______
),
@ -128,7 +128,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
}
}
break;
case _BASE:
default:
if ( clockwise ) {
@ -136,9 +136,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
} 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
@ -149,7 +150,7 @@ 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;
@ -157,7 +158,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
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);
@ -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;
@ -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; }
@ -212,17 +213,17 @@ 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);
@ -230,7 +231,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
rgb_value.r = 0xff;
rgb_value.g = 0x00;
rgb_value.b = 0x00;
paddle_pos_full = 8;
paddle_lives = 4;
bounce_count = 0;
@ -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) {
@ -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) {
@ -290,7 +291,7 @@ 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);
}
@ -298,15 +299,15 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
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) {
@ -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;
@ -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) {
@ -410,12 +411,12 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
break;
}
}
}
}
}
break;
default:
fn_active = false;
if (game_start) {
@ -423,7 +424,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
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)) {

View file

@ -76,7 +76,7 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
set_mods(mod_state); // Add back in the CTRL key - so ctrl-key will work if ctrl was never released after paging.
} else if (get_mods() & MOD_MASK_SHIFT) {
uint8_t mod_state = get_mods();
unregister_mods(MOD_MASK_SHIFT);
unregister_mods(MOD_MASK_SHIFT);
if (clockwise) {
#ifdef MOUSEKEY_ENABLE // If using the mouse scroll - make sure MOUSEKEY is enabled
tap_code(KC_MS_WH_DOWN);
@ -96,7 +96,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
@ -108,17 +109,17 @@ static void set_rgb_scroll_leds_off(void);
// Called on powerup and is the last _init that is run.
void keyboard_post_init_user(void) {
int mods[35] = {0,2,3,4,5,11,17,33,49,55,65,95,97,79,94,85,93,96,90,69,92,67,76,80,91,75,86,68,77,81,92,28,34,39,44};
int j;
/* output each array element's value */
for (j = 0; j < 35; j++ ) {
g_led_config.flags[mods[j]] = LED_FLAG_MODIFIER;
}
if (!rgb_matrix_is_enabled()) {
rgb_matrix_enable();
if (!rgb_matrix_is_enabled()) {
rgb_matrix_enable();
#ifdef CONSOLE_ENABLE
uprintf("ERROR! RGB Matrix Enabled and wrote to EEPROM! -How was the RGB Matrix Disabled?");
#endif
@ -205,15 +206,15 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
case LED_EQL:
rgb_matrix_mode(RGB_MATRIX_TYPING_HEATMAP);
break;
#endif //RGB_MATRIX_FRAMEBUFFER_EFFECTS
#endif //RGB_MATRIX_FRAMEBUFFER_EFFECTS
case QMKBEST:
if (record->event.pressed) { // when keycode QMKBEST is pressed
SEND_STRING("QMK rocks");
} else { // when keycode QMKBEST key is released
} else { // when keycode QMKBEST key is released
SEND_STRING("!!");
}
break;
}
}
return true;
}
@ -245,7 +246,7 @@ void rgb_matrix_indicators_user(void) {
// 87, led 07 88, led 18
// 91, led 08 92, led 19
static void set_rgb_caps_leds_on() {
static void set_rgb_caps_leds_on() {
rgb_matrix_set_color(0, 255, 0, 0); //Escape Key
rgb_matrix_set_color(3, 255, 0, 0); //capslock key
rgb_matrix_set_color(5, 255, 0, 0); //Left CTRL key
@ -289,11 +290,11 @@ static void set_rgb_caps_leds_off() {
rgb_matrix_set_color(92, 0, 0, 0); //Right LED 19
}
static void set_rgb_scroll_leds_on() {
static void set_rgb_scroll_leds_on() {
rgb_matrix_set_color(72, 255, 255, 255); // Under Rotary (HOME)
}
static void set_rgb_scroll_leds_off() {
static void set_rgb_scroll_leds_off() {
rgb_matrix_set_color(72, 0, 0, 0); // Under Rotary (HOME)
}

View file

@ -76,14 +76,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

View file

@ -53,5 +53,6 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
} else {
tap_code(KC_MS_WH_LEFT);
}
return true;
//return true; //set to return false to counteract enabled encoder in pro.c
return false;
}

View file

@ -69,5 +69,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;
}

View file

@ -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

View file

@ -102,7 +102,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

View file

@ -78,14 +78,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

View file

@ -84,7 +84,8 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
}
break;
}
return true;
//return true; //set to return false to counteract enabled encoder in pro.c
return false;
}
#endif // ENCODER_ENABLE