Skip to content

Commit

Permalink
Merge pull request qmk#23 from ibootstrapper/master
Browse files Browse the repository at this point in the history
added q3 rev 0120 left-hand gamer layer
  • Loading branch information
KeychronMacro authored Apr 11, 2022
2 parents ee06a5b + e664c23 commit 7b2c239
Show file tree
Hide file tree
Showing 11 changed files with 771 additions and 0 deletions.
1 change: 1 addition & 0 deletions keyboards/keychron/q3/q3.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ bool dip_switch_update_kb(uint8_t index, bool active) {
return false;
}
if (index == 0) {
layer_state_set(1UL << (active ? 2 : 0));
default_layer_set(1UL << (active ? 2 : 0));
}
return true;
Expand Down
2 changes: 2 additions & 0 deletions keyboards/keychron/q3/q3.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@
# include "rev_0122.h"
#elif defined(KEYBOARD_keychron_q3_rev_0123)
# include "rev_0123.h"
#elif defined(KEYBOARD_keychron_q3_rev_0120_lhg)
# include "rev_0120_lhg.h"
#endif
47 changes: 47 additions & 0 deletions keyboards/keychron/q3/rev_0120_lhg/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* Copyright 2021 @ Keychron (https://www.keychron.com)
*
* 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 <http://www.gnu.org/licenses/>.
*/

#pragma once

/* USB Device descriptor parameter */
#define PRODUCT_ID 0x0120
#define DEVICE_VER 0x0100

/* key matrix pins */
#define MATRIX_ROW_PINS { B5, B4, B3, A15, A14, A13 }
#define MATRIX_COL_PINS { C14, C15, A0, A1, A2, A3, A4, A5, A6, A7, B0, B1, A8, A9, A10, H3 }

/* We uses a pin with a stronger pull resistor than the internal MCU pins */
// #define MATRIX_UNSELECT_DRIVE_HIGH

/* RGB Matrix Configuration */
#define DRIVER_1_LED_TOTAL 48
#define DRIVER_2_LED_TOTAL 39
#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)

/* Enable CapsLcok LED */
#define CAPS_LOCK_LED_INDEX 50

// setup 5 layers
// 0: Mac
// 1: Mac function
// 2: Windows
// 3: Left Handed Gaming
// 4: Windows Function
#define DYNAMIC_KEYMAP_LAYER_COUNT 5

#define RGB_MATRIX_KEYPRESSES
#define RGB_MATRIX_KEYRELEASES
103 changes: 103 additions & 0 deletions keyboards/keychron/q3/rev_0120_lhg/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"keyboard_name": "Keychron Q3",
"url": "https://github.com/Keychron",
"maintainer": "lalalademaxiya1",
"layouts": {
"LAYOUT_ansi_87": {
"layout": [
{"label":"Esc", "x":0, "y":0},
{"label":"F1", "x":2, "y":0},
{"label":"F2", "x":3, "y":0},
{"label":"F3", "x":4, "y":0},
{"label":"F4", "x":5, "y":0},
{"label":"F5", "x":6.5, "y":0},
{"label":"F5", "x":7.5, "y":0},
{"label":"F7", "x":8.5, "y":0},
{"label":"F8", "x":9.5, "y":0},
{"label":"F9", "x":11, "y":0},
{"label":"F10", "x":12, "y":0},
{"label":"F11", "x":13, "y":0},
{"label":"F12", "x":14, "y":0},
{"label":"Print", "x":15.25, "y":0},
{"label":"Cortana", "x":16.25, "y":0},
{"label":"Light", "x":17.25, "y":0},

{"label":"`~", "x":0, "y":1.25},
{"label":"1!", "x":1, "y":1.25},
{"label":"2@", "x":2, "y":1.25},
{"label":"3#", "x":3, "y":1.25},
{"label":"4$", "x":4, "y":1.25},
{"label":"5%", "x":5, "y":1.25},
{"label":"6^", "x":6, "y":1.25},
{"label":"7&", "x":7, "y":1.25},
{"label":"8*", "x":8, "y":1.25},
{"label":"9(", "x":9, "y":1.25},
{"label":"0)", "x":10, "y":1.25},
{"label":"-_", "x":11, "y":1.25},
{"label":"=+", "x":12, "y":1.25},
{"label":"Backspace", "x":13, "y":1.25, "w":2},
{"label":"Insert", "x":15.25, "y":1.25},
{"label":"Home", "x":16.25, "y":1.25},
{"label":"Page Up", "x":17.25, "y":1.25},

{"label":"Tab", "x":0, "y":2.25, "w":1.5},
{"label":"Q", "x":1.5, "y":2.25},
{"label":"W", "x":2.5, "y":2.25},
{"label":"E", "x":3.5, "y":2.25},
{"label":"R", "x":4.5, "y":2.25},
{"label":"T", "x":5.5, "y":2.25},
{"label":"Y", "x":6.5, "y":2.25},
{"label":"U", "x":7.5, "y":2.25},
{"label":"I", "x":8.5, "y":2.25},
{"label":"O", "x":9.5, "y":2.25},
{"label":"P", "x":10.5, "y":2.25},
{"label":"[{", "x":11.5, "y":2.25},
{"label":"]}", "x":12.5, "y":2.25},
{"label":"\\|", "x":13.5, "y":2.25, "w":1.5},
{"label":"Delete", "x":15.25, "y":2.25},
{"label":"End", "x":16.25, "y":2.25},
{"label":"Page Down", "x":17.25, "y":2.25},

{"label":"Caps Lock", "x":0, "y":3.25, "w":1.75},
{"label":"A", "x":1.75, "y":3.25},
{"label":"S", "x":2.75, "y":3.25},
{"label":"D", "x":3.75, "y":3.25},
{"label":"F", "x":4.75, "y":3.25},
{"label":"G", "x":5.75, "y":3.25},
{"label":"H", "x":6.75, "y":3.25},
{"label":"J", "x":7.75, "y":3.25},
{"label":"K", "x":8.75, "y":3.25},
{"label":"L", "x":9.75, "y":3.25},
{"label":";:", "x":10.75, "y":3.25},
{"label":"'\"", "x":11.75, "y":3.25},
{"label":"Enter", "x":12.75, "y":3.25, "w":2.25},

{"label":"Left Shift", "x":0, "y":4.25, "w":2.25},
{"label":"Z", "x":2.25, "y":4.25},
{"label":"X", "x":3.25, "y":4.25},
{"label":"C", "x":4.25, "y":4.25},
{"label":"V", "x":5.25, "y":4.25},
{"label":"B", "x":6.25, "y":4.25},
{"label":"N", "x":7.25, "y":4.25},
{"label":"M", "x":8.25, "y":4.25},
{"label":",<", "x":9.25, "y":4.25},
{"label":".>", "x":10.25, "y":4.25},
{"label":"/?", "x":11.25, "y":4.25},
{"label":"Right Shift", "x":12.25, "y":4.25, "w":2.75},
{"label":"Up", "x":16.25, "y":4.25},

{"label":"Left Ctrl", "x":0, "y":5.25, "w":1.25}
{"label":"Left Win", "x":1.25, "y":5.25, "w":1.25},
{"label":"Left Alt", "x":2.5, "y":5.25, "w":1.25},
{"label":"Space", "x":3.75, "y":5.25, "w":6.25},
{"label":"Right Alt", "x":10, "y":5.25, "w":1.25},
{"label":"Right Win", "x":11.25, "y":5.25, "w":1.25},
{"label":"Fn", "x":12.5, "y":5.25, "w":1.25},
{"label":"Right Ctrl", "x":13.75, "y":5.25, "w":1.25},
{"label":"Left", "x":15.25, "y":5.25},
{"label":"Down", "x":16.25, "y":5.25},
{"label":"Right", "x":17.25, "y":5.25}
]
}
}
}
161 changes: 161 additions & 0 deletions keyboards/keychron/q3/rev_0120_lhg/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
/* Copyright 2021 @ Keychron (https://www.keychron.com)
*
* 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 <http://www.gnu.org/licenses/>.
*/

