aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboards/keychron/q1/rev_0100/keymaps/gtg465x/README.md17
-rw-r--r--keyboards/keychron/q1/rev_0100/keymaps/gtg465x/config.h8
-rw-r--r--keyboards/keychron/q1/rev_0100/keymaps/gtg465x/keymap.c28
-rw-r--r--keyboards/keychron/q1/rev_0100/keymaps/gtg465x/keymap_user.h28
-rw-r--r--keyboards/keychron/q1/rev_0100/keymaps/gtg465x/rgb_matrix_user.c71
-rw-r--r--keyboards/keychron/q1/rev_0100/keymaps/gtg465x/rgb_matrix_user.h24
-rw-r--r--keyboards/keychron/q1/rev_0100/keymaps/gtg465x/rules.mk4
7 files changed, 169 insertions, 11 deletions
diff --git a/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/README.md b/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/README.md
index c10416e69..c2d5799bb 100644
--- a/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/README.md
+++ b/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/README.md
@@ -2,3 +2,20 @@
2 2
3- On macOS, F3 opens Mission Control and F4 opens Launchpad without needing to configure shortcuts in System Preferences 3- On macOS, F3 opens Mission Control and F4 opens Launchpad without needing to configure shortcuts in System Preferences
4- RGB lighting turns off when the computer sleeps 4- RGB lighting turns off when the computer sleeps
5- Caps Lock and alpha keys turn red to indicate when Caps Lock is on
6- When the Fn layer is active, RGB lighting turns off for keys that are not assigned
7
8## Changelog
9
10### 10/3/2021 - 1.0.3
11
12- Feature: When the Fn layer is active, RGB lighting turns off for keys that are not assigned
13
14### 10/1/2021 - 1.0.2
15
16- Added Caps Lock indicator (my implementation is different, but this was inspired by mkillewald)
17- Mission Control and Launchpad custom keycodes are now defined using the VIA user keycodes range so they can be labeled properly in VIA
18
19### 9/28/2021 - 1.0.1
20
21- Initial release
diff --git a/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/config.h b/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/config.h
index 3a20f0b00..5ac05d04c 100644
--- a/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/config.h
+++ b/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/config.h
@@ -16,6 +16,10 @@
16 16
17#pragma once 17#pragma once
18 18
19
20/* RGB Matrix Configuration */ 19/* RGB Matrix Configuration */
21#define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended 20#ifdef RGB_MATRIX_ENABLE
21# define RGB_DISABLE_WHEN_USB_SUSPENDED
22# define CAPS_LOCK_INDICATOR_COLOR RGB_RED
23# define CAPS_LOCK_INDICATOR_LIGHT_ALPHAS
24# define FN_LAYER_TRANSPARENT_KEYS_OFF
25#endif
diff --git a/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/keymap.c b/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/keymap.c
index 79ef0bf86..7f806f6b4 100644
--- a/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/keymap.c
+++ b/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/keymap.c
@@ -15,18 +15,20 @@
15 */ 15 */
16 16
17#include QMK_KEYBOARD_H 17#include QMK_KEYBOARD_H
18#include "keymap_user.h"
19#ifdef RGB_MATRIX_ENABLE
20# include "rgb_matrix_user.h"
21#endif
18 22
19 23// clang-format off
20enum layers{
21 MAC_BASE,
22 MAC_FN,
23 WIN_BASE,
24 WIN_FN
25};
26 24
27enum custom_keycodes { 25enum custom_keycodes {
28 KC_MISSION_CONTROL = SAFE_RANGE, 26#ifdef VIA_ENABLE
29 KC_LAUNCHPAD 27 KC_MISSION_CONTROL = USER00,
28#else
29 KC_MISSION_CONTROL = SAFE_RANGE,
30#endif
31 KC_LAUNCHPAD
30}; 32};
31 33
32#define KC_MCTL KC_MISSION_CONTROL 34#define KC_MCTL KC_MISSION_CONTROL
@@ -70,6 +72,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
70 72
71}; 73};
72 74
75// clang-format on
76
77void matrix_init_user(void) {
78#ifdef RGB_MATRIX_ENABLE
79 rgb_matrix_init_user();
80#endif
81}
82
73bool process_record_user(uint16_t keycode, keyrecord_t *record) { 83bool process_record_user(uint16_t keycode, keyrecord_t *record) {
74 switch (keycode) { 84 switch (keycode) {
75 case KC_MISSION_CONTROL: 85 case KC_MISSION_CONTROL:
diff --git a/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/keymap_user.h b/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/keymap_user.h
new file mode 100644
index 000000000..728114d55
--- /dev/null
+++ b/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/keymap_user.h
@@ -0,0 +1,28 @@
1/* Copyright 2021 @ Grayson Carr
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19// clang-format off
20
21enum layers {
22 MAC_BASE,
23 MAC_FN,
24 WIN_BASE,
25 WIN_FN
26};
27
28// clang-format on
diff --git a/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/rgb_matrix_user.c b/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/rgb_matrix_user.c
new file mode 100644
index 000000000..9bc7231ec
--- /dev/null
+++ b/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/rgb_matrix_user.c
@@ -0,0 +1,71 @@
1/* Copyright 2021 @ Grayson Carr
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include QMK_KEYBOARD_H
18#include "rgb_matrix_user.h"
19#include "keymap_user.h"
20
21keypos_t led_index_key_position[DRIVER_LED_TOTAL];
22
23void rgb_matrix_init_user(void) {
24 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
25 for (uint8_t col = 0; col < MATRIX_COLS; col++) {
26 uint8_t led_index = g_led_config.matrix_co[row][col];
27 if (led_index != NO_LED) {
28 led_index_key_position[led_index] = (keypos_t){.row = row, .col = col};
29 }
30 }
31 }
32}
33
34void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
35 uint8_t current_layer = get_highest_layer(layer_state);
36 switch (current_layer) {
37 case MAC_BASE:
38 case WIN_BASE:
39#ifdef CAPS_LOCK_INDICATOR_COLOR
40 if (host_keyboard_led_state().caps_lock) {
41 rgb_matrix_set_color_by_keycode(led_min, led_max, current_layer, is_caps_lock_indicator, CAPS_LOCK_INDICATOR_COLOR);
42 }
43#endif
44 break;
45 case MAC_FN:
46 case WIN_FN:
47#ifdef FN_LAYER_TRANSPARENT_KEYS_OFF
48 rgb_matrix_set_color_by_keycode(led_min, led_max, current_layer, is_transparent, RGB_OFF);
49#endif
50 break;
51 }
52}
53
54void rgb_matrix_set_color_by_keycode(uint8_t led_min, uint8_t led_max, uint8_t layer, bool (*is_keycode)(uint16_t), uint8_t red, uint8_t green, uint8_t blue) {
55 for (uint8_t i = led_min; i < led_max; i++) {
56 uint16_t keycode = keymap_key_to_keycode(layer, led_index_key_position[i]);
57 if ((*is_keycode)(keycode)) {
58 rgb_matrix_set_color(i, red, green, blue);
59 }
60 }
61}
62
63bool is_caps_lock_indicator(uint16_t keycode) {
64#ifdef CAPS_LOCK_INDICATOR_LIGHT_ALPHAS
65 return (KC_A <= keycode && keycode <= KC_Z) || keycode == KC_CAPS;
66#else
67 return keycode == KC_CAPS;
68#endif
69}
70
71bool is_transparent(uint16_t keycode) { return keycode == KC_TRNS; }
diff --git a/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/rgb_matrix_user.h b/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/rgb_matrix_user.h
new file mode 100644
index 000000000..dead45416
--- /dev/null
+++ b/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/rgb_matrix_user.h
@@ -0,0 +1,24 @@
1/* Copyright 2021 @ Grayson Carr
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19void rgb_matrix_init_user(void);
20
21void rgb_matrix_set_color_by_keycode(uint8_t led_min, uint8_t led_max, uint8_t layer, bool (*is_keycode)(uint16_t), uint8_t red, uint8_t green, uint8_t blue);
22
23bool is_caps_lock_indicator(uint16_t keycode);
24bool is_transparent(uint16_t keycode);
diff --git a/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/rules.mk b/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/rules.mk
index 96d2d189b..42ba38028 100644
--- a/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/rules.mk
+++ b/keyboards/keychron/q1/rev_0100/keymaps/gtg465x/rules.mk
@@ -1,2 +1,6 @@
1VIA_ENABLE = yes 1VIA_ENABLE = yes
2MOUSEKEY_ENABLE = no 2MOUSEKEY_ENABLE = no
3
4ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
5 SRC += rgb_matrix_user.c
6endif