From 8e2b8413b4b0c464da383def06d0269d85aa47cb Mon Sep 17 00:00:00 2001 From: HorrorTroll Date: Sat, 14 May 2022 10:16:46 +0700 Subject: [PATCH] [Keyboard] Add M64 RGB (#17069) --- keyboards/mss_studio/m63_rgb/m63_rgb.c | 10 +- keyboards/mss_studio/m64_rgb/config.h | 104 ++++++++++ keyboards/mss_studio/m64_rgb/info.json | 79 ++++++++ .../m64_rgb/keymaps/default/keymap.c | 184 ++++++++++++++++++ .../m64_rgb/keymaps/default/readme.md | 3 + .../mss_studio/m64_rgb/keymaps/via/config.h | 20 ++ .../mss_studio/m64_rgb/keymaps/via/keymap.c | 184 ++++++++++++++++++ .../mss_studio/m64_rgb/keymaps/via/readme.md | 3 + .../mss_studio/m64_rgb/keymaps/via/rules.mk | 1 + keyboards/mss_studio/m64_rgb/m64_rgb.c | 50 +++++ keyboards/mss_studio/m64_rgb/m64_rgb.h | 49 +++++ keyboards/mss_studio/m64_rgb/readme.md | 24 +++ keyboards/mss_studio/m64_rgb/rules.mk | 22 +++ 13 files changed, 728 insertions(+), 5 deletions(-) create mode 100644 keyboards/mss_studio/m64_rgb/config.h create mode 100644 keyboards/mss_studio/m64_rgb/info.json create mode 100644 keyboards/mss_studio/m64_rgb/keymaps/default/keymap.c create mode 100644 keyboards/mss_studio/m64_rgb/keymaps/default/readme.md create mode 100644 keyboards/mss_studio/m64_rgb/keymaps/via/config.h create mode 100644 keyboards/mss_studio/m64_rgb/keymaps/via/keymap.c create mode 100644 keyboards/mss_studio/m64_rgb/keymaps/via/readme.md create mode 100644 keyboards/mss_studio/m64_rgb/keymaps/via/rules.mk create mode 100644 keyboards/mss_studio/m64_rgb/m64_rgb.c create mode 100644 keyboards/mss_studio/m64_rgb/m64_rgb.h create mode 100644 keyboards/mss_studio/m64_rgb/readme.md create mode 100644 keyboards/mss_studio/m64_rgb/rules.mk diff --git a/keyboards/mss_studio/m63_rgb/m63_rgb.c b/keyboards/mss_studio/m63_rgb/m63_rgb.c index dd071849b55..fdc216f1991 100644 --- a/keyboards/mss_studio/m63_rgb/m63_rgb.c +++ b/keyboards/mss_studio/m63_rgb/m63_rgb.c @@ -26,11 +26,11 @@ led_config_t g_led_config = { { { 54, 55, 56, NO_LED, NO_LED, 57, NO_LED, NO_LED, NO_LED, 58, 59, 60, 61, 62 } }, { // Key matrix (0 -> 62) - {0 , 0}, {16 , 0}, {33 , 0}, {49 , 0}, {66 , 0}, {82 , 0}, {99 , 0}, {115, 0}, {132, 0}, {148, 0}, {165, 0}, {181, 0}, {198, 0}, {214, 0}, - {3 , 16}, {23 , 16}, {39 , 16}, {56 , 16}, {72 , 16}, {88 , 16}, {105, 16}, {121, 16}, {138, 16}, {154, 16}, {171, 16}, {187, 16}, {204, 16}, {220, 16}, - {5 , 32}, {26 , 32}, {42 , 32}, {59 , 32}, {75 , 32}, {92 , 32}, {108, 32}, {124, 32}, {141, 32}, {157, 32}, {174, 32}, {190, 32}, {214, 32}, - {8 , 48}, {28 , 48}, {48 , 48}, {65 , 48}, {81 , 48}, {98 , 48}, {114, 48}, {131, 48}, {147, 48}, {164, 48}, {186, 48}, {208, 48}, {224, 48}, - {2 , 64}, {20 , 64}, {38 , 64}, {100, 64}, {160, 64}, {176, 64}, {192, 64}, {208, 64}, {224, 64}, + {0 , 0}, {16 , 0}, {32 , 0}, {48 , 0}, {64 , 0}, {80 , 0}, {96 , 0}, {112, 0}, {128, 0}, {144, 0}, {160, 0}, {176, 0}, {192, 0}, {216, 0}, + {4 , 16}, {24 , 16}, {40 , 16}, {56 , 16}, {72 , 16}, {88 , 16}, {104, 16}, {120, 16}, {136, 16}, {152, 16}, {168, 16}, {184, 16}, {200, 16}, {220, 16}, + {6 , 32}, {28 , 32}, {44 , 32}, {60 , 32}, {76 , 32}, {92 , 32}, {108, 32}, {124, 32}, {140, 32}, {156, 32}, {172, 32}, {188, 32}, {214, 32}, + {10 , 48}, {36 , 48}, {52 , 48}, {68 , 48}, {84 , 48}, {100, 48}, {116, 48}, {132, 48}, {148, 48}, {164, 48}, {186, 48}, {208, 48}, {224, 48}, + {2 , 64}, {22 , 64}, {42 , 64}, {102, 64}, {160, 64}, {176, 64}, {192, 64}, {208, 64}, {224, 64}, // Underglow (63 -> 74) {216, 56}, {181, 57}, {138, 59}, {105, 58}, {52 , 60}, {10 , 60}, diff --git a/keyboards/mss_studio/m64_rgb/config.h b/keyboards/mss_studio/m64_rgb/config.h new file mode 100644 index 00000000000..0c7f8d17e1f --- /dev/null +++ b/keyboards/mss_studio/m64_rgb/config.h @@ -0,0 +1,104 @@ +/* Copyright 2021 Mss Studio + * Copyright 2022 HorrorTroll + * + * 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 0x4D4B +#define PRODUCT_ID 0x6064 +#define DEVICE_VER 0x0001 +#define MANUFACTURER Mss Studio +#define PRODUCT M64 RGB + +/* key matrix size */ +#define MATRIX_ROWS 5 +#define MATRIX_COLS 14 + +/* key matrix pins */ +#define MATRIX_ROW_PINS { B3, B4, A0, A2, A3 } +#define MATRIX_COL_PINS { B0, B1, B2, B10, A7, A6, A5, A4, B5, B6, A1, B7, B8, B9 } + +/* COL2ROW or ROW2COL */ +#define DIODE_DIRECTION COL2ROW + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCE 5 + +/* Forcing to use NKRO instead 6KRO */ +#define FORCE_NKRO + +/* Change larger keys per scan for elite gaming */ +#define QMK_KEYS_PER_SCAN 12 + +#ifdef RGB_MATRIX_ENABLE + #define DRIVER_LED_TOTAL 76 + #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200 + #define RGB_MATRIX_STARTUP_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS + #define RGB_MATRIX_KEYPRESSES + #define RGB_MATRIX_FRAMEBUFFER_EFFECTS + + /* RGB Matrix config */ + #define RGB_DI_PIN B15 + + /* RGB Matrix effect */ + #define ENABLE_RGB_MATRIX_ALPHAS_MODS + #define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN + #define ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT + #define ENABLE_RGB_MATRIX_BREATHING + #define ENABLE_RGB_MATRIX_BAND_SAT + #define ENABLE_RGB_MATRIX_BAND_VAL + #define ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT + #define ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL + #define ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT + #define ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL + #define ENABLE_RGB_MATRIX_CYCLE_ALL + #define ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT + #define ENABLE_RGB_MATRIX_CYCLE_UP_DOWN + #define ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON + #define ENABLE_RGB_MATRIX_CYCLE_OUT_IN + #define ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL + #define ENABLE_RGB_MATRIX_CYCLE_PINWHEEL + #define ENABLE_RGB_MATRIX_CYCLE_SPIRAL + #define ENABLE_RGB_MATRIX_DUAL_BEACON + #define ENABLE_RGB_MATRIX_RAINBOW_BEACON + #define ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS + #define ENABLE_RGB_MATRIX_RAINDROPS + #define ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS + #define ENABLE_RGB_MATRIX_HUE_BREATHING + #define ENABLE_RGB_MATRIX_HUE_PENDULUM + #define ENABLE_RGB_MATRIX_HUE_WAVE + #define ENABLE_RGB_MATRIX_PIXEL_RAIN + #define ENABLE_RGB_MATRIX_PIXEL_FRACTAL +// enabled only if RGB_MATRIX_FRAMEBUFFER_EFFECTS is defined + #define ENABLE_RGB_MATRIX_TYPING_HEATMAP + #define ENABLE_RGB_MATRIX_DIGITAL_RAIN +// enabled only of RGB_MATRIX_KEYPRESSES or RGB_MATRIX_KEYRELEASES is defined + #define ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE + #define ENABLE_RGB_MATRIX_SOLID_REACTIVE + #define ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE + #define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE + #define ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS + #define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS + #define ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS + #define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS + #define ENABLE_RGB_MATRIX_SPLASH + #define ENABLE_RGB_MATRIX_MULTISPLASH + #define ENABLE_RGB_MATRIX_SOLID_SPLASH + #define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH +#endif diff --git a/keyboards/mss_studio/m64_rgb/info.json b/keyboards/mss_studio/m64_rgb/info.json new file mode 100644 index 00000000000..264e8943771 --- /dev/null +++ b/keyboards/mss_studio/m64_rgb/info.json @@ -0,0 +1,79 @@ +{ + "keyboard_name": "M64 RGB", + "url": "", + "maintainer": "HorrorTroll", + "layouts": { + "LAYOUT_64_ansi": { + "layout": [ + {"label":"Esc", "x":0, "y":0}, + {"label":"1!", "x":1, "y":0}, + {"label":"2@", "x":2, "y":0}, + {"label":"3#", "x":3, "y":0}, + {"label":"4$", "x":4, "y":0}, + {"label":"5%", "x":5, "y":0}, + {"label":"6^", "x":6, "y":0}, + {"label":"7&", "x":7, "y":0}, + {"label":"8*", "x":8, "y":0}, + {"label":"9(", "x":9, "y":0}, + {"label":"0)", "x":10, "y":0}, + {"label":"-_", "x":11, "y":0}, + {"label":"=+", "x":12, "y":0}, + {"label":"Backspace", "x":13, "y":0, "w":2}, + + {"label":"Tab", "x":0, "y":1, "w":1.5}, + {"label":"Q", "x":1.5, "y":1}, + {"label":"W", "x":2.5, "y":1}, + {"label":"E", "x":3.5, "y":1}, + {"label":"R", "x":4.5, "y":1}, + {"label":"T", "x":5.5, "y":1}, + {"label":"Y", "x":6.5, "y":1}, + {"label":"U", "x":7.5, "y":1}, + {"label":"I", "x":8.5, "y":1}, + {"label":"O", "x":9.5, "y":1}, + {"label":"P", "x":10.5, "y":1}, + {"label":"[{", "x":11.5, "y":1}, + {"label":"]}", "x":12.5, "y":1}, + {"label":"\\|", "x":13.5, "y":1, "w":1.5}, + + {"label":"Caps Lock", "x":0, "y":2, "w":1.75}, + {"label":"A", "x":1.75, "y":2}, + {"label":"S", "x":2.75, "y":2}, + {"label":"D", "x":3.75, "y":2}, + {"label":"F", "x":4.75, "y":2}, + {"label":"G", "x":5.75, "y":2}, + {"label":"H", "x":6.75, "y":2}, + {"label":"J", "x":7.75, "y":2}, + {"label":"K", "x":8.75, "y":2}, + {"label":"L", "x":9.75, "y":2}, + {"label":";:", "x":10.75, "y":2}, + {"label":"'\"", "x":11.75, "y":2}, + {"label":"Enter", "x":12.75, "y":2, "w":2.25}, + + {"label":"Shift", "x":0, "y":3, "w":2}, + {"label":"Z", "x":2, "y":3}, + {"label":"X", "x":3, "y":3}, + {"label":"C", "x":4, "y":3}, + {"label":"V", "x":5, "y":3}, + {"label":"B", "x":6, "y":3}, + {"label":"N", "x":7, "y":3}, + {"label":"M", "x":8, "y":3}, + {"label":",<", "x":9, "y":3}, + {"label":".>", "x":10, "y":3}, + {"label":"/?", "x":11, "y":3}, + {"label":"Shift", "x":12, "y":3}, + {"label":"\u2191", "x":13, "y":3}, + {"label":"Delete", "x":14, "y":3}, + + {"label":"Ctrl", "x":0, "y":4, "w":1.25}, + {"label":"Win", "x":1.25, "y":4, "w":1.25}, + {"label":"Alt", "x":2.5, "y":4, "w":1.25}, + {"label":"Space", "x":3.75, "y":4, "w":6.25}, + {"label":"Alt", "x":10, "y":4}, + {"label":"Fn", "x":11, "y":4}, + {"label":"\u2190", "x":12, "y":4}, + {"label":"\u2193", "x":13, "y":4}, + {"label":"\u2192", "x":14, "y":4} + ] + } + } +} diff --git a/keyboards/mss_studio/m64_rgb/keymaps/default/keymap.c b/keyboards/mss_studio/m64_rgb/keymaps/default/keymap.c new file mode 100644 index 00000000000..f348dc69fe2 --- /dev/null +++ b/keyboards/mss_studio/m64_rgb/keymaps/default/keymap.c @@ -0,0 +1,184 @@ +/* Copyright 2021 Mss Studio + * Copyright 2022 HorrorTroll + * + * 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 +#include + +// Each layer gets a name for readability, which is then used in the keymap matrix below. +// The underscores don't mean anything - you can have a layer called STUFF or any other name. +// Layer names don't all need to be of the same length, obviously, and you can also skip them +// entirely and just use numbers. + +enum layer_names { + _BASE, + _FN, +}; + +enum user_rgb_mode { + RGB_MODE_ALL, + RGB_MODE_KEYLIGHT, + RGB_MODE_UNDERGLOW, + RGB_MODE_NONE, +}; + +typedef union { + uint32_t raw; + struct { + uint8_t rgb_mode :8; + }; +} user_config_t; + +user_config_t user_config; + +// enum layer_keycodes { }; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + +/* + ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + │Esc│ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │ Bakspc│ + ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ + │ Tab │ q │ w │ e │ r │ t │ y │ u │ i │ o │ p │ [ │ ] │ \ │ + ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ + │ Caps │ a │ s │ d │ f │ g │ h │ j │ k │ l │ ; │ ' │ Enter │ + ├──────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬───┬───┤ + │LShift │ z │ x │ c │ v │ b │ n │ m │ , │ . │ / │Rft│ ↑ │Del│ + ├────┬──┴─┬─┴──┬┴───┴───┴───┴───┴───┴───┼───┼───┼───┼───┼───┤ + │LCrl│GUI │LAlt│ Space │RAt│Fn │ ← │ ↓ │ → │ + └────┴────┴────┴────────────────────────┴───┴───┴───┴───┴───┘ + ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + │ │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │ ( │ ) │ _ │ + │ │ + ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ + │ │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ { │ } │ | │ + ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ + │ Caps │ A │ S │ D │ F │ G │ H │ J │ K │ L │ : │ " │ │ + ├──────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬───┬───┤ + │LShift │ Z │ X │ C │ V │ B │ N │ M │ < │ > │ ? │Rft│ │ │ + ├────┬──┴─┬─┴──┬┴───┴───┴───┴───┴───┴───┼───┼───┼───┼───┼───┤ + │ │ │ │ │ │ │ │ │ │ + └────┴────┴────┴────────────────────────┴───┴───┴───┴───┴───┘ +*/ + /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 */ + [_BASE] = LAYOUT_64_ansi( + 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_EQL, KC_BSPC, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, 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_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_SLSH, + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FN), KC_LEFT, KC_DOWN, KC_RIGHT + ), + +/* + ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + │ ` │F1 │F2 │F3 │F4 │F5 │F6 │F7 │F8 │F9 │F10│F11│F12│ Delete│ + ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ + │Reset│ │ │ │ │ │ │ │Ins│ │PSc│ │Hui│ Mod │ + ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ + │ │ │ │ │ │ │ │ │ │Tog│ │ │ │ + ├──────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬───┬───┤ + │ │ │ │Cal│ │ │ │Mut│VoD│VoU│ │ │Vai│ │ + ├────┬──┴─┬─┴──┬┴───┴───┴───┴───┴───┴───┼───┼───┼───┼───┼───┤ + │ │ │ │ │ │ │Spd│Vad│Spi│ + └────┴────┴────┴────────────────────────┴───┴───┴───┴───┴───┘ +*/ + /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 */ + [_FN] = LAYOUT_64_ansi( + 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_DEL, + RESET, _______, _______, _______, _______, _______, _______, _______, KC_INS, _______, KC_PSCR, _______, RGB_HUI, RGB_MOD, + _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOG, _______, _______, _______, + _______, _______, _______, KC_CALC, _______, _______, _______, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, RGB_VAI, _______, + _______, _______, _______, _______, _______, _______, RGB_SPD, RGB_VAD, RGB_SPI + ), +}; + +void keyboard_post_init_user(void) { + user_config.raw = eeconfig_read_user(); + switch (user_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 | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR); + 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_set_color_all(0, 0, 0); + break; + } +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case RGB_TOG: + if (record->event.pressed) { + 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); + user_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); + user_config.rgb_mode = RGB_MODE_UNDERGLOW; + } + break; + case (LED_FLAG_UNDERGLOW): { + rgb_matrix_set_flags(LED_FLAG_NONE); + rgb_matrix_set_color_all(0, 0, 0); + user_config.rgb_mode = RGB_MODE_NONE; + } + break; + default: { + rgb_matrix_set_flags(LED_FLAG_ALL); + rgb_matrix_enable_noeeprom(); + user_config.rgb_mode = RGB_MODE_ALL; + } + break; + } + eeconfig_update_user(user_config.raw); + } + return false; + } + + return true; +} + +void rgb_matrix_indicators_user(void) { + HSV hsv = rgb_matrix_config.hsv; + uint8_t time = scale16by8(g_rgb_timer, qadd8(32, 1)); + hsv.h = time; + RGB rgb = hsv_to_rgb(hsv); + + if ((rgb_matrix_get_flags() & LED_FLAG_KEYLIGHT)) { + if (host_keyboard_led_state().caps_lock) { + rgb_matrix_set_color(28, rgb.r, rgb.g, rgb.b); + } + } else { + if (host_keyboard_led_state().caps_lock) { + rgb_matrix_set_color(28, rgb.r, rgb.g, rgb.b); + } else { + rgb_matrix_set_color(28, 0, 0, 0); + } + } +} diff --git a/keyboards/mss_studio/m64_rgb/keymaps/default/readme.md b/keyboards/mss_studio/m64_rgb/keymaps/default/readme.md new file mode 100644 index 00000000000..810af1193be --- /dev/null +++ b/keyboards/mss_studio/m64_rgb/keymaps/default/readme.md @@ -0,0 +1,3 @@ +# Default Layout + +Keymap is default 64 qwerty, 64% layout diff --git a/keyboards/mss_studio/m64_rgb/keymaps/via/config.h b/keyboards/mss_studio/m64_rgb/keymaps/via/config.h new file mode 100644 index 00000000000..188407396a7 --- /dev/null +++ b/keyboards/mss_studio/m64_rgb/keymaps/via/config.h @@ -0,0 +1,20 @@ +/* Copyright 2021 Mss Studio + * Copyright 2022 HorrorTroll + * + * 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 + +#define DYNAMIC_KEYMAP_LAYER_COUNT 2 diff --git a/keyboards/mss_studio/m64_rgb/keymaps/via/keymap.c b/keyboards/mss_studio/m64_rgb/keymaps/via/keymap.c new file mode 100644 index 00000000000..f348dc69fe2 --- /dev/null +++ b/keyboards/mss_studio/m64_rgb/keymaps/via/keymap.c @@ -0,0 +1,184 @@ +/* Copyright 2021 Mss Studio + * Copyright 2022 HorrorTroll + * + * 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 +#include + +// Each layer gets a name for readability, which is then used in the keymap matrix below. +// The underscores don't mean anything - you can have a layer called STUFF or any other name. +// Layer names don't all need to be of the same length, obviously, and you can also skip them +// entirely and just use numbers. + +enum layer_names { + _BASE, + _FN, +}; + +enum user_rgb_mode { + RGB_MODE_ALL, + RGB_MODE_KEYLIGHT, + RGB_MODE_UNDERGLOW, + RGB_MODE_NONE, +}; + +typedef union { + uint32_t raw; + struct { + uint8_t rgb_mode :8; + }; +} user_config_t; + +user_config_t user_config; + +// enum layer_keycodes { }; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + +/* + ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + │Esc│ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │ Bakspc│ + ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ + │ Tab │ q │ w │ e │ r │ t │ y │ u │ i │ o │ p │ [ │ ] │ \ │ + ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ + │ Caps │ a │ s │ d │ f │ g │ h │ j │ k │ l │ ; │ ' │ Enter │ + ├──────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬───┬───┤ + │LShift │ z │ x │ c │ v │ b │ n │ m │ , │ . │ / │Rft│ ↑ │Del│ + ├────┬──┴─┬─┴──┬┴───┴───┴───┴───┴───┴───┼───┼───┼───┼───┼───┤ + │LCrl│GUI │LAlt│ Space │RAt│Fn │ ← │ ↓ │ → │ + └────┴────┴────┴────────────────────────┴───┴───┴───┴───┴───┘ + ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + │ │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │ ( │ ) │ _ │ + │ │ + ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ + │ │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ { │ } │ | │ + ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ + │ Caps │ A │ S │ D │ F │ G │ H │ J │ K │ L │ : │ " │ │ + ├──────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬───┬───┤ + │LShift │ Z │ X │ C │ V │ B │ N │ M │ < │ > │ ? │Rft│ │ │ + ├────┬──┴─┬─┴──┬┴───┴───┴───┴───┴───┴───┼───┼───┼───┼───┼───┤ + │ │ │ │ │ │ │ │ │ │ + └────┴────┴────┴────────────────────────┴───┴───┴───┴───┴───┘ +*/ + /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 */ + [_BASE] = LAYOUT_64_ansi( + 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_EQL, KC_BSPC, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, 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_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_SLSH, + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FN), KC_LEFT, KC_DOWN, KC_RIGHT + ), + +/* + ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + │ ` │F1 │F2 │F3 │F4 │F5 │F6 │F7 │F8 │F9 │F10│F11│F12│ Delete│ + ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ + │Reset│ │ │ │ │ │ │ │Ins│ │PSc│ │Hui│ Mod │ + ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ + │ │ │ │ │ │ │ │ │ │Tog│ │ │ │ + ├──────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬───┬───┤ + │ │ │ │Cal│ │ │ │Mut│VoD│VoU│ │ │Vai│ │ + ├────┬──┴─┬─┴──┬┴───┴───┴───┴───┴───┴───┼───┼───┼───┼───┼───┤ + │ │ │ │ │ │ │Spd│Vad│Spi│ + └────┴────┴────┴────────────────────────┴───┴───┴───┴───┴───┘ +*/ + /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 */ + [_FN] = LAYOUT_64_ansi( + 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_DEL, + RESET, _______, _______, _______, _______, _______, _______, _______, KC_INS, _______, KC_PSCR, _______, RGB_HUI, RGB_MOD, + _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOG, _______, _______, _______, + _______, _______, _______, KC_CALC, _______, _______, _______, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, RGB_VAI, _______, + _______, _______, _______, _______, _______, _______, RGB_SPD, RGB_VAD, RGB_SPI + ), +}; + +void keyboard_post_init_user(void) { + user_config.raw = eeconfig_read_user(); + switch (user_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 | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR); + 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_set_color_all(0, 0, 0); + break; + } +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case RGB_TOG: + if (record->event.pressed) { + 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); + user_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); + user_config.rgb_mode = RGB_MODE_UNDERGLOW; + } + break; + case (LED_FLAG_UNDERGLOW): { + rgb_matrix_set_flags(LED_FLAG_NONE); + rgb_matrix_set_color_all(0, 0, 0); + user_config.rgb_mode = RGB_MODE_NONE; + } + break; + default: { + rgb_matrix_set_flags(LED_FLAG_ALL); + rgb_matrix_enable_noeeprom(); + user_config.rgb_mode = RGB_MODE_ALL; + } + break; + } + eeconfig_update_user(user_config.raw); + } + return false; + } + + return true; +} + +void rgb_matrix_indicators_user(void) { + HSV hsv = rgb_matrix_config.hsv; + uint8_t time = scale16by8(g_rgb_timer, qadd8(32, 1)); + hsv.h = time; + RGB rgb = hsv_to_rgb(hsv); + + if ((rgb_matrix_get_flags() & LED_FLAG_KEYLIGHT)) { + if (host_keyboard_led_state().caps_lock) { + rgb_matrix_set_color(28, rgb.r, rgb.g, rgb.b); + } + } else { + if (host_keyboard_led_state().caps_lock) { + rgb_matrix_set_color(28, rgb.r, rgb.g, rgb.b); + } else { + rgb_matrix_set_color(28, 0, 0, 0); + } + } +} diff --git a/keyboards/mss_studio/m64_rgb/keymaps/via/readme.md b/keyboards/mss_studio/m64_rgb/keymaps/via/readme.md new file mode 100644 index 00000000000..ee171181300 --- /dev/null +++ b/keyboards/mss_studio/m64_rgb/keymaps/via/readme.md @@ -0,0 +1,3 @@ +# Default Layout with VIA + +Keymap is default 64 qwerty, 64% layout diff --git a/keyboards/mss_studio/m64_rgb/keymaps/via/rules.mk b/keyboards/mss_studio/m64_rgb/keymaps/via/rules.mk new file mode 100644 index 00000000000..1e5b99807cb --- /dev/null +++ b/keyboards/mss_studio/m64_rgb/keymaps/via/rules.mk @@ -0,0 +1 @@ +VIA_ENABLE = yes diff --git a/keyboards/mss_studio/m64_rgb/m64_rgb.c b/keyboards/mss_studio/m64_rgb/m64_rgb.c new file mode 100644 index 00000000000..26fed2b2fe3 --- /dev/null +++ b/keyboards/mss_studio/m64_rgb/m64_rgb.c @@ -0,0 +1,50 @@ +/* Copyright 2021 Mss Studio + * Copyright 2022 HorrorTroll + * + * 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 "m64_rgb.h" + +#ifdef RGB_MATRIX_ENABLE +led_config_t g_led_config = { { + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }, + { 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 }, + { 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, NO_LED, 40 }, + { 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54 }, + { 55, 56, 57, NO_LED, NO_LED, 58, NO_LED, NO_LED, NO_LED, 59, 60, 61, 62, 63 } +}, { + // Key matrix (0 -> 63) + {0 , 0}, {16 , 0}, {32 , 0}, {48 , 0}, {64 , 0}, {80 , 0}, {96 , 0}, {112, 0}, {128, 0}, {144, 0}, {160, 0}, {176, 0}, {192, 0}, {216, 0}, + {4 , 16}, {24 , 16}, {40 , 16}, {56 , 16}, {72 , 16}, {88 , 16}, {104, 16}, {120, 16}, {136, 16}, {152, 16}, {168, 16}, {184, 16}, {200, 16}, {220, 16}, + {6 , 32}, {28 , 32}, {44 , 32}, {60 , 32}, {76 , 32}, {92 , 32}, {108, 32}, {124, 32}, {140, 32}, {156, 32}, {172, 32}, {188, 32}, {214, 32}, + {8 , 48}, {32 , 48}, {48 , 48}, {64 , 48}, {80 , 48}, {96 , 48}, {112, 48}, {128, 48}, {144, 48}, {160, 48}, {176, 48}, {192, 48}, {208, 48}, {224, 48}, + {2 , 64}, {22 , 64}, {42 , 64}, {102, 64}, {160, 64}, {176, 64}, {192, 64}, {208, 64}, {224, 64}, + + // Underglow (64 -> 75) + {216, 56}, {181, 57}, {138, 59}, {105, 58}, {52 , 60}, {10 , 60}, + {20 , 12}, {54 , 12}, {102, 10}, {145, 13}, {182, 9}, {211, 10}, +}, { + // Key matrix (0 -> 63) + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 4, 4, + 1, 1, 1, 4, 1, 1, 4, 4, 4, + + // Underglow (64 -> 75) + 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2 +} }; +#endif diff --git a/keyboards/mss_studio/m64_rgb/m64_rgb.h b/keyboards/mss_studio/m64_rgb/m64_rgb.h new file mode 100644 index 00000000000..e12bf5bc7b7 --- /dev/null +++ b/keyboards/mss_studio/m64_rgb/m64_rgb.h @@ -0,0 +1,49 @@ +/* Copyright 2021 Mss Studio + * Copyright 2022 HorrorTroll + * + * 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" + +#define XXX KC_NO + +/* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + * │00 │01 │02 │03 │04 │05 │06 │07 │08 │09 │0A │0B │0C │0D │ + * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ + * │10 │11 │12 │13 │14 │15 │16 │17 │18 │19 │1A │1B │1C │1D │ + * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ + * │20 │21 │22 │23 │24 │25 │26 │27 │28 │29 │2A │2B │2D │ + * ├──────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬───┬───┤ + * │30 │31 │32 │33 │34 │35 │36 │37 │38 │39 │3A │3B │3C │3D │ + * ├────┬──┴─┬─┴──┬┴───┴───┴───┴───┴───┴───┼───┼───┼───┼───┼───┤ + * │40 │41 │42 │45 │49 │4A │4B │4C │4D │ + * └────┴────┴────┴────────────────────────┴───┴───┴───┴───┴───┘ + */ + +#define LAYOUT_64_ansi( \ + K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ + K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ + K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2D, \ + K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, \ + K40, K41, K42, K45, K49, K4A, K4B, K4C, K4D \ +) { \ + { K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D }, \ + { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D }, \ + { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, XXX, K2D }, \ + { K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D }, \ + { K40, K41, K42, XXX, XXX, K45, XXX, XXX, XXX, K49, K4A, K4B, K4C, K4D } \ +} diff --git a/keyboards/mss_studio/m64_rgb/readme.md b/keyboards/mss_studio/m64_rgb/readme.md new file mode 100644 index 00000000000..1925622b9cf --- /dev/null +++ b/keyboards/mss_studio/m64_rgb/readme.md @@ -0,0 +1,24 @@ +# M64 RGB + +Support STM32F072CBU6 keyboard. + +* Keyboard Maintainer: [HorrorTroll](https://github.com/HorrorTroll) +* Hardware Supported: STM32F072CBU6 + +Make example for this keyboard (after setting up your build environment): + + make mss_studio/m64_rgb:default + +Flashing example for this keyboard: + + make mss_studio/m64_rgb:default:flash + +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). + +## Bootloader + +Enter the bootloader in 3 ways: + +* **Bootmagic reset**: Hold down the key at (0,0) in the matrix (Esc key) and plug in the keyboard +* **Physical reset button**: Press and hold the button on the back of the PCB, then plug in the keyboard +* **Keycode in layout**: Press the key mapped to `RESET` if it is available diff --git a/keyboards/mss_studio/m64_rgb/rules.mk b/keyboards/mss_studio/m64_rgb/rules.mk new file mode 100644 index 00000000000..9291499b777 --- /dev/null +++ b/keyboards/mss_studio/m64_rgb/rules.mk @@ -0,0 +1,22 @@ +# MCU name +MCU = STM32F072 + +# Bootloader selection +BOOTLOADER = stm32-dfu + +# Build Options +# change yes to no to disable +# +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite +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 +NKRO_ENABLE = yes # Enable N-Key Rollover +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow +AUDIO_ENABLE = no # Audio output + +# RGB Matrix enabled +RGB_MATRIX_ENABLE = yes +RGB_MATRIX_DRIVER = WS2812