e6fa351d3bb40bc5023850a55f9e47c72f40bdb5

Author
Bertrand Le Roy <beleroy@microsoft.com>
Committer
GitHub <noreply@github.com>
Date

Message

DecenTKL numpad (#24696)

Diff

This diff is truncated to protect this page.

  1diff --git a/keyboards/decent/numpad/config.h b/keyboards/decent/numpad/config.h
  2new file mode 100644
  3index 0000000000000000000000000000000000000000..f5114d3ce03a16e1ec993a1a94ffc7579946e362
  4--- /dev/null
  5+++ b/keyboards/decent/numpad/config.h
  6@@ -0,0 +1,8 @@
  7+// Copyright 2023 QMK
  8+// SPDX-License-Identifier: GPL-2.0-or-later
  9+
 10+#pragma once
 11+
 12+#define JOYSTICK_AXIS_COUNT 4
 13+#define JOYSTICK_BUTTON_COUNT 10
 14+#define JOYSTICK_HAS_HAT
 15diff --git a/keyboards/decent/numpad/keyboard.json b/keyboards/decent/numpad/keyboard.json
 16new file mode 100644
 17index 0000000000000000000000000000000000000000..eb45c72232ff80e709ce5cb8c5b4aa4fb9253a35
 18--- /dev/null
 19+++ b/keyboards/decent/numpad/keyboard.json
 20@@ -0,0 +1,148 @@
 21+{
 22+    "manufacturer": "Bertrand Le roy",
 23+    "keyboard_name": "DecenTKL NumPad",
 24+    "maintainer": "bleroy",
 25+    "url": "https://github.com/bleroy/3d-junkyard/blob/main/DecenTKL/",
 26+    "tags": ["ansi", "numpad", "rgb", "atari", "joystick"],
 27+    "bootloader": "rp2040",
 28+    "diode_direction": "COL2ROW",
 29+    "features": {
 30+        "bootmagic": true,
 31+        "rgb_matrix": true,
 32+        "extrakey": true,
 33+        "mousekey": true,
 34+        "joystick": true
 35+    },
 36+    "matrix_pins": {
 37+        "cols": ["GP0", "GP1", "GP2", "GP3"],
 38+        "rows": ["GP4", "GP5", "GP6", "GP7", "GP8", "GP9"]
 39+    },
 40+    "processor": "RP2040",
 41+    "usb": {
 42+        "device_version": "1.0.0",
 43+        "pid": "0x0000",
 44+        "vid": "0xFEED"
 45+    },
 46+    "ws2812": {
 47+        "pin": "GP20",
 48+        "driver": "vendor"
 49+    },
 50+    "bootmagic": {
 51+        "matrix": [1, 0]
 52+    },
 53+    "layouts": {
 54+        "LAYOUT": {
 55+            "layout": [
 56+                {"matrix": [0, 0], "x": 0.75, "y": 0, "label": "F11"},
 57+                {"matrix": [0, 1], "x": 2.25, "y": 0, "label": "F12"},
 58+
 59+                {"matrix": [1, 0], "x": 0, "y": 1, "label": "Num"},
 60+                {"matrix": [1, 1], "x": 1, "y": 1, "label": "/"},
 61+                {"matrix": [1, 2], "x": 2, "y": 1, "label": "*"},
 62+                {"matrix": [1, 3], "x": 3, "y": 1, "label": "-"},
 63+
 64+                {"matrix": [2, 0], "x": 0, "y": 2, "label": "7"},
 65+                {"matrix": [2, 1], "x": 1, "y": 2, "label": "8"},
 66+                {"matrix": [2, 2], "x": 2, "y": 2, "label": "9"},
 67+                {"matrix": [2, 3], "x": 3, "y": 2, "h": 2, "label": "+"},
 68+
 69+                {"matrix": [3, 0], "x": 0, "y": 3, "label": "4"},
 70+                {"matrix": [3, 1], "x": 1, "y": 3, "label": "5"},
 71+                {"matrix": [3, 2], "x": 2, "y": 3, "label": "6"},
 72+
 73+                {"matrix": [4, 0], "x": 0, "y": 4, "label": "1"},
 74+                {"matrix": [4, 1], "x": 1, "y": 4, "label": "2"},
 75+                {"matrix": [4, 2], "x": 2, "y": 4, "label": "3"},
 76+                {"matrix": [4, 3], "x": 3, "y": 4, "h": 2, "label": "Enter"},
 77+
 78+                {"matrix": [5, 0], "x": 0, "y": 5, "w": 2, "label": "0"},
 79+                {"matrix": [5, 2], "x": 2, "y": 5, "label": "."}
 80+            ]
 81+        }
 82+    },
 83+    "rgb_matrix": {
 84+        "center_point": [37, 42],
 85+        "max_brightness": 125,
 86+        "sleep": true,
 87+        "animations": {
 88+            "alphas_mods": true,
 89+            "band_pinwheel_sat": true,
 90+            "band_pinwheel_val": true,
 91+            "band_sat": true,
 92+            "band_spiral_sat": true,
 93+            "band_spiral_val": true,
 94+            "band_val": true,
 95+            "breathing": true,
 96+            "cycle_all": true,
 97+            "cycle_left_right": true,
 98+            "cycle_out_in": true,
 99+            "cycle_out_in_dual": true,
100+            "cycle_pinwheel": true,
101+            "cycle_spiral": true,
102+            "cycle_up_down": true,
103+            "digital_rain": true,
104+            "dual_beacon": true,
105+            "flower_blooming": true,
106+            "gradient_left_right": true,
107+            "gradient_up_down": true,
108+            "hue_breathing": true,
109+            "hue_pendulum": true,
110+            "hue_wave": true,
111+            "jellybean_raindrops": true,
112+            "multisplash": true,
113+            "pixel_flow": true,
114+            "pixel_fractal": true,
115+            "pixel_rain": true,
116+            "rainbow_beacon": true,
117+            "rainbow_moving_chevron": true,
118+            "rainbow_pinwheels": true,
119+            "raindrops": true,
120diff --git a/keyboards/decent/numpad/keymaps/default/keymap.c b/keyboards/decent/numpad/keymaps/default/keymap.c
121new file mode 100644
122index 0000000000000000000000000000000000000000..c450b186d9eeeb815e060287e8fa9d41b5531868
123--- /dev/null
124+++ b/keyboards/decent/numpad/keymaps/default/keymap.c
125@@ -0,0 +1,41 @@
126+// Copyright 2023 QMK
127+// SPDX-License-Identifier: GPL-2.0-or-later
128+
129+#include QMK_KEYBOARD_H
130+
131+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
132+    /*
133+    *     /─────/─────/
134+    *    /F11  /F12  /
135+    *   /─────/─────/
136+    * ┌───┬───┬───┬───┐
137+    * │Num│ / │ * │ - │
138+    * ├───┼───┼───┼───┤
139+    * │ 7 │ 8 │ 9 │ + │
140+    * ├───┼───┼───┤   │
141+    * │ 4 │ 5 │ 6 │   │
142+    * ├───┼───┼───┼───┤
143+    * │ 1 │ 2 │ 3 │Ent│
144+    * ├───┴───┼───┤ er│
145+    * │ 0     │ . │   │
146+    * └───────┴───┴───┘
147+    */
148+    [0] = LAYOUT(
149+        KC_F11,  KC_F12,
150+
151+        MO(1),   KC_KP_SLASH, KC_KP_ASTERISK, KC_KP_MINUS,
152+        KC_KP_7, KC_KP_8,     KC_KP_9,        KC_KP_PLUS,
153+        KC_KP_4, KC_KP_5,     KC_KP_6,
154+        KC_KP_1, KC_KP_2,     KC_KP_3,        KC_KP_ENTER,
155+        KC_KP_0,              KC_KP_DOT
156+    ),
157+    [1] = LAYOUT(
158+        S(KC_F11), S(KC_F12),
159+        
160+        _______, _______, _______, RM_VALD,
161+        _______, RM_HUEU, _______, RM_VALU,
162+        RM_SPDD, _______, RM_SPDU,
163+        RM_PREV, RM_HUED, RM_NEXT, QK_BOOT,
164+        RM_TOGG,          _______
165+    ),
166+};
167diff --git a/keyboards/decent/numpad/numpad.c b/keyboards/decent/numpad/numpad.c
168new file mode 100644
169index 0000000000000000000000000000000000000000..5a8b0327461bb1718c03fac6ab56d8a70eb06cac
170--- /dev/null
171+++ b/keyboards/decent/numpad/numpad.c
172@@ -0,0 +1,111 @@
173+// Copyright 2024 B. Le Roy
174+// SPDX-License-Identifier: GPL-2.0-or-later
175+
176+#include "quantum.h"
177+#include "analog.h"
178+
179+joystick_config_t joystick_axes[JOYSTICK_AXIS_COUNT] = {
180+    [0] = JOYSTICK_AXIS_VIRTUAL,
181+    [1] = JOYSTICK_AXIS_VIRTUAL,
182+    [2] = JOYSTICK_AXIS_VIRTUAL,
183+    [3] = JOYSTICK_AXIS_VIRTUAL
184+};
185+
186+void keyboard_post_init_kb(void) {
187+    gpio_set_pin_input_high(GP10); // Up1
188+    gpio_set_pin_input_high(GP11); // Down1
189+    gpio_set_pin_input_high(GP12); // Left1
190+    gpio_set_pin_input_high(GP13); // Right1
191+    gpio_set_pin_input_high(GP14); // Fire1
192+    gpio_set_pin_input_high(GP15);
193+    gpio_set_pin_input_high(GP16);
194+    gpio_set_pin_input_high(GP17);
195+    gpio_set_pin_input_high(GP18);
196+    gpio_set_pin_input_high(GP19);
197+
198+    keyboard_post_init_user();
199+}
200+
201+void set_button_state(int btn, bool state) {
202+    if (state) {
203+        unregister_joystick_button(btn);
204+    }
205+    else {
206+        register_joystick_button(btn);
207+    }
208+}
209+
210+void housekeeping_task_kb(void) {
211+    set_button_state(0, gpio_read_pin(GP16));
212+    set_button_state(1, gpio_read_pin(GP18));
213+    set_button_state(2, gpio_read_pin(GP17));
214+    set_button_state(3, gpio_read_pin(GP15));
215+    set_button_state(4, gpio_read_pin(GP14));
216+    set_button_state(5, gpio_read_pin(GP19));
217+    bool up = !gpio_read_pin(10);
218+    bool down = !gpio_read_pin(11);
219+    bool left = !gpio_read_pin(12);
220+    bool right = !gpio_read_pin(13);
221+    if (up) {
222+        if (left) {
223+            joystick_set_hat(7);
224+        }
225+        else if (right) {
226+            joystick_set_hat(1);
227+        }
228+        else {
229+            joystick_set_hat(0);
230+        }
231+    }
232+    else if (down) {
233+        if (left) {
234+            joystick_set_hat(5);
235+        }
236+        else if (right) {
237+            joystick_set_hat(3);
238+        }
239+        else {
240+            joystick_set_hat(4);
241+        }
242+    }
243+    else if (left) {
244+        joystick_set_hat(6);
245+    }
246+    else if (right) {
247+        joystick_set_hat(2);
248+    }
249+    else {
250+        joystick_set_hat(-1);
251+    }
252+    int16_t analog = analogReadPin(GP26);
253+    joystick_set_axis(0, analog);
254+    analog = analogReadPin(GP27);
255+    joystick_set_axis(1, analog);
256+    analog = analogReadPin(GP28);
257+    joystick_set_axis(2, analog);
258+    analog = analogReadPin(GP29);
259+    joystick_set_axis(3, analog);
260+}
261+
262+bool rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {
263+    if (!rgb_matrix_indicators_advanced_user(led_min, led_max)) {
264+        return false;
265+    }
266+    
267+    if (get_highest_layer(layer_state) > 0) {
268+        uint8_t layer = get_highest_layer(layer_state);
269+
270+        for (uint8_t row = 0; row < MATRIX_ROWS; ++row) {
271+            for (uint8_t col = 0; col < MATRIX_COLS; ++col) {
272diff --git a/keyboards/decent/numpad/readme.md b/keyboards/decent/numpad/readme.md
273new file mode 100644
274index 0000000000000000000000000000000000000000..83436bf8c03d77f27422503b53290cf56420216f
275--- /dev/null
276+++ b/keyboards/decent/numpad/readme.md
277@@ -0,0 +1,71 @@
278+# DecenTKL NumPad
279+
280+*A numeric pad to go with the DecenTKL keyboard*
281+
282+This numeric pad also includes a 3-port USB hub, enabling the connection of the TKL
283+keyboard on the back of the pad.
284+
285+The pad also has two Atari joystick ports.
286+
287+* Keyboard Maintainer: [Bertrand Le roy](https://github.com/bleroy/3d-junkyard/blob/main/DecenTKL/)
288+* Hardware Supported: DecenTKL (RP2040-based)
289+* Hardware Availability: Custom built but open-source
290+
291+Make example for this keyboard (after setting up your build environment):
292+
293+    make decent/numpad:default
294+
295+Flashing example for this keyboard:
296+
297+    make decent/numpad:default:flash
298+