summary refs log tree commit diff
path: root/keyboards/wekey
diff options
context:
space:
mode:
authorjack <0x6A73@pm.me>2023-06-19 09:46:27 -0600
committerGitHub <noreply@github.com>2023-06-19 09:46:27 -0600
commitc4a67d3f3302f3096bb6b15921c9587643164ba9 (patch)
treebf10e469333ba42b708e76cfc085eb450d92359e /keyboards/wekey
parent74fbd5a0313769655914166bc872d41461509bd3 (diff)
Remove encoder in-matrix workaround code (#20389)
Diffstat (limited to 'keyboards/wekey')
-rw-r--r--keyboards/wekey/we27/encoder_actions.c52
-rw-r--r--keyboards/wekey/we27/encoder_actions.h23
-rw-r--r--keyboards/wekey/we27/info.json39
-rw-r--r--keyboards/wekey/we27/keymaps/default/keymap.c27
-rw-r--r--keyboards/wekey/we27/keymaps/default/rules.mk1
-rw-r--r--keyboards/wekey/we27/keymaps/via/keymap.c27
-rw-r--r--keyboards/wekey/we27/keymaps/via/rules.mk1
-rw-r--r--keyboards/wekey/we27/rules.mk2
-rw-r--r--keyboards/wekey/we27/we27.c12
9 files changed, 38 insertions, 146 deletions
diff --git a/keyboards/wekey/we27/encoder_actions.c b/keyboards/wekey/we27/encoder_actions.c
deleted file mode 100644
index 87a53676e6..0000000000
--- a/keyboards/wekey/we27/encoder_actions.c
+++ /dev/null
@@ -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
diff --git a/keyboards/wekey/we27/encoder_actions.h b/keyboards/wekey/we27/encoder_actions.h
deleted file mode 100644
index 1a7fb72014..0000000000
--- a/keyboards/wekey/we27/encoder_actions.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 <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-
-#include "quantum.h"
-
-void encoder_action_unregister(void);
-
-void encoder_action_register(uint8_t index, bool clockwise);
diff --git a/keyboards/wekey/we27/info.json b/keyboards/wekey/we27/info.json
index 7fa45a13ab..62b477bce5 100644
--- a/keyboards/wekey/we27/info.json
+++ b/keyboards/wekey/we27/info.json
@@ -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}
-            ]
         }
     }
 }
diff --git a/keyboards/wekey/we27/keymaps/default/keymap.c b/keyboards/wekey/we27/keymaps/default/keymap.c
index 741b25e3e7..c16cef9dd6 100644
--- a/keyboards/wekey/we27/keymaps/default/keymap.c
+++ b/keyboards/wekey/we27/keymaps/default/keymap.c
@@ -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
diff --git a/keyboards/wekey/we27/keymaps/default/rules.mk b/keyboards/wekey/we27/keymaps/default/rules.mk
new file mode 100644
index 0000000000..ee32568148
--- /dev/null
+++ b/keyboards/wekey/we27/keymaps/default/rules.mk
@@ -0,0 +1 @@
+ENCODER_MAP_ENABLE = yes
diff --git a/keyboards/wekey/we27/keymaps/via/keymap.c b/keyboards/wekey/we27/keymaps/via/keymap.c
index 741b25e3e7..c16cef9dd6 100644
--- a/keyboards/wekey/we27/keymaps/via/keymap.c
+++ b/keyboards/wekey/we27/keymaps/via/keymap.c
@@ -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
diff --git a/keyboards/wekey/we27/keymaps/via/rules.mk b/keyboards/wekey/we27/keymaps/via/rules.mk
index 36b7ba9cbc..1189f4ad19 100644
--- a/keyboards/wekey/we27/keymaps/via/rules.mk
+++ b/keyboards/wekey/we27/keymaps/via/rules.mk
@@ -1,2 +1,3 @@
 VIA_ENABLE = yes
 LTO_ENABLE = yes
+ENCODER_MAP_ENABLE = yes
diff --git a/keyboards/wekey/we27/rules.mk b/keyboards/wekey/we27/rules.mk
index c76f29ff75..e799183b38 100644
--- a/keyboards/wekey/we27/rules.mk
+++ b/keyboards/wekey/we27/rules.mk
@@ -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
diff --git a/keyboards/wekey/we27/we27.c b/keyboards/wekey/we27/we27.c
index 9f2b85d95f..03ec6f5512 100644
--- a/keyboards/wekey/we27/we27.c
+++ b/keyboards/wekey/we27/we27.c
@@ -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;
-};