Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
453b862
Personal keymap
bfayers Dec 14, 2023
fdc6490
Add tap dance for leftshift/caps
bfayers Dec 14, 2023
49af0c5
Add config + rules
bfayers Dec 14, 2023
3c01485
Add macros
bfayers Dec 14, 2023
e1765d8
Move macros/tap dance above the keymaps
bfayers Dec 14, 2023
52d6713
Ensure that rgb matrix is enabled
bfayers Dec 14, 2023
6826464
Add cmd+spc on capslock
bfayers Dec 14, 2023
bee4466
strip out redundant mac_keycode
bfayers Dec 14, 2023
432a153
strip out snap&cortana
bfayers Dec 14, 2023
144f633
strip out siri key
bfayers Dec 14, 2023
6c651b9
comments
bfayers Dec 14, 2023
d9edfef
Move RGB settings to info.json
bfayers Dec 14, 2023
0d77392
define default rgb animation
bfayers Dec 14, 2023
b1db330
create macro that fires differently on mac vs windows
bfayers Dec 14, 2023
3fb8433
remove factory_test.c from compile, as it interferes with defining di…
bfayers Dec 14, 2023
7beef47
Comments
bfayers Dec 14, 2023
86cbd6c
make sshot macro dynamic to OS switch
bfayers Dec 14, 2023
d06bd0b
default win_mac
bfayers Dec 14, 2023
3f019de
aligning base layers
bfayers Dec 14, 2023
5801230
Use a single base layer, and a special layer key to mix mac and windo…
bfayers Dec 14, 2023
8af793e
move KC_TASK and KC_FILE into keymap
bfayers Dec 14, 2023
1ccfb91
comments for keymap
bfayers Dec 14, 2023
66a0e39
actually make dynamic start hook send direction variable
bfayers Dec 15, 2023
15b9a72
Attempt at dynamic macro record indicators
bfayers Dec 15, 2023
5f94556
Whole keyboard flash on recording
bfayers Dec 15, 2023
78b26c8
remove attempts at dynamic macro recording indicator
bfayers Dec 15, 2023
4f3bf3a
turn on debug console
bfayers Dec 15, 2023
05b2926
enable custom rgb matrix effects
bfayers Dec 15, 2023
9e2e50e
create empty custom matrix effect
bfayers Dec 15, 2023
9c29a1c
Create function to blink dynamic macro key when recording
bfayers Dec 15, 2023
80d9059
Remove all debug prints
bfayers Dec 15, 2023
2a65939
disable debug console
bfayers Dec 15, 2023
a80fd5a
link where file was taken from
bfayers Dec 15, 2023
c80d192
move some macros (task,file) back to k2_pro.c/h to solve some issues
bfayers Dec 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion keyboards/keychron/bluetooth/bluetooth.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ SRC += \
$(BLUETOOTH_DIR)/lpm.c \
$(BLUETOOTH_DIR)/lpm_stm32l432.c \
$(BLUETOOTH_DIR)/battery.c \
$(BLUETOOTH_DIR)/factory_test.c \
$(BLUETOOTH_DIR)/bat_level_animation.c \
$(BLUETOOTH_DIR)/rtc_timer.c

