From 9cdbc040cd352aa1f44022c90f137ba5bcbe1c36 Mon Sep 17 00:00:00 2001 From: James Young <18669334+noroadsleft@users.noreply.github.com> Date: Fri, 19 Nov 2021 06:12:49 +0000 Subject: [PATCH] =?UTF-8?q?FFKeebs=20P=C3=BAca=20Refactor=20(#15208)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- keyboards/ffkeebs/puca/info.json | 88 +++++++++++++++-- .../ffkeebs/puca/keymaps/default/keymap.c | 54 ++++------ .../puca/keymaps/default_numpad/keymap.c | 38 +++++++ .../puca/keymaps/default_ortho/keymap.c | 38 +++++++ keyboards/ffkeebs/puca/puca.c | 20 +++- keyboards/ffkeebs/puca/puca.h | 98 +++++++++++++++---- keyboards/ffkeebs/puca/readme.md | 2 +- keyboards/ffkeebs/puca/rules.mk | 6 +- 8 files changed, 276 insertions(+), 68 deletions(-) create mode 100644 keyboards/ffkeebs/puca/keymaps/default_numpad/keymap.c create mode 100644 keyboards/ffkeebs/puca/keymaps/default_ortho/keymap.c diff --git a/keyboards/ffkeebs/puca/info.json b/keyboards/ffkeebs/puca/info.json index 0b5b957e63..204f0ca497 100644 --- a/keyboards/ffkeebs/puca/info.json +++ b/keyboards/ffkeebs/puca/info.json @@ -2,35 +2,105 @@ "keyboard_name": "Puca", "url": "https://ffkeebs.com/collections/puca/", "maintainer": "Sleepdealr", + "layout_aliases": { + "LAYOUT": "LAYOUT_all" + }, "layouts": { - "LAYOUT": { + "LAYOUT_all": { "layout": [ { "label": "Rotary", "x": 0.5, "y": 0 }, { "label": "Pg Up", "x": 2, "y": 0 }, { "label": "Pg Dn", "x": 3, "y": 0 }, + { "label": "Layer Toggle", "x": 0, "y": 1.25 }, { "label": "/", "x": 1, "y": 1.25 }, { "label": "*", "x": 2, "y": 1.25 }, { "label": "-", "x": 3, "y": 1.25 }, + { "label": "7", "x": 0, "y": 2.25 }, { "label": "8", "x": 1, "y": 2.25 }, { "label": "9", "x": 2, "y": 2.25 }, - { "label": "+", "x": 3, "y": 2.25, "h": 2 }, - { "label": "+", "x": 4, "y": 2.25 }, + { "label": "+", "x": 3, "y": 2.25 }, + { "label": "+", "x": 4, "y": 2.25, "h": 2 }, + { "label": "4", "x": 0, "y": 3.25 }, { "label": "5", "x": 1, "y": 3.25 }, { "label": "6", "x": 2, "y": 3.25 }, - { "label": "|", "x": 4, "y": 3.25 }, + { "label": "|", "x": 3, "y": 3.25 }, + { "label": "1", "x": 0, "y": 4.25 }, { "label": "2", "x": 1, "y": 4.25 }, { "label": "3", "x": 2, "y": 4.25 }, - { "label": "Enter", "x": 3, "y": 4.25, "h": 2 }, - { "label": "Enter", "x": 4, "y": 4.25 }, + { "label": "Enter", "x": 3, "y": 4.25 }, + { "label": "Enter", "x": 4, "y": 4.25, "h": 2 }, + + { "label": "0", "x": 0, "y": 5.25 }, + { "label": "00", "x": 1, "y": 5.25 }, + { "label": ".", "x": 2, "y": 5.25 }, + { "label": ".", "x": 3, "y": 5.25 }, + + { "label": "0", "x": 0, "y": 6.25, "w": 2 } + ] + }, + "LAYOUT_numpad": { + "layout": [ + { "label": "Rotary", "x": 0.5, "y": 0 }, + { "label": "Pg Up", "x": 2, "y": 0 }, + { "label": "Pg Dn", "x": 3, "y": 0 }, + + { "label": "Layer Toggle", "x": 0, "y": 1.25 }, + { "label": "/", "x": 1, "y": 1.25 }, + { "label": "*", "x": 2, "y": 1.25 }, + { "label": "-", "x": 3, "y": 1.25 }, + + { "label": "7", "x": 0, "y": 2.25 }, + { "label": "8", "x": 1, "y": 2.25 }, + { "label": "9", "x": 2, "y": 2.25 }, + + { "label": "4", "x": 0, "y": 3.25 }, + { "label": "5", "x": 1, "y": 3.25 }, + { "label": "6", "x": 2, "y": 3.25 }, + { "label": "+", "x": 3, "y": 2.25, "h": 2 }, + + { "label": "1", "x": 0, "y": 4.25 }, + { "label": "2", "x": 1, "y": 4.25 }, + { "label": "3", "x": 2, "y": 4.25 }, + { "label": "0", "x": 0, "y": 5.25, "w": 2 }, { "label": ".", "x": 2, "y": 5.25 }, - { "label": ".", "x": 4, "y": 5.25 }, - { "label": "0", "x": 0, "y": 6.25 }, - { "label": "00", "x": 1, "y": 6.25 } + { "label": "Enter", "x": 3, "y": 4.25, "h": 2 } + ] + }, + "LAYOUT_ortho": { + "layout": [ + { "label": "Rotary", "x": 0.5, "y": 0 }, + { "label": "Pg Up", "x": 2, "y": 0 }, + { "label": "Pg Dn", "x": 3, "y": 0 }, + + { "label": "Layer Toggle", "x": 0, "y": 1.25 }, + { "label": "/", "x": 1, "y": 1.25 }, + { "label": "*", "x": 2, "y": 1.25 }, + { "label": "-", "x": 3, "y": 1.25 }, + + { "label": "7", "x": 0, "y": 2.25 }, + { "label": "8", "x": 1, "y": 2.25 }, + { "label": "9", "x": 2, "y": 2.25 }, + { "label": "+", "x": 3, "y": 2.25 }, + + { "label": "4", "x": 0, "y": 3.25 }, + { "label": "5", "x": 1, "y": 3.25 }, + { "label": "6", "x": 2, "y": 3.25 }, + { "label": "|", "x": 3, "y": 3.25 }, + + { "label": "1", "x": 0, "y": 4.25 }, + { "label": "2", "x": 1, "y": 4.25 }, + { "label": "3", "x": 2, "y": 4.25 }, + { "label": "Enter", "x": 3, "y": 4.25 }, + + { "label": "0", "x": 0, "y": 5.25 }, + { "label": "00", "x": 1, "y": 5.25 }, + { "label": ".", "x": 2, "y": 5.25 }, + { "label": "Enter", "x": 3, "y": 5.25 } ] } } diff --git a/keyboards/ffkeebs/puca/keymaps/default/keymap.c b/keyboards/ffkeebs/puca/keymaps/default/keymap.c index fb8a6bc7c1..12c20c0149 100644 --- a/keyboards/ffkeebs/puca/keymaps/default/keymap.c +++ b/keyboards/ffkeebs/puca/keymaps/default/keymap.c @@ -1,4 +1,4 @@ -/* Copyright 2021 Sleepdealer +/* Copyright 2021 Sleepdealer, James Young for QMK (@noroadsleft) * * 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 @@ -15,38 +15,26 @@ */ #include QMK_KEYBOARD_H -// 00 Functionality -enum custom_keycodes { - MC_00 = SAFE_RANGE, -}; - -bool process_record_user(uint16_t keycode, keyrecord_t *record) { - switch (keycode) { - case MC_00: - if (record->event.pressed) { - SEND_STRING("00"); - } - break; - } - return true; -}; - - const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - LAYOUT( - KC_MUTE, KC_PGUP, KC_PGDN, - TG(1), KC_PSLS, KC_PAST, KC_PMNS, - KC_P7, KC_P8, KC_P9, KC_PPLS, KC_PPLS, - KC_P4, KC_P5, KC_P6, KC_PIPE, - KC_P1, KC_P2, KC_P3, KC_ENTER, KC_ENTER, - KC_P0, MC_00, KC_PDOT, KC_PDOT, - KC_P0), - LAYOUT( + + [0] = LAYOUT_all( + KC_MUTE, KC_PGUP, KC_PGDN, + TG(1), KC_PSLS, KC_PAST, KC_PMNS, + KC_P7, KC_P8, KC_P9, KC_PPLS, KC_PPLS, + KC_P4, KC_P5, KC_P6, KC_PIPE, + KC_P1, KC_P2, KC_P3, KC_ENTER, KC_ENTER, + KC_P0, MC_00, KC_PDOT, KC_PDOT, + KC_P0 + ), + + [1] = LAYOUT_all( KC_TRNS, RGB_HUI, RGB_VAI, - TG(1), RGB_TOG, RGB_HUD, RGB_VAD, - KC_PGUP, KC_UP, KC_PGDN, RGB_MOD, RGB_MOD, - KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, - KC_INS, KC_HOME, KC_END, RGB_RMOD, RGB_RMOD, - KC_ESC, KC_TRNS, KC_DEL, KC_TRNS, - KC_ESC) + TG(1), RGB_TOG, RGB_HUD, RGB_VAD, + KC_PGUP, KC_UP, KC_PGDN, RGB_MOD, RGB_MOD, + KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, + KC_INS, KC_HOME, KC_END, RGB_RMOD, RGB_RMOD, + KC_ESC, KC_TRNS, KC_DEL, KC_TRNS, + KC_ESC + ), + }; diff --git a/keyboards/ffkeebs/puca/keymaps/default_numpad/keymap.c b/keyboards/ffkeebs/puca/keymaps/default_numpad/keymap.c new file mode 100644 index 0000000000..fe67678612 --- /dev/null +++ b/keyboards/ffkeebs/puca/keymaps/default_numpad/keymap.c @@ -0,0 +1,38 @@ +/* Copyright 2021 Sleepdealer, James Young for QMK (@noroadsleft) + * + * 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 QMK_KEYBOARD_H + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + [0] = LAYOUT_numpad( + KC_MUTE, KC_PGUP, KC_PGDN, + TG(1), KC_PSLS, KC_PAST, KC_PMNS, + KC_P7, KC_P8, KC_P9, + KC_P4, KC_P5, KC_P6, KC_PPLS, + KC_P1, KC_P2, KC_P3, + KC_P0, KC_PDOT, KC_ENTER + ), + + [1] = LAYOUT_numpad( + _______, RGB_HUI, RGB_VAI, + TG(1), RGB_TOG, RGB_HUD, RGB_VAD, + KC_PGUP, KC_UP, KC_PGDN, + KC_LEFT, KC_DOWN, KC_RGHT, RGB_MOD, + KC_INS, KC_HOME, KC_END, + KC_ESC, KC_DEL, RGB_RMOD + ), + +}; diff --git a/keyboards/ffkeebs/puca/keymaps/default_ortho/keymap.c b/keyboards/ffkeebs/puca/keymaps/default_ortho/keymap.c new file mode 100644 index 0000000000..e734e69745 --- /dev/null +++ b/keyboards/ffkeebs/puca/keymaps/default_ortho/keymap.c @@ -0,0 +1,38 @@ +/* Copyright 2021 Sleepdealer, James Young for QMK (@noroadsleft) + * + * 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 QMK_KEYBOARD_H + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + [0] = LAYOUT_ortho( + KC_MUTE, KC_PGUP, KC_PGDN, + TG(1), KC_PSLS, KC_PAST, KC_PMNS, + KC_P7, KC_P8, KC_P9, KC_PPLS, + KC_P4, KC_P5, KC_P6, KC_PIPE, + KC_P1, KC_P2, KC_P3, KC_ENTER, + KC_P0, MC_00, KC_PDOT, KC_ENTER + ), + + [1] = LAYOUT_ortho( + _______, RGB_HUI, RGB_VAI, + TG(1), RGB_TOG, RGB_HUD, RGB_VAD, + KC_PGUP, KC_UP, KC_PGDN, RGB_MOD, + KC_LEFT, KC_DOWN, KC_RGHT, XXXXXXX, + KC_INS, KC_HOME, KC_END, RGB_RMOD, + KC_ESC, XXXXXXX, KC_DEL, XXXXXXX + ) + +}; diff --git a/keyboards/ffkeebs/puca/puca.c b/keyboards/ffkeebs/puca/puca.c index e08ac0cb3b..624643e8dc 100644 --- a/keyboards/ffkeebs/puca/puca.c +++ b/keyboards/ffkeebs/puca/puca.c @@ -15,6 +15,20 @@ */ #include "puca.h" +bool process_record_kb(uint16_t keycode, keyrecord_t* record) { + if (!process_record_user(keycode, record)) { + return false; + } + switch (keycode) { + case MC_00: + if (record->event.pressed) { + SEND_STRING("00"); + } + break; + } + return true; +} + bool encoder_update_kb(uint8_t index, bool clockwise) { if (!encoder_update_user(index, clockwise)) { return false; } if (clockwise) { @@ -105,7 +119,7 @@ __attribute__((weak)) void oled_task_user(void) { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}; - + void animation_phase(void) { current_idle_frame = (current_idle_frame + 1) % IDLE_FRAMES; oled_write_raw_P(idle[abs((IDLE_FRAMES - 1) - current_idle_frame)], ANIM_SIZE); @@ -114,7 +128,7 @@ __attribute__((weak)) void oled_task_user(void) { anim_timer = timer_read32(); animation_phase(); } - + oled_set_cursor(0, 6); oled_write_P(PSTR("PUCA\nPAD\n"), false); oled_write_P(PSTR("-----\n"), false); @@ -130,4 +144,4 @@ __attribute__((weak)) void oled_task_user(void) { break; } } -#endif \ No newline at end of file +#endif diff --git a/keyboards/ffkeebs/puca/puca.h b/keyboards/ffkeebs/puca/puca.h index bc17c9f36f..ab4dc37916 100644 --- a/keyboards/ffkeebs/puca/puca.h +++ b/keyboards/ffkeebs/puca/puca.h @@ -16,26 +16,86 @@ #pragma once -// K24 is 2U Plus -// K44 is 2u Enter -// K54 is 2u 0 - - #include "quantum.h" -#define LAYOUT( \ - K00, K02, K03, \ - K10, K11, K12, K13, \ - K20, K21, K22, K23, K24,\ - K30, K31, K32, K33, \ - K40, K41, K42, K43, K44,\ - K50, K51, K52, K53, \ - K54 \ +/* Keycodes defined here can be used by any keymap. If you wish to + * define additional keycodes for your personal keymap only, assign + * your first custom keycode to `= NEW_SAFE_RANGE`. + * + * See `process_record_kb()` in `puca.c`. + */ +enum keyboard_keycodes { + MC_00 = SAFE_RANGE, + NEW_SAFE_RANGE, +}; + +#define XXX KC_NO + +/* + * ┌───┐ ┌───┬───┐ + * │00 │ │02 │03 │ + * └───┘ └───┴───┘ + * ┌───┬───┬───┬───┐ + * │10 │11 │12 │13 │ + * ├───┼───┼───┼───┤ ┌───┐ + * │20 │21 │22 │23 │ │ │ + * ├───┼───┼───┼───┤ │24 │ 2u Plus + * │30 │31 │32 │33 │ │ │ + * ├───┼───┼───┼───┤ ├───┤ + * │40 │41 │42 │43 │ │ │ + * ├───┼───┼───┼───┤ │44 │ 2u Enter + * │50 │51 │52 │53 │ │ │ + * └───┴───┴───┴───┘ └───┘ + * ┌───────┐ + * │54 │ 2u 0 + * └───────┘ + */ + +#define LAYOUT_all( \ + K00, K02, K03, \ + K10, K11, K12, K13, \ + K20, K21, K22, K23, K24,\ + K30, K31, K32, K33, \ + K40, K41, K42, K43, K44,\ + K50, K51, K52, K53, \ + K54 \ ) { \ - { K00, KC_NO, K02, K03, KC_NO }, \ - { K10, K11, K12, K13, KC_NO }, \ - { K20, K21, K22, K23, K24 }, \ - { K30, K31, K32, K33, KC_NO }, \ - { K40, K41, K42, K43, K44 }, \ - { K50, K51, K52, K53, K54 }, \ + { K00, XXX, K02, K03, XXX }, \ + { K10, K11, K12, K13, XXX }, \ + { K20, K21, K22, K23, K24 }, \ + { K30, K31, K32, K33, XXX }, \ + { K40, K41, K42, K43, K44 }, \ + { K50, K51, K52, K53, K54 }, \ +} + +#define LAYOUT_numpad( \ + K00, K02, K03, \ + K10, K11, K12, K13, \ + K20, K21, K22, \ + K30, K31, K32, K24, \ + K40, K41, K42, \ + K54, K52, K44 \ +) { \ + { K00, XXX, K02, K03, XXX }, \ + { K10, K11, K12, K13, XXX }, \ + { K20, K21, K22, XXX, K24 }, \ + { K30, K31, K32, XXX, XXX }, \ + { K40, K41, K42, XXX, K44 }, \ + { XXX, XXX, K52, XXX, K54 }, \ +} + +#define LAYOUT_ortho( \ + K00, K02, K03, \ + K10, K11, K12, K13, \ + K20, K21, K22, K23, \ + K30, K31, K32, K33, \ + K40, K41, K42, K43, \ + K50, K51, K52, K53 \ +) { \ + { K00, XXX, K02, K03, XXX }, \ + { K10, K11, K12, K13, XXX }, \ + { K20, K21, K22, K23, XXX }, \ + { K30, K31, K32, K33, XXX }, \ + { K40, K41, K42, K43, XXX }, \ + { K50, K51, K52, K53, XXX }, \ } diff --git a/keyboards/ffkeebs/puca/readme.md b/keyboards/ffkeebs/puca/readme.md index ff0b2c49ae..ca4e0f93f9 100644 --- a/keyboards/ffkeebs/puca/readme.md +++ b/keyboards/ffkeebs/puca/readme.md @@ -2,7 +2,7 @@ * Keyboard Maintainer: [Sleepdealer](https://github.com/Sleepdealr) * Hardware Supported: Puca Pad -* Hardware Availability: Puca GB +* Hardware Availability: [Puca GB](https://ffkeebs.com/collections/puca) ## Bootloader diff --git a/keyboards/ffkeebs/puca/rules.mk b/keyboards/ffkeebs/puca/rules.mk index b27ecc458b..ede448ac23 100644 --- a/keyboards/ffkeebs/puca/rules.mk +++ b/keyboards/ffkeebs/puca/rules.mk @@ -19,7 +19,7 @@ NKRO_ENABLE = no # USB Nkey Rollover BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow -ENCODER_ENABLE = yes #Rotary encoder +ENCODER_ENABLE = yes # Enable rotary encoder support +OLED_ENABLE = yes # Enable OLED support -OLED_ENABLE = yes #OLED -LTO_ENABLE = yes # Enable Link Time Optimization to reduce firmware size +LTO_ENABLE = yes # Enable Link Time Optimization to reduce firmware size