summaryrefslogtreecommitdiffstats
path: root/keyboards/kbdfans/kbd67
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/kbdfans/kbd67')
-rw-r--r--keyboards/kbdfans/kbd67/mkiirgb/keymaps/spx01/config.h41
-rw-r--r--keyboards/kbdfans/kbd67/mkiirgb/keymaps/spx01/keymap.c158
-rw-r--r--keyboards/kbdfans/kbd67/mkiirgb/keymaps/spx01/readme.md23
-rw-r--r--keyboards/kbdfans/kbd67/mkiirgb/keymaps/spx01/rgb_matrix_user.inc68
-rw-r--r--keyboards/kbdfans/kbd67/mkiirgb/keymaps/spx01/rules.mk4
5 files changed, 294 insertions, 0 deletions
diff --git a/keyboards/kbdfans/kbd67/mkiirgb/keymaps/spx01/config.h b/keyboards/kbdfans/kbd67/mkiirgb/keymaps/spx01/config.h
new file mode 100644
index 0000000000..2d2dc00132
--- /dev/null
+++ b/keyboards/kbdfans/kbd67/mkiirgb/keymaps/spx01/config.h
@@ -0,0 +1,41 @@
+/* Copyright 2022 spx01 (@spx01)
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+/* --- custom defines only used in my own code --- */
+
+/* easily switch on debugging features */
+#define CUSTOM_DEBUG false
+
+/* hexrgb mode special keys, these shouldn't be KC_A to KC_F or KC_0 to KC_9 */
+/* keycode that triggers saving the current rgb_static color into eeprom */
+#define HEXRGB_SAVE_KC KC_S
+/* keycode that triggers resetting rgb_static to the color saved in the eeprom */
+#define HEXRGB_RESET_KC KC_R
+
+/* --- keyboard configuration macros --- */
+
+#if CUSTOM_DEBUG
+# define NO_DEBUG
+# define NO_PRINT
+#endif
+
+#define RETRO_TAPPING
+#define PERMISSIVE_HOLD
+
+#undef RGB_MATRIX_STARTUP_MODE
+#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CUSTOM_RGB_STATIC
diff --git a/keyboards/kbdfans/kbd67/mkiirgb/keymaps/spx01/keymap.c b/keyboards/kbdfans/kbd67/mkiirgb/keymaps/spx01/keymap.c
new file mode 100644
index 0000000000..ca90c77b42
--- /dev/null
+++ b/keyboards/kbdfans/kbd67/mkiirgb/keymaps/spx01/keymap.c
@@ -0,0 +1,158 @@
+/* Copyright 2022 spx01 (@spx01)
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#include QMK_KEYBOARD_H
+#include "print.h"
+
+enum CustomKeycodes {
+ CK_HEXRGB = SAFE_RANGE,
+ /* esc when shift is held, grave otherwise; particularly useful for windows' task manager shortcut */
+ CK_ESCG,
+};
+
+enum Layers {
+ _LAYER1,
+ _LAYER2,
+};
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ // clang-format off
+ [_LAYER1] = LAYOUT_65_ansi_blocker(
+ QK_GESC, 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_HOME,
+ 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_BSLASH, KC_PGUP,
+ LT(_LAYER2, 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_PGDN,
+ 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_END,
+ KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_LEFT, KC_DOWN, KC_RIGHT),
+ [_LAYER2] = LAYOUT_65_ansi_blocker(
+ CK_ESCG, 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, KC_INS,
+ KC_TRNS, KC_TRNS, KC_TRNS, EE_CLR, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_TRNS, KC_TRNS, RESET, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MUTE, KC_TRNS, KC_TRNS, CK_HEXRGB, KC_MPLY, KC_VOLU, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, RGB_TOG, KC_TRNS, KC_TRNS, KC_MPRV, KC_VOLD, KC_MNXT),
+ /* [] = LAYOUT_65_ansi_blocker(
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), */
+ // clang-format on
+};
+
+/* exported by the rgb_static effect */
+void RGB_STATIC_save_eeprom(void);
+void RGB_STATIC_reset(void);
+extern uint8_t g_rgb_static_color[3];
+
+/* returns number corresponding to hex digit represented by keycode or -1 if keycode isn't a valid hex digit */
+static int8_t key_hexdigit(uint16_t keycode) {
+ if (keycode >= KC_A && keycode <= KC_F) {
+ return keycode - KC_A + 10;
+ }
+ if (keycode >= KC_1 && keycode <= KC_0) {
+ int8_t res = keycode - KC_1 + 1;
+ /* mod 10 considering res is between 1 and 10 */
+ res *= res != 10;
+ return res;
+ }
+ return -1;
+}
+
+typedef struct {
+ bool active;
+ uint8_t color[3];
+ uint8_t count;
+} RGBHexState;
+static RGBHexState hexrgb;
+
+/* handles input mode for an rgb value */
+static void hexrgb_input(uint16_t keycode) {
+ /* only check for special keys when input mode has just been triggered */
+ if (hexrgb.count == 0) {
+ switch (keycode) {
+ case HEXRGB_SAVE_KC:
+ RGB_STATIC_save_eeprom();
+ hexrgb.active = false;
+ return;
+ case HEXRGB_RESET_KC:
+ RGB_STATIC_reset();
+ hexrgb.active = false;
+ return;
+ default:
+ }
+ }
+
+ int8_t digit = key_hexdigit(keycode);
+ /* exit input mode if an invalid key has been pressed */
+ if (digit == -1) {
+ hexrgb.count = 0;
+ hexrgb.active = false;
+ return;
+ }
+
+ /* append digit to current color */
+ uint8_t idx = hexrgb.count / 2;
+ hexrgb.color[idx] <<= 4;
+ hexrgb.color[idx] |= digit;
+
+ ++hexrgb.count;
+ /* done with input */
+ if (hexrgb.count == 6) {
+ hexrgb.active = false;
+ hexrgb.count = 0;
+ /* copy color to rgb_static's buffer */
+ for (int8_t i = 0; i < 3; ++i) {
+ g_rgb_static_color[i] = hexrgb.color[i];
+ hexrgb.color[i] = 0;
+ }
+ }
+}
+
+void keyboard_post_init_user(void) {
+#if CUSTOM_DEBUG
+ debug_enable = true;
+ debug_matrix = true;
+#endif
+}
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ /* shift status last time ck_escg was pressed so that the correct key can be released */
+ static bool ck_escg_last_shifted;
+
+ if (hexrgb.active && record->event.pressed) {
+ hexrgb_input(keycode);
+ /* while in input mode nothing passes through */
+ return false;
+ }
+
+ switch (keycode) {
+ case CK_HEXRGB:
+ hexrgb.active = record->event.pressed;
+ return false;
+ case CK_ESCG:
+ /* if pressed, inject key, otherwise delete it */
+ if (record->event.pressed) {
+ bool shifted = get_mods() & MOD_BIT(KC_LSHIFT);
+ add_key(shifted ? KC_ESC : KC_GRV);
+ ck_escg_last_shifted = shifted;
+ } else {
+ del_key(ck_escg_last_shifted ? KC_ESC : KC_GRV);
+ }
+ send_keyboard_report();
+ return false;
+ default:
+ }
+ return true;
+}
diff --git a/keyboards/kbdfans/kbd67/mkiirgb/keymaps/spx01/readme.md b/keyboards/kbdfans/kbd67/mkiirgb/keymaps/spx01/readme.md
new file mode 100644
index 0000000000..86b90772b0
--- /dev/null
+++ b/keyboards/kbdfans/kbd67/mkiirgb/keymaps/spx01/readme.md
@@ -0,0 +1,23 @@
+# spx01's KBD67 MKIIRGB Layout
+
+This is a fairly simple QWERTY 2 layer layout, full list of particularities below:
+
+* Besides Fn acting like a standard layer switch, CapsLock is set to switch to layer 2 while held and activate CapsLock when tapped.
+* The Esc key/grave key (top left) is set to QMK's "Grave Escape" (sends Esc when tapped alone, Grave when tapped together with Shift/Ctrl/GUI), but on the 2nd layer it's set to the CK_ESCG custom keycode, acting like grave when tapped alone and as Esc when Shift is also held down. This means that there is easy access to both the characters (grave and tilde) and the Esc key while also allowing for shortcuts such as Ctrl+Shift+Esc with Ctrl+Shift+Caps+Esc (the Windows Task Manager shortcut).
+* The default RGB Matrix effect is set to a custom one, RGB_STATIC, which sets a solid RGB color based on a global variable, featuring EEPROM saving and automatic loading independent on the HSV EEPROM memory that the standard effects use. This was done in order to accomodate the next feature.
+* The HexRGB mode is triggered by pressing the '/' key in the second layer (CK_HEXRGB) and enables the user to type a 6 digit hexadecimal color code that is then stored as the color for the RGB_STATIC effect. If any invalid key is pressed during color input, the keymap will go back to its normal behavior without any changes to RGB.
+* Besides keys representing hexadecimal digits (0-9 and a-f), there are also 2 more keys that provide functionality in the HexRGB input mode (only as a first keypress). HEXRGB_SAVE_KC (set by default to S) triggers the RGB_STATIC effect to save the currently set RGB color to EEPROM and the HEXRGB_RESET_KC (set by default to R) resets the RGB color to the one currently saved in EEPROM. These 2 keys can be reassigned in config.h.
+
+Various 2nd layer keys:
+* 1 to '+' for F1-12
+* P for PrtSc/Print
+* Backspace for Delete
+* Home (top right key) for Insert
+* E for resetting EEPROM
+* '\\' for bootloader mode
+* Space for toggling RGB on or off
+* Right Shift for pausing media
+* Left/Right for previous track/next track
+* Up/Down for volume up/down
+
+**Note: I disabled VIA in rules.mk because I don't use it, but there is enough memory space for it to be enabled.**
diff --git a/keyboards/kbdfans/kbd67/mkiirgb/keymaps/spx01/rgb_matrix_user.inc b/keyboards/kbdfans/kbd67/mkiirgb/keymaps/spx01/rgb_matrix_user.inc
new file mode 100644
index 0000000000..85c4dc2cad
--- /dev/null
+++ b/keyboards/kbdfans/kbd67/mkiirgb/keymaps/spx01/rgb_matrix_user.inc
@@ -0,0 +1,68 @@
+/* Copyright 2022 spx01 (@spx01)
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+RGB_MATRIX_EFFECT(RGB_STATIC)
+
+#define UNWRAP_RGB_PARAMS(x) x[0], x[1], x[2]
+#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+
+/* eeprom saved data structure */
+typedef struct {
+ union {
+ uint32_t whole;
+ uint8_t rgb[3];
+ };
+} UserData;
+
+uint8_t g_rgb_static_color[3];
+
+/* save current colors to eeprom */
+void RGB_STATIC_save_eeprom(void) {
+ UserData data = {0};
+ for (int8_t i = 0; i < 3; ++i) {
+ data.rgb[i] = g_rgb_static_color[i];
+ }
+ eeconfig_update_user(data.whole);
+}
+
+/* initialize by loading the eeprom colors */
+static void RGB_STATIC_init(void) {
+ UserData data;
+ data.whole = eeconfig_read_user();
+ for (int8_t i = 0; i < 3; ++i) {
+ g_rgb_static_color[i] = data.rgb[i];
+ }
+}
+
+/* reset colors to eeprom values */
+void RGB_STATIC_reset(void) {
+ RGB_STATIC_init();
+}
+
+static bool RGB_STATIC(effect_params_t *params) {
+ if (params->init) {
+ RGB_STATIC_init();
+ }
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
+ for (uint8_t i = led_min; i < led_max; i++) {
+ RGB_MATRIX_TEST_LED_FLAGS();
+ rgb_matrix_set_color(i, UNWRAP_RGB_PARAMS(g_rgb_static_color));
+ }
+ return rgb_matrix_check_finished_leds(led_max);
+}
+
+#endif
+#undef UNWRAP_RGB_PARAMS
diff --git a/keyboards/kbdfans/kbd67/mkiirgb/keymaps/spx01/rules.mk b/keyboards/kbdfans/kbd67/mkiirgb/keymaps/spx01/rules.mk
new file mode 100644
index 0000000000..2700c035cc
--- /dev/null
+++ b/keyboards/kbdfans/kbd67/mkiirgb/keymaps/spx01/rules.mk
@@ -0,0 +1,4 @@
+VIA_ENABLE = no
+LTO_ENABLE = yes
+CONSOLE_ENABLE = no
+RGB_MATRIX_CUSTOM_USER = yes