Expand Down
18 changes: 1 addition & 17 deletions keyboards/keychron/k2_pro/iso/rgb/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,11 @@
"rgb_matrix": {
"driver": "CKLED2001",
"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
"splash": true
}
}
}
2 changes: 2 additions & 0 deletions keyboards/keychron/k2_pro/iso/rgb/keymaps/bfayers/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//Set default RGB mode to 'Splash'
#define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_SPLASH
167 changes: 167 additions & 0 deletions keyboards/keychron/k2_pro/iso/rgb/keymaps/bfayers/keymap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
/* Copyright 2022 @ 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

// clang-format off
// List of Layers
enum layers{
BASE,
MAC_FN,
WIN_FN
};

// Tap Dance Declarations
enum {
TD_LSHIFT_CAPS,
};

// Tap Dance Definitions
tap_dance_action_t tap_dance_actions[] = {
// Tap once for Escape, twice for Caps Lock
[TD_LSHIFT_CAPS] = ACTION_TAP_DANCE_DOUBLE(KC_LSFT, KC_CAPS),
};

// Macro Definitions
enum custom_keycodes {
SSHOT = SAFE_RANGE,
GUI_SPC,
OS_FN
};

// This will be true when the switch is set to windows, and false when the switch is set to mac.
bool on_windows = false;

bool dip_switch_update_user(uint8_t index, bool active) {
if (index == 0) {
on_windows = active;
}
return true;
}

// Macro Processing
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case SSHOT:
if (record->event.pressed) {
if (on_windows) {
SEND_STRING(SS_LGUI(SS_LSFT("S")));
} else {
SEND_STRING(SS_LCMD(SS_LOPT("8")));
}
return false;
}
break;
case GUI_SPC:
if (record->event.pressed) {
SEND_STRING(SS_LGUI(" "));
return false;
}
break;
case OS_FN:
if (record->event.pressed) {
layer_move(MAC_FN);
if (on_windows) {
//If we are on the windows side also enable the WIN_FN layer to mix them.
layer_on(WIN_FN);
}
} else {
//When we release the OS_FN key, move back to the BASE layer.
layer_move(BASE);
}
return false;
break;
}
return true;
}

bool dynamic_recording = false;
bool lit = false;
bool using_1 = true;
static uint16_t recording_timer;
// Dynamic Macro Hooks
void dynamic_macro_record_start_user(int8_t direction) {
//Switch to custom defined empty RGB effect
rgb_matrix_mode_noeeprom(RGB_MATRIX_CUSTOM_empty_effect);
//Turn off all keys
rgb_matrix_set_color_all(0,0,0);
dynamic_recording = true;
if (direction == 1) {
using_1 = true;
} else {
using_1 = false;
}
recording_timer = timer_read();
}
void dynamic_macro_record_end_user(int8_t direction) {
dynamic_recording = false;
//Restore previous RGB mode.
rgb_matrix_reload_from_eeprom();
}

bool rgb_matrix_indicators_user(void) {
if (dynamic_recording) {
if (lit) {
if (timer_elapsed(recording_timer) > 500) {
if (using_1) {
rgb_matrix_set_color(42, 0, 0, 0);
} else {
rgb_matrix_set_color(43, 0, 0, 0);
}
lit = false;
recording_timer = timer_read();
}
} else {
if (timer_elapsed(recording_timer) > 250) {
if (using_1) {
rgb_matrix_set_color(42, 255, 0, 0);
} else {
rgb_matrix_set_color(43, 255, 0, 0);
}
lit = true;
recording_timer = timer_read();
}
}
}
return true;
}

//Definition of layers
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[BASE] = LAYOUT_iso_85(
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, SSHOT, 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_ENT, KC_PGDN,
GUI_SPC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_BSLS, KC_HOME,
TD(TD_LSHIFT_CAPS), KC_INT1, 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, OS_FN, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),

[MAC_FN] = LAYOUT_iso_85(
KC_TRNS, 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_TRNS, KC_TRNS, RGB_TOG,
KC_TRNS, BT_HST1, BT_HST2, BT_HST3, 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, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, DM_REC1, DM_REC2, 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, DM_PLY1, DM_PLY2, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, BAT_LVL, NK_TOGG, 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_FN] = LAYOUT_iso_85(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TASK, KC_FILE, 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, 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, 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)
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
RGB_MATRIX_EFFECT(empty_effect)

#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS

// Taken from https://github.com/tcteo/qmk_firmware/blob/28487fb8695f5afdc9594514174ffe9635d4eec0/keyboards/kbdcraft/adam0110/keymaps/tcteo/rgb_matrix_user.inc
// https://github.com/qmk/qmk_firmware/issues/14686
// [Bug] Cannot control RGB Matrix manually, colors repeatedly overwritten with solid color under RGB_MATRIX_NONE mode #14686
// As a workaround, define a custom effect that does nothing, set it as the init default in keymap.c: rgb_matrix_mode_noeeprom(RGB_MATRIX_CUSTOM_empty_effect);
// When this effect is active, values written with rgb_matrix_set_color() aren't overwritten.

bool empty_effect(effect_params_t* params) {
return false;
}

#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
4 changes: 4 additions & 0 deletions keyboards/keychron/k2_pro/iso/rgb/keymaps/bfayers/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
TAP_DANCE_ENABLE = yes
DYNAMIC_MACRO_ENABLE = yes
# CONSOLE_ENABLE = yes
RGB_MATRIX_CUSTOM_USER = yes
43 changes: 9 additions & 34 deletions keyboards/keychron/k2_pro/k2_pro.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ typedef struct PACKED {

static uint32_t power_on_indicator_timer_buffer;
static uint32_t siri_timer_buffer = 0;
static uint8_t mac_keycode[4] = {KC_LOPT, KC_ROPT, KC_LCMD, KC_RCMD};

key_combination_t key_comb_list[4] = {
{2, {KC_LWIN, KC_TAB}}, // Task (win)
{2, {KC_LWIN, KC_E}}, // Files (win)
{3, {KC_LSFT, KC_LGUI, KC_4}}, // Snapshot (mac)
{2, {KC_LWIN, KC_C}} // Cortana (win)
};

#ifdef KC_BLUETOOTH_ENABLE
bool firstDisconnect = true;
Expand All @@ -59,9 +51,9 @@ static void pairing_key_timer_cb(void *arg) {
#endif

bool dip_switch_update_kb(uint8_t index, bool active) {
if (index == 0) {
/*if (index == 0) {
default_layer_set(1UL << (active ? 2 : 0));
}
}*/
dip_switch_update_user(index, active);

