Skip to content

Instantly share code, notes, and snippets.

@desaster
Created October 12, 2022 17:53
Show Gist options
  • Save desaster/67464067028b257b1ada51c6f3a31281 to your computer and use it in GitHub Desktop.
Save desaster/67464067028b257b1ada51c6f3a31281 to your computer and use it in GitHub Desktop.
My personal customizations to the Keychron Q3 VIAL firmware
My personal customizations to the Keychron Q3 VIAL firmware.
* Add some custom backlight to certain keys if "mac" layer is enabled. This is
done because I use the "mac" layer to remap some keys to F-keys for quick
access, so this modification lights them up for clarity
* new custom keycode KC_BRCYCLE will cycle through three different backlight
brightnesses. I map this to Fn-Space, so it behaves a bit like the backlight
settings on my Lenovo laptop
This diff is for the unofficial VIAL branch by adophoxia
https://github.com/adophoxia/VIAL-for-Keychron
https://github.com/adophoxia/vial-qmk/tree/vial-keychron
diff --git a/keyboards/keychron/q3/q3.c b/keyboards/keychron/q3/q3.c
index fcf3e906f0..b91894506f 100644
--- a/keyboards/keychron/q3/q3.c
+++ b/keyboards/keychron/q3/q3.c
@@ -70,6 +70,29 @@ void rgb_matrix_indicators_kb(void) {
}
rgb_matrix_set_color(CAPS_LOCK_LED_INDEX, b, b, b); // white, with the adjusted brightness
}
+
+ // These are 9009 style colors:
+ // 3C RGB(216, 151, 147)
+ // 3B RGB(129, 162, 145)
+
+ // set custom colors to the right side keys if we are in the "mac" layer
+ if (IS_LAYER_ON(0) || IS_LAYER_ON(1)) {
+ rgb_matrix_set_color(INS_LED_INDEX, 216, 151, 147);
+ rgb_matrix_set_color(HOME_LED_INDEX, 216, 151, 147);
+ rgb_matrix_set_color(PGUP_LED_INDEX, 216, 151, 147);
+ rgb_matrix_set_color(DEL_LED_INDEX, 216, 151, 147);
+ rgb_matrix_set_color(END_LED_INDEX, 216, 151, 147);
+ rgb_matrix_set_color(PGDN_LED_INDEX, 216, 151, 147);
+
+ /*
+ rgb_matrix_set_color(INS_LED_INDEX, 129, 162, 145);
+ rgb_matrix_set_color(HOME_LED_INDEX, 129, 162, 145);
+ rgb_matrix_set_color(PGUP_LED_INDEX, 129, 162, 145);
+ rgb_matrix_set_color(DEL_LED_INDEX, 129, 162, 145);
+ rgb_matrix_set_color(END_LED_INDEX, 129, 162, 145);
+ rgb_matrix_set_color(PGDN_LED_INDEX, 129, 162, 145);
+ */
+ }
}
#endif
diff --git a/keyboards/keychron/q3/rev_0122/config.h b/keyboards/keychron/q3/rev_0122/config.h
index 7bd5bd4af0..1a4fda102c 100644
--- a/keyboards/keychron/q3/rev_0122/config.h
+++ b/keyboards/keychron/q3/rev_0122/config.h
@@ -29,3 +29,10 @@
/* Enable caps-lock LED */
#define CAPS_LOCK_LED_INDEX 49
+
+#define INS_LED_INDEX 30
+#define HOME_LED_INDEX 31
+#define PGUP_LED_INDEX 32
+#define DEL_LED_INDEX 46
+#define END_LED_INDEX 47
+#define PGDN_LED_INDEX 48
diff --git a/keyboards/keychron/q3/rev_0122/keymaps/vial/keymap.c b/keyboards/keychron/q3/rev_0122/keymaps/vial/keymap.c
index cdfb3c1fdb..7d98d113c9 100644
--- a/keyboards/keychron/q3/rev_0122/keymaps/vial/keymap.c
+++ b/keyboards/keychron/q3/rev_0122/keymaps/vial/keymap.c
@@ -35,7 +35,8 @@ enum custom_keycodes {
KC_TASK_VIEW,
KC_FILE_EXPLORER,
KC_SCREEN_SHOT,
- KC_CORTANA
+ KC_CORTANA,
+ KC_BRCYCLE
};
#define KC_MCTL KC_MISSION_CONTROL
@@ -162,6 +163,32 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}
}
return false; // Skip all further processing of this key
+
+ // Cycle through a limited number of brightness settings
+ case KC_BRCYCLE:
+ if (!record->event.pressed) {
+ return false;
+ }
+
+ HSV curr_hsv = rgb_matrix_get_hsv();
+ unsigned char brightness = curr_hsv.v;
+
+ // step through 3 possible values.
+ if (brightness < 0x40) {
+ brightness = 0x40;
+ } else if (brightness < 0x80) {
+ brightness = 0x80; // highest brightness (128), should we go even higher?
+ } else { // >= 0x80
+ brightness = 0;
+ }
+
+ rgb_matrix_sethsv_noeeprom(curr_hsv.h, curr_hsv.s, brightness);
+
+ // or store it in EEPROM:
+ // rgb_matrix_sethsv(curr_hsv.h, curr_hsv.s, brightness);
+
+ return false; // Skip all further processing of this key
+
default:
return true; // Process all other keycodes normally
}
diff --git a/keyboards/keychron/q3/rev_0122/keymaps/vial/vial.json b/keyboards/keychron/q3/rev_0122/keymaps/vial/vial.json
index 8a302e9901..caa1465e77 100644
--- a/keyboards/keychron/q3/rev_0122/keymaps/vial/vial.json
+++ b/keyboards/keychron/q3/rev_0122/keymaps/vial/vial.json
@@ -15,7 +15,8 @@
{"name": "Task View", "title": "Task View in windows", "shortName": "Task View"},
{"name": "File Explorer", "title": "File Explorer in windows", "shortName": "File Explorer"},
{"name": "Screen Shot", "title": "Screenshot in macOS", "shortName": "Screen Shot"},
- {"name": "Cortana", "title": "Cortana in windows", "shortName": "Cortana"}
+ {"name": "Cortana", "title": "Cortana in windows", "shortName": "Cortana"},
+ {"name": "Brightness Cycle", "title": "Cycle brightness settings", "shortName": "Brightness Cycle"}
],
"layouts": {
"keymap":[
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment