Last active
January 13, 2022 15:28
-
-
Save ksh3/9091cdd07f0498bde1ae834ae3eef4af to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Copyright 2012 Jun Wako <[email protected]> | |
| Copyright 2015 Jack Humbert | |
| 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 | |
| // Each layer gets a name for readability, which is then used in the keymap matrix below. | |
| // The underscores don't mean anything - you can have a layer called STUFF or any other name. | |
| // Layer names don't all need to be of the same length, obviously, and you can also skip them | |
| // entirely and just use numbers. | |
| enum layer_number { | |
| _QWERTY = 0, | |
| _RAISE, | |
| KC_OPSYM | |
| }; | |
| #define KC_ KC_TRNS | |
| #define KC_RST RESET | |
| #define RAISE_TAB LT(_RAISE, KC_TAB) | |
| #define LSFT_SPC LSFT_T(KC_SPC) | |
| #define RSFT_ENT RSFT_T(KC_ENT) | |
| #define CMD_JA RGUI_T(KC_LANG1) | |
| #define CMD_EN RGUI_T(KC_LANG2) | |
| #define CMD_DEL LGUI_T(KC_DEL) | |
| #define ALT_BS ALT_T(KC_BSPC) | |
| #define ALT_DEL ALT_T(KC_DEL) | |
| #define ALT_EN ALT_T(KC_LANG2) | |
| #define CTRL_ESC LCTL_T(KC_ESC) | |
| #define LA_SEL MEH(KC_LEFT) | |
| #define LA_SEL_AL SGUI(KC_LEFT) | |
| #define RA_SEL MEH(KC_RIGHT) | |
| #define RA_SEL_AL SGUI(KC_RIGHT) | |
| const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |
| // &| Q W E R T Y U I O P =+ | |
| // [{ A S D F G H J K L ;: '" | |
| // ]} Z X C V B N M ,< .> /? -_ | |
| [_QWERTY] = LAYOUT( \ | |
| //,--------+--------+---------+--------+---------+--------. ,--------+---------+--------+---------+--------+--------. | |
| KC_OPSYM, KC_Q , KC_W , KC_E , KC_R , KC_T , KC_Y , KC_U , KC_I , KC_O , KC_P , KC_EQL, | |
| //|--------+--------+---------+--------+---------+--------| |--------+---------+--------+---------+--------+--------| | |
| KC_LBRC , KC_A , KC_S , KC_D , KC_F , KC_G , KC_H , KC_J , KC_K , KC_L , KC_SCLN, KC_QUOT, | |
| //|--------+--------+---------+--------+---------+--------| |--------+---------+--------+---------+--------+--------| | |
| KC_RBRC, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_N , KC_M , KC_COMM, KC_DOT , KC_SLSH, KC_MINS, | |
| //`--------+--------+---------+--------+---------+--------/ \--------+---------+--------+---------+--------+--------' | |
| ALT_BS , CMD_DEL, LSFT_SPC, CTRL_ESC, RAISE_TAB, RSFT_ENT, CMD_JA, ALT_EN | |
| // `----------+--------+---------+--------' `--------+---------+--------+---------' | |
| ), | |
| // `~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) \| | |
| // BD BU VU VD LSA LS RS RSA ← ↓ ↑ → VU VD | |
| // F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 | |
| [_RAISE] = LAYOUT( \ | |
| //,--------+--------+--------+--------+--------+--------. ,--------+--------+--------+--------+--------+--------. | |
| KC_GRV, KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 , KC_BSLS, | |
| //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| | |
| KC_SLCK, KC_PAUS, LA_SEL_AL, LA_SEL, RA_SEL, RA_SEL_AL, KC_LEFT, KC_DOWN, KC_UP , KC_RGHT, KC__VOLDOWN, KC__VOLUP , | |
| //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| | |
| KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , KC_F12 , | |
| //`--------+--------+--------+--------+--------+--------/ \--------+--------+--------+--------+--------+--------' | |
| _______, _______, _______, _______, _______, _______, _______, _______ | |
| // `--------+--------+--------+--------' `--------+--------+--------+--------' | |
| ), | |
| }; | |
| void matrix_init_user(void) { | |
| //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h | |
| #ifdef SSD1306OLED | |
| iota_gfx_init(!has_usb()); // turns on the display | |
| #endif | |
| } | |
| //SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h | |
| #ifdef SSD1306OLED | |
| // When add source files to SRC in rules.mk, you can use functions. | |
| const char *read_layer_state(void); | |
| const char *read_logo(void); | |
| void set_keylog(uint16_t keycode, keyrecord_t *record); | |
| const char *read_keylog(void); | |
| const char *read_keylogs(void); | |
| // const char *read_mode_icon(bool swap); | |
| // const char *read_host_led_state(void); | |
| // void set_timelog(void); | |
| // const char *read_timelog(void); | |
| void matrix_scan_user(void) { | |
| iota_gfx_task(); | |
| } | |
| void matrix_render_user(struct CharacterMatrix *matrix) { | |
| if (is_master) { | |
| // If you want to change the display of OLED, you need to change here | |
| matrix_write_ln(matrix, read_layer_state()); | |
| matrix_write_ln(matrix, read_keylog()); | |
| matrix_write_ln(matrix, read_keylogs()); | |
| //matrix_write_ln(matrix, read_mode_icon(keymap_config.swap_lalt_lgui)); | |
| //matrix_write_ln(matrix, read_host_led_state()); | |
| //matrix_write_ln(matrix, read_timelog()); | |
| } else { | |
| matrix_write(matrix, read_logo()); | |
| } | |
| } | |
| void matrix_update(struct CharacterMatrix *dest, const struct CharacterMatrix *source) { | |
| if (memcmp(dest->display, source->display, sizeof(dest->display))) { | |
| memcpy(dest->display, source->display, sizeof(dest->display)); | |
| dest->dirty = true; | |
| } | |
| } | |
| void iota_gfx_task_user(void) { | |
| struct CharacterMatrix matrix; | |
| matrix_clear(&matrix); | |
| matrix_render_user(&matrix); | |
| matrix_update(&display, &matrix); | |
| } | |
| #endif//SSD1306OLED | |
| bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |
| static bool lshift_pressed= false; | |
| static bool rshift_pressed = false; | |
| static bool ctrl_pressed = false; | |
| if (record->event.pressed) { | |
| #ifdef SSD1306OLED | |
| set_keylog(keycode, record); | |
| #endif | |
| // set_timelog(); | |
| } | |
| switch (keycode) { | |
| case _QWERTY: | |
| if (record->event.pressed) { | |
| set_single_persistent_default_layer(_QWERTY); | |
| } | |
| return false; | |
| break; | |
| case _RAISE: | |
| if (record->event.pressed) { | |
| layer_on(_RAISE); | |
| } else { | |
| layer_off(_RAISE); | |
| } | |
| return false; | |
| break; | |
| case CTRL_ESC: | |
| ctrl_pressed = keyboard_report->mods & MOD_BIT(KC_LCTRL); | |
| if (record->event.pressed & !ctrl_pressed) { | |
| tap_code(KC_LANG2); | |
| return true; | |
| } | |
| break; | |
| case KC_OPSYM: | |
| lshift_pressed = keyboard_report->mods & MOD_BIT(KC_LSFT); | |
| rshift_pressed = keyboard_report->mods & MOD_BIT(KC_RSFT); | |
| if (record->event.pressed) { | |
| if (rshift_pressed || lshift_pressed) { | |
| tap_code(KC_BSLS); | |
| } else { | |
| register_code(KC_LSFT); | |
| tap_code(KC_7); | |
| unregister_code(KC_LSFT); | |
| } | |
| } | |
| return false; | |
| break; | |
| } | |
| return true; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment