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/nightly_boards/octopad/config.h | 4 -- keyboards/nightly_boards/octopad/encoder_action.c | 47 ---------------- keyboards/nightly_boards/octopad/encoder_action.h | 23 -------- keyboards/nightly_boards/octopad/info.json | 6 +-- .../octopad/keymaps/default/keymap.c | 15 +++--- .../octopad/keymaps/default/rules.mk | 1 + .../nightly_boards/octopad/keymaps/via/keymap.c | 62 +++++----------------- .../nightly_boards/octopad/keymaps/via/rules.mk | 3 +- keyboards/nightly_boards/octopad/octopad.c | 28 ---------- keyboards/nightly_boards/octopad/octopad.h | 20 ------- keyboards/nightly_boards/octopad/rules.mk | 3 -- 11 files changed, 24 insertions(+), 188 deletions(-) delete mode 100644 keyboards/nightly_boards/octopad/encoder_action.c delete mode 100644 keyboards/nightly_boards/octopad/encoder_action.h create mode 100644 keyboards/nightly_boards/octopad/keymaps/default/rules.mk delete mode 100644 keyboards/nightly_boards/octopad/octopad.c delete mode 100644 keyboards/nightly_boards/octopad/octopad.h (limited to 'keyboards/nightly_boards/octopad') diff --git a/keyboards/nightly_boards/octopad/config.h b/keyboards/nightly_boards/octopad/config.h index 10aebd0d07..b8b9535fb0 100644 --- a/keyboards/nightly_boards/octopad/config.h +++ b/keyboards/nightly_boards/octopad/config.h @@ -28,10 +28,6 @@ along with this program. If not, see . #define RGBLIGHT_EFFECT_ALTERNATING #define RGBLIGHT_EFFECT_TWINKLE -/* Encoders */ -#define ENCODERS_CW_KEY { { 3, 2 },{ 1, 2 } } -#define ENCODERS_CCW_KEY { { 2, 2 },{ 0, 2 } } - /* Audio */ #define AUDIO_PIN B5 diff --git a/keyboards/nightly_boards/octopad/encoder_action.c b/keyboards/nightly_boards/octopad/encoder_action.c deleted file mode 100644 index 522fb58d5a..0000000000 --- a/keyboards/nightly_boards/octopad/encoder_action.c +++ /dev/null @@ -1,47 +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 . - */ - -#include "encoder_action.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); -} diff --git a/keyboards/nightly_boards/octopad/encoder_action.h b/keyboards/nightly_boards/octopad/encoder_action.h deleted file mode 100644 index fb22632632..0000000000 --- a/keyboards/nightly_boards/octopad/encoder_action.h +++ /dev/null @@ -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 . - */ - -#pragma once - -#include "quantum.h" - -void encoder_action_unregister(void); - -void encoder_action_register(uint8_t index, bool clockwise); \ No newline at end of file diff --git a/keyboards/nightly_boards/octopad/info.json b/keyboards/nightly_boards/octopad/info.json index 6a889bece6..0f1463e986 100644 --- a/keyboards/nightly_boards/octopad/info.json +++ b/keyboards/nightly_boards/octopad/info.json @@ -10,7 +10,7 @@ }, "matrix_pins": { "cols": ["F1", "F0", "D0", "D1", "B1"], - "rows": ["B2", "B3", null] + "rows": ["B2", "B3"] }, "diode_direction": "COL2ROW", "encoder": { @@ -30,13 +30,9 @@ "layouts": { "LAYOUT": { "layout": [ - {"matrix": [2, 0], "x": 0, "y": 0}, {"matrix": [0, 4], "x": 1, "y": 0}, - {"matrix": [2, 1], "x": 2, "y": 0}, - {"matrix": [2, 2], "x": 3.5, "y": 0}, {"matrix": [1, 4], "x": 4.5, "y": 0}, - {"matrix": [2, 3], "x": 5.5, "y": 0}, {"matrix": [0, 0], "x": 1.25, "y": 1.25}, {"matrix": [0, 1], "x": 2.25, "y": 1.25}, diff --git a/keyboards/nightly_boards/octopad/keymaps/default/keymap.c b/keyboards/nightly_boards/octopad/keymaps/default/keymap.c index 7025c89375..78613e55ba 100644 --- a/keyboards/nightly_boards/octopad/keymaps/default/keymap.c +++ b/keyboards/nightly_boards/octopad/keymaps/default/keymap.c @@ -17,16 +17,15 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - /* Base */ - /* ENC1_CCW, ENC1_P, ENC1_CW, ENC2_CCW, ENC2_P, ENC2_CW, - MACRO1, MACRO2, MACRO3, MACRO4, - MACRO5, MACRO6, MACRO7, MACRO8 - */ [0] = LAYOUT( - KC_VOLD, KC_ESC, KC_VOLU, KC_BRID, QK_BOOT, KC_BRIU, + KC_ESC, QK_BOOT, KC_Q, KC_W, KC_E, KC_R, KC_A, KC_S, KC_D, KC_F - - ), + ) }; +#ifdef ENCODER_MAP_ENABLE +const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = { + [0] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(KC_BRID, KC_BRIU) } +}; +#endif diff --git a/keyboards/nightly_boards/octopad/keymaps/default/rules.mk b/keyboards/nightly_boards/octopad/keymaps/default/rules.mk new file mode 100644 index 0000000000..ee32568148 --- /dev/null +++ b/keyboards/nightly_boards/octopad/keymaps/default/rules.mk @@ -0,0 +1 @@ +ENCODER_MAP_ENABLE = yes diff --git a/keyboards/nightly_boards/octopad/keymaps/via/keymap.c b/keyboards/nightly_boards/octopad/keymaps/via/keymap.c index 44c2d63cc7..2cb3b7ed99 100644 --- a/keyboards/nightly_boards/octopad/keymaps/via/keymap.c +++ b/keyboards/nightly_boards/octopad/keymaps/via/keymap.c @@ -17,57 +17,21 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - /* Base */ - /* ENC1_CCW, ENC1_P, ENC1_CW, ENC2_CCW, ENC2_P, ENC2_CW, - MACRO1, MACRO2, MACRO3, MACRO4, - MACRO5, MACRO6, MACRO7, MACRO8 - */ [0] = LAYOUT( - KC_VOLD, KC_ESC, KC_VOLU, KC_BRID, QK_BOOT, KC_BRIU, + KC_ESC, QK_BOOT, KC_Q, KC_W, KC_E, KC_R, KC_A, KC_S, KC_D, KC_F - - ), - [1] = LAYOUT( - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS - - ), - [2] = LAYOUT( - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS - - ), - [3] = LAYOUT( - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS - - ), - [4] = LAYOUT( - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS - - ), - [5] = LAYOUT( - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS - - ), - [6] = LAYOUT( - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS - - ), - [7] = LAYOUT( - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS - ), + [1 ... 7] = LAYOUT( + _______, _______, + _______, _______, _______, _______, + _______, _______, _______, _______ + ) +}; + +#ifdef ENCODER_MAP_ENABLE +const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = { + [0] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(KC_BRID, KC_BRIU) }, + [1 ... 7] = { ENCODER_CCW_CW(_______, _______), ENCODER_CCW_CW(_______, _______) } }; +#endif diff --git a/keyboards/nightly_boards/octopad/keymaps/via/rules.mk b/keyboards/nightly_boards/octopad/keymaps/via/rules.mk index 43061db1dd..1189f4ad19 100644 --- a/keyboards/nightly_boards/octopad/keymaps/via/rules.mk +++ b/keyboards/nightly_boards/octopad/keymaps/via/rules.mk @@ -1,2 +1,3 @@ VIA_ENABLE = yes -LTO_ENABLE = yes \ No newline at end of file +LTO_ENABLE = yes +ENCODER_MAP_ENABLE = yes diff --git a/keyboards/nightly_boards/octopad/octopad.c b/keyboards/nightly_boards/octopad/octopad.c deleted file mode 100644 index e05782677e..0000000000 --- a/keyboards/nightly_boards/octopad/octopad.c +++ /dev/null @@ -1,28 +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 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 "octopad.h" - -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; -}; diff --git a/keyboards/nightly_boards/octopad/octopad.h b/keyboards/nightly_boards/octopad/octopad.h deleted file mode 100644 index 33cf8e0b68..0000000000 --- a/keyboards/nightly_boards/octopad/octopad.h +++ /dev/null @@ -1,20 +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 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 . - */ - -#pragma once - -#include "quantum.h" -#include "encoder_action.h" diff --git a/keyboards/nightly_boards/octopad/rules.mk b/keyboards/nightly_boards/octopad/rules.mk index d36fbdc860..660f934499 100644 --- a/keyboards/nightly_boards/octopad/rules.mk +++ b/keyboards/nightly_boards/octopad/rules.mk @@ -12,6 +12,3 @@ BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow AUDIO_ENABLE = yes # Audio output ENCODER_ENABLE = yes # Enable Rotary Encoders - -# Added encoder Action -SRC += encoder_action.c -- cgit v1.2.3