From c4a67d3f3302f3096bb6b15921c9587643164ba9 Mon Sep 17 00:00:00 2001 From: jack <0x6A73@pm.me> Date: Mon, 19 Jun 2023 09:46:27 -0600 Subject: Remove encoder in-matrix workaround code (#20389) --- keyboards/wuque/mammoth20x/config.h | 4 -- keyboards/wuque/mammoth20x/info.json | 2 - .../wuque/mammoth20x/keymaps/default/keymap.c | 4 +- keyboards/wuque/mammoth20x/keymaps/via/keymap.c | 17 ++++-- keyboards/wuque/mammoth20x/keymaps/via/rules.mk | 1 + keyboards/wuque/mammoth20x/mammoth20x.c | 62 ---------------------- 6 files changed, 16 insertions(+), 74 deletions(-) delete mode 100644 keyboards/wuque/mammoth20x/mammoth20x.c (limited to 'keyboards/wuque/mammoth20x') diff --git a/keyboards/wuque/mammoth20x/config.h b/keyboards/wuque/mammoth20x/config.h index c35fac65d6..db5a8d534e 100644 --- a/keyboards/wuque/mammoth20x/config.h +++ b/keyboards/wuque/mammoth20x/config.h @@ -22,7 +22,3 @@ along with this program. If not, see . /* Locking resynchronize hack */ #define LOCKING_RESYNC_ENABLE - -// Note: array is { col, row ) -#define ENCODERS_CW_KEY { { 3, 2 } } -#define ENCODERS_CCW_KEY { { 3, 4 } } diff --git a/keyboards/wuque/mammoth20x/info.json b/keyboards/wuque/mammoth20x/info.json index 3c0c0e29b8..f7917ae26d 100644 --- a/keyboards/wuque/mammoth20x/info.json +++ b/keyboards/wuque/mammoth20x/info.json @@ -29,9 +29,7 @@ {"matrix": [0, 0], "x": 0, "y": 0}, {"matrix": [0, 1], "x": 1, "y": 0}, {"matrix": [0, 2], "x": 2, "y": 0}, - {"matrix": [2, 3], "x": 3, "y": 0, "w": 0.5}, {"matrix": [0, 3], "x": 3.5, "y": 0}, - {"matrix": [4, 3], "x": 4.5, "y": 0, "w": 0.5}, {"matrix": [1, 0], "x": 0, "y": 1}, {"matrix": [1, 1], "x": 1, "y": 1}, diff --git a/keyboards/wuque/mammoth20x/keymaps/default/keymap.c b/keyboards/wuque/mammoth20x/keymaps/default/keymap.c index e19b3bc172..5f444bbff3 100644 --- a/keyboards/wuque/mammoth20x/keymaps/default/keymap.c +++ b/keyboards/wuque/mammoth20x/keymaps/default/keymap.c @@ -18,7 +18,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [0] = LAYOUT( - KC_ESC, KC_PAUS, KC_DEL, KC_VOLU, KC_MUTE, KC_VOLD, + KC_ESC, KC_PAUS, KC_DEL, KC_MUTE, KC_LNUM, KC_PSLS, KC_PAST, KC_PMNS, KC_P7, KC_P8, KC_P9, KC_P4, KC_P5, KC_P6, KC_PPLS, @@ -26,7 +26,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_P0, KC_PDOT, KC_PENT ), [1] = LAYOUT( - _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, diff --git a/keyboards/wuque/mammoth20x/keymaps/via/keymap.c b/keyboards/wuque/mammoth20x/keymaps/via/keymap.c index e5fe34fd7b..76db645d0e 100644 --- a/keyboards/wuque/mammoth20x/keymaps/via/keymap.c +++ b/keyboards/wuque/mammoth20x/keymaps/via/keymap.c @@ -18,7 +18,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [0] = LAYOUT( - KC_ESC, KC_PAUS, KC_DEL, KC_VOLD, KC_MUTE, KC_VOLU, + KC_ESC, KC_PAUS, KC_DEL, KC_MUTE, KC_NUM, KC_PSLS, KC_PAST, KC_PMNS, KC_P7, KC_P8, KC_P9, KC_P4, KC_P5, KC_P6, KC_PPLS, @@ -26,7 +26,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_P0, KC_PDOT, KC_PENT ), [1] = LAYOUT( - _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, @@ -34,7 +34,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______, _______ ), [2] = LAYOUT( - _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, @@ -42,7 +42,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______, _______ ), [3] = LAYOUT( - _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, @@ -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 diff --git a/keyboards/wuque/mammoth20x/keymaps/via/rules.mk b/keyboards/wuque/mammoth20x/keymaps/via/rules.mk index 36b7ba9cbc..1189f4ad19 100644 --- a/keyboards/wuque/mammoth20x/keymaps/via/rules.mk +++ b/keyboards/wuque/mammoth20x/keymaps/via/rules.mk @@ -1,2 +1,3 @@ VIA_ENABLE = yes LTO_ENABLE = yes +ENCODER_MAP_ENABLE = yes diff --git a/keyboards/wuque/mammoth20x/mammoth20x.c b/keyboards/wuque/mammoth20x/mammoth20x.c deleted file mode 100644 index eeaea79c71..0000000000 --- a/keyboards/wuque/mammoth20x/mammoth20x.c +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright 2021 wuquestudio - * - * 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 2 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 . - */ - -#include "quantum.h" - -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); -} - -void matrix_scan_kb(void) -{ - encoder_action_unregister(); - matrix_scan_user(); -} - -bool encoder_update_kb(uint8_t index, bool clockwise) -{ - encoder_action_register(index, clockwise); - return true; -}; -- cgit v1.2.3