diff --git a/keyboards/royal_kludge/rk61/keymaps/default/keymap.c b/keyboards/royal_kludge/rk61/keymaps/default/keymap.c new file mode 100644 index 000000000000..10a9cf4f6e64 --- /dev/null +++ b/keyboards/royal_kludge/rk61/keymaps/default/keymap.c @@ -0,0 +1,31 @@ +/* +Copyright 2022 mr. JULY + +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 "layout.h" + +enum layer_names { + _BASE, // default layer + _RMODS, // right modifiers: Alt, context menu, Ctrl instead of arrows + _FN, // functional layer (F1-F10, backlight controls etc.) +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE] = BASE_KEYMAP, + [_RMODS] = RMODS_KEYMAP, + [_FN] = FN_KEYMAP +}; diff --git a/keyboards/royal_kludge/rk61/keymaps/default/layout.h b/keyboards/royal_kludge/rk61/keymaps/default/layout.h new file mode 100644 index 000000000000..17ce86d037e9 --- /dev/null +++ b/keyboards/royal_kludge/rk61/keymaps/default/layout.h @@ -0,0 +1,64 @@ +/* +Copyright 2022 mr. JULY + +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 + +/* +Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 */ + +#define LAYOUT( \ + k0_00, k0_01, k0_02, k0_03, k0_04, k0_05, k0_06, k0_07, k0_08, k0_09, k0_10, k0_11, k0_12, k0_13, \ + k1_00, k1_01, k1_02, k1_03, k1_04, k1_05, k1_06, k1_07, k1_08, k1_09, k1_10, k1_11, k1_12, k1_13, \ + k2_00, k2_01, k2_02, k2_03, k2_04, k2_05, k2_06, k2_07, k2_08, k2_09, k2_10, k2_11, k2_12, k2_13, \ + k3_00, k3_01, k3_02, k3_03, k3_04, k3_05, k3_06, k3_07, k3_08, k3_09, k3_10, k3_11, k3_12, k3_13, \ + k4_00, k4_01, k4_02, k4_03, k4_04, k4_05, k4_06, k4_07, k4_08, k4_09, k4_10, k4_11, k4_12, k4_13 \ + ) { \ + { k0_00, k0_01, k0_02, k0_03, k0_04, k0_05, k0_06, k0_07, k0_08, k0_09, k0_10, k0_11, k0_12, k0_13, }, \ + { k1_00, k1_01, k1_02, k1_03, k1_04, k1_05, k1_06, k1_07, k1_08, k1_09, k1_10, k1_11, k1_12, k1_13, }, \ + { k2_00, k2_01, k2_02, k2_03, k2_04, k2_05, k2_06, k2_07, k2_08, k2_09, k2_10, k2_11, k2_12, k2_13, }, \ + { k3_00, k3_01, k3_02, k3_03, k3_04, k3_05, k3_06, k3_07, k3_08, k3_09, k3_10, k3_11, k3_12, k3_13, }, \ + { k4_00, k4_01, k4_02, k4_03, k4_04, k4_05, k4_06, k4_07, k4_08, k4_09, k4_10, k4_11, k4_12, k4_13, } \ +} +// default layer +#define BASE_KEYMAP_(caps, nuhs, nubs) 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_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, \ + caps, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, nuhs, KC_ENT, \ + KC_LSFT, nubs, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_RSFT, XXXXXXX, \ + KC_LCTL, KC_LGUI, KC_LALT, XXXXXXX, XXXXXXX, XXXXXXX, KC_SPC, XXXXXXX, XXXXXXX, KC_LEFT, KC_DOWN, KC_RIGHT, XXXXXXX, MO(_FN) \ +) +#define BASE_KEYMAP BASE_KEYMAP_(KC_CAPS, KC_NUHS, KC_NUBS) + +// snap right hand modifiers: Alt, context menu, Ctrl instead of arrows +#define RMODS_KEYMAP_(ralt) LAYOUT( \ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_SLSH, _______, _______, \ + _______, _______, _______, _______, _______, _______, _______, _______, _______, ralt, KC_APP, KC_RCTL, _______, _______ \ +) + +#define RMODS_KEYMAP RMODS_KEYMAP_(KC_RALT) + +// functional layer (F1-F10, backlight controls etc.) +#define FN_KEYMAP LAYOUT( \ + 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, \ + _______, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_PSCR, KC_SLCK, KC_PAUS, _______, RGB_HUI, RGB_SAI, RGB_VAI, RGB_MOD, \ + RESET, KC_VOLU, KC_BRIU, _______, _______, _______, KC_INS, KC_HOME, KC_PGUP, _______, RGB_SPD, RGB_SPI, RGB_MOD, TG(_RMODS), \ + _______, _______, KC_VOLD, KC_BRID, _______, _______, _______, KC_DEL, KC_END, KC_PGDN, _______, KC_SLSH, _______, _______, \ + _______, GUI_TOG, _______, _______, _______, _______, _______, _______, _______, KC_RALT, KC_APP, KC_RCTL, _______, _______ \ +) diff --git a/keyboards/royal_kludge/rk61/keymaps/iso-neo-l3l4/combo.c b/keyboards/royal_kludge/rk61/keymaps/iso-neo-l3l4/combo.c new file mode 100644 index 000000000000..c331763ca4cd --- /dev/null +++ b/keyboards/royal_kludge/rk61/keymaps/iso-neo-l3l4/combo.c @@ -0,0 +1,29 @@ +/* +Copyright 2022 mr. JULY + +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 "quantum.h" + +enum combo_event { + CAPS_COMBO, +}; + +const uint16_t PROGMEM caps_combo[] = {KC_LSFT, KC_RSFT, COMBO_END}; // Combo: both Shift keys together for CAPS_LOCK + +// Register the combo action +combo_t key_combos[COMBO_COUNT] = { + [CAPS_COMBO] = COMBO(caps_combo, KC_CAPS), +}; diff --git a/keyboards/royal_kludge/rk61/keymaps/iso-neo-l3l4/config.h b/keyboards/royal_kludge/rk61/keymaps/iso-neo-l3l4/config.h new file mode 100644 index 000000000000..862b8f7a7419 --- /dev/null +++ b/keyboards/royal_kludge/rk61/keymaps/iso-neo-l3l4/config.h @@ -0,0 +1,22 @@ +/* +Copyright 2022 mr. JULY + +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 KEYMAP_ISO 1 + +#define COMBO_COUNT 1 // Number of defined combos diff --git a/keyboards/royal_kludge/rk61/keymaps/iso-neo-l3l4/keymap.c b/keyboards/royal_kludge/rk61/keymaps/iso-neo-l3l4/keymap.c new file mode 100644 index 000000000000..0eeea3e3f22d --- /dev/null +++ b/keyboards/royal_kludge/rk61/keymaps/iso-neo-l3l4/keymap.c @@ -0,0 +1,48 @@ +/* +Copyright 2022 mr. JULY + +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 "keymap_german.h" +#include "../default/layout.h" + +enum layer_names { + _BASE, // default layer + _RMODS, // right modifiers: Alt, context menu, Ctrl instead of arrows + _L3, // neo layout layer 3 (special symbols: punctuation, braces etc.) + _L4, // neo layout layer 4 (navigation and numbers) + _FN, // functional layer (F1-F10, backlight controls etc.) +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE] = BASE_KEYMAP_(MO(_L3), MO(_L3), MO(_L4)), + [_RMODS] = RMODS_KEYMAP_(MO(_L4)), + [_L3] = { + { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, }, + { _______, RALT(KC_DOT),DE_UNDS, DE_LBRC, DE_RBRC, DE_CIRC, DE_EXLM, DE_LABK, DE_RABK, DE_EQL, DE_AMPR, _______, _______, _______, }, + { _______, DE_BSLS, DE_SLSH, DE_LCBR, DE_RCBR, DE_ASTR, DE_QUES, DE_LPRN, DE_RPRN, DE_MINS, DE_COLN, DE_AT, _______, _______, }, + { _______, _______, DE_HASH, DE_DLR, DE_PIPE, DE_TILD, DE_GRV, DE_PLUS, DE_PERC, DE_DQUO, DE_QUOT, DE_SCLN, _______, _______, }, + { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, } + }, + [_L4] = { + { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, }, + { _______, KC_PGUP, KC_BSPC, KC_UP, KC_DEL, KC_PGDN, KC_PSLS, KC_P7, KC_P8, KC_P9, KC_PMNS, _______, _______, _______, }, + { _______, KC_HOME, KC_LEFT, KC_DOWN, KC_RIGHT, KC_END, KC_PAST, KC_P4, KC_P5, KC_P6, KC_PPLS, _______, _______, _______, }, + { _______, _______, KC_ESC, KC_TAB, KC_INS, KC_ENTER, LCTL(DE_Z), KC_NLCK, KC_P1, KC_P2, KC_P3, KC_PDOT, _______, _______, }, + { _______, _______, _______, _______, _______, _______, KC_P0, _______, _______, _______, _______, _______, _______, _______, } + }, + [_FN] = FN_KEYMAP +}; diff --git a/keyboards/royal_kludge/rk61/keymaps/iso-neo-l3l4/rules.mk b/keyboards/royal_kludge/rk61/keymaps/iso-neo-l3l4/rules.mk new file mode 100644 index 000000000000..437819311203 --- /dev/null +++ b/keyboards/royal_kludge/rk61/keymaps/iso-neo-l3l4/rules.mk @@ -0,0 +1,3 @@ +COMBO_ENABLE = yes # Used to allow chording of keys to trigger an action + +SRC += combo.c diff --git a/keyboards/royal_kludge/rk61/keymaps/iso/config.h b/keyboards/royal_kludge/rk61/keymaps/iso/config.h new file mode 100644 index 000000000000..ad4df11bad84 --- /dev/null +++ b/keyboards/royal_kludge/rk61/keymaps/iso/config.h @@ -0,0 +1,20 @@ +/* +Copyright 2022 mr. JULY + +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 KEYMAP_ISO 1 \ No newline at end of file diff --git a/keyboards/royal_kludge/rk61/keymaps/iso/keymap.c b/keyboards/royal_kludge/rk61/keymaps/iso/keymap.c new file mode 100644 index 000000000000..0c992e59d37e --- /dev/null +++ b/keyboards/royal_kludge/rk61/keymaps/iso/keymap.c @@ -0,0 +1,18 @@ +/* +Copyright 2022 mr. JULY + +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 "../default/keymap.c" diff --git a/keyboards/royal_kludge/rk61/keymaps/korkem/config.h b/keyboards/royal_kludge/rk61/keymaps/korkem/config.h new file mode 100644 index 000000000000..0cabf116a457 --- /dev/null +++ b/keyboards/royal_kludge/rk61/keymaps/korkem/config.h @@ -0,0 +1,26 @@ +/* +Copyright 2022 mr. JULY + +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 KEYMAP_ISO 1 + +// allow fast typing on home row mods +#define IGNORE_MOD_TAP_INTERRUPT + +// enable rapid switch from tap to hold, disables double tap hold auto-repeat +#define TAPPING_FORCE_HOLD diff --git a/keyboards/royal_kludge/rk61/keymaps/korkem/features/caps_word.c b/keyboards/royal_kludge/rk61/keymaps/korkem/features/caps_word.c new file mode 100644 index 000000000000..a858fd58a7e8 --- /dev/null +++ b/keyboards/royal_kludge/rk61/keymaps/korkem/features/caps_word.c @@ -0,0 +1,159 @@ +// Copyright 2021-2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// For full documentation, see +// https://getreuer.info/posts/keyboards/caps-word + +#include "caps_word.h" + +static bool caps_word_active = false; + +// Many keyboards enable the Command feature, which by default is also activated +// by Left Shift + Right Shift. It can be configured to use a different key +// combination by defining IS_COMMAND(). We make a non-fatal warning if Command +// is enabled but IS_COMMAND() is *not* defined. +#if defined(COMMAND_ENABLE) && !defined(IS_COMMAND) +#pragma message "Caps Word and Command should not be enabled at the same time, since both use the Left Shift + Right Shift key combination. Please disable Command, or ensure that `IS_COMMAND` is not set to (get_mods() == MOD_MASK_SHIFT)." +#endif // defined(COMMAND_ENABLE) && !defined(IS_COMMAND) + +#if CAPS_WORD_IDLE_TIMEOUT > 0 +#if CAPS_WORD_IDLE_TIMEOUT < 100 || CAPS_WORD_IDLE_TIMEOUT > 30000 +// Constrain timeout to a sensible range. With the 16-bit timer, the longest +// representable timeout is 32768 ms, rounded here to 30000 ms = half a minute. +#error "caps_word: CAPS_WORD_IDLE_TIMEOUT must be between 100 and 30000 ms" +#endif + +static uint16_t idle_timer = 0; + +void caps_word_task(void) { + if (caps_word_active && timer_expired(timer_read(), idle_timer)) { + caps_word_set(false); + } +} +#endif // CAPS_WORD_IDLE_TIMEOUT > 0 + +bool process_caps_word(uint16_t keycode, keyrecord_t* record) { +#ifndef NO_ACTION_ONESHOT + const uint8_t mods = get_mods() | get_oneshot_mods(); +#else + const uint8_t mods = get_mods(); +#endif // NO_ACTION_ONESHOT + + if (!caps_word_active) { + // Pressing both shift keys at the same time enables caps word. + if (mods == MOD_MASK_SHIFT) { + caps_word_set(true); // Activate Caps Word. + return false; + } + return true; + } else { +#if CAPS_WORD_IDLE_TIMEOUT > 0 + idle_timer = record->event.time + CAPS_WORD_IDLE_TIMEOUT; +#endif // CAPS_WORD_IDLE_TIMEOUT > 0 + } + + if (!record->event.pressed) { return true; } + + if (!(mods & ~MOD_MASK_SHIFT)) { + switch (keycode) { + // Ignore MO, TO, TG, TT, and OSL layer switch keys. + case QK_MOMENTARY ... QK_MOMENTARY_MAX: + case QK_TO ... QK_TO_MAX: + case QK_TOGGLE_LAYER ... QK_TOGGLE_LAYER_MAX: + case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX: + case QK_ONE_SHOT_LAYER ... QK_ONE_SHOT_LAYER_MAX: + return true; + +#ifndef NO_ACTION_TAPPING + case QK_MOD_TAP ... QK_MOD_TAP_MAX: + if (record->tap.count == 0) { + // Deactivate if a mod becomes active through holding a mod-tap key. + caps_word_set(false); + return true; + } + keycode &= 0xff; + break; + +#ifndef NO_ACTION_LAYER + case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: +#endif // NO_ACTION_LAYER + if (record->tap.count == 0) { return true; } + keycode &= 0xff; + break; +#endif // NO_ACTION_TAPPING + +#ifdef SWAP_HANDS_ENABLE + case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX: + if (keycode > 0x56F0 || record->tap.count == 0) { return true; } + keycode &= 0xff; + break; +#endif // SWAP_HANDS_ENABLE + } + + clear_weak_mods(); + if (caps_word_press_user(keycode)) { + send_keyboard_report(); + return true; + } + } + + caps_word_set(false); // Deactivate Caps Word. + return true; +} + +void caps_word_set(bool active) { + if (active != caps_word_active) { + if (active) { + clear_mods(); +#ifndef NO_ACTION_ONESHOT + clear_oneshot_mods(); +#endif // NO_ACTION_ONESHOT +#if CAPS_WORD_IDLE_TIMEOUT > 0 + idle_timer = timer_read() + CAPS_WORD_IDLE_TIMEOUT; +#endif // CAPS_WORD_IDLE_TIMEOUT > 0 + } else { + // Make sure weak shift is off. + unregister_weak_mods(MOD_BIT(KC_LSFT)); + } + + caps_word_active = active; + caps_word_set_user(active); + } +} + +bool caps_word_get(void) { return caps_word_active; } + +__attribute__((weak)) void caps_word_set_user(bool active) {} + +__attribute__((weak)) bool caps_word_press_user(uint16_t keycode) { + switch (keycode) { + // Keycodes that continue Caps Word, with shift applied. + case KC_A ... KC_Z: + case KC_MINS: + add_weak_mods(MOD_BIT(KC_LSFT)); // Apply shift to the next key. + return true; + + // Keycodes that continue Caps Word, without shifting. + case KC_1 ... KC_0: + case KC_BSPC: + case KC_DEL: + case KC_UNDS: + return true; + + default: + return false; // Deactivate Caps Word. + } +} + diff --git a/keyboards/royal_kludge/rk61/keymaps/korkem/features/caps_word.h b/keyboards/royal_kludge/rk61/keymaps/korkem/features/caps_word.h new file mode 100644 index 000000000000..adec54f61b24 --- /dev/null +++ b/keyboards/royal_kludge/rk61/keymaps/korkem/features/caps_word.h @@ -0,0 +1,136 @@ +// Copyright 2021-2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// Caps Word, activated by pressing both shift keys at the same time. +// +// This library implements "Caps Word", which is like conventional Caps Lock, +// but automatically disables itself at the end of the word. This is useful for +// typing all-caps identifiers like `MOD_MASK_ALT`. +// +// Caps Word is activated by pressing the left and right shift keys at the same +// time. This way you don't need a dedicated key for using Caps Word. I've +// tested that this works as expected with one-shot mods and Space Cadet Shift. +// If your shift keys are mod-taps, activate Caps Word by holding both shift +// mod-tap keys until the tapping term, release them, then begin typing. +// +// Optionally, Caps Word may be configured to deactivate if the keyboard is idle +// for some time. This is useful to mitigate unintended shifting when you get +// interrupted or switch to the mouse while Caps Word is active. In your +// config.h, define `CAPS_WORD_IDLE_TIMEOUT` with a time in milliseconds: +// +// #define CAPS_WORD_IDLE_TIMEOUT 5000 // Turn off Caps Word after 5 seconds. +// +// and in your keymap.c, define (or add to) `matrix_scan_user()` as +// +// void matrix_scan_user(void) { +// caps_word_task(); +// // Other tasks... +// } +// +// For full documentation, see +// https://getreuer.info/posts/keyboards/caps-word + +#pragma once + +#include "quantum.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Call this function from `process_record_user()` to implement Caps Word. +bool process_caps_word(uint16_t keycode, keyrecord_t* record); + +// If CAPS_WORD_IDLE_TIMEOUT is set, call `caps_word_task()` from +// `matrix_scan_user()` as described above. +// +// If CAPS_WORD_IDLE_TIMEOUT isn't set, calling this function has no effect (but +// will still compile). +#if CAPS_WORD_IDLE_TIMEOUT > 0 +void caps_word_task(void); +#else +static inline void caps_word_task(void) {} +#endif + +// Activates or deactivates Caps Word. For instance activate Caps Word with a +// combo by defining a `COMBO_ACTION` that calls `caps_word_set(true)`: +// +// void process_combo_event(uint16_t combo_index, bool pressed) { +// switch(combo_index) { +// case CAPS_COMBO: +// if (pressed) { +// caps_word_set(true); // Activate Caps Word. +// } +// break; +// +// // Other combos... +// } +// } +void caps_word_set(bool active); + +// Returns whether Caps Word is currently active. +bool caps_word_get(void); + +// An optional callback that gets called when Caps Word turns on or off. This is +// useful to represent the current Caps Word state, e.g. by setting an LED or +// playing a sound. In your keymap, define +// +// void caps_word_set_user(bool active) { +// if (active) { +// // Do something when Caps Word activates. +// } else { +// // Do something when Caps Word deactivates. +// } +// } +void caps_word_set_user(bool active); + +// An optional callback which is called on every key press while Caps Word is +// active. When the key should be shifted (that is, a letter key), the callback +// should call `add_weak_mods(MOD_BIT(KC_LSFT))` to shift the key. The callback +// also determines whether the key should continue Caps Word. Returning true +// continues the current "word", while returning false is "word breaking" and +// deactivates Caps Word. The default callback is +// +// bool caps_word_press_user(uint16_t keycode) { +// switch (keycode) { +// // Keycodes that continue Caps Word, with shift applied. +// case KC_A ... KC_Z: +// case KC_MINS: +// add_weak_mods(MOD_BIT(KC_LSFT)); // Apply shift to the next key. +// return true; +// +// // Keycodes that continue Caps Word, without shifting. +// case KC_1 ... KC_0: +// case KC_BSPC: +// case KC_DEL: +// case KC_UNDS: +// return true; +// +// default: +// return false; // Deactivate Caps Word. +// } +// } +// +// To customize, copy the above function into your keymap and add/remove +// keycodes to the above cases. +// +// NOTE: Outside of this callback, you can use `caps_word_set(false)` to +// deactivate Caps Word. +bool caps_word_press_user(uint16_t keycode); + +#ifdef __cplusplus +} +#endif + diff --git a/keyboards/royal_kludge/rk61/keymaps/korkem/features/layer_lock.c b/keyboards/royal_kludge/rk61/keymaps/korkem/features/layer_lock.c new file mode 100644 index 000000000000..8ca74d3d7fa7 --- /dev/null +++ b/keyboards/royal_kludge/rk61/keymaps/korkem/features/layer_lock.c @@ -0,0 +1,95 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// For full documentation, see +// https://getreuer.info/posts/keyboards/layer-lock + +#include "layer_lock.h" + +// The current lock state. The kth bit is on if layer k is locked. +static layer_state_t locked_layers = 0; + +bool process_layer_lock(uint16_t keycode, keyrecord_t* record, + uint16_t lock_keycode) { + // The intention is that locked layers remain on. If something outside of + // this feature turned any locked layers off, unlock them. + if ((locked_layers & ~layer_state) != 0) { + layer_lock_set_user(locked_layers &= layer_state); + } + + if (keycode == lock_keycode) { + if (record->event.pressed) { // The layer lock key was pressed. + layer_lock_invert(get_highest_layer(layer_state)); + } + return false; + } + + switch (keycode) { + case QK_MOMENTARY ... QK_MOMENTARY_MAX: // `MO(layer)` keys. + case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX: { // `TT(layer)`. + const uint8_t layer = keycode & 255; + if (is_layer_locked(layer)) { + // Event on `MO` or `TT` key where layer is locked. + if (record->event.pressed) { // On press, unlock the layer. + layer_lock_invert(layer); + } + return false; // Skip default handling. + } + } break; + +#ifndef NO_ACTION_TAPPING + case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: // `LT(layer, key)` keys. + if (record->tap.count == 0 && !record->event.pressed && + is_layer_locked((keycode >> 8) & 15)) { + // Release event on a held layer-tap key where the layer is locked. + return false; // Skip default handling so that layer stays on. + } + break; +#endif // NO_ACTION_TAPPING + } + + return true; +} + +bool is_layer_locked(uint8_t layer) { + return locked_layers & ((layer_state_t)1 << layer); +} + +void layer_lock_invert(uint8_t layer) { + const layer_state_t mask = (layer_state_t)1 << layer; + if ((locked_layers & mask) == 0) { // Layer is being locked. +#ifndef NO_ACTION_ONESHOT + if (layer == get_oneshot_layer()) { + reset_oneshot_layer(); // Reset so that OSL doesn't turn layer off. + } +#endif // NO_ACTION_ONESHOT + layer_on(layer); + } else { // Layer is being unlocked. + layer_off(layer); + } + layer_lock_set_user(locked_layers ^= mask); +} + +// Implement layer_lock_on/off by deferring to layer_lock_invert. +void layer_lock_on(uint8_t layer) { + if (!is_layer_locked(layer)) { layer_lock_invert(layer); } +} + +void layer_lock_off(uint8_t layer) { + if (is_layer_locked(layer)) { layer_lock_invert(layer); } +} + +__attribute__((weak)) void layer_lock_set_user(layer_state_t locked_layers) {} + diff --git a/keyboards/royal_kludge/rk61/keymaps/korkem/features/layer_lock.h b/keyboards/royal_kludge/rk61/keymaps/korkem/features/layer_lock.h new file mode 100644 index 000000000000..ee57e4209bca --- /dev/null +++ b/keyboards/royal_kludge/rk61/keymaps/korkem/features/layer_lock.h @@ -0,0 +1,88 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// Layer Lock, a key to stay in the current layer. +// +// Layers are often accessed by holding a button, e.g. with a momentary layer +// switch `MO(layer)` or layer tap `LT(layer, key)` key. But you may sometimes +// want to "lock" or "toggle" the layer so that it stays on without having to +// hold down a button. One way to do that is with a tap-toggle `TT` layer key, +// but here is an alternative. +// +// This library implements a "Layer Lock key". When tapped, it "locks" the +// highest layer to stay active, assuming the layer was activated by one of the +// following keys: +// +// * `MO(layer)` momentary layer switch +// * `LT(layer, key)` layer tap +// * `OSL(layer)` one-shot layer +// * `TT(layer)` layer tap toggle +// +// Tapping the Layer Lock key again unlocks and turns off the layer. +// +// NOTE: When a layer is "locked", other layer keys such as `TO(layer)` or +// manually calling `layer_off(layer)` will override and unlock the layer. +// +// For full documentation, see +// https://getreuer.info/posts/keyboards/layer-lock + +#pragma once + +#include "quantum.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// In your keymap, define a custom keycode to use for Layer Lock. Then handle +// Layer Lock from your `process_record_user` function by calling +// `process_layer_lock`, passing your custom keycode for the `lock_keycode` arg: +// +// #include "features/layer_lock.h" +// +// bool process_record_user(uint16_t keycode, keyrecord_t* record) { +// if (!process_layer_lock(keycode, record, LLOCK)) { return false; } +// // Your macros ... +// +// return true; +// } +bool process_layer_lock(uint16_t keycode, keyrecord_t* record, + uint16_t lock_keycode); + +// Returns true if `layer` is currently locked. +bool is_layer_locked(uint8_t layer); + +// Locks and turns on `layer`. +void layer_lock_on(uint8_t layer); + +// Unlocks and turns off `layer`. +void layer_lock_off(uint8_t layer); + +// Toggles whether `layer` is locked. +void layer_lock_invert(uint8_t layer); + +// An optional callback that gets called when a layer is locked or unlocked. +// This is useful to represent the current lock state, e.g. by setting an LED or +// playing a sound. In your keymap, define +// +// void layer_lock_set_user(layer_state_t locked_layers) { +// // Do something like `set_led(is_layer_locked(NAV));` +// } +void layer_lock_set_user(layer_state_t locked_layers); + +#ifdef __cplusplus +} +#endif + diff --git a/keyboards/royal_kludge/rk61/keymaps/korkem/keymap.c b/keyboards/royal_kludge/rk61/keymaps/korkem/keymap.c new file mode 100644 index 000000000000..a8f89cb77cb1 --- /dev/null +++ b/keyboards/royal_kludge/rk61/keymaps/korkem/keymap.c @@ -0,0 +1,254 @@ +/* +Copyright 2022 mr. JULY + +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 "keymap_german.h" +#include "korkem.h" + +// Layer Lock key +// see https://getreuer.info/posts/keyboards/layer-lock/ +#include "features/layer_lock.h" + +// Caps Word +// see https://getreuer.info/posts/keyboards/caps-word/ +// remove after merge of official CAPS_WORD support +#include "features/caps_word.h" + +enum custom_keycodes { + LLOCK = SAFE_RANGE, + CU_QUES, +}; + +enum layer_names { + _STD, // default layer (QWERTY) + _DE_BAS,// custom base layer (DE_) + _EN_BAS,// custom base layer (EN_) + _DE_SYM,// special symbols: punctuation, braces etc. (DE_) + _EN_SYM,// special symbols: punctuation, braces etc. (EN_) + _NAV, // navigation + _MOU, // mouse + _NUM, // numbers + _FUN, // functional layer for right hand (F1-F12) + _DE_LNG,// foreign languages support (DE_) + _EN_LNG,// foreign languages support (EN_) + _FN, // functional layer (F1-F10, backlight controls etc.) +}; + +#define IS_GERMAN IS_LAYER_ON(_DE_BAS) + +// TODO: remove after merge of official CAPS_WORD support +#define CAPSWRD LSFT(KC_RSFT) + +// german specific symbol keys available on english international keyboard +#define EN_EURO RALT(KC_5) +#define EN_ODIA RALT(KC_P) +#define EN_UDIA RALT(KC_Y) +#define EN_ADIA RALT(KC_Q) +#define EN_SS RALT(KC_S) + +// Left-hand home row mods +#define HOME_L6 LT(_FUN, KC_TAB) +#define HOME_L5 LGUI_T(KC_A) +#define HOME_L4 LALT_T(KC_S) +#define HOME_L3 LCTL_T(KC_D) +#define HOME_L2 LSFT_T(KC_F) + +// Right-hand home row mods +#define HOME_R2 RSFT_T(KC_J) +#define HOME_R3 RCTL_T(KC_K) +#define HOME_R4 LALT_T(KC_L) +#define HOME_R5 RGUI_T(CU_QUES) + +// layer activation +#define ESC_NUM LT(_NUM, KC_ESC) +#define DE__SYM LT(_DE_SYM, KC_SPC) +#define EN__SYM LT(_EN_SYM, KC_SPC) +#define BSP_NAV LT(_NAV, KC_BSPC) +#define ENT_MOU LT(_MOU, KC_ENT) + +// foreign languages support activation +#define DE_Q_LN LT(_DE_LNG, DE_Q) +#define EN_Q_LN LT(_EN_LNG, KC_Q) + +// layer toggle +#define DE_BASE TO(_DE_BAS) +#define EN_BASE TO(_EN_BAS) + +// shortcuts +#define U_RDO C(S(DE_Z)) +#define U_PST S(KC_INS) +#define U_CPY C(KC_INS) +#define U_CUT S(KC_DEL) +#define U_UND C(DE_Z) + +// needed for BASE_KEYMAP functionality +#define _RMODS _DE_BAS + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_STD] = BASE_KEYMAP, + [_DE_BAS] = LAYOUT_korkem( + DE_Q_LN, DE_W, DE_E, DE_R, DE_T, DE_Z, DE_U, DE_I, DE_O, DE_P, + HOME_L5, HOME_L4, HOME_L3, HOME_L2, DE_G, DE_H, HOME_R2, HOME_R3, HOME_R4, HOME_R5, + DE_Y, DE_X, DE_C, DE_V, DE_B, DE_N, DE_M, DE_COMM, DE_DOT, DE_MINS, + HOME_L6, ESC_NUM, DE__SYM, BSP_NAV, ENT_MOU + ), + [_DE_SYM] = LAYOUT_korkem( + DE_AT, DE_UNDS, DE_LBRC, DE_RBRC, DE_CIRC, DE_EXLM, DE_LABK, DE_RABK, DE_EQL, DE_AMPR, + DE_BSLS, DE_SLSH, DE_LCBR, DE_RCBR, DE_ASTR, DE_QUES, DE_LPRN, DE_RPRN, DE_MINS, DE_COLN, + DE_HASH, DE_DLR, DE_PIPE, DE_TILD, DE_GRV, DE_PLUS, DE_PERC, DE_DQUO, DE_QUOT, DE_SCLN, + KC_TAB, CAPSWRD, XXXXXXX, KC_DEL, KC_ENT + ), + [_EN_BAS] = LAYOUT_korkem( + EN_Q_LN, KC_W, KC_E, KC_R, KC_T, KC_Z, KC_U, KC_I, KC_O, KC_P, + HOME_L5, HOME_L4, HOME_L3, HOME_L2, KC_G, KC_H, HOME_R2, HOME_R3, HOME_R4, HOME_R5, + KC_Y, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_MINS, + HOME_L6, ESC_NUM, EN__SYM, BSP_NAV, KC_ENT + ), + [_EN_SYM] = LAYOUT_korkem( + KC_AT, KC_UNDS, KC_LBRC, KC_RBRC, KC_CIRC, KC_EXLM, KC_LABK, KC_RABK, KC_EQL, KC_AMPR, + KC_BSLS, KC_SLSH, KC_LCBR, KC_RCBR, KC_ASTR, KC_QUES, KC_LPRN, KC_RPRN, KC_MINS, KC_COLN, + KC_HASH, KC_DLR, KC_PIPE, KC_TILD, KC_GRV, KC_PLUS, KC_PERC, KC_DQUO, KC_QUOT, KC_SCLN, + KC_TAB, CAPSWRD, XXXXXXX, KC_DEL, KC_ENT + ), + [_NAV] = LAYOUT_korkem( + KC_PGUP, KC_BSPC, KC_UP, KC_DEL, KC_PGDN, U_RDO, U_PST, U_CPY, U_CUT, U_UND, + KC_HOME, KC_LEFT, KC_DOWN, KC_RIGHT, KC_END, XXXXXXX, KC_LSFT, KC_LCTL, KC_LALT, KC_LGUI, + KC_CAPS, KC_TAB, KC_INS, KC_ENT, CAPSWRD, LLOCK, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + KC_TAB, KC_ESC, KC_SPC, XXXXXXX, KC_ENT + ), + [_MOU] = LAYOUT_korkem( + KC_WH_U, KC_WH_U, KC_MS_U, KC_WH_D, KC_WH_D, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, RESET, + KC_WH_L, KC_MS_L, KC_MS_D, KC_MS_R, KC_WH_R, XXXXXXX, KC_LSFT, KC_LCTL, KC_LALT, KC_LGUI, + U_UND, U_CUT, U_CPY, U_PST, U_RDO, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + KC_BTN2, KC_BTN3, KC_BTN1, KC_BSPC, XXXXXXX + ), + [_NUM] = LAYOUT_korkem( + U_UND, U_CUT, U_CPY, U_PST, U_RDO, KC_PSLS, KC_P7, KC_P8, KC_P9, KC_PMNS, + KC_LGUI, KC_LALT, KC_LCTL, KC_LSFT, XXXXXXX, KC_PAST, KC_P4, KC_P5, KC_P6, KC_PPLS, + XXXXXXX, XXXXXXX, XXXXXXX, KC_ENT, LLOCK, KC_NLCK, KC_P1, KC_P2, KC_P3, KC_PDOT, + KC_TAB, XXXXXXX, KC_P0, KC_BSPC, KC_ENT + ), + [_FUN] = LAYOUT_korkem( + U_UND, U_CUT, U_CPY, U_PST, U_RDO, KC_PSCR, KC_F7, KC_F8, KC_F9, KC_F12, + KC_LGUI, KC_LALT, KC_LCTL, KC_LSFT, XXXXXXX, KC_SLCK, KC_F4, KC_F5, KC_F6, KC_F11, + DE_BASE, EN_BASE, XXXXXXX, KC_ENT, LLOCK, KC_PAUS, KC_F1, KC_F2, KC_F3, KC_F10, + XXXXXXX, KC_ESC, KC_SPC, KC_BSPC, KC_ENT + ), + [_DE_LNG] = LAYOUT_korkem( + XXXXXXX, U_CUT, U_CPY, U_PST, U_RDO, XXXXXXX, DE_CIRC, DE_LBRC, DE_LCBR, XXXXXXX, + KC_LGUI, KC_LALT, KC_LCTL, KC_LSFT, XXXXXXX, DE_EURO, DE_ODIA, DE_UDIA, DE_ADIA, DE_SS, + XXXXXXX, XXXXXXX, XXXXXXX, KC_ENT, LLOCK, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + KC_TAB, KC_ESC, KC_SPC, KC_BSPC, KC_ENT + ), + [_EN_LNG] = LAYOUT_korkem( + XXXXXXX, U_CUT, U_CPY, U_PST, U_RDO, XXXXXXX, KC_CIRC, KC_LBRC, KC_LCBR, XXXXXXX, + KC_LGUI, KC_LALT, KC_LCTL, KC_LSFT, XXXXXXX, EN_EURO, EN_ODIA, EN_UDIA, EN_ADIA, EN_SS, + XXXXXXX, XXXXXXX, XXXXXXX, KC_ENT, LLOCK, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + KC_TAB, KC_ESC, KC_SPC, KC_BSPC, KC_ENT + ), + [_FN] = FN_KEYMAP +}; + + +// Key overrides (https://docs.qmk.fm/#/feature_key_overrides) +// shift + '[' = ']' +const key_override_t ko_de_s_lbrc = ko_make_basic(MOD_MASK_SHIFT, DE_LBRC, DE_RBRC); +// shift + '{' = '}' +const key_override_t ko_de_s_lcbr = ko_make_basic(MOD_MASK_SHIFT, DE_LCBR, DE_RCBR); +// shift + ',' = ';' on main english layer +const key_override_t ko_en_s_comm = ko_make_with_layers(MOD_MASK_SHIFT, KC_COMM, KC_SCLN, 1 << _EN_BAS); +// shift + '.' = ':' on main english layer +const key_override_t ko_en_s_dot = ko_make_with_layers(MOD_MASK_SHIFT, KC_DOT, KC_COLN, 1 << _EN_BAS); + +// This globally defines all key overrides to be used +const key_override_t **key_overrides = (const key_override_t *[]){ + &ko_de_s_lbrc, + &ko_de_s_lcbr, + &ko_en_s_comm, + &ko_en_s_dot, + NULL // Null terminate the array of overrides! +}; + +// allow different keys for normal and shifted states on mod-tap modifiers +bool process_custom_mod_tap(uint16_t keycode, keyrecord_t* record) { + switch (keycode) { + case HOME_R5: + if (record->tap.count && record->event.pressed) { + bool is_german = IS_GERMAN; + uint16_t exlm = is_german ? DE_EXLM : KC_EXLM; + uint16_t ques = is_german ? DE_QUES : KC_QUES; + + if (get_mods() & MOD_MASK_SHIFT) { + tap_code16(exlm); // Send '!' on shift tap + } else { + tap_code16(ques); // Send '?' on tap + } + return false; // Return false to ignore further processing of key + } + } + + return true; +} + +// foreign languages support for CAPS_WORD +bool caps_word_press_user(uint16_t keycode) { + switch (keycode) { + // Keycodes that continue Caps Word, with shift applied. + case KC_A ... KC_Z: + add_weak_mods(MOD_BIT(KC_LSFT)); // Apply shift to the next key. + // Keycodes that continue Caps Word, without shifting. + case KC_1 ... KC_0: + case KC_BSPC: + case KC_DEL: + return true; + } + + if (IS_GERMAN) { + switch (keycode) { + case DE_ADIA: + case DE_ODIA: + case DE_UDIA: + case DE_MINS: + add_weak_mods(MOD_BIT(KC_LSFT)); + case DE_UNDS: + return true; + } + } else { + switch (keycode) { + case EN_ADIA: + case EN_ODIA: + case EN_UDIA: + case KC_MINS: + add_weak_mods(MOD_BIT(KC_LSFT)); + case KC_UNDS: + return true; + } + } + + return false; // Deactivate Caps Word. +} + +// custom event processing +bool process_record_user(uint16_t keycode, keyrecord_t* record) { + return + // TODO: remove after merge of official CAPS_WORD support + process_caps_word(keycode, record) && + process_layer_lock(keycode, record, LLOCK) && + process_custom_mod_tap(keycode, record) && + true; +} + diff --git a/keyboards/royal_kludge/rk61/keymaps/korkem/korkem.h b/keyboards/royal_kludge/rk61/keymaps/korkem/korkem.h new file mode 100644 index 000000000000..5cdd2a8df1bb --- /dev/null +++ b/keyboards/royal_kludge/rk61/keymaps/korkem/korkem.h @@ -0,0 +1,57 @@ +/* +Copyright 2022 mr. JULY + +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 "../default/layout.h" + + +#define LAYOUT_PATCH_korkem( \ + k0_00, k0_01, k0_02, k0_03, k0_04, k0_05, k0_06, k0_07, k0_08, k0_09, k0_10, k0_11, k0_12, k0_13, \ + k1_00, k1_01, k1_02, k1_03, k1_04, k1_05, k1_06, k1_07, k1_08, k1_09, k1_10, k1_11, k1_12, k1_13, \ + k2_00, k2_01, k2_02, k2_03, k2_04, k2_05, k2_06, k2_07, k2_08, k2_09, k2_10, k2_11, k2_12, k2_13, \ + k3_00, k3_01, k3_02, k3_03, k3_04, k3_05, k3_06, k3_07, k3_08, k3_09, k3_10, k3_11, k3_12, k3_13, \ + k4_00, k4_01, k4_02, k4_03, k4_04, k4_05, k4_06, k4_07, k4_08, k4_09, k4_10, k4_11, k4_12, k4_13, \ + p1_01, p1_02, p1_03, p1_04, p1_05, p1_06, p1_07, p1_08, p1_09, p1_10, \ + p2_01, p2_02, p2_03, p2_04, p2_05, p2_06, p2_07, p2_08, p2_09, p2_10, \ + p3_01, p3_02, p3_03, p3_04, p3_05, p3_06, p3_07, p3_08, p3_09, p3_10, \ + p4_01, p4_02, p4_03, p4_04, p4_05 \ + ) LAYOUT(\ + k0_00, k0_01, k0_02, k0_03, k0_04, k0_05, k0_06, k0_07, k0_08, k0_09, k0_10, k0_11, k0_12, k0_13, \ + k1_00, p1_01, p1_02, p1_03, p1_04, p1_05, p1_06, p1_07, p1_08, p1_09, p1_10, k1_11, k1_12, k1_13, \ + p4_01, p2_01, p2_02, p2_03, p2_04, p2_05, p2_06, p2_07, p2_08, p2_09, p2_10, k2_11, k2_12, p4_05, \ + k3_00, k3_01, p3_01, p3_02, p3_03, p3_04, p3_05, p3_06, p3_07, p3_08, p3_09, p3_10, k3_12, k3_13, \ + k4_00, k4_01, p4_02, k4_03, k4_04, k4_05, p4_03, k4_07, k4_08, p4_04, k4_10, k4_11, k4_12, k4_13 \ +) + +#define LAYOUT_korkem( \ + p1_01, p1_02, p1_03, p1_04, p1_05, p1_06, p1_07, p1_08, p1_09, p1_10, \ + p2_01, p2_02, p2_03, p2_04, p2_05, p2_06, p2_07, p2_08, p2_09, p2_10, \ + p3_01, p3_02, p3_03, p3_04, p3_05, p3_06, p3_07, p3_08, p3_09, p3_10, \ + p4_01, p4_02, p4_03, p4_04, p4_05 \ +) LAYOUT_PATCH_korkem( \ + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \ + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \ + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \ + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \ + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, \ + p1_01, p1_02, p1_03, p1_04, p1_05, p1_06, p1_07, p1_08, p1_09, p1_10, \ + p2_01, p2_02, p2_03, p2_04, p2_05, p2_06, p2_07, p2_08, p2_09, p2_10, \ + p3_01, p3_02, p3_03, p3_04, p3_05, p3_06, p3_07, p3_08, p3_09, p3_10, \ + p4_01, p4_02, p4_03, p4_04, p4_05 \ +) + diff --git a/keyboards/royal_kludge/rk61/keymaps/korkem/rules.mk b/keyboards/royal_kludge/rk61/keymaps/korkem/rules.mk new file mode 100644 index 000000000000..c9d9ba08f21e --- /dev/null +++ b/keyboards/royal_kludge/rk61/keymaps/korkem/rules.mk @@ -0,0 +1,11 @@ +KEY_OVERRIDE_ENABLE = yes # Enable send different key codes depending on the modifiers + +MOUSEKEY_ENABLE = yes # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control + +COMMAND_ENABLE = no # Enable the way to change keyboard’s behavior without having to flash or unplug it +#CAPS_WORD_ENABLE = yes + +# TODO: remove after merge of official CAPS_WORD support +SRC += features/caps_word.c +SRC += features/layer_lock.c diff --git a/keyboards/royal_kludge/rk61/rgb/config.h b/keyboards/royal_kludge/rk61/rgb/config.h new file mode 100644 index 000000000000..5e016252f464 --- /dev/null +++ b/keyboards/royal_kludge/rk61/rgb/config.h @@ -0,0 +1,102 @@ +/* Copyright 2020 euwbah +* +* Copyright 2022 mr. JULY +* +* 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 0x0C45 +#define PRODUCT_ID 0x024F +#define DEVICE_VER 0x0121 + +#define MANUFACTURER Royal Kludge +#define PRODUCT RK61 RGB +#define DESCRIPTION RK61 QMK OpenRGB + +/* key matrix size */ +#define MATRIX_ROWS 5 +#define MATRIX_COLS 14 + +/* The rk 61 retrieves all columns at once, scanning one row at a time */ +#define DIODE_DIRECTION COL2ROW + +#define MATRIX_COL_PINS { A8, A9, A10, A11, A12, A13, A14, A15, B0, B1, B2, B3, B4, B5 } +#define MATRIX_ROW_PINS { D11, D10, D9, D8, D7 } + +/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ +#define DEBOUNCE 5 + +/* Enable NKRO - Up to 248 keys at the same time. */ +#define FORCE_NKRO + +/* RGB Non-Reactive Effects */ +#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_FRACTAL +#define ENABLE_RGB_MATRIX_PIXEL_RAIN +#define ENABLE_RGB_MATRIX_TYPING_HEATMAP +#define ENABLE_RGB_MATRIX_DIGITAL_RAIN + +/* RGB Reactive Effects Toggle */ +#define RGB_MATRIX_FRAMEBUFFER_EFFECTS +#define RGB_MATRIX_KEYPRESSES +//#define RGB_MATRIX_KEYRELEASES + +/* RGB Reactive Effects */ +#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 + +#include "config_led.h" + +/* Enable RGB sleep */ +#define RGB_DISABLE_WHEN_USB_SUSPENDED true diff --git a/keyboards/royal_kludge/rk61/rgb/config_led.c b/keyboards/royal_kludge/rk61/rgb/config_led.c new file mode 100644 index 000000000000..1949dc24b614 --- /dev/null +++ b/keyboards/royal_kludge/rk61/rgb/config_led.c @@ -0,0 +1,132 @@ +/* +Copyright 2020 euwbah + +Copyright 2022 mr. JULY + +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 . +*/ + +#ifdef RGB_MATRIX_ENABLE + +# include "rgb_matrix.h" +# include "config_led.h" + +// readability +#define NA NO_LED + +#ifdef KEYMAP_ISO +// CAPS LED number +#define CL 27 +// GUI LED number +#define GL 55 +/* ISO keymap */ +/* + * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + * │ │ │ │ │ │ │ │ │ │ │ │ │ │     │ + * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ + * │     │   │  │  │  │  │  │  │  │  │  │  │  │     │ + * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐   │ + * │ CAPS │   │  │ │  │  │  │  │  │  │  │  │  │    │ + * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴┬───┤ + * │    │  │  │  │  │  │  │  │  │  │  │  │    │ │ + * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴──┬┴──┬┴──┬───┼───┤ + * │ │ GUI│  │                      │ │ │ │ │ │ + * └────┴────┴────┴────────────────────────┴───┴───┴───┴───┴───┘ + */ +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, NA,}, + {CL, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,}, + {41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, NA,}, + {54, GL, 56, NA, NA, NA, 57, NA, NA, 58, 59, 60, NA, 61,} + }, + { + {8, 0}, {24, 0}, {39, 0}, {55, 0}, {70, 0}, {86, 0}, {101, 0}, {117, 0}, {132, 0}, {148, 0}, {164, 0}, {180, 0}, {195, 0}, {218, 0}, + {11, 16}, {31, 16}, {47, 16}, {62, 16}, {78, 16}, {93, 16}, {109, 16}, {124, 16}, {140, 16}, {155, 16}, {171, 16}, {186, 16}, {202, 16}, + {13, 32}, {34, 32}, {50, 32}, {65, 32}, {81, 32}, {96, 32}, {112, 32}, {128, 32}, {143, 32}, {159, 32}, {174, 32}, {190, 32}, {206, 32}, {215, 32}, + {17, 48}, {27, 48}, {42, 48}, {57, 48}, {73, 48}, {88, 48}, {104, 48}, {119, 48}, {135, 48}, {150, 48}, {166, 48}, {182, 48}, {211, 48}, + {10, 64}, {29, 64}, {49, 64}, {107, 64}, {165, 64}, {185, 64}, {204, 64}, {224, 64}, + }, + { + 4,4,4,4,4,4,4,4,4,4, + 4,4,4,4,4,4,4,4,4,4, + 4,4,4,4,4,4,4,4,4,4, + 4,4,4,4,4,4,4,4,4,4, + 4,4,4,4,4,4,4,4,4,4, + 4,4,4,4,4,4,4,4,4,4, + 4, + } +}; +#else +/* ANSI (default) keymap */ +/* + * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + * │ │ │ │ │ │ │ │ │ │ │ │ │ │     │ + * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ + * │     │   │  │  │  │  │  │  │  │  │  │  │  │     │ + * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ + * │ CAPS │   │  │ │  │  │  │  │  │  │  │  │       │ + * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤ + * │      │  │  │  │  │  │  │  │  │  │  │    │ + * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ + * │ │ GUI│  │                      │ │ │ │ │ + * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘ + */ +// CAPS LED number +#define CL 27 +// GUI LED number +#define GL 54 +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,}, + {CL, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, NA, 40,}, + {41, NA, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, NA,}, + {53, GL, 55, NA, NA, NA, 56, NA, NA, 57, 58, 59, NA, 60,} + }, + { + {8, 0}, {24, 0}, {39, 0}, {55, 0}, {70, 0}, {86, 0}, {101, 0}, {117, 0}, {132, 0}, {148, 0}, {164, 0}, {180, 0}, {195, 0}, {218, 0}, + {11, 16}, {31, 16}, {47, 16}, {62, 16}, {78, 16}, {93, 16}, {109, 16}, {124, 16}, {140, 16}, {155, 16}, {171, 16}, {186, 16}, {202, 16}, {221, 16}, + {13, 32}, {34, 32}, {50, 32}, {65, 32}, {81, 32}, {96, 32}, {112, 32}, {128, 32}, {143, 32}, {159, 32}, {174, 32}, {190, 32}, {215, 32}, + {17, 48}, {42, 48}, {57, 48}, {73, 48}, {88, 48}, {104, 48}, {119, 48}, {135, 48}, {150, 48}, {166, 48}, {182, 48}, {211, 48}, + {10, 64}, {29, 64}, {49, 64}, {107, 64}, {165, 64}, {185, 64}, {204, 64}, {224, 64}, + }, + { + 4,4,4,4,4,4,4,4,4,4, + 4,4,4,4,4,4,4,4,4,4, + 4,4,4,4,4,4,4,4,4,4, + 4,4,4,4,4,4,4,4,4,4, + 4,4,4,4,4,4,4,4,4,4, + 4,4,4,4,4,4,4,4,4,4, + 4, + } +}; +#endif + +void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { + led_t led_state = host_keyboard_led_state(); + + if (led_state.caps_lock) { + // Set capslock key to (capslock is led number defined as `CL`) + rgb_matrix_set_color(CL, 255, 130, 15); + } + + if (keymap_config.no_gui) { + // Set GUI key to lemon (GUI is led number defined as `GL`) + rgb_matrix_set_color(GL, 255, 230, 15); + } +} + +#endif diff --git a/keyboards/royal_kludge/rk61/rgb/config_led.h b/keyboards/royal_kludge/rk61/rgb/config_led.h new file mode 100644 index 000000000000..b72e6ceac7d4 --- /dev/null +++ b/keyboards/royal_kludge/rk61/rgb/config_led.h @@ -0,0 +1,34 @@ +/* +Copyright 2020 euwbah + +Copyright 2022 mr. JULY + +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.h" + +// Backlight configuration +#define BACKLIGHT_LEVELS 8 + +#define LED_MATRIX_ROWS MATRIX_ROWS +#define LED_MATRIX_ROW_CHANNELS 3 +#define LED_MATRIX_ROWS_HW (LED_MATRIX_ROWS * LED_MATRIX_ROW_CHANNELS) +#define LED_MATRIX_ROW_PINS { C5, C4, C6, C8, C7, C9, C11, C10, C12, C14, C13, B13, B15, D3, B14 } + +#define LED_MATRIX_COLS MATRIX_COLS +#define LED_MATRIX_COL_PINS MATRIX_COL_PINS + +#define DRIVER_LED_TOTAL (70) diff --git a/keyboards/royal_kludge/rk61/rgb/imgs/enter-bootloader.jpg b/keyboards/royal_kludge/rk61/rgb/imgs/enter-bootloader.jpg new file mode 100644 index 000000000000..bc20fbdc7dd3 Binary files /dev/null and b/keyboards/royal_kludge/rk61/rgb/imgs/enter-bootloader.jpg differ diff --git a/keyboards/royal_kludge/rk61/rgb/info.json b/keyboards/royal_kludge/rk61/rgb/info.json new file mode 100644 index 000000000000..4402085c54be --- /dev/null +++ b/keyboards/royal_kludge/rk61/rgb/info.json @@ -0,0 +1,332 @@ +{ + "keyboard_name": "RK61 RGB", + "url": "https://www.lazada.sg/products/royal-kludge-rk61-usb-wired-bluetooth-dual-mode-60-rgb-backlit-mechanical-gaming-keyboard-i1341602754.html", + "maintainer": "mr-july", + "width": 15, + "height": 5, + "layouts": { + "LAYOUT_default": { + "layout": [ + { + "label": "~", + "x": 0, + "y": 0 + }, + { + "label": "!", + "x": 1, + "y": 0 + }, + { + "label": "@", + "x": 2, + "y": 0 + }, + { + "label": "#", + "x": 3, + "y": 0 + }, + { + "label": "$", + "x": 4, + "y": 0 + }, + { + "label": "%", + "x": 5, + "y": 0 + }, + { + "label": "^", + "x": 6, + "y": 0 + }, + { + "label": "&", + "x": 7, + "y": 0 + }, + { + "label": "*", + "x": 8, + "y": 0 + }, + { + "label": "(", + "x": 9, + "y": 0 + }, + { + "label": ")", + "x": 10, + "y": 0 + }, + { + "label": "_", + "x": 11, + "y": 0 + }, + { + "label": "+", + "x": 12, + "y": 0 + }, + { + "label": "Bksp", + "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.25 + }, + { + "label": "Z", + "x": 2.25, + "y": 3 + }, + { + "label": "X", + "x": 3.25, + "y": 3 + }, + { + "label": "C", + "x": 4.25, + "y": 3 + }, + { + "label": "V", + "x": 5.25, + "y": 3 + }, + { + "label": "B", + "x": 6.25, + "y": 3 + }, + { + "label": "N", + "x": 7.25, + "y": 3 + }, + { + "label": "M", + "x": 8.25, + "y": 3 + }, + { + "label": "<", + "x": 9.25, + "y": 3 + }, + { + "label": ">", + "x": 10.25, + "y": 3 + }, + { + "label": "?", + "x": 11.25, + "y": 3 + }, + { + "label": "Shift", + "x": 12.25, + "y": 3, + "w": 2.75 + }, + { + "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 + }, + { + "x": 3.75, + "y": 4, + "w": 6.25 + }, + { + "label": "Alt", + "x": 10, + "y": 4, + "w": 1.25 + }, + { + "label": "Menu", + "x": 11.25, + "y": 4, + "w": 1.25 + }, + { + "label": "Ctrl", + "x": 12.5, + "y": 4, + "w": 1.25 + }, + { + "label": "Fn", + "x": 13.75, + "y": 4, + "w": 1.25 + } + ] + } + } +} diff --git a/keyboards/royal_kludge/rk61/rgb/readme.md b/keyboards/royal_kludge/rk61/rgb/readme.md new file mode 100644 index 000000000000..48a63ac6b168 --- /dev/null +++ b/keyboards/royal_kludge/rk61/rgb/readme.md @@ -0,0 +1,68 @@ +# RK61 RGB + +![RK61 RGB](https://i.pinimg.com/originals/01/e2/1f/01e21f1ba56526a0f2fe5047b6d25f11.png) + +Royal Kludge RK61 non-hotswap rgb edition, original PID 0x24F. + +Tested on the Royal Kludge RK61 non-hotswap RGB dual-mode edition, original PID 0x24F +(RK61 firmware v1.03.000n, purchased after May 2020). + +- MCU: HFD2201KBA (rebrand SN32F248BF) +- PCB: RK61-JX-RGB-HFD; REV: 01; 2019/08/13 +- Wired only, no bluetooth support. + +Keyboard Maintainer: [mr-july](https://github.com/mr-july) + +For the white-backlit non-rgb version of the RK61, check out [Diff-fusion's repo](https://github.com/Diff-fusion/qmk_firmware) + + +Note: keymap differs slightly from stock firmware for FN combinations +configuring RGB settings. Also adds ability to control volume and display +brightness + additional FN keys. +See [keymap.c](keymaps/default/keymap.c), and refer to the [list +of QMK keycodes](https://beta.docs.qmk.fm/using-qmk/simple-keycodes/keycodes). + +----------------- + + +Make example for this keyboard (after setting up your build environment): + + make royal_kludge/rk61/rgb:default + +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: + +- [Sonix Flasher](https://github.com/SonixQMK/sonix-flasher): if you have the original firmware, just start the program and click the "Reboot to Bootloader [HFD]" button. +- Physical reset: short the two contacts to the left of the space bar switch with a wire/paperclip, accessible from the bottom of PCB. + ![HW bootloader](imgs/enter-bootloader.jpg) + After shorting, just connect the USB cable. The keyboard started in bootloader mode and is ready to be flashed. +- Layout (after loading QMK): FN + CapsLock + +## Flashing + +### Option 1. SONiX USB MCU ISP Tool + +Download the [SONiX USB MCU ISP Tool](https://www.sonix.com.tw/files/1/B6648B8BB74030BDE050007F01002479) from the [MCU SN32F248B page](https://www.sonix.com.tw/article-en-4336-30356) and use the program, included in archive. +More detailed instructions may be found in this [Video](https://youtu.be/2MHtLEiXaXg?t=940). + +### Option 2. Sonix Flasher + +Use the Python program from [this repository](https://github.com/SonixQMK/sonix-flasher) + +### Option 3. SonixFlasherC + +Use the C program from [this repository](https://github.com/SonixQMK/SonixFlasherC) + +## Original firmware + +### Unchanged + +The original firmware can be found on [Google Drive](https://drive.google.com/drive/folders/1Qx_4Ql_n_4TafIpe-guBf9F-IfuuVHOy) + +### Patched + +There is a version of original firmware, which was patched to be able to start the keyboard in bootloader mode by holding the `Esc` button while connecting the USB cable. The patched files are available on [Dropbox](https://www.dropbox.com/sh/jy1741tsamyjt6a/AAA58nafcQ_wCTlKke11ck30a?dl=0). +With this firmware it is possible to switch from QMK to original firmware and back without shorting contacts on PCB. diff --git a/keyboards/royal_kludge/rk61/rgb/rgb.h b/keyboards/royal_kludge/rk61/rgb/rgb.h new file mode 100644 index 000000000000..00bdf1e032ff --- /dev/null +++ b/keyboards/royal_kludge/rk61/rgb/rgb.h @@ -0,0 +1,4 @@ +#pragma once + +#include "quantum.h" + diff --git a/keyboards/royal_kludge/rk61/rgb/rules.mk b/keyboards/royal_kludge/rk61/rgb/rules.mk new file mode 100644 index 000000000000..46573bc4de55 --- /dev/null +++ b/keyboards/royal_kludge/rk61/rgb/rules.mk @@ -0,0 +1,31 @@ +# project specific files +SRC = ../../../drivers/led/sn32/matrix_sn32f24xx.c +SRC += config_led.c + +# MCU name +MCU = SN32F248BF + +# Build Options +# comment out to disable the options. +# +LTO_ENABLE = no +BACKLIGHT_ENABLE = no +MAGIC_ENABLE = yes +MAGIC_KEYCODE_ENABLE = yes +BOOTMAGIC_ENABLE = yes # 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 +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +NKRO_ENABLE = yes # USB Nkey Rollover +AUDIO_ENABLE = no +RGBLIGHT_ENABLE = no +SERIAL_LINK_ENABLE = no +WAIT_FOR_USB = no +CUSTOM_MATRIX = yes +KEYBOARD_SHARED_EP = no + +# Custom RGB matrix handling +RGB_MATRIX_ENABLE = yes +RGB_MATRIX_DRIVER = SN32F24xB