return true;
Expand All @@ -75,35 +67,18 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
static uint8_t host_idx = 0;

switch (keycode) {
case KC_LOPTN:
case KC_ROPTN:
case KC_LCMMD:
case KC_RCMMD:
case KC_TASK:
if (record->event.pressed) {
register_code(mac_keycode[keycode - KC_LOPTN]);
} else {
unregister_code(mac_keycode[keycode - KC_LOPTN]);
SEND_STRING(SS_LGUI(SS_TAP(X_TAB)));
return false;
}
return false; // Skip all further processing of this key)
case KC_TASK:
break;
case KC_FILE:
case KC_SNAP:
case KC_CTANA:
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
case KC_SIRI:
if (record->event.pressed && siri_timer_buffer == 0) {
register_code(KC_LGUI);
register_code(KC_SPACE);
siri_timer_buffer = sync_timer_read32() | 1;
SEND_STRING(SS_LGUI(SS_TAP(X_E)));
return false;
}
return false; // Skip all further processing of this key
break;
#ifdef KC_BLUETOOTH_ENABLE
case BT_HST1 ... BT_HST3:
if (get_transport() == TRANSPORT_BLUETOOTH) {
Expand Down
9 changes: 1 addition & 8 deletions keyboards/keychron/k2_pro/k2_pro.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,8 @@

// clang-format off
enum {
KC_LOPTN = USER_START,
KC_ROPTN,
KC_LCMMD,
KC_RCMMD,
KC_TASK,
KC_TASK = USER_START,
KC_FILE,
KC_SNAP,
KC_CTANA,
KC_SIRI,
#ifdef KC_BLUETOOTH_ENABLE
BT_HST1,
BT_HST2,
Expand Down
2 changes: 1 addition & 1 deletion keyboards/keychron/k2_pro/rules.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Enter lower-power sleep mode when on the ChibiOS idle thread
OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE
OPT_DEFS += -DNO_USB_STARTUP_CHECK -DENABLE_FACTORY_TEST
OPT_DEFS += -DNO_USB_STARTUP_CHECK

SRC += matrix.c

Expand Down
10 changes: 5 additions & 5 deletions quantum/process_keycode/process_dynamic_macro.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void dynamic_macro_led_blink(void) {

/* User hooks for Dynamic Macros */

__attribute__((weak)) void dynamic_macro_record_start_user(void) {
__attribute__((weak)) void dynamic_macro_record_start_user(int8_t direction) {
dynamic_macro_led_blink();
}

Expand Down Expand Up @@ -62,10 +62,10 @@ __attribute__((weak)) bool dynamic_macro_valid_key_user(uint16_t keycode, keyrec
* @param[out] macro_pointer The new macro buffer iterator.
* @param[in] macro_buffer The macro buffer used to initialize macro_pointer.
*/
void dynamic_macro_record_start(keyrecord_t **macro_pointer, keyrecord_t *macro_buffer) {
void dynamic_macro_record_start(keyrecord_t **macro_pointer, keyrecord_t *macro_buffer, int8_t direction) {
dprintln("dynamic macro recording: started");

dynamic_macro_record_start_user();
dynamic_macro_record_start_user(direction);

clear_keyboard();
layer_clear();
Expand Down Expand Up @@ -213,11 +213,11 @@ bool process_dynamic_macro(uint16_t keycode, keyrecord_t *record) {
if (!record->event.pressed) {
switch (keycode) {
case QK_DYNAMIC_MACRO_RECORD_START_1:
dynamic_macro_record_start(&macro_pointer, macro_buffer);
dynamic_macro_record_start(&macro_pointer, macro_buffer, +1);
macro_id = 1;
return false;
case QK_DYNAMIC_MACRO_RECORD_START_2:
dynamic_macro_record_start(&macro_pointer, r_macro_buffer);
dynamic_macro_record_start(&macro_pointer, r_macro_buffer, -1);
macro_id = 2;
return false;
case QK_DYNAMIC_MACRO_PLAY_1:
Expand Down
2 changes: 1 addition & 1 deletion quantum/process_keycode/process_dynamic_macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

void dynamic_macro_led_blink(void);
bool process_dynamic_macro(uint16_t keycode, keyrecord_t *record);
void dynamic_macro_record_start_user(void);
void dynamic_macro_record_start_user(int8_t direction);
void dynamic_macro_play_user(int8_t direction);
void dynamic_macro_record_key_user(int8_t direction, keyrecord_t *record);
void dynamic_macro_record_end_user(int8_t direction);