From 849fc327167a9a28f0b3d41a15c5301166785d11 Mon Sep 17 00:00:00 2001 From: sheldonmlee Date: Mon, 1 Nov 2021 18:51:55 +0800 Subject: [PATCH] Tweaked keymap and added stub so process_record_user() would work. --- keymap.c | 101 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 55 insertions(+), 46 deletions(-) diff --git a/keymap.c b/keymap.c index 264f762..c35b0c2 100755 --- a/keymap.c +++ b/keymap.c @@ -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