From 569f280fdfbd311df5c3187bd84603799ae6be33 Mon Sep 17 00:00:00 2001 From: JAO1988 <92758759+JAO1988@users.noreply.github.com> Date: Fri, 27 Sep 2024 14:35:23 -0400 Subject: [PATCH] Keychron C2 RGB ANSI (#426) * Updated C2 files with older SN32_Master files in separate folder. * Update config.h Changed definitions of config.h to match current tree of sn32_develop * Keychron C2 SN32_Develop Corrections Removed c2/rgb/old folder as appended files are no longer needed, updated rgb.c with new functions for dip_switch_enable, and updated keymaps with appropriate QMK optimizations and dipswitch toggle function. * Update rgb.c Correction on line 68 - Added ; after false parameter. * keymap.c, rgb.c sleep LED, config.h optimizations Corrected and adjusted the appropriate keys for default/via keymap files, corrected and adjusted rgb.c sleep LEDs when power matrix goes to sleep, and removed unnecessary code from config.h. * Removed VIA code due to EEPROM limits. Removed, adjusted, and optimized code. * Update readme.md Added additional comments and changes to manual. * Update keyboards/keychron/c2/rgb/rgb.c Co-authored-by: Dimitris Mantzouranis --------- Co-authored-by: Dimitris Mantzouranis --- keyboards/keychron/c2/rgb/config.h | 28 ++ keyboards/keychron/c2/rgb/keyboard.json | 291 ++++++++++++++++++ .../keychron/c2/rgb/keymaps/default/keymap.c | 117 +++++++ keyboards/keychron/c2/rgb/readme.md | 85 +++++ keyboards/keychron/c2/rgb/rgb.c | 81 +++++ 5 files changed, 602 insertions(+) create mode 100644 keyboards/keychron/c2/rgb/config.h create mode 100644 keyboards/keychron/c2/rgb/keyboard.json create mode 100644 keyboards/keychron/c2/rgb/keymaps/default/keymap.c create mode 100644 keyboards/keychron/c2/rgb/readme.md create mode 100644 keyboards/keychron/c2/rgb/rgb.c diff --git a/keyboards/keychron/c2/rgb/config.h b/keyboards/keychron/c2/rgb/config.h new file mode 100644 index 000000000000..62420ce64f7f --- /dev/null +++ b/keyboards/keychron/c2/rgb/config.h @@ -0,0 +1,28 @@ +/* +Copyright 2024 SiphonedAnomaly + +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 SN32F2XX_RGB_MATRIX_ROW_PINS { C0, C1, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, B6, B7, B8, B9, B10, B11 } +#define SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL SN32F2XX_PWM_OUTPUT_ACTIVE_HIGH /* Parameter added for PWM Transistor Permutations */ +#define SN32F2XX_RGB_OUTPUT_ACTIVE_LEVEL SN32F2XX_RGB_OUTPUT_ACTIVE_LOW /* Parameter added for RGB Transistor Permutations */ + +#define LED_WIN_PIN B12 +#define LED_MAC_PIN B15 + +// START LAYER DEFINITIONS +#define WIN_BASE 0 +#define WIN_FN 1 +#define MAC_BASE 2 +#define MAC_FN 3 \ No newline at end of file diff --git a/keyboards/keychron/c2/rgb/keyboard.json b/keyboards/keychron/c2/rgb/keyboard.json new file mode 100644 index 000000000000..59ccf74e8124 --- /dev/null +++ b/keyboards/keychron/c2/rgb/keyboard.json @@ -0,0 +1,291 @@ +{ + "manufacturer": "Keychron", + "keyboard_name": "Keychron C2 RGB", + "maintainer": "SiphonedAnomaly", + "bootloader": "sn32-dfu", + "diode_direction": "ROW2COL", + "features": { + "bootmagic": true, + "command": false, + "console": false, + "extrakey": true, + "mousekey": false, + "nkro": true, + "rgb_matrix": true, + "dip_switch": true + }, + "bootloader_instructions": "Hold FN + ESC", + "indicators": { + "caps_lock": "B13", + "num_lock": "B14", + "on_state": 1 + }, + "dip_switch": { + "pins": ["D6"] + }, + "matrix_pins": { + "rows": ["C15", "D11", "D10", "D9", "D8", "D7"] + "cols": ["A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "A10", "A11", "A12", "A13", "A14", "B0", "B1", "B2", "B3", "B4", "B5"], + }, + "debounce": 1, + "processor": "SN32F248BF", + "url": "https://www.keychron.com/products/keychron-c2-wired-mechanical-keyboard?variant=32294075170905" + "usb": { + "device_version": "1.0.0", + "pid": "0xFE22", + "vid": "0x3434" + }, + "layouts": { + "LAYOUT_ansi": { + "layout": [ + {"matrix":[0, 0], "x":0, "y":0}, + {"matrix":[0, 1], "x":2, "y":0}, + {"matrix":[0, 2], "x":3, "y":0}, + {"matrix":[0, 3], "x":4, "y":0}, + {"matrix":[0, 4], "x":5, "y":0}, + {"matrix":[0, 5], "x":6.5, "y":0}, + {"matrix":[0, 6], "x":7.5, "y":0}, + {"matrix":[0, 7], "x":8.5, "y":0}, + {"matrix":[0, 8], "x":9.5, "y":0}, + {"matrix":[0, 9], "x":11, "y":0}, + {"matrix":[0,10], "x":12, "y":0}, + {"matrix":[0,11], "x":13, "y":0}, + {"matrix":[0,12], "x":14, "y":0}, + {"matrix":[0,14], "x":15.25, "y":0}, + {"matrix":[0,15], "x":16.25, "y":0}, + {"matrix":[0,16], "x":17.25, "y":0}, + + {"matrix":[1, 0], "x":0, "y":1.25}, + {"matrix":[1, 1], "x":1, "y":1.25}, + {"matrix":[1, 2], "x":2, "y":1.25}, + {"matrix":[1, 3], "x":3, "y":1.25}, + {"matrix":[1, 4], "x":4, "y":1.25}, + {"matrix":[1, 5], "x":5, "y":1.25}, + {"matrix":[1, 6], "x":6, "y":1.25}, + {"matrix":[1, 7], "x":7, "y":1.25}, + {"matrix":[1, 8], "x":8, "y":1.25}, + {"matrix":[1, 9], "x":9, "y":1.25}, + {"matrix":[1,10], "x":10, "y":1.25}, + {"matrix":[1,11], "x":11, "y":1.25}, + {"matrix":[1,12], "x":12, "y":1.25}, + {"matrix":[1,13], "x":13, "y":1.25, "w":2}, + {"matrix":[1,14], "x":15.25, "y":1.25}, + {"matrix":[1,15], "x":16.25, "y":1.25}, + {"matrix":[1,16], "x":17.25, "y":1.25}, + {"matrix":[1,17], "x":18.5, "y":1.25}, + {"matrix":[1,18], "x":19.5, "y":1.25}, + {"matrix":[1,19], "x":20.5, "y":1.25}, + {"matrix":[1,20], "x":21.5, "y":1.25}, + + {"matrix":[2, 0], "x":0, "y":2.25, "w":1.5}, + {"matrix":[2, 1], "x":1.5, "y":2.25}, + {"matrix":[2, 2], "x":2.5, "y":2.25}, + {"matrix":[2, 3], "x":3.5, "y":2.25}, + {"matrix":[2, 4], "x":4.5, "y":2.25}, + {"matrix":[2, 5], "x":5.5, "y":2.25}, + {"matrix":[2, 6], "x":6.5, "y":2.25}, + {"matrix":[2, 7], "x":7.5, "y":2.25}, + {"matrix":[2, 8], "x":8.5, "y":2.25}, + {"matrix":[2, 9], "x":9.5, "y":2.25}, + {"matrix":[2,10], "x":10.5, "y":2.25}, + {"matrix":[2,11], "x":11.5, "y":2.25}, + {"matrix":[2,12], "x":12.5, "y":2.25}, + {"matrix":[2,13], "x":13.5, "y":2.25, "w":1.5}, + {"matrix":[2,14], "x":15.25, "y":2.25}, + {"matrix":[2,15], "x":16.25, "y":2.25}, + {"matrix":[2,16], "x":17.25, "y":2.25}, + {"matrix":[2,17], "x":18.25, "y":2.25}, + {"matrix":[2,18], "x":19.25, "y":2.25}, + {"matrix":[2,19], "x":20.25, "y":2.25}, + {"matrix":[2,20], "x":21.25, "y":2.25, "h":2}, + + {"matrix":[3, 0], "x":0, "y":3.25, "w":1.75}, + {"matrix":[3, 1], "x":1.75, "y":3.25}, + {"matrix":[3, 2], "x":2.75, "y":3.25}, + {"matrix":[3, 3], "x":3.75, "y":3.25}, + {"matrix":[3, 4], "x":4.75, "y":3.25}, + {"matrix":[3, 5], "x":5.75, "y":3.25}, + {"matrix":[3, 6], "x":6.75, "y":3.25}, + {"matrix":[3, 7], "x":7.75, "y":3.25}, + {"matrix":[3, 8], "x":8.75, "y":3.25}, + {"matrix":[3, 9], "x":9.75, "y":3.25}, + {"matrix":[3,10], "x":10.75, "y":3.25} + {"matrix":[3,11], "x":11.75, "y":3.25}, + {"matrix":[3,13], "x":12.75, "y":3.25, "w":2.25}, + {"matrix":[3,17], "x":18.5, "y":3.25}, + {"matrix":[3,18], "x":19.5, "y":3.25}, + {"matrix":[3,19], "x":20.5, "y":3.25}, + + {"matrix":[4, 0], "x":0, "y":4.25, "w":2.25}, + {"matrix":[4, 2], "x":2.25, "y":4.25}, + {"matrix":[4, 3], "x":3.25, "y":4.25}, + {"matrix":[4, 4], "x":4.25, "y":4.25}, + {"matrix":[4, 5], "x":5.25, "y":4.25}, + {"matrix":[4, 6], "x":6.25, "y":4.25}, + {"matrix":[4, 7], "x":7.25, "y":4.25}, + {"matrix":[4, 8], "x":8.25, "y":4.25}, + {"matrix":[4, 9], "x":9.25, "y":4.25}, + {"matrix":[4,10], "x":10.25, "y":4.25}, + {"matrix":[4,11], "x":11.25, "y":4.25}, + {"matrix":[4,13], "x":12.25, "y":4.25, "w":2.75} + {"matrix":[4,15], "x":16.25, "y":4.25}, + {"matrix":[4,17], "x":18.25, "y":4.25}, + {"matrix":[4,18], "x":19.25, "y":4.25}, + {"matrix":[4,19], "x":20.25, "y":4.25}, + {"matrix":[4,20], "x":21.5, "y":4.25, "h":2}, + + {"matrix":[5, 0], "x":0, "y":5.25, "w":1.25}, + {"matrix":[5, 1], "x":1.25, "y":5.25, "w":1.25}, + {"matrix":[5, 2], "x":2.5, "y":5.25, "w":1.25}, + {"matrix":[5, 6], "x":3.75, "y":5.25, "w":6.25}, + {"matrix":[5, 9], "x":10, "y":5.25, "w":1.25}, + {"matrix":[5,10], "x":11.25, "y":5.25, "w":1.25}, + {"matrix":[5,11], "x":12.5, "y":5.25, "w":1.25}, + {"matrix":[5,13], "x":13.75, "y":5.25, "w":1.25}, + {"matrix":[5,14], "x":15.25, "y":5.25}, + {"matrix":[5,15], "x":16.25, "y":5.25}, + {"matrix":[5,16], "x":17.25, "y":5.25}, + {"matrix":[5,18], "x":18.5, "y":5.25, "w":2}, + {"matrix":[5,19], "x":20.5, "y":5.25} + ] + } + }, + "rgb_matrix": { + "driver": "sn32f2xx", + "animations": { + "breathing": true, + "band_spiral_val": true, + "cycle_all": true, + "cycle_left_right": true, + "cycle_up_down": true, + "rainbow_moving_chevron": true, + "cycle_out_in": true, + "cycle_out_in_dual": true, + "cycle_pinwheel": true, + "cycle_spiral": true, + "dual_beacon": true, + "rainbow_beacon": true, + "jellybean_raindrops": true, + "pixel_rain": true, + "typing_heatmap": true, + "digital_rain": true, + "solid_reactive_simple": true, + "solid_reactive_multiwide": true, + "solid_reactive_multinexus": true, + "splash": true, + "solid_splash": true + }, + "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, 14], "flags":4, "x":174, "y":0}, + {"matrix":[0, 15], "flags":4, "x":187, "y":0}, + {"matrix":[0, 16], "flags":4, "x":199, "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, 14], "flags":4, "x":174, "y":13}, + {"matrix":[1, 15], "flags":4, "x":187, "y":13}, + {"matrix":[1, 16], "flags":4, "x":199, "y":13}, + {"matrix":[1, 17], "flags":4, "x":211, "y":13}, + {"matrix":[1, 18], "flags":4, "x":224, "y":13}, + {"matrix":[1, 19], "flags":4, "x":236, "y":13}, + {"matrix":[1, 20], "flags":4, "x":249, "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, 14], "flags":4, "x":174, "y":26}, + {"matrix":[2, 15], "flags":4, "x":187, "y":26}, + {"matrix":[2, 16], "flags":4, "x":199, "y":26}, + {"matrix":[2, 17], "flags":4, "x":211, "y":26}, + {"matrix":[2, 18], "flags":4, "x":224, "y":26}, + {"matrix":[2, 19], "flags":4, "x":236, "y":26}, + {"matrix":[2, 20], "flags":4, "x":249, "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, 17], "flags":4, "x":211, "y":38}, + {"matrix":[3, 18], "flags":4, "x":224, "y":38}, + {"matrix":[3, 19], "flags":4, "x":236, "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, 15], "flags":4, "x":187, "y":51}, + {"matrix":[4, 17], "flags":4, "x":211, "y":51}, + {"matrix":[4, 18], "flags":4, "x":224, "y":51}, + {"matrix":[4, 19], "flags":4, "x":236, "y":51}, + {"matrix":[4, 20], "flags":4, "x":249, "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, 9], "flags":4, "x":124, "y":64}, + {"matrix":[5, 10], "flags":4, "x":137, "y":64}, + {"matrix":[5, 11], "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}, + {"matrix":[5, 16], "flags":4, "x":199, "y":64}, + {"matrix":[5, 18], "flags":4, "x":224, "y":64}, + {"matrix":[5, 19], "flags":4, "x":236, "y":64} + ], + "sleep": true + } +} diff --git a/keyboards/keychron/c2/rgb/keymaps/default/keymap.c b/keyboards/keychron/c2/rgb/keymaps/default/keymap.c new file mode 100644 index 000000000000..72dfd7a505dd --- /dev/null +++ b/keyboards/keychron/c2/rgb/keymaps/default/keymap.c @@ -0,0 +1,117 @@ +/* +Copyright 2024 SiphonedAnomaly + +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. + +#define KC_TASK LGUI(KC_TAB) // Task viewer +#define KC_FLXP LGUI(KC_E) // Windows file explorer +#define KC_CRTN LGUI(KC_C) // Cortana | Microsoft Teams +#define KC_SNIP LGUI(LSFT(KC_S)) // Windows snip tool + +#define KC_MSSN LGUI(KC_F3) // Mission Control +#define KC_FIND LALT(LGUI(KC_SPC)) // Finder +#define KC_SIRI LGUI(KC_SPC) // Siri +#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] = { + /* Windows layout + +-----------------------------------------------------------------------------------------------------------------+ + | ESC | | F1 | F2 | F3 | F4 | | F5 | F6 | F7 | F8 | | F9| F10| F11| F12| | |PSCR|CORT|RGB | | + +--------------------------------------------------------------------------+ +--------------+ +-------------------+ + | ~ | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | BACKSP | |INS |HOME|PGUP| |NLCK| P/ | P* | P- | + +--------------------------------------------------------------------------+ +--------------+ +-------------------+ + | TAB | Q | W | E | R | T | Y | U | I | O | P | [ | ] | \ | |DEL |END |PGDN| | P7 | P8 | P9 | | + +--------------------------------------------------------------------------+ +--------------+ +--------------+ P+ | + | CAPSLCK | A | S | D | F | G | H | J | K | L | ; | ' | RETURN | | P4 | P5 | P6 | | + +--------------------------------------------------------------------------+ +----+ +-------------------+ + | LSHIFT | Z | X | C | V | B | N | M | , | . | / | RSHIFT | | UP | | P1 | P2 | P3 | | + +--------------------------------------------------------------------------+ +--------------+ +---------------PRET| + |LCTRL| LGUI| LALT | SPACE | RALT| RGUI | FN | RCTRL | |LFT |DWN |RGT | | P0 | . | | + +-----------------------------------------------------------------------------------------------------------------+ + */ + + [WIN_BASE] = LAYOUT_ansi( // Windows Base layout + /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 */ + 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_CRTN, RGB_TOG, + 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_INS, KC_HOME, KC_PGUP, KC_NUM, KC_PSLS, KC_PAST, KC_PMNS, + 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_DEL, KC_END, KC_PGDN, KC_P7, KC_P8, KC_P9, KC_PPLS, + 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_P4, KC_P5, KC_P6, + 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_P1, KC_P2, KC_P3, KC_PENT, + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, MO(WIN_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT ), + + [WIN_FN] = LAYOUT_ansi( // Windows FN Overlay + /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 */ + QK_BOOT, 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_SNIP, _______, RGB_MOD, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_HUI, RGB_VAI, RGB_SAI, RGB_M_TW, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_HUD, RGB_VAD, RGB_SAD, RGB_M_X, RGB_M_G, RGB_M_T, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_M_SW, RGB_M_SN, RGB_M_K, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SPI, RGB_M_P, RGB_M_B, RGB_M_R, _______, + _______, _______, _______, _______, _______, _______, _______, _______, RGB_RMOD, RGB_SPD, RGB_MOD, _______, _______ ), + + + + /* Mac layout + +-----------------------------------------------------------------------------------------------------------------+ + | ESC | | F1 | F2 | F3 | F4 | | F5 | F6 | F7 | F8 | | F9| F10| F11| F12| | |PSCR|SIRI|RGB | | + +--------------------------------------------------------------------------+ +--------------+ +-------------------+ + | ~ | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | BACKSP | |INS |HOME|PGUP| |NLCK| P/ | P* | P- | + +--------------------------------------------------------------------------+ +--------------+ +-------------------+ + | TAB | Q | W | E | R | T | Y | U | I | O | P | [ | ] | \ | |DEL |END |PGDN| | P7 | P8 | P9 | | + +--------------------------------------------------------------------------+ +--------------+ +--------------+ P+ | + | CAPSLCK | A | S | D | F | G | H | J | K | L | ; | ' | RETURN | | P4 | P5 | P6 | | + +--------------------------------------------------------------------------+ +----+ +-------------------+ + | LSHIFT | Z | X | C | V | B | N | M | , | . | / | RSHIFT | | UP | | P1 | P2 | P3 | | + +--------------------------------------------------------------------------+ +--------------+ +---------------PRET| + |LCTRL| LALT| LGUI | SPACE | RGUI| RALT | FN | RCTRL | |LFT |DWN |RGT | | P0 | . | | + +-----------------------------------------------------------------------------------------------------------------+ + */ + + [MAC_BASE] = LAYOUT_ansi( // Mac Base layout + /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 */ + 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_SIRI, RGB_TOG, + 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_INS, KC_HOME, KC_PGUP, KC_NUM, KC_PSLS, KC_PAST, KC_PMNS, + 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_DEL, KC_END, KC_PGDN, KC_P7, KC_P8, KC_P9, KC_PPLS, + 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_P4, KC_P5, KC_P6, + 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_P1, KC_P2, KC_P3, KC_PENT, + KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, KC_RALT, MO(MAC_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT ), + + [MAC_FN] = LAYOUT_ansi( // Mac FN Overlay + /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 */ + QK_BOOT, 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, _______, RGB_MOD, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_HUI, RGB_VAI, RGB_SAI, RGB_M_TW, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_HUD, RGB_VAD, RGB_SAD, RGB_M_X, RGB_M_G, RGB_M_T, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_M_SW, RGB_M_SN, RGB_M_K, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SPI, RGB_M_P, RGB_M_B, RGB_M_R, _______, + _______, _______, _______, _______, _______, _______, _______, _______, RGB_RMOD, RGB_SPD, RGB_MOD, _______, _______ ), +}; + +/* Mac/Windows - Toggle Switch parameters */ +bool dip_switch_update_user(uint8_t index, bool active){ + if(index == 0) { + if(active) { // Mac mode + layer_move(0); + } else { // Windows mode + layer_move(2); + } + } + return true; +} \ No newline at end of file diff --git a/keyboards/keychron/c2/rgb/readme.md b/keyboards/keychron/c2/rgb/readme.md new file mode 100644 index 000000000000..74a715c5b51e --- /dev/null +++ b/keyboards/keychron/c2/rgb/readme.md @@ -0,0 +1,85 @@ +# Keychron C2 RGB + +![Keychron C2](https://i.imgur.com/QtV3Kk3.jpg) + +A customizable Full-Size ANSI keyboard. + +* Keyboard Maintainer(s): [SonixQMK](https://github.com/SonixQMK), [IsaacDynamo](https://github.com/IsaacDynamo), [noldevin](https://github.com/noldevin), [vjdato21](https://github.com/vjdato21), [aaronsb](https://github.com/aaronsb), [JAO1988](https://github.com/JAO1988) +* Hardware Supported: Keychron C2 RGB +* Hardware Availability: [Keychron](https://www.keychron.com/products/keychron-c2-wired-mechanical-keyboard) + +Make example for this keyboard (after setting up your build environment): + + make keychron/c2/rgb:default + +## How to Flash +Flashing example for this keyboard: +1. If your keyboard currently has stock firmware installed, put your keyboard first into bootloader by shorting the boot pins found under the spacebar before plugging in your keyboard to the PC. Otherwise, press `Fn + Esc` to put your keyboard into bootloader. +1. Download and run [Sonix Flasher](https://github.com/SonixQMK/sonix-flasher/releases/latest). +1. In Sonix Flasher, select `SN32F24X` under 'Device'. And select `0x00` as the qmk offset. +1. Lastly, click 'Flash QMK...' and locate the compiled firmware. + +* * * +# Keymapping +### Windows Mode +
+ +Without Fn | With Fn +---------- | ------- +F1 | Decrease PC Brightness +F2 | Increase PC Brightness +F3 | Task View +F4 | File Explorer +F5 | Decrease KB Brightness +F6 | Increase KB Brightness +F7 | Previous Track +F8 | Play/Pause Track +F9 | Next Track +F10 | Mute +F11 | Decrease Volume +F12 | Increase Volume +Print Screen | Snip & Sketch +Cortana / Microsoft Teams | None +Change RGB | Toggle RGB +⊞ | Windows Key Lock Toggle +Home | NKRO Toggle +↑ | Increase RGB Hue +← | Decrease RGB Saturation +↓ | Decrease RGB Hue +→ | Increase RGB Saturation + +
+ +### Mac Mode +
+ +Without Fn | With Fn +---------- | ------- +F1 | Decrease PC Brightness +F2 | Increase PC Brightness +F3 | Mission Control +F4 | Finder +F5 | Decrease KB Brightness +F6 | Increase KB Brightness +F7 | Previous Track +F8 | Play/Pause Track +F9 | Next Track +F10 | Mute +F11 | Decrease Volume +F12 | Increase Volume +Take a screenshot (whole screen) | Take a screenshot (specific area) +Siri (hold down) | None +Change RGB | Toggle RGB +Home | NKRO Toggle +↑ | Increase RGB Hue +← | Decrease RGB Saturation +↓ | Decrease RGB Hue +→ | Increase RGB Saturation + +
+ +* * * + +For more information and more detailed flashing instructions, please visit https://github.com/CanUnesi/QMK-on-K6#readme + +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/c2/rgb/rgb.c b/keyboards/keychron/c2/rgb/rgb.c new file mode 100644 index 000000000000..b9a8d4a7b830 --- /dev/null +++ b/keyboards/keychron/c2/rgb/rgb.c @@ -0,0 +1,81 @@ +/* Copyright 2024 NetUserGet, SiphonedAnomaly + * + * 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" + +bool mode_leds_show = true; + +#ifdef DIP_SWITCH_ENABLE + static void mode_leds_update(void){ + if (!mode_leds_show) { + gpio_write_pin_low(LED_MAC_PIN); + gpio_write_pin_low(LED_WIN_PIN); + } + else { + if (layer_state_is(WIN_BASE)) { + gpio_write_pin_high(LED_WIN_PIN) && gpio_write_pin_low(LED_MAC_PIN); + } + if (layer_state_is(MAC_BASE)) { + gpio_write_pin_high(LED_MAC_PIN) && gpio_write_pin_low(LED_WIN_PIN); + } + } + } + bool dip_switch_update_kb(uint8_t index, bool active) { + if (!dip_switch_update_user(index, active)) { + return false; + } + if (index == 0) { + if (active) { + default_layer_state_set_kb(1 << MAC_BASE); /* set layer 2 to be on */ + } + } + mode_leds_update(); + return true; + } +#endif // DIP_SWITCH_ENABLE + + +void keyboard_pre_init_kb(void) { + // Setup Win & Mac LED Pins as output + gpio_set_pin_output(LED_WIN_PIN); + gpio_set_pin_output(LED_MAC_PIN); +} + +void keyboard_post_init_kb(void) { + // Setup Default Keymap. + // If you chose to not have the dipswich enabled change this WIN_BASE to be your default keymap. + // Eg: MAC_BASE + default_layer_state_set_kb(1 << WIN_BASE); /* set layer 0 to be on */ +} + +#ifdef RGB_MATRIX_SLEEP + void suspend_power_down_kb(void) { + // Turn leds off + mode_leds_show = false; + mode_leds_update(); + + rgb_matrix_set_suspend_state(true); + + } + + void suspend_wakeup_init_kb(void) { + mode_leds_show = true; + mode_leds_update(); + + rgb_matrix_set_suspend_state(false); + + } +#endif // RGB_MATRIX_SLEEP \ No newline at end of file