#include QMK_KEYBOARD_H

enum layers{
MAC_BASE,
MAC_FN,
WIN_BASE,
WIN_FN
};

enum custom_keycodes {
KC_MISSION_CONTROL = SAFE_RANGE,
KC_LAUNCHPAD,
KC_LOPTN,
KC_ROPTN,
KC_LCMMD,
KC_RCMMD,
KC_SIRI,
KC_TASK_VIEW,
KC_FILE_EXPLORER,
KC_SCREEN_SHOT,
KC_CORTANA
};

#define KC_MCTL KC_MISSION_CONTROL
#define KC_LPAD KC_LAUNCHPAD
#define KC_TASK KC_TASK_VIEW
#define KC_FLXP KC_FILE_EXPLORER
#define KC_SNAP KC_SCREEN_SHOT
#define KC_CRTA KC_CORTANA

typedef struct PACKED {
uint8_t len;
uint8_t keycode[3];
} key_combination_t;

key_combination_t key_comb_list[4] = {
{2, {KC_LWIN, KC_TAB}},
{2, {KC_LWIN, KC_E}},
{3, {KC_LSFT, KC_LCMD, KC_4}},
{2, {KC_LWIN, KC_C}}
};

static uint8_t mac_keycode[4] = { KC_LOPT, KC_ROPT, KC_LCMD, KC_RCMD };

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[MAC_BASE] = LAYOUT_ansi_87(
KC_ESC, KC_BRID, KC_BRIU, KC_MCTL, KC_LPAD, RGB_VAD, RGB_VAI, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, KC_SNAP, KC_SIRI, 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_INS, KC_HOME, 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_DEL, KC_END, 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_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_LCTL, KC_LOPTN, KC_LCMMD, KC_SPC, KC_RCMMD, KC_ROPTN,MO(MAC_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),

[MAC_FN] = LAYOUT_ansi_87(
KC_TRNS, 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_TRNS, KC_TRNS, RGB_TOG,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
RGB_TOG, RGB_MOD, RGB_VAI, RGB_HUI, RGB_SAI, RGB_SPI, NK_TOGG, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, RGB_RMOD, RGB_VAD, RGB_HUD, RGB_SAD, RGB_SPD, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),

[WIN_BASE] = LAYOUT_ansi_87(
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_CRTA, 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_INS, KC_HOME, 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_DEL, KC_END, 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_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_LCTL, KC_LCMD, KC_LALT, KC_SPC, KC_RALT, KC_RWIN, MO(WIN_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),

[WIN_FN] = LAYOUT_ansi_87(
KC_TRNS, 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_TRNS, KC_TRNS, RGB_TOG,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
RGB_TOG, RGB_MOD, RGB_VAI, RGB_HUI, RGB_SAI, RGB_SPI, NK_TOGG, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, RGB_RMOD, RGB_VAD, RGB_HUD, RGB_SAD, RGB_SPD, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
};

uint16_t prev;
bool siri;

void matrix_scan_user(void) {
if (siri) {
if (timer_elapsed(prev) >= 500) {
siri = false;
unregister_code(KC_LCMD);
unregister_code(KC_SPACE);
}
}
}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case KC_MISSION_CONTROL:
if (record->event.pressed) {
host_consumer_send(0x29F);
} else {
host_consumer_send(0);
}
return false; // Skip all further processing of this key
case KC_LAUNCHPAD:
if (record->event.pressed) {
host_consumer_send(0x2A0);
} else {
host_consumer_send(0);
}
return false; // Skip all further processing of this key
case KC_LOPTN:
case KC_ROPTN:
case KC_LCMMD:
case KC_RCMMD:
if (record->event.pressed) {
register_code(mac_keycode[keycode - KC_LOPTN]);
} else {
unregister_code(mac_keycode[keycode - KC_LOPTN]);
}
return false; // Skip all further processing of this key
case KC_SIRI:
if (record->event.pressed) {
register_code(KC_LCMD);
register_code(KC_SPACE);
prev = timer_read() | 1;
siri = true;
} else {
// Do something else when release
}
return false; // Skip all further processing of this key
case KC_TASK:
case KC_FLXP:
case KC_SNAP:
case KC_CRTA:
if (record->event.pressed) {
for (uint8_t i = 0; i < key_comb_list[keycode - KC_TASK].len; i++) {
register_code(key_comb_list[keycode - KC_TASK].keycode[i]);
}
} else {
for (uint8_t i = 0; i < key_comb_list[keycode - KC_TASK].len; i++) {
unregister_code(key_comb_list[keycode - KC_TASK].keycode[i]);
}
}
return false; // Skip all further processing of this key
default:
return true; // Process all other keycodes normally
}
}
Loading

0 comments on commit 7b2c239

Please sign in to comment.