Tweaked keymap and added stub so process_record_user() would work.

This commit is contained in:
sheldonmlee 2021-11-01 18:51:55 +08:00
parent 775533c47f
commit 849fc32716

101
keymap.c
View File

@ -110,7 +110,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
_______, KC_UNDS, KC_LBRC, KC_LCBR, KC_LPRN,KC_MINUS, KC_PLUS, KC_RPRN, KC_RCBR, KC_RBRC, KC_EQL, _______,
//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
_______, KC_PIPE, OS_CTRL, OS_ALT, OS_GUI, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_BSLS, _______,
_______, KC_PIPE, OS_CTRL, OS_ALT, OS_SHFT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_BSLS, _______,
//|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
_______, _______, _______, MO(L3), _______, _______
//`--------------------------' `--------------------------'
@ -126,7 +126,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
_______, KC_CAPS, KC_HOME, KC_PGUP, KC_PGDN, KC_END, KC_LEFT, KC_DOWN, KC_UP,KC_RIGHT, XXXXXXX, KC_ENT,
//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
_______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_INS, XXXXXXX, OS_GUI, OS_ALT, OS_CTRL, XXXXXXX, _______,
_______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_INS, XXXXXXX, OS_SHFT, OS_ALT, OS_CTRL, XXXXXXX, _______,
//|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
_______, _______, MO(L3), _______, _______, _______
//`--------------------------' `--------------------------'
@ -138,7 +138,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
XXXXXXX, DL_COLE, DL_QWER, DL_GAME, XXXXXXX, KC_F11, KC_F12, KC_PSCR, KC_SLCK, KC_PAUS, XXXXXXX, XXXXXXX,
//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
XXXXXXX, XXXXXXX, OS_CTRL, OS_ALT, OS_GUI, XXXXXXX, XXXXXXX, OS_GUI, OS_ALT, OS_CTRL, XXXXXXX, XXXXXXX,
XXXXXXX, XXXXXXX, OS_CTRL, OS_ALT, OS_SHFT, XXXXXXX, XXXXXXX,OS_SHFT, OS_ALT, OS_CTRL, XXXXXXX, XXXXXXX,
//|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
_______, _______, _______, _______, _______, _______
//`--------------------------' `--------------------------'
@ -177,6 +177,54 @@ oneshot_state os_ctrl_state = os_up_unqueued;
oneshot_state os_alt_state = os_up_unqueued;
oneshot_state os_cmd_state = os_up_unqueued;
// function prototype
void set_keylog(uint16_t keycode, keyrecord_t *record);
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
update_oneshot(
&os_shft_state, KC_LSFT, OS_SHFT,
keycode, record
);
update_oneshot(
&os_ctrl_state, KC_LCTL, OS_CTRL,
keycode, record
);
update_oneshot(
&os_alt_state, KC_LALT, OS_ALT,
keycode, record
);
update_oneshot(
&os_cmd_state, KC_LGUI, OS_GUI,
keycode, record
);
switch (keycode) {
case DL_COLE:
if (record->event.pressed) {
set_single_persistent_default_layer(COLE);
}
return false;
break;
case DL_QWER:
if (record->event.pressed) {
set_single_persistent_default_layer(QWER);
}
return false;
break;
case DL_GAME:
if (record->event.pressed) {
set_single_persistent_default_layer(G0);
}
return false;
break;
default:
if (record->event.pressed) {
set_keylog(keycode, record); // This is calles a stub unless OLED_DRIVER_ENABLE is true
}
return true;
}
}
#ifdef OLED_DRIVER_ENABLE
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
if (!is_master) {
@ -272,49 +320,10 @@ void oled_task_user(void) {
oled_render_logo();
}
}
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
update_oneshot(
&os_shft_state, KC_LSFT, OS_SHFT,
keycode, record
);
update_oneshot(
&os_ctrl_state, KC_LCTL, OS_CTRL,
keycode, record
);
update_oneshot(
&os_alt_state, KC_LALT, OS_ALT,
keycode, record
);
update_oneshot(
&os_cmd_state, KC_LGUI, OS_GUI,
keycode, record
);
switch (keycode) {
case DL_COLE:
if (record->event.pressed) {
set_single_persistent_default_layer(COLE);
}
return false;
break;
case DL_QWER:
if (record->event.pressed) {
set_single_persistent_default_layer(QWER);
}
return false;
break;
case DL_GAME:
if (record->event.pressed) {
set_single_persistent_default_layer(G0);
}
return false;
break;
default:
if (record->event.pressed) {
set_keylog(keycode, record);
}
return true;
}
#else
// stub so process_record_user() works without enabling OLED_DRIVER_ENABLE
void set_keylog(uint16_t keycode, keyrecord_t *record) {
return;
}
#endif // OLED_DRIVER_ENABLE