From 42ac7c0541b2a9c2f38f6c2aac6d05163dec4a37 Mon Sep 17 00:00:00 2001 From: StefanGrindelwald <42373600+StefanGrindelwald@users.noreply.github.com> Date: Wed, 21 Jul 2021 01:46:29 +0800 Subject: [PATCH 1/2] [Keyboard] Add Momoka ergo (#13127) Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: Drashna Jaelre Co-authored-by: Ryan --- keyboards/momoka_ergo/config.h | 131 ++++++++++++++++++ keyboards/momoka_ergo/info.json | 82 +++++++++++ .../momoka_ergo/keymaps/default/keymap.c | 55 ++++++++ .../momoka_ergo/keymaps/default/readme.md | 1 + keyboards/momoka_ergo/momoka_ergo.c | 17 +++ keyboards/momoka_ergo/momoka_ergo.h | 53 +++++++ keyboards/momoka_ergo/readme.md | 29 ++++ keyboards/momoka_ergo/rules.mk | 23 +++ 8 files changed, 391 insertions(+) create mode 100644 keyboards/momoka_ergo/config.h create mode 100644 keyboards/momoka_ergo/info.json create mode 100644 keyboards/momoka_ergo/keymaps/default/keymap.c create mode 100644 keyboards/momoka_ergo/keymaps/default/readme.md create mode 100644 keyboards/momoka_ergo/momoka_ergo.c create mode 100644 keyboards/momoka_ergo/momoka_ergo.h create mode 100644 keyboards/momoka_ergo/readme.md create mode 100644 keyboards/momoka_ergo/rules.mk diff --git a/keyboards/momoka_ergo/config.h b/keyboards/momoka_ergo/config.h new file mode 100644 index 00000000000..3c22e3fc845 --- /dev/null +++ b/keyboards/momoka_ergo/config.h @@ -0,0 +1,131 @@ +/* +Copyright 2021 StefanGrindelwald + +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 "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x0000 +#define DEVICE_VER 0x0001 +#define MANUFACTURER StefanGrindelwald +#define PRODUCT Momoka Ergo + +/* key matrix size */ +#define MATRIX_ROWS 14 +#define MATRIX_COLS 6 + +/* + * Keyboard Matrix Assignments + * + * Change this to how you wired your keyboard + * COLS: AVR pins used for columns, left to right + * ROWS: AVR pins used for rows, top to bottom + * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode) + * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) + * + */ +#define MATRIX_ROW_PINS { C6, D7, E6, B4, B5, B6, B7 } +#define MATRIX_COL_PINS { F7, F6, F5, F4, F1, F0 } +#define UNUSED_PINS + +/* COL2ROW, ROW2COL */ +#define DIODE_DIRECTION COL2ROW +#define SELECT_SOFT_SERIAL_SPEED 5 +/* + * Split Keyboard specific options, make sure you have 'SPLIT_KEYBOARD = yes' in your rules.mk, and define SOFT_SERIAL_PIN. + */ +#define SOFT_SERIAL_PIN D1 // or D1, D2, D3, E6 + +#define RGB_DI_PIN C7 +#define RGBLIGHT_ANIMATIONS +#define RGBLED_NUM 22 +#define RGBLED_SPLIT { 11, 11 } +#define RGBLIGHT_HUE_STEP 8 +#define RGBLIGHT_SAT_STEP 8 +#define RGBLIGHT_VAL_STEP 8 + +/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ +#define DEBOUNCE 3 + +/* define if matrix has ghost (lacks anti-ghosting diodes) */ +//#define MATRIX_HAS_GHOST + +/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ +#define LOCKING_SUPPORT_ENABLE +/* Locking resynchronize hack */ +#define LOCKING_RESYNC_ENABLE + +/* If defined, GRAVE_ESC will always act as ESC when CTRL is held. + * This is useful for the Windows task manager shortcut (ctrl+shift+esc). + */ +//#define GRAVE_ESC_CTRL_OVERRIDE + +/* + * Force NKRO + * + * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved + * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the + * makefile for this to work.) + * + * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) + * until the next keyboard reset. + * + * NKRO may prevent your keystrokes from being detected in the BIOS, but it is + * fully operational during normal computer usage. + * + * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) + * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by + * bootmagic, NKRO mode will always be enabled until it is toggled again during a + * power-up. + * + */ +//#define FORCE_NKRO + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ + +/* disable debug print */ +//#define NO_DEBUG + +/* disable print */ +//#define NO_PRINT + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT + +/* disable these deprecated features by default */ +#define NO_ACTION_MACRO +#define NO_ACTION_FUNCTION + +/* Bootmagic Lite key configuration */ +//#define BOOTMAGIC_LITE_ROW 0 +//#define BOOTMAGIC_LITE_COLUMN 0 +#define BOOTMAGIC_KEY_SALT KC_RSFT||KC_LSFT +#define BOOTMAGIC_KEY_SKIP KC_ESC +#define BOOTMAGIC_KEY_EEPROM_CLEAR KC_NO +#define OOTMAGIC_KEY_BOOTLOADER KC_RCTL||KC_LCTL +#define BOOTMAGIC_KEY_EE_HANDS_LEFT KC_T +#define BOOTMAGIC_KEY_EE_HANDS_RIGHT KC_Y +#define USE_SERIAL +#define SPLIT_USB_DETECT +#define EE_HANDS diff --git a/keyboards/momoka_ergo/info.json b/keyboards/momoka_ergo/info.json new file mode 100644 index 00000000000..ecbae947b07 --- /dev/null +++ b/keyboards/momoka_ergo/info.json @@ -0,0 +1,82 @@ +{ + "keyboard_name": "MOMOKA_ERGO", + "url": "", + "maintainer": "StefanGrindelwald", + "width": 19.5, + "height": 9.375, + "layouts": { + "LAYOUT": { + "layout": [ + {"label":"L02", "x":3.5, "y":0}, + {"label":"R03", "x":15, "y":0}, + {"label":"L03", "x":2.5, "y":0.125}, + {"label":"L01", "x":4.5, "y":0.125}, + {"label":"R04", "x":14, "y":0.125}, + {"label":"R02", "x":16, "y":0.125}, + {"label":"L00", "x":5.5, "y":0.25}, + {"label":"R05", "x":13, "y":0.25}, + {"label":"L05", "x":0, "y":0.375, "w":1.5}, + {"label":"L04", "x":1.5, "y":0.375}, + {"label":"R01", "x":17, "y":0.375}, + {"label":"R00", "x":18, "y":0.375, "w":1.5}, + {"label":"L12", "x":3.5, "y":1}, + {"label":"R13", "x":15, "y":1}, + {"label":"L13", "x":2.5, "y":1.125}, + {"label":"L11", "x":4.5, "y":1.125}, + {"label":"R14", "x":14, "y":1.125}, + {"label":"R12", "x":16, "y":1.125}, + {"label":"L10", "x":5.5, "y":1.25}, + {"label":"R15", "x":13, "y":1.25}, + {"label":"L15", "x":0, "y":1.375, "w":1.5}, + {"label":"L14", "x":1.5, "y":1.375}, + {"label":"R11", "x":17, "y":1.375}, + {"label":"R10", "x":18, "y":1.375, "w":1.5}, + {"label":"L22", "x":3.5, "y":2}, + {"label":"R23", "x":15, "y":2}, + {"label":"L23", "x":2.5, "y":2.125}, + {"label":"L21", "x":4.5, "y":2.125}, + {"label":"R24", "x":14, "y":2.125}, + {"label":"R22", "x":16, "y":2.125}, + {"label":"L20", "x":5.5, "y":2.25}, + {"label":"R25", "x":13, "y":2.25}, + {"label":"L25", "x":0, "y":2.375, "w":1.5}, + {"label":"L24", "x":1.5, "y":2.375}, + {"label":"R21", "x":17, "y":2.375}, + {"label":"R20", "x":18, "y":2.375, "w":1.5}, + {"label":"L32", "x":3.5, "y":3}, + {"label":"R33", "x":15, "y":3}, + {"label":"L33", "x":2.5, "y":3.125}, + {"label":"L31", "x":4.5, "y":3.125}, + {"label":"R34", "x":14, "y":3.125}, + {"label":"R32", "x":16, "y":3.125}, + {"label":"L30", "x":5.5, "y":3.25}, + {"label":"R35", "x":13, "y":3.25}, + {"label":"L35", "x":0, "y":3.375, "w":1.5}, + {"label":"L34", "x":1.5, "y":3.375}, + {"label":"R31", "x":17, "y":3.375}, + {"label":"R30", "x":18, "y":3.375, "w":1.5}, + {"label":"L42", "x":3.5, "y":4}, + {"label":"R43", "x":15, "y":4}, + {"label":"L43", "x":2.5, "y":4.125}, + {"label":"L41", "x":4.5, "y":4.125}, + {"label":"R44", "x":14, "y":4.125}, + {"label":"R42", "x":16, "y":4.125}, + {"label":"L45", "x":0.5, "y":4.375}, + {"label":"L44", "x":1.5, "y":4.375}, + {"label":"R41", "x":17, "y":4.375}, + {"label":"R40", "x":18, "y":4.375}, + {"label":"L51", "x":1, "y":4.375}, + {"label":"L40", "x":2, "y":4.375}, + {"label":"L52", "x":0, "y":5.375, "h":2}, + {"label":"L61", "x":1, "y":5.375, "h":2}, + {"label":"L50", "x":2, "y":5.375}, + {"label":"L60", "x":2, "y":6.375}, + {"label":"R45", "x":-3.0, "y":6.375}, + {"label":"R54", "x":-2, "y":6.375}, + {"label":"R55", "x":-3.0, "y":7.375}, + {"label":"R64", "x":-2, "y":7.375, "h":2}, + {"label":"R53", "x":-1.0, "y":7.375, "h":2}, + {"label":"R65", "x":-3.0, "y":8.375}] + } + } +} diff --git a/keyboards/momoka_ergo/keymaps/default/keymap.c b/keyboards/momoka_ergo/keymaps/default/keymap.c new file mode 100644 index 00000000000..ca1131ba2f0 --- /dev/null +++ b/keyboards/momoka_ergo/keymaps/default/keymap.c @@ -0,0 +1,55 @@ +/* Copyright 2021 StefanGrindelwald + * + * 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 + +// Defines names for use in layer keycodes and the keymap +enum layer_names { + _BASE, + _FN1, + _FN2 +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Base */ + [_BASE] = LAYOUT( + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, + MO(_FN1), KC_GRV, KC_EQL, KC_LEFT, KC_RGHT, KC_LALT, KC_RGUI, KC_UP, KC_DOWN, KC_LBRC, KC_RBRC, MO(_FN1), + KC_BSPC, KC_LCTL, KC_HOME, KC_PGUP, KC_RCTL, KC_SPC, + KC_DEL, KC_END, KC_PGDN, KC_ENT + ), + [_FN1] = LAYOUT( + KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + MO(_FN2), _______, _______, _______, _______, _______, _______, _______, RGB_RMOD,RGB_MOD, RGB_TOG, MO(_FN2), + _______, _______, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, RGB_VAI, RGB_VAD, RGB_SAI, RGB_SAD, _______, + _______, _______, _______, RGB_HUI, _______, _______, + _______, _______, RGB_HUD, _______ + ), + [_FN2] = LAYOUT( + KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, RESET, _______, _______, _______, _______, RESET, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, RGB_RMOD,RGB_MOD, RGB_TOG, _______, + _______, _______, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, RGB_VAI, RGB_VAD, RGB_SAI, RGB_SAD, _______, + _______, _______, _______, RGB_HUI, _______, _______, + _______, _______, RGB_HUD, _______ + ) + +}; diff --git a/keyboards/momoka_ergo/keymaps/default/readme.md b/keyboards/momoka_ergo/keymaps/default/readme.md new file mode 100644 index 00000000000..390149d6bb3 --- /dev/null +++ b/keyboards/momoka_ergo/keymaps/default/readme.md @@ -0,0 +1 @@ +# The default keymap for momoka_ergo diff --git a/keyboards/momoka_ergo/momoka_ergo.c b/keyboards/momoka_ergo/momoka_ergo.c new file mode 100644 index 00000000000..8069d7f5122 --- /dev/null +++ b/keyboards/momoka_ergo/momoka_ergo.c @@ -0,0 +1,17 @@ +/* Copyright 2021 StefanGrindelwald + * + * 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 "momoka_ergo.h" diff --git a/keyboards/momoka_ergo/momoka_ergo.h b/keyboards/momoka_ergo/momoka_ergo.h new file mode 100644 index 00000000000..93faad44908 --- /dev/null +++ b/keyboards/momoka_ergo/momoka_ergo.h @@ -0,0 +1,53 @@ +/* Copyright 2021 StefanGrindelwald + * + * 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" + +/* This is a shortcut to help you visually see your layout. + * + * The first section contains all of the arguments representing the physical + * layout of the board and position of the keys. + * + * The second converts the arguments into a two-dimensional array which + * represents the switch matrix. + */ +#define LAYOUT( \ + L05, L04, L03, L02, L01, L00, R05, R04, R03, R02, R01, R00, \ + L15, L14, L13, L12, L11, L10, R15, R14, R13, R12, R11, R10, \ + L25, L24, L23, L22, L21, L20, R25, R24, R23, R22, R21, R20, \ + L35, L34, L33, L32, L31, L30, R35, R34, R33, R32, R31, R30, \ + L45, L44, L43, L42, L41, L40, R45, R44, R43, R42, R41, R40, \ + L52, L51, L50, R55, R54, R53, \ + L61, L60, R65, R64 \ + ) \ + { \ + { L00, L01, L02, L03, L04, L05 }, \ + { L10, L11, L12, L13, L14, L15 }, \ + { L20, L21, L22, L23, L24, L25 }, \ + { L30, L31, L32, L33, L34, L35 }, \ + { L40, L41, L42, L43, L44, L45 },\ + { L50, L51, L52, KC_NO,KC_NO,KC_NO },\ + { L60, L61,KC_NO,KC_NO,KC_NO,KC_NO },\ + { R05, R04, R03, R02, R01, R00 }, \ + { R15, R14, R13, R12, R11, R10 }, \ + { R25, R24, R23, R22, R21, R20 }, \ + { R35, R34, R33, R32, R31, R30 }, \ + { R45, R44, R43, R42, R41, R40 },\ + { R55, R54, R53, KC_NO, KC_NO, KC_NO }, \ + { R65, R64, KC_NO, KC_NO, KC_NO, KC_NO } \ + } diff --git a/keyboards/momoka_ergo/readme.md b/keyboards/momoka_ergo/readme.md new file mode 100644 index 00000000000..d0a289abaf8 --- /dev/null +++ b/keyboards/momoka_ergo/readme.md @@ -0,0 +1,29 @@ +# momoka_ergo + +![momoka_ergo](https://github.com/StefanGrindelwald/TestDemo/blob/master/Momoka_ergo.jpg?raw=true) + +The MOMOKA Ergo is a split keyboard that is based on the Ergodox standard layout. It has 35 keys and 11 RGB backlights on each part. The two parts of the keyboard is connected by a TRRS cable. + +* Keyboard Maintainer: [StefanGrindelwald](https://github.com/StefanGrindelwald) +* Hardware Supported: momoka.co/ergo +* Hardware Availability: momoka.co/ergo + +Bootloader: + +With the default keymap, you can easily use FN+Shift+D to enter the bootloader in left side and FN+shift+K in right side. Or you can just use the microswitch in the PCB. + +Make example for this keyboard (after setting up your build environment): + + make momoka_ergo:default + +Flashing example for this keyboard(Note that you need flash the both side keyboard respectively): + +For the left side: + + make momoka_ergo:default:dfu-split-left + +For the right side: + + make momoka_ergo:default:dfu-split-right + +See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). diff --git a/keyboards/momoka_ergo/rules.mk b/keyboards/momoka_ergo/rules.mk new file mode 100644 index 00000000000..402f5b199aa --- /dev/null +++ b/keyboards/momoka_ergo/rules.mk @@ -0,0 +1,23 @@ +# MCU name +MCU = atmega32u4 + +# Bootloader selection +BOOTLOADER = atmel-dfu + +# Build Options +# change yes to no to disable +# +BOOTMAGIC_ENABLE = full # Virtual DIP switch configuration +MOUSEKEY_ENABLE = no # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = no # Console for debug +COMMAND_ENABLE = no # Commands for debug and configuration +# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +NKRO_ENABLE = no # USB Nkey Rollover +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow +BLUETOOTH_ENABLE = no # Enable Bluetooth +AUDIO_ENABLE = no # Audio output +SPLIT_KEYBOARD = yes From 3591312fa3d41cf18bc873a974698af3a59afcca Mon Sep 17 00:00:00 2001 From: Paul Ewers Date: Tue, 20 Jul 2021 10:46:52 -0700 Subject: [PATCH 2/2] [Keymap] Updates to personal Drop ALT keymap (#13058) --- .../massdrop/alt/keymaps/ewersp/README.md | 14 +- .../massdrop/alt/keymaps/ewersp/keymap.c | 134 ++++++++++++------ 2 files changed, 97 insertions(+), 51 deletions(-) diff --git a/keyboards/massdrop/alt/keymaps/ewersp/README.md b/keyboards/massdrop/alt/keymaps/ewersp/README.md index d2e691a9ef5..8a19bb6c19a 100644 --- a/keyboards/massdrop/alt/keymaps/ewersp/README.md +++ b/keyboards/massdrop/alt/keymaps/ewersp/README.md @@ -6,11 +6,13 @@ This keymap is very similar to the default keymap for the Drop ALT, but it overl ### For example: ``` -LeftAlt + 1...N -> F1...FN -LeftAlt + L/R Arrows -> Home/End -LeftAlt + Home -> End -LeftAlt + Backspace -> Delete -LeftAlt + Esc -> Backtick (`) +LeftAlt + 1...N -> F1...FN +LeftAlt + L/R Arrows -> Home/End +LeftAlt + Home -> End +LeftAlt + Backspace -> Delete +LeftAlt + Esc -> Backtick (`) +LeftAlt + Shift + Esc -> Tilde (~) +LeftAlt + LeftShift + 4 -> Alt+F4 ``` The novel part of this keymap is that it **preserves the default functionality** of the left alt key, so ```'alt + tab', 'ctrl + alt + del', 'alt + f4'```, etc. all work as expected without using any janky timers. @@ -23,8 +25,6 @@ And finally, the original alt key functionality can be toggled at any time by pr This keymap was based on the 'default' Drop ALT keymap (and _not_ 'default_md') which means it supports all the fancy QMK RGB patterns, and isn't limited to the stock options that come with the board. -It's also worth noting that this keymap fixes an outstanding issue where the caps lock LED flickers when the RGB mode is keylight or underglow. I could not find a general purpose fix, but the one included here works quite well. - If you have any questions, feel free to reach out to me at: ewersp [at] gmail [dot] com. Enjoy! **<3** diff --git a/keyboards/massdrop/alt/keymaps/ewersp/keymap.c b/keyboards/massdrop/alt/keymaps/ewersp/keymap.c index 483ea3cfb2a..d4f05b9f32d 100644 --- a/keyboards/massdrop/alt/keymaps/ewersp/keymap.c +++ b/keyboards/massdrop/alt/keymaps/ewersp/keymap.c @@ -38,7 +38,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, KC_MUTE, _______, RGB_SPD, RGB_VAI, RGB_SPI, RGB_HUI, RGB_SAI, _______, U_T_AUTO,U_T_AGCR,_______, KC_PSCR, KC_SLCK, KC_PAUS, _______, KC_END, _______, RGB_RMOD,RGB_VAD, RGB_MOD, RGB_HUD, RGB_SAD, _______, _______, _______, _______, _______, _______, _______, KC_VOLU, - _______, RGB_TOG, _______, _______, _______, MD_BOOT, NK_TOGG, DBG_TOG, _______, TG(ALT), _______, _______, KC_PGUP, KC_VOLD, + _______, RGB_TOG, _______, _______, EEP_RST, MD_BOOT, NK_TOGG, DBG_TOG, _______, TG(ALT), _______, _______, KC_PGUP, KC_VOLD, _______, _______, KC_LALT, _______, _______, _______, KC_HOME, KC_PGDN, KC_END ), [SUPR] = LAYOUT_65_ansi_blocker( @@ -50,34 +50,56 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ) }; -// If the super alt layer is the active layer -bool super_alt_layer_active = false; +// EEPROM storage mode +enum alt_rgb_mode { + RGB_MODE_ALL, + RGB_MODE_KEYLIGHT, + RGB_MODE_UNDERGLOW, + RGB_MODE_NONE, +}; -// If we need to unregister alt when leaving the super alt layer -bool need_to_unregister_alt = false; +// EEPROM storage type +typedef union { + uint32_t raw; + struct { + uint8_t rgb_mode :8; + }; +} alt_config_t; + +alt_config_t alt_config; + +// Read from EEPROM on init to load the last saved mode +void keyboard_post_init_kb(void) { + alt_config.raw = eeconfig_read_user(); + switch (alt_config.rgb_mode) { + case RGB_MODE_ALL: + rgb_matrix_set_flags(LED_FLAG_ALL); + rgb_matrix_enable_noeeprom(); + break; + case RGB_MODE_KEYLIGHT: + rgb_matrix_set_flags(LED_FLAG_KEYLIGHT); + rgb_matrix_set_color_all(0, 0, 0); + break; + case RGB_MODE_UNDERGLOW: + rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); + rgb_matrix_set_color_all(0, 0, 0); + break; + case RGB_MODE_NONE: + rgb_matrix_set_flags(LED_FLAG_NONE); + rgb_matrix_disable_noeeprom(); + break; + } +} #define MODS_SHIFT (get_mods() & MOD_BIT(KC_LSHIFT) || get_mods() & MOD_BIT(KC_RSHIFT)) #define MODS_CTRL (get_mods() & MOD_BIT(KC_LCTL) || get_mods() & MOD_BIT(KC_RCTRL)) #define MODS_ALT (get_mods() & MOD_BIT(KC_LALT) || get_mods() & MOD_BIT(KC_RALT)) -// Taken from 'g_led_config' in config_led.c -#define CAPS_LOCK_LED_ID 30 +// If the super alt layer is the active layer +bool super_alt_layer_active = false; -// This runs every matrix scan (every 'frame') -void rgb_matrix_indicators_user(void) { - led_flags_t flags = rgb_matrix_get_flags(); - - // If we're in either keylight or underglow modes (but not both simultaneously) - if (HAS_FLAGS(flags, LED_FLAG_KEYLIGHT) != HAS_FLAGS(flags, LED_FLAG_UNDERGLOW)) { - - // This fixes a bug where the caps lock LED flickers when toggled in either keylight or underglow modes - if (host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK)) { - rgb_matrix_set_color(CAPS_LOCK_LED_ID, RGB_WHITE); - } else { - rgb_matrix_set_color(CAPS_LOCK_LED_ID, 0, 0, 0); - } - } -} +// If we need to unregister alt when leaving the super alt layer +bool need_to_unregister_alt = false; // This runs code every time that the layers get changed layer_state_t layer_state_set_user(layer_state_t state) { @@ -118,6 +140,16 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } // We still want to process the keycode normally return true; + case KC_F4: + // Map alt+shift+4 to alt+f4 + if (super_alt_layer_active && (get_mods() & MOD_BIT(KC_LSHIFT))) { + if (record->event.pressed) { + register_code(KC_LALT); + } else { + unregister_code(KC_LALT); + } + } + return true; case ALT_DEL: if (record->event.pressed) { register_code(KC_DEL); @@ -164,30 +196,44 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } } return false; + case EEP_RST: + if (record->event.pressed) { + key_timer = timer_read32(); + } else { + if (timer_elapsed32(key_timer) >= 500) { + eeconfig_init(); + } + } + return false; case RGB_TOG: if (record->event.pressed) { - switch (rgb_matrix_get_flags()) { - case LED_FLAG_ALL: { - rgb_matrix_set_flags(LED_FLAG_KEYLIGHT); - rgb_matrix_set_color_all(0, 0, 0); - } - break; - case LED_FLAG_KEYLIGHT: { - rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); - rgb_matrix_set_color_all(0, 0, 0); - } - break; - case LED_FLAG_UNDERGLOW: { - rgb_matrix_set_flags(LED_FLAG_NONE); - rgb_matrix_disable_noeeprom(); - } - break; - default: { - rgb_matrix_set_flags(LED_FLAG_ALL); - rgb_matrix_enable_noeeprom(); - } - break; - } + switch (rgb_matrix_get_flags()) { + case LED_FLAG_ALL: { + rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR); + rgb_matrix_set_color_all(0, 0, 0); + alt_config.rgb_mode = RGB_MODE_KEYLIGHT; + break; + } + case (LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR): { + rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); + rgb_matrix_set_color_all(0, 0, 0); + alt_config.rgb_mode = RGB_MODE_UNDERGLOW; + break; + } + case LED_FLAG_UNDERGLOW: { + rgb_matrix_set_flags(LED_FLAG_NONE); + rgb_matrix_disable_noeeprom(); + alt_config.rgb_mode = RGB_MODE_NONE; + break; + } + default: { + rgb_matrix_set_flags(LED_FLAG_ALL); + rgb_matrix_enable_noeeprom(); + alt_config.rgb_mode = RGB_MODE_ALL; + break; + } + } + eeconfig_update_user(alt_config.raw); } return false; default: