From 186310f5a73e6e5c9aaccbddea60422fd30c7d2b Mon Sep 17 00:00:00 2001 From: Santanu Paik <127647619+ITNerd69@users.noreply.github.com> Date: Fri, 3 Nov 2023 23:41:30 +0530 Subject: [PATCH] [Keyboard] Add Keychron K2v2 RGB ANSI (#360) * Ported over Keychron K2v2 ANSI firmware files. * Fixed VendorID and removed unnecessary strings. --- keyboards/keychron/k2/rgb/v2/ansi/config.h | 17 ++ keyboards/keychron/k2/rgb/v2/ansi/info.json | 267 ++++++++++++++++++ .../k2/rgb/v2/ansi/keymaps/default/keymap.c | 172 +++++++++++ .../k2/rgb/v2/ansi/keymaps/via/keymap.c | 172 +++++++++++ .../k2/rgb/v2/ansi/keymaps/via/readme.md | 11 + .../k2/rgb/v2/ansi/keymaps/via/rules.mk | 1 + keyboards/keychron/k2/rgb/v2/ansi/readme.md | 29 ++ keyboards/keychron/k2/rgb/v2/ansi/rules.mk | 2 + keyboards/keychron/k2/rgb/v2/config.h | 2 + .../keychron/k2/rgb/v2/via_json/k2_ansi.json | 18 ++ 10 files changed, 691 insertions(+) create mode 100644 keyboards/keychron/k2/rgb/v2/ansi/config.h create mode 100644 keyboards/keychron/k2/rgb/v2/ansi/info.json create mode 100644 keyboards/keychron/k2/rgb/v2/ansi/keymaps/default/keymap.c create mode 100644 keyboards/keychron/k2/rgb/v2/ansi/keymaps/via/keymap.c create mode 100644 keyboards/keychron/k2/rgb/v2/ansi/keymaps/via/readme.md create mode 100644 keyboards/keychron/k2/rgb/v2/ansi/keymaps/via/rules.mk create mode 100644 keyboards/keychron/k2/rgb/v2/ansi/readme.md create mode 100644 keyboards/keychron/k2/rgb/v2/ansi/rules.mk create mode 100644 keyboards/keychron/k2/rgb/v2/via_json/k2_ansi.json diff --git a/keyboards/keychron/k2/rgb/v2/ansi/config.h b/keyboards/keychron/k2/rgb/v2/ansi/config.h new file mode 100644 index 000000000000..e34545eb177d --- /dev/null +++ b/keyboards/keychron/k2/rgb/v2/ansi/config.h @@ -0,0 +1,17 @@ +/* Copyright 2023 Santanu Paik (https://github.com/itnerd69) + * + * 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 . + */ + +#define RGB_MATRIX_LED_COUNT 84 diff --git a/keyboards/keychron/k2/rgb/v2/ansi/info.json b/keyboards/keychron/k2/rgb/v2/ansi/info.json new file mode 100644 index 000000000000..230d051ede70 --- /dev/null +++ b/keyboards/keychron/k2/rgb/v2/ansi/info.json @@ -0,0 +1,267 @@ +{ + "keyboard_name": "Keychron K2v2 RGB ANSI", + "manufacturer": "Keychron", + "url": "https://www.keychron.com/products/keychron-k2-wireless-mechanical-keyboard", + "maintainer": "ITNerd69", + "usb": { + "pid": "0xFE02", + "vid": "0x3434", + "device_version": "1.0.0" + }, + "matrix_pins": { + "cols": ["A8", "A9", "A10", "A11", "A12", "A13", "A14", "A15", "B0", "B1", "B2", "B3", "B4", "B5", "B6", "B7"], + "rows": ["C15", "D11", "D10", "D9", "D8", "D7"] + }, + "diode_direction": "COL2ROW", + "features": { + "rgb_matrix": true, + "bootmagic": true, + "command": false, + "console": false, + "extrakey": true, + "mousekey": false, + "nkro": true, + "dip_switch": true + }, + "processor": "SN32F248BF", + "bootloader": "sn32-dfu", + "debounce": 5, + "indicators": { + "caps_lock": "B9", + "on_state": 1 + }, + "layouts": { + "LAYOUT_ansi": { + "layout": [ + {"matrix":[0, 0], "x":0, "y":0}, + {"matrix":[0, 1], "x":1, "y":0}, + {"matrix":[0, 2], "x":2, "y":0}, + {"matrix":[0, 3], "x":3, "y":0}, + {"matrix":[0, 4], "x":4, "y":0}, + {"matrix":[0, 5], "x":5, "y":0}, + {"matrix":[0, 6], "x":6, "y":0}, + {"matrix":[0, 7], "x":7, "y":0}, + {"matrix":[0, 8], "x":8, "y":0}, + {"matrix":[0, 9], "x":9, "y":0}, + {"matrix":[0, 10], "x":10, "y":0}, + {"matrix":[0, 11], "x":11, "y":0}, + {"matrix":[0, 12], "x":12, "y":0}, + {"matrix":[0, 13], "x":13, "y":0}, + {"matrix":[0, 14], "x":14, "y":0}, + {"matrix":[0, 15], "x":15, "y":0}, + + {"matrix":[1, 0], "x":0, "y":1}, + {"matrix":[1, 1], "x":1, "y":1}, + {"matrix":[1, 2], "x":2, "y":1}, + {"matrix":[1, 3], "x":3, "y":1}, + {"matrix":[1, 4], "x":4, "y":1}, + {"matrix":[1, 5], "x":5, "y":1}, + {"matrix":[1, 6], "x":6, "y":1}, + {"matrix":[1, 7], "x":7, "y":1}, + {"matrix":[1, 8], "x":8, "y":1}, + {"matrix":[1, 9], "x":9, "y":1}, + {"matrix":[1, 10], "x":10, "y":1}, + {"matrix":[1, 11], "x":11, "y":1}, + {"matrix":[1, 12], "x":12, "y":1}, + {"matrix":[1, 13], "x":13, "y":1, "w":2}, + {"matrix":[1, 15], "x":15, "y":1}, + + {"matrix":[2, 0], "x":0, "y":2, "w":1.5}, + {"matrix":[2, 1], "x":1.5, "y":2}, + {"matrix":[2, 2], "x":2.5, "y":2}, + {"matrix":[2, 3], "x":3.5, "y":2}, + {"matrix":[2, 4], "x":4.5, "y":2}, + {"matrix":[2, 5], "x":5.5, "y":2}, + {"matrix":[2, 6], "x":6.5, "y":2}, + {"matrix":[2, 7], "x":7.5, "y":2}, + {"matrix":[2, 8], "x":8.5, "y":2}, + {"matrix":[2, 9], "x":9.5, "y":2}, + {"matrix":[2, 10], "x":10.5, "y":2}, + {"matrix":[2, 11], "x":11.5, "y":2}, + {"matrix":[2, 12], "x":12.5, "y":2}, + {"matrix":[2, 13], "x":13.5, "y":2, "w":1.5}, + {"matrix":[2, 15], "x":15, "y":2}, + + {"matrix":[3, 0], "x":0, "y":3, "w":1.75}, + {"matrix":[3, 1], "x":1.75, "y":3}, + {"matrix":[3, 2], "x":2.75, "y":3}, + {"matrix":[3, 3], "x":3.75, "y":3}, + {"matrix":[3, 4], "x":4.75, "y":3}, + {"matrix":[3, 5], "x":5.75, "y":3}, + {"matrix":[3, 6], "x":6.75, "y":3}, + {"matrix":[3, 7], "x":7.75, "y":3}, + {"matrix":[3, 8], "x":8.75, "y":3}, + {"matrix":[3, 9], "x":9.75, "y":3}, + {"matrix":[3, 10], "x":10.75, "y":3}, + {"matrix":[3, 11], "x":11.75, "y":3}, + {"matrix":[3, 13], "x":12.75, "y":3, "w":2.25}, + {"matrix":[3, 15], "x":15, "y":3}, + + {"matrix":[4, 0], "x":0, "y":4, "w":2.25}, + {"matrix":[4, 2], "x":2.25, "y":4}, + {"matrix":[4, 3], "x":3.25, "y":4}, + {"matrix":[4, 4], "x":4.25, "y":4}, + {"matrix":[4, 5], "x":5.25, "y":4}, + {"matrix":[4, 6], "x":6.25, "y":4}, + {"matrix":[4, 7], "x":7.25, "y":4}, + {"matrix":[4, 8], "x":8.25, "y":4}, + {"matrix":[4, 9], "x":9.25, "y":4}, + {"matrix":[4, 10], "x":10.25, "y":4}, + {"matrix":[4, 11], "x":11.25, "y":4}, + {"matrix":[4, 13], "x":12.25, "y":4, "w":1.75}, + {"matrix":[4, 14], "x":14, "y":4}, + {"matrix":[4, 15], "x":15, "y":4}, + + {"matrix":[5, 0], "x":0, "y":5, "w":1.25}, + {"matrix":[5, 1], "x":1.25, "y":5, "w":1.25}, + {"matrix":[5, 2], "x":2.5, "y":5, "w":1.25}, + {"matrix":[5, 6], "x":3.75, "y":5, "w":6.25}, + {"matrix":[5, 10], "x":10, "y":5}, + {"matrix":[5, 11], "x":11, "y":5}, + {"matrix":[5, 12], "x":12, "y":5}, + {"matrix":[5, 13], "x":13, "y":5}, + {"matrix":[5, 14], "x":14, "y":5}, + {"matrix":[5, 15], "x":15, "y":5} + ] + } + }, + "rgb_matrix": { + "driver": "sn32f24xb", + "layout": [ + { "matrix": [ 0, 0 ], "flags": 4, "x": 0, "y": 0 }, + { "matrix": [ 0, 1 ], "flags": 4, "x": 12, "y": 0 }, + { "matrix": [ 0, 2 ], "flags": 4, "x": 25, "y": 0 }, + { "matrix": [ 0, 3 ], "flags": 4, "x": 37, "y": 0 }, + { "matrix": [ 0, 4 ], "flags": 4, "x": 50, "y": 0 }, + { "matrix": [ 0, 5 ], "flags": 4, "x": 62, "y": 0 }, + { "matrix": [ 0, 6 ], "flags": 4, "x": 75, "y": 0 }, + { "matrix": [ 0, 7 ], "flags": 4, "x": 87, "y": 0 }, + { "matrix": [ 0, 8 ], "flags": 4, "x": 100, "y": 0 }, + { "matrix": [ 0, 9 ], "flags": 4, "x": 112, "y": 0 }, + { "matrix": [ 0, 10 ], "flags": 4, "x": 124, "y": 0 }, + { "matrix": [ 0, 11 ], "flags": 4, "x": 137, "y": 0 }, + { "matrix": [ 0, 12 ], "flags": 4, "x": 149, "y": 0 }, + { "matrix": [ 0, 13 ], "flags": 4, "x": 162, "y": 0 }, + { "matrix": [ 0, 14 ], "flags": 4, "x": 174, "y": 0 }, + { "matrix": [ 0, 15 ], "flags": 4, "x": 187, "y": 0 }, + + { "matrix": [ 1, 0 ], "flags": 4, "x": 0, "y": 13 }, + { "matrix": [ 1, 1 ], "flags": 4, "x": 12, "y": 13 }, + { "matrix": [ 1, 2 ], "flags": 4, "x": 25, "y": 13 }, + { "matrix": [ 1, 3 ], "flags": 4, "x": 37, "y": 13 }, + { "matrix": [ 1, 4 ], "flags": 4, "x": 50, "y": 13 }, + { "matrix": [ 1, 5 ], "flags": 4, "x": 62, "y": 13 }, + { "matrix": [ 1, 6 ], "flags": 4, "x": 75, "y": 13 }, + { "matrix": [ 1, 7 ], "flags": 4, "x": 87, "y": 13 }, + { "matrix": [ 1, 8 ], "flags": 4, "x": 100, "y": 13 }, + { "matrix": [ 1, 9 ], "flags": 4, "x": 112, "y": 13 }, + { "matrix": [ 1, 10 ], "flags": 4, "x": 124, "y": 13 }, + { "matrix": [ 1, 11 ], "flags": 4, "x": 137, "y": 13 }, + { "matrix": [ 1, 12 ], "flags": 4, "x": 149, "y": 13 }, + { "matrix": [ 1, 13 ], "flags": 4, "x": 168, "y": 13 }, + { "matrix": [ 1, 15 ], "flags": 4, "x": 187, "y": 13 }, + + { "matrix": [ 2, 0 ], "flags": 4, "x": 3, "y": 26 }, + { "matrix": [ 2, 1 ], "flags": 4, "x": 19, "y": 26 }, + { "matrix": [ 2, 2 ], "flags": 4, "x": 31, "y": 26 }, + { "matrix": [ 2, 3 ], "flags": 4, "x": 44, "y": 26 }, + { "matrix": [ 2, 4 ], "flags": 4, "x": 56, "y": 26 }, + { "matrix": [ 2, 5 ], "flags": 4, "x": 68, "y": 26 }, + { "matrix": [ 2, 6 ], "flags": 4, "x": 81, "y": 26 }, + { "matrix": [ 2, 7 ], "flags": 4, "x": 93, "y": 26 }, + { "matrix": [ 2, 8 ], "flags": 4, "x": 106, "y": 26 }, + { "matrix": [ 2, 9 ], "flags": 4, "x": 118, "y": 26 }, + { "matrix": [ 2, 10 ], "flags": 4, "x": 131, "y": 26 }, + { "matrix": [ 2, 11 ], "flags": 4, "x": 143, "y": 26 }, + { "matrix": [ 2, 12 ], "flags": 4, "x": 156, "y": 26 }, + { "matrix": [ 2, 13 ], "flags": 4, "x": 168, "y": 26 }, + { "matrix": [ 2, 15 ], "flags": 4, "x": 187, "y": 26 }, + + { "matrix": [ 3, 0 ], "flags": 4, "x": 5, "y": 38 }, + { "matrix": [ 3, 1 ], "flags": 4, "x": 22, "y": 38 }, + { "matrix": [ 3, 2 ], "flags": 4, "x": 34, "y": 38 }, + { "matrix": [ 3, 3 ], "flags": 4, "x": 47, "y": 38 }, + { "matrix": [ 3, 4 ], "flags": 4, "x": 59, "y": 38 }, + { "matrix": [ 3, 5 ], "flags": 4, "x": 72, "y": 38 }, + { "matrix": [ 3, 6 ], "flags": 4, "x": 84, "y": 38 }, + { "matrix": [ 3, 7 ], "flags": 4, "x": 96, "y": 38 }, + { "matrix": [ 3, 8 ], "flags": 4, "x": 109, "y": 38 }, + { "matrix": [ 3, 9 ], "flags": 4, "x": 121, "y": 38 }, + { "matrix": [ 3, 10 ], "flags": 4, "x": 134, "y": 38 }, + { "matrix": [ 3, 11 ], "flags": 4, "x": 146, "y": 38 }, + { "matrix": [ 3, 13 ], "flags": 4, "x": 166, "y": 38 }, + { "matrix": [ 3, 15 ], "flags": 4, "x": 187, "y": 38 }, + + { "matrix": [ 4, 0 ], "flags": 4, "x": 8, "y": 51 }, + { "matrix": [ 4, 2 ], "flags": 4, "x": 28, "y": 51 }, + { "matrix": [ 4, 3 ], "flags": 4, "x": 40, "y": 51 }, + { "matrix": [ 4, 4 ], "flags": 4, "x": 53, "y": 51 }, + { "matrix": [ 4, 5 ], "flags": 4, "x": 65, "y": 51 }, + { "matrix": [ 4, 6 ], "flags": 4, "x": 78, "y": 51 }, + { "matrix": [ 4, 7 ], "flags": 4, "x": 90, "y": 51 }, + { "matrix": [ 4, 8 ], "flags": 4, "x": 103, "y": 51 }, + { "matrix": [ 4, 9 ], "flags": 4, "x": 115, "y": 51 }, + { "matrix": [ 4, 10 ], "flags": 4, "x": 128, "y": 51 }, + { "matrix": [ 4, 11 ], "flags": 4, "x": 140, "y": 51 }, + { "matrix": [ 4, 13 ], "flags": 4, "x": 157, "y": 51 }, + { "matrix": [ 4, 14 ], "flags": 4, "x": 174, "y": 51 }, + { "matrix": [ 4, 15 ], "flags": 4, "x": 187, "y": 51 }, + + { "matrix": [ 5, 0 ], "flags": 4, "x": 2, "y": 64 }, + { "matrix": [ 5, 1 ], "flags": 4, "x": 17, "y": 64 }, + { "matrix": [ 5, 2 ], "flags": 4, "x": 33, "y": 64 }, + { "matrix": [ 5, 6 ], "flags": 4, "x": 79, "y": 64 }, + { "matrix": [ 5, 10 ], "flags": 4, "x": 124, "y": 64 }, + { "matrix": [ 5, 11 ], "flags": 4, "x": 137, "y": 64 }, + { "matrix": [ 5, 12 ], "flags": 4, "x": 149, "y": 64 }, + { "matrix": [ 5, 13 ], "flags": 4, "x": 162, "y": 64 }, + { "matrix": [ 5, 14 ], "flags": 4, "x": 174, "y": 64 }, + { "matrix": [ 5, 15 ], "flags": 4, "x": 187, "y": 64 } + ], + "animations": { + "alphas_mods" : true, + "band_pinwheel_sat" : true, + "band_pinwheel_val" : true, + "band_sat" : true, + "band_spiral_sat" : true, + "band_spiral_val" : true, + "band_val" : true, + "breathing" : true, + "cycle_all" : true, + "cycle_left_right" : true, + "cycle_out_in" : true, + "cycle_out_in_dual" : true, + "cycle_pinwheel" : true, + "cycle_spiral" : true, + "cycle_up_down" : true, + "digital_rain" : true, + "dual_beacon" : true, + "gradient_left_right" : true, + "gradient_up_down" : true, + "hue_breathing" : true, + "hue_pendulum" : true, + "hue_wave" : true, + "jellybean_raindrops" : true, + "multisplash" : true, + "pixel_flow" : true, + "pixel_fractal" : true, + "pixel_rain" : true, + "rainbow_beacon" : true, + "rainbow_moving_chevron" : true, + "rainbow_pinwheels" : true, + "raindrops" : true, + "solid_multisplash" : true, + "solid_reactive" : true, + "solid_reactive_cross" : true, + "solid_reactive_multicross" : true, + "solid_reactive_multinexus" : true, + "solid_reactive_multiwide" : true, + "solid_reactive_nexus" : true, + "solid_reactive_simple" : true, + "solid_reactive_wide" : true, + "solid_splash" : true, + "splash" : true, + "typing_heatmap" : true + } + } +} diff --git a/keyboards/keychron/k2/rgb/v2/ansi/keymaps/default/keymap.c b/keyboards/keychron/k2/rgb/v2/ansi/keymaps/default/keymap.c new file mode 100644 index 000000000000..5455fb701901 --- /dev/null +++ b/keyboards/keychron/k2/rgb/v2/ansi/keymaps/default/keymap.c @@ -0,0 +1,172 @@ +/* +Copyright 2022 Dimitris Mantzouranis +Copyright 2022 Pablo Ramirez +Copyright 2023 Santanu Paik (https://github.com/ITNerd69) + +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 + +// 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 { + WIN_BASE = 0, + WIN_FN = 1, + MAC_BASE = 2, + MAC_FN = 3, +}; +#define KC_TASK LGUI(KC_TAB) // Task viewer +#define KC_FLXP LGUI(KC_E) // Windows file explorer + +#define KC_MSSN LGUI(KC_F3) // Mission Control +#define KC_FIND LALT(LGUI(KC_SPC)) // Finder +#define KC_MSCR LSFT(LGUI(KC_3)) // Mac screenshot +#define KC_MSNP LSFT(LGUI(KC_4)) // Mac snip tool + + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + /* + ***************************************************************************************************************** + * ESC * F1 * F2 * F3 * F4 * F5 * F6 * F7 * F8 * F9 * F10 * F11 * F12 * PSCR * DEL * RMOD * + ***************************************************************************************************************** + * ~ * 1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 0 * * * = * BSPC * PGUP * + ***************************************************************************************************************** + * TAB * Q * W * E * R * T * Y * U * I * O * P * [ * ] * \ * PGDN * + ***************************************************************************************************************** + * CAPS * A * S * D * F * G * H * J * K * L * ; * ' * ENT * HOME * + ***************************************************************************************************************** + * LSFT * Z * X * C * V * B * N * M * , * . * / * RSFT * UP * END * + ***************************************************************************************************************** + * LCTL * LGUI * LALT * SPC * RALT * FN * RCTL * LEFT * DOWN * RGHT * + ***************************************************************************************************************** + */ + [WIN_BASE] = LAYOUT_ansi( + /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ + KC_ESC, 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_PSCR, KC_DEL, RGB_MOD , + KC_GRV, 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_PGUP , + 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_PGDN , + 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_HOME , + 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(WIN_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT + ), + + /* + ***************************************************************************************************************** + *RESET * BRID * BRIU * TASK * FLXP * RVAD * RVAI * MPRV * MPLY * MNXT * MUTE * VOLD * VOLU * * INS * RTOG * + ***************************************************************************************************************** + * * * * * * * * * * * * * * * * + ***************************************************************************************************************** + * * * * * * * * * * * * * * * * + ***************************************************************************************************************** + * * * * * * * * * * * * * * * + ***************************************************************************************************************** + * * * * * * * * * * * * * RSAI * * + ***************************************************************************************************************** + * * * * * * * * RHUD * RSAD * RHUI * + ***************************************************************************************************************** + */ + [WIN_FN] = LAYOUT_ansi( + /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ + Q_RESET, KC_BRID, KC_BRIU, KC_TASK, KC_FLXP, RGB_VAD, RGB_VAI, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, _______, KC_INS, RGB_TOG , + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ , + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ , + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ , + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SAI, _______ , + _______, _______, _______, _______, _______, _______, _______, RGB_HUD, RGB_SAD, RGB_HUI + ), + + /* + ***************************************************************************************************************** + * ESC * F1 * F2 * F3 * F4 * F5 * F6 * F7 * F8 * F9 * F10 * F11 * F12 * PSCR * DEL * RMOD * + ***************************************************************************************************************** + * ~ * 1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 0 * * * = * BSPC * PGUP * + ***************************************************************************************************************** + * TAB * Q * W * E * R * T * Y * U * I * O * P * [ * ] * \ * PGDN * + ***************************************************************************************************************** + * CAPS * A * S * D * F * G * H * J * K * L * ; * ' * ENT * HOME * + ***************************************************************************************************************** + * LSFT * Z * X * C * V * B * N * M * , * . * / * RSFT * UP * END * + ***************************************************************************************************************** + * LCTL * LALT * LGUI * SPC * LGUI * FN * RCTL * LEFT * DOWN * RGHT * + ***************************************************************************************************************** + */ + [MAC_BASE] = LAYOUT_ansi( + /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ + KC_ESC, 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_MSCR, KC_DEL, RGB_MOD , + KC_GRV, 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_PGUP , + 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_PGDN , + 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_HOME , + 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_LALT, KC_LGUI, KC_SPC, KC_RGUI, MO(MAC_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT + ), + + /* + ***************************************************************************************************************** + *RESET * BRID * BRIU * TASK * FLXP * RVAD * RVAI * MPRV * MPLY * MNXT * MUTE * VOLD * VOLU * * INS * RTOG * + ***************************************************************************************************************** + * * * * * * * * * * * * * * * * + ***************************************************************************************************************** + * * * * * * * * * * * * * * * * + ***************************************************************************************************************** + * * * * * * * * * * * * * * * + ***************************************************************************************************************** + * * * * * * * * * * * * * RSAI * * + ***************************************************************************************************************** + * * * * * * * * RHUD * RSAD * RHUI * + ***************************************************************************************************************** + */ + [MAC_FN] = LAYOUT_ansi( + /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ + Q_RESET, KC_BRID, KC_BRIU, KC_MSSN, KC_FIND, RGB_VAD, RGB_VAI, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, KC_MSNP, KC_INS, RGB_TOG , + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ , + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ , + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ , + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SAI, _______ , + _______, _______, _______, _______, _______, _______, _______, RGB_HUD, RGB_SAD, RGB_HUI + ) +}; + +bool dip_switch_update_user(uint8_t index, bool active) { + switch(index) { + case 0: // OS switch + if (active) { // Mac/iOS mode + layer_move(MAC_BASE); + } + else { // Windows/Android mode + layer_move(WIN_BASE); + } + break; + case 1: // Connection switch + // Probably it's not possible to do anything sensible here as switching from Cable to BT requires turning off the board. (BT / OFF / Cable) + if (active) { // BT mode + // do stuff + } + else { //Cable mode + // do stuff + } + break; + } + return true; +} + +void keyboard_post_init_user(void) { + // Customise these values to desired behaviour + // debug_enable = true; + // debug_matrix = true; + // debug_keyboard = true; + // debug_mouse = true; +} diff --git a/keyboards/keychron/k2/rgb/v2/ansi/keymaps/via/keymap.c b/keyboards/keychron/k2/rgb/v2/ansi/keymaps/via/keymap.c new file mode 100644 index 000000000000..5455fb701901 --- /dev/null +++ b/keyboards/keychron/k2/rgb/v2/ansi/keymaps/via/keymap.c @@ -0,0 +1,172 @@ +/* +Copyright 2022 Dimitris Mantzouranis +Copyright 2022 Pablo Ramirez +Copyright 2023 Santanu Paik (https://github.com/ITNerd69) + +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 + +// 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 { + WIN_BASE = 0, + WIN_FN = 1, + MAC_BASE = 2, + MAC_FN = 3, +}; +#define KC_TASK LGUI(KC_TAB) // Task viewer +#define KC_FLXP LGUI(KC_E) // Windows file explorer + +#define KC_MSSN LGUI(KC_F3) // Mission Control +#define KC_FIND LALT(LGUI(KC_SPC)) // Finder +#define KC_MSCR LSFT(LGUI(KC_3)) // Mac screenshot +#define KC_MSNP LSFT(LGUI(KC_4)) // Mac snip tool + + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + /* + ***************************************************************************************************************** + * ESC * F1 * F2 * F3 * F4 * F5 * F6 * F7 * F8 * F9 * F10 * F11 * F12 * PSCR * DEL * RMOD * + ***************************************************************************************************************** + * ~ * 1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 0 * * * = * BSPC * PGUP * + ***************************************************************************************************************** + * TAB * Q * W * E * R * T * Y * U * I * O * P * [ * ] * \ * PGDN * + ***************************************************************************************************************** + * CAPS * A * S * D * F * G * H * J * K * L * ; * ' * ENT * HOME * + ***************************************************************************************************************** + * LSFT * Z * X * C * V * B * N * M * , * . * / * RSFT * UP * END * + ***************************************************************************************************************** + * LCTL * LGUI * LALT * SPC * RALT * FN * RCTL * LEFT * DOWN * RGHT * + ***************************************************************************************************************** + */ + [WIN_BASE] = LAYOUT_ansi( + /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ + KC_ESC, 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_PSCR, KC_DEL, RGB_MOD , + KC_GRV, 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_PGUP , + 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_PGDN , + 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_HOME , + 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(WIN_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT + ), + + /* + ***************************************************************************************************************** + *RESET * BRID * BRIU * TASK * FLXP * RVAD * RVAI * MPRV * MPLY * MNXT * MUTE * VOLD * VOLU * * INS * RTOG * + ***************************************************************************************************************** + * * * * * * * * * * * * * * * * + ***************************************************************************************************************** + * * * * * * * * * * * * * * * * + ***************************************************************************************************************** + * * * * * * * * * * * * * * * + ***************************************************************************************************************** + * * * * * * * * * * * * * RSAI * * + ***************************************************************************************************************** + * * * * * * * * RHUD * RSAD * RHUI * + ***************************************************************************************************************** + */ + [WIN_FN] = LAYOUT_ansi( + /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ + Q_RESET, KC_BRID, KC_BRIU, KC_TASK, KC_FLXP, RGB_VAD, RGB_VAI, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, _______, KC_INS, RGB_TOG , + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ , + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ , + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ , + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SAI, _______ , + _______, _______, _______, _______, _______, _______, _______, RGB_HUD, RGB_SAD, RGB_HUI + ), + + /* + ***************************************************************************************************************** + * ESC * F1 * F2 * F3 * F4 * F5 * F6 * F7 * F8 * F9 * F10 * F11 * F12 * PSCR * DEL * RMOD * + ***************************************************************************************************************** + * ~ * 1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 0 * * * = * BSPC * PGUP * + ***************************************************************************************************************** + * TAB * Q * W * E * R * T * Y * U * I * O * P * [ * ] * \ * PGDN * + ***************************************************************************************************************** + * CAPS * A * S * D * F * G * H * J * K * L * ; * ' * ENT * HOME * + ***************************************************************************************************************** + * LSFT * Z * X * C * V * B * N * M * , * . * / * RSFT * UP * END * + ***************************************************************************************************************** + * LCTL * LALT * LGUI * SPC * LGUI * FN * RCTL * LEFT * DOWN * RGHT * + ***************************************************************************************************************** + */ + [MAC_BASE] = LAYOUT_ansi( + /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ + KC_ESC, 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_MSCR, KC_DEL, RGB_MOD , + KC_GRV, 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_PGUP , + 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_PGDN , + 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_HOME , + 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_LALT, KC_LGUI, KC_SPC, KC_RGUI, MO(MAC_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT + ), + + /* + ***************************************************************************************************************** + *RESET * BRID * BRIU * TASK * FLXP * RVAD * RVAI * MPRV * MPLY * MNXT * MUTE * VOLD * VOLU * * INS * RTOG * + ***************************************************************************************************************** + * * * * * * * * * * * * * * * * + ***************************************************************************************************************** + * * * * * * * * * * * * * * * * + ***************************************************************************************************************** + * * * * * * * * * * * * * * * + ***************************************************************************************************************** + * * * * * * * * * * * * * RSAI * * + ***************************************************************************************************************** + * * * * * * * * RHUD * RSAD * RHUI * + ***************************************************************************************************************** + */ + [MAC_FN] = LAYOUT_ansi( + /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ + Q_RESET, KC_BRID, KC_BRIU, KC_MSSN, KC_FIND, RGB_VAD, RGB_VAI, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, KC_MSNP, KC_INS, RGB_TOG , + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ , + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ , + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ , + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SAI, _______ , + _______, _______, _______, _______, _______, _______, _______, RGB_HUD, RGB_SAD, RGB_HUI + ) +}; + +bool dip_switch_update_user(uint8_t index, bool active) { + switch(index) { + case 0: // OS switch + if (active) { // Mac/iOS mode + layer_move(MAC_BASE); + } + else { // Windows/Android mode + layer_move(WIN_BASE); + } + break; + case 1: // Connection switch + // Probably it's not possible to do anything sensible here as switching from Cable to BT requires turning off the board. (BT / OFF / Cable) + if (active) { // BT mode + // do stuff + } + else { //Cable mode + // do stuff + } + break; + } + return true; +} + +void keyboard_post_init_user(void) { + // Customise these values to desired behaviour + // debug_enable = true; + // debug_matrix = true; + // debug_keyboard = true; + // debug_mouse = true; +} diff --git a/keyboards/keychron/k2/rgb/v2/ansi/keymaps/via/readme.md b/keyboards/keychron/k2/rgb/v2/ansi/keymaps/via/readme.md new file mode 100644 index 000000000000..fd39804111ce --- /dev/null +++ b/keyboards/keychron/k2/rgb/v2/ansi/keymaps/via/readme.md @@ -0,0 +1,11 @@ +# Keychron K2v2 RGB ANSI + +K2v2 RGB ANSI with VIA support + +Make example for this keyboard (after setting up your build environment): + + qmk compile -kb keychron/k2/rgb/v2/ansi -km via + +* * * + +See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). diff --git a/keyboards/keychron/k2/rgb/v2/ansi/keymaps/via/rules.mk b/keyboards/keychron/k2/rgb/v2/ansi/keymaps/via/rules.mk new file mode 100644 index 000000000000..036bd6d1c3ec --- /dev/null +++ b/keyboards/keychron/k2/rgb/v2/ansi/keymaps/via/rules.mk @@ -0,0 +1 @@ +VIA_ENABLE = yes \ No newline at end of file diff --git a/keyboards/keychron/k2/rgb/v2/ansi/readme.md b/keyboards/keychron/k2/rgb/v2/ansi/readme.md new file mode 100644 index 000000000000..4966c3f8e422 --- /dev/null +++ b/keyboards/keychron/k2/rgb/v2/ansi/readme.md @@ -0,0 +1,29 @@ +# Keychron K2V2 RGB ANSI + + +*A 75% keyboard sold by keychron* + +* Keyboard Maintainer: [ITNerd69](https://github.com/itnerd69) (based on work of dexter93 on a previous branch) +* Hardware Supported: *Keychron K2V2 RGB, MCU: SN32F248BF* +* Hardware Availability: *https://www.keychron.com/products/keychron-k2-hot-swappable-wireless-mechanical-keyboard* + +Compile example for this keyboard (after setting up your build environment): + + qmk compile -kb keychron/k2/rgb/v2/ansi -km default + +Compile example for this keyboard with VIA (after setting up your build environment): + + qmk compile -kb keychron/k2/rgb/v2/ansi -km via + +This keyboard must be flashed with an external [GUI](https://github.com/SonixQMK/sonix-flasher) or [CLI](https://github.com/SonixQMK/SonixFlasherC) + + + +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 2 ways: + +* **Physical Bootloader Pins**: Turn off the keyboard, Using a pair of tweezers or a paperclip, short the 2 pins left from spacebar switch holes and hold the tweezers on the pins while turning the keyboard on, this should put it into the bootloader. +* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available. In the default keymap Fn+Esc. diff --git a/keyboards/keychron/k2/rgb/v2/ansi/rules.mk b/keyboards/keychron/k2/rgb/v2/ansi/rules.mk new file mode 100644 index 000000000000..047de4137dd5 --- /dev/null +++ b/keyboards/keychron/k2/rgb/v2/ansi/rules.mk @@ -0,0 +1,2 @@ +EEPROM_DRIVER = wear_leveling +WEAR_LEVELING_DRIVER = sn32_flash diff --git a/keyboards/keychron/k2/rgb/v2/config.h b/keyboards/keychron/k2/rgb/v2/config.h index b73fd532640d..4b6863ddb57f 100644 --- a/keyboards/keychron/k2/rgb/v2/config.h +++ b/keyboards/keychron/k2/rgb/v2/config.h @@ -1,5 +1,6 @@ /* Copyright 2022 Philip Mourdjis * Copyright 2023 KeijoMika (https://github.com/KeijoMika) + * Copyright 2023 Santanu Paik (https://github.com/ITNerd69) * * 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 @@ -21,3 +22,4 @@ #define WEAR_LEVELING_SN32_EMULATION_PAGE_COUNT 29 #define RGB_MATRIX_FRAMEBUFFER_EFFECTS #define RGB_MATRIX_KEYPRESSES +#define RGB_DISABLE_WHEN_USB_SUSPENDED diff --git a/keyboards/keychron/k2/rgb/v2/via_json/k2_ansi.json b/keyboards/keychron/k2/rgb/v2/via_json/k2_ansi.json new file mode 100644 index 000000000000..d10601d4925c --- /dev/null +++ b/keyboards/keychron/k2/rgb/v2/via_json/k2_ansi.json @@ -0,0 +1,18 @@ +{ + "name": "Keychron K2v2 RGB ANSI", + "vendorId": "0x3434", + "productId": "0xFE02", + "matrix": {"rows": 6, "cols": 16}, + "keycodes": ["qmk_lighting"], + "layouts": { + "keymap": [ + [ "0,0","0,1","0,2","0,3","0,4","0,5","0,6","0,7","0,8","0,9","0,10","0,11","0,12","0,13","0,14","0,15" ], + [ "1,0","1,1","1,2","1,3","1,4","1,5","1,6","1,7","1,8","1,9","1,10","1,11","1,12",{"w": 2},"1,13","1,15" ], + [{"w": 1.5},"2,0","2,1","2,2","2,3","2,4","2,5","2,6","2,7","2,8","2,9","2,10","2,11","2,12",{"w": 1.5},"2,13","2,15" ], + [{"w": 1.75},"3,0","3,1","3,2","3,3","3,4","3,5","3,6","3,7","3,8","3,9","3,10","3,11",{"w": 2.25},"3,13","3,15" ], + [{"w": 2.25},"4,0","4,2","4,3","4,4","4,5","4,6","4,7","4,8","4,9","4,10","4,11",{"w": 1.75},"4,13","4,14","4,15" ], + [{"w": 1.25},"5,0",{"w": 1.25},"5,1",{"w": 1.25},"5,2",{"w": 6.25},"5,6","5,10","5,11","5,12","5,13","5,14","5,15" ] + ] + }, + "menus": [ "qmk_rgb_matrix"] +}