1
0
Fork 0

Remove encoder in-matrix workaround code (#20389)

This commit is contained in:
jack 2023-06-19 09:46:27 -06:00 committed by GitHub
parent 74fbd5a031
commit c4a67d3f33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
241 changed files with 1106 additions and 5235 deletions

View file

@ -1,52 +0,0 @@
/* Copyright 2020 Neil Brian Ramirez
* Copyright 2021 drashna jael're (@drashna)
* Copyright 2021 uybv
*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "encoder_actions.h"
#ifdef ENCODER_ENABLE
static uint8_t encoder_state[NUM_ENCODERS] = {0};
static keypos_t encoder_cw[NUM_ENCODERS] = ENCODERS_CW_KEY;
static keypos_t encoder_ccw[NUM_ENCODERS] = ENCODERS_CCW_KEY;
void encoder_action_unregister(void) {
for (int index = 0; index < NUM_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(),
.type = KEY_EVENT
};
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(),
.type = KEY_EVENT
};
encoder_state[index] = (clockwise ^ 1) | (clockwise << 1);
action_exec(encoder_event);
}
#endif

View file

@ -1,23 +0,0 @@
/* Copyright 2020 Neil Brian Ramirez
*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "quantum.h"
void encoder_action_unregister(void);
void encoder_action_register(uint8_t index, bool clockwise);

View file

@ -63,45 +63,6 @@
{"matrix": [5, 3], "x": 3, "y": 5.5},
{"matrix": [4, 4], "x": 4, "y": 4.5, "h": 2}
]
},
"LAYOUT_numpad_6x5_encoder": {
"layout": [
{"matrix": [0, 0], "x": 0, "y": 0.75},
{"matrix": [0, 1], "x": 1, "y": 0.75},
{"matrix": [0, 2], "x": 2, "y": 0.75},
{"matrix": [0, 3], "x": 3, "y": 0.75},
{"matrix": [0, 4], "x": 4, "y": 0.75},
{"matrix": [3, 4], "x": 3.75, "y": 0, "w": 0.75, "h": 0.75},
{"matrix": [5, 4], "x": 4.5, "y": 0, "w": 0.75, "h": 0.75},
{"matrix": [1, 0], "x": 0, "y": 2.25},
{"matrix": [1, 1], "x": 1, "y": 2.25},
{"matrix": [1, 2], "x": 2, "y": 2.25},
{"matrix": [1, 3], "x": 3, "y": 2.25},
{"matrix": [1, 4], "x": 4, "y": 2.25},
{"matrix": [2, 0], "x": 0, "y": 3.25},
{"matrix": [2, 1], "x": 1, "y": 3.25},
{"matrix": [2, 2], "x": 2, "y": 3.25},
{"matrix": [2, 3], "x": 3, "y": 3.25},
{"matrix": [3, 0], "x": 0, "y": 4.25},
{"matrix": [3, 1], "x": 1, "y": 4.25},
{"matrix": [3, 2], "x": 2, "y": 4.25},
{"matrix": [3, 3], "x": 3, "y": 4.25},
{"matrix": [2, 4], "x": 4, "y": 3.25, "h": 2},
{"matrix": [4, 0], "x": 0, "y": 5.25},
{"matrix": [4, 1], "x": 1, "y": 5.25},
{"matrix": [4, 2], "x": 2, "y": 5.25},
{"matrix": [4, 3], "x": 3, "y": 5.25},
{"matrix": [5, 0], "x": 0, "y": 6.25},
{"matrix": [5, 1], "x": 1, "y": 6.25, "w": 2},
{"matrix": [5, 3], "x": 3, "y": 6.25},
{"matrix": [4, 4], "x": 4, "y": 5.25, "h": 2}
]
}
}
}

View file

@ -17,32 +17,32 @@
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Base */
[0] = LAYOUT_numpad_6x5_encoder(
KC_ESC , KC_PWR , KC_SLEP, KC_F11 , KC_MUTE, KC_VOLD, KC_VOLU,
[0] = LAYOUT_numpad_6x5(
KC_ESC , KC_PWR , KC_SLEP, KC_F11 , KC_MUTE,
KC_NUM, KC_BSPC, KC_PSLS, KC_PAST, KC_PMNS,
RGB_MOD, KC_P7 , KC_P8 , KC_P9 ,
RGB_RMOD, KC_P4 , KC_P5 , KC_P6 , KC_PPLS,
RGB_TOG, KC_P1 , KC_P2 , KC_P3 ,
MO(1) , KC_P0 , KC_PDOT, KC_PENT
),
[1] = LAYOUT_numpad_6x5_encoder(
_______, _______, _______, _______, KC_MPLY, KC_MPRV, KC_MNXT,
[1] = LAYOUT_numpad_6x5(
_______, _______, _______, _______, KC_MPLY,
_______, _______, _______, _______, _______,
RGB_SPI, RGB_HUI, RGB_SAI, RGB_VAI,
RGB_SPD, RGB_HUD, RGB_SAD, RGB_VAD, _______,
_______, _______, _______, _______,
_______, _______, _______, _______,
_______, _______, _______, QK_BOOT
),
[2] = LAYOUT_numpad_6x5_encoder(
_______, _______, _______, _______, _______, _______, _______,
[2] = LAYOUT_numpad_6x5(
_______, _______, _______, _______, _______,
_______, _______, _______, _______, _______,
_______, _______, _______, _______,
_______, _______, _______, _______, _______,
_______, _______, _______, _______,
_______, _______, _______, _______
),
[3] = LAYOUT_numpad_6x5_encoder(
_______, _______, _______, _______, _______, _______, _______,
[3] = LAYOUT_numpad_6x5(
_______, _______, _______, _______, _______,
_______, _______, _______, _______, _______,
_______, _______, _______, _______,
_______, _______, _______, _______, _______,
@ -50,3 +50,12 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_______, _______, _______, _______
)
};
#ifdef ENCODER_MAP_ENABLE
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
[0] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
[1] = { ENCODER_CCW_CW(_______, _______) },
[2] = { ENCODER_CCW_CW(_______, _______) },
[3] = { ENCODER_CCW_CW(_______, _______) },
};
#endif

View file

@ -0,0 +1 @@
ENCODER_MAP_ENABLE = yes

View file

@ -17,32 +17,32 @@
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Base */
[0] = LAYOUT_numpad_6x5_encoder(
KC_ESC , KC_PWR , KC_SLEP, KC_F11 , KC_MUTE, KC_VOLD, KC_VOLU,
[0] = LAYOUT_numpad_6x5(
KC_ESC , KC_PWR , KC_SLEP, KC_F11 , KC_MUTE,
KC_NUM, KC_BSPC, KC_PSLS, KC_PAST, KC_PMNS,
RGB_MOD, KC_P7 , KC_P8 , KC_P9 ,
RGB_RMOD, KC_P4 , KC_P5 , KC_P6 , KC_PPLS,
RGB_TOG, KC_P1 , KC_P2 , KC_P3 ,
MO(1) , KC_P0 , KC_PDOT, KC_PENT
),
[1] = LAYOUT_numpad_6x5_encoder(
_______, _______, _______, _______, KC_MPLY, KC_MPRV, KC_MNXT,
[1] = LAYOUT_numpad_6x5(
_______, _______, _______, _______, KC_MPLY,
_______, _______, _______, _______, _______,
RGB_SPI, RGB_HUI, RGB_SAI, RGB_VAI,
RGB_SPD, RGB_HUD, RGB_SAD, RGB_VAD, _______,
_______, _______, _______, _______,
_______, _______, _______, _______,
_______, _______, _______, QK_BOOT
),
[2] = LAYOUT_numpad_6x5_encoder(
_______, _______, _______, _______, _______, _______, _______,
[2] = LAYOUT_numpad_6x5(
_______, _______, _______, _______, _______,
_______, _______, _______, _______, _______,
_______, _______, _______, _______,
_______, _______, _______, _______, _______,
_______, _______, _______, _______,
_______, _______, _______, _______
),
[3] = LAYOUT_numpad_6x5_encoder(
_______, _______, _______, _______, _______, _______, _______,
[3] = LAYOUT_numpad_6x5(
_______, _______, _______, _______, _______,
_______, _______, _______, _______, _______,
_______, _______, _______, _______,
_______, _______, _______, _______, _______,
@ -50,3 +50,12 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_______, _______, _______, _______
)
};
#ifdef ENCODER_MAP_ENABLE
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
[0] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
[1] = { ENCODER_CCW_CW(_______, _______) },
[2] = { ENCODER_CCW_CW(_______, _______) },
[3] = { ENCODER_CCW_CW(_______, _______) },
};
#endif

View file

@ -1,2 +1,3 @@
VIA_ENABLE = yes
LTO_ENABLE = yes
ENCODER_MAP_ENABLE = yes

View file

@ -15,5 +15,3 @@ RGB_MATRIX_ENABLE = yes # Use RGB matrix
DEBOUNCE_TYPE = sym_defer_pk
RGB_MATRIX_CUSTOM_KB = yes
SRC += encoder_actions.c

View file

@ -15,7 +15,6 @@
*/
#include "quantum.h"
#include "encoder_actions.h"
#ifdef RGB_MATRIX_ENABLE
@ -45,14 +44,3 @@ led_config_t g_led_config = { {
} };
#endif
void matrix_scan_kb(void) {
encoder_action_unregister();
matrix_scan_user();
}
bool encoder_update_kb(uint8_t index, bool clockwise) {
if (!encoder_update_user(index, clockwise)) { return false; }
encoder_action_register(index, clockwise);
return true;
};