diff options
Diffstat (limited to 'keyboards/0xcb/static/keymaps/via/keymap.c')
| -rw-r--r-- | keyboards/0xcb/static/keymaps/via/keymap.c | 197 |
1 files changed, 197 insertions, 0 deletions
diff --git a/keyboards/0xcb/static/keymaps/via/keymap.c b/keyboards/0xcb/static/keymaps/via/keymap.c new file mode 100644 index 000000000..c860c941d --- /dev/null +++ b/keyboards/0xcb/static/keymaps/via/keymap.c | |||
| @@ -0,0 +1,197 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2021 0xCB - Conor Burns | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | #include QMK_KEYBOARD_H | ||
| 18 | // clang-format off | ||
| 19 | enum layer_names { | ||
| 20 | _HOME, | ||
| 21 | _FN2, | ||
| 22 | _FN3, | ||
| 23 | _FN4 | ||
| 24 | }; | ||
| 25 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 26 | [_HOME] = LAYOUT( | ||
| 27 | KC_MPLY, | ||
| 28 | KC_GESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, | ||
| 29 | KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_ENT, | ||
| 30 | KC_LSPO, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_RSPC, | ||
| 31 | KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC, KC_SPC, KC_RALT, MO(1), MO(2) | ||
| 32 | ), | ||
| 33 | [_FN2] = LAYOUT( | ||
| 34 | RESET, | ||
| 35 | KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, | ||
| 36 | KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, _______, | ||
| 37 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 38 | _______, _______, _______, _______, _______, _______, _______, _______, _______ | ||
| 39 | ), | ||
| 40 | [_FN3] = LAYOUT( | ||
| 41 | EEP_RST, | ||
| 42 | _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_LBRC, KC_RBRC, KC_BSLS, | ||
| 43 | _______, _______, _______, _______, _______, _______, _______, _______, KC_SCLN, KC_QUOT, _______, | ||
| 44 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_SLSH, | ||
| 45 | _______, _______, _______, _______, _______, _______, _______, _______, _______ | ||
| 46 | ), | ||
| 47 | [_FN4] = LAYOUT( | ||
| 48 | _______, | ||
| 49 | _______, KC_MUTE, KC_VOLD, KC_VOLU, KC_MPRV, KC_MNXT, KC_MSTP, KC_INS, KC_HOME, KC_DEL, KC_END, _______, | ||
| 50 | _______, _______, KC_BRID, KC_BRIU, _______, _______, _______, KC_PGUP, KC_UP, KC_PGDN, _______, | ||
| 51 | _______, _______, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, | ||
| 52 | _______, _______, _______, _______, _______, _______, _______, _______, _______ | ||
| 53 | ), | ||
| 54 | }; | ||
| 55 | // clang-format on | ||
| 56 | |||
| 57 | /*layer switcher */ | ||
| 58 | layer_state_t layer_state_set_user(layer_state_t state) { | ||
| 59 | state = update_tri_layer_state(state, _FN2, _FN3, _FN4); | ||
| 60 | return state; | ||
| 61 | } | ||
| 62 | /* rotary encoder (MX12) - add different functions for layers here */ | ||
| 63 | #ifdef ENCODER_ENABLE | ||
| 64 | bool encoder_update_user(uint8_t index, bool clockwise) { | ||
| 65 | if (IS_LAYER_ON(_FN4)) { | ||
| 66 | if (clockwise) { | ||
| 67 | tap_code(KC_VOLU); | ||
| 68 | } else { | ||
| 69 | tap_code(KC_VOLD); | ||
| 70 | } | ||
| 71 | } else if (IS_LAYER_ON(_FN3)) { | ||
| 72 | if (clockwise) { | ||
| 73 | tap_code(KC_VOLU); | ||
| 74 | } else { | ||
| 75 | tap_code(KC_VOLD); | ||
| 76 | } | ||
| 77 | } else if (IS_LAYER_ON(_FN2)) { | ||
| 78 | if (clockwise) { | ||
| 79 | tap_code(KC_VOLU); | ||
| 80 | } else { | ||
| 81 | tap_code(KC_VOLD); | ||
| 82 | } | ||
| 83 | } else { | ||
| 84 | if (clockwise) { | ||
| 85 | tap_code(KC_VOLU); | ||
| 86 | } else { | ||
| 87 | tap_code(KC_VOLD); | ||
| 88 | } | ||
| 89 | } | ||
| 90 | return true; | ||
| 91 | } | ||
| 92 | #endif | ||
| 93 | |||
| 94 | /* oled stuff :) */ | ||
| 95 | #ifdef OLED_DRIVER_ENABLE | ||
| 96 | uint16_t startup_timer = 0; | ||
| 97 | |||
| 98 | oled_rotation_t oled_init_user(oled_rotation_t rotation) { | ||
| 99 | startup_timer = timer_read(); | ||
| 100 | return rotation; | ||
| 101 | } | ||
| 102 | static void render_logo(void) { | ||
| 103 | static const char PROGMEM raw_logo[] = { | ||
| 104 | 0, 8, 0,192,194,192,192, 60, 60, 44, 60,188, 60, 60, 60, 60, 44, 61, 60,192,192,192,208, 1, 0,252,252,180,252, 60, 60, 44, 60,252,253,252,252, 60, 60, 44, 60,244,220,252,252, 0, 0, 16, 0, 0, 0,192,192, 65,192, 60, 60, 52, 60,192,193,192,192, 16, 0, 0,144, 4, 0,252,125,244, 60, 60, 60, 60, 61,252,252,244,252, 60, 60, 60, 61,248,108,252, 0, 0, 61, 60,188, 60, 52,252,252,220,252, 61, 60, 60, 52, 0, 0,192,210, 64,192, 60, 60, 44, 61, 60, 60, 60, 61, 52, 60, 60, 60,192,192, 64,196, 0, 4, 0, | ||
| 105 | 0, 16, 0, 61, 63, 55, 63,192, 64,192,196,192,192,192,200,192,196,192,192, 3, 3, 2, 11, 0, 0, 35, 3, 3, 3, 0, 64, 2, 0,255,255,253,247, 0, 0, 0, 32, 1, 0, 1, 65, 8, 0,189,244,252,236, 3,130, 3, 1, 0, 68, 0, 0, 3, 34,131, 3,252,252,236,252, 0, 32, 17, 1, 1, 0, 0, 32, 0, 2,255,255,127,247, 0, 1, 0, 8, 1, 1, 1, 0, 0, 0, 16, 0, 64, 0,255,191,255,251, 0,129, 0, 2, 32, 0,255,255,239,255, 0, 0, 2, 0, 0, 0, 8, 64, 0, 1, 0, 0, 3, 35, 3, 3, 0, 8, 0, | ||
| 106 | 1, 16, 0,192, 64,194,192, 3, 67, 3, 3, 9, 3, 3, 3, 3, 2, 83, 3,252,252,188,244, 0, 2, 32, 0, 0, 2, 0,144, 0, 0,255,255,237,255, 0, 16, 0, 0, 0, 64, 2, 0,128, 0,255,123,255,255, 60, 52, 60, 60, 60, 60, 60, 60, 44, 60, 56, 60,239,255,126,255, 0, 2, 32, 0, 0, 34, 0, 0, 16, 0,255,255,255,223, 0, 0, 4, 0, 0, 0, 33, 0, 0, 17, 0, 0, 0, 0,255,255,239,255, 0,128, 0, 0, 72, 0,255,253,247,255, 0, 0, 1, 0,144, 0, 4, 0, 32, 0, 0, 2,192,192,192,200, 0, 16, 0, | ||
| 107 | 64, 4, 0, 3, 7, 3, 3, 60, 60, 52,188, 60, 61, 60, 60, 60, 60, 44, 60, 67, 3, 3, 3, 0, 0, 64, 0, 0, 4, 0, 0, 16, 0, 47, 63, 62, 63, 0, 0,132, 0, 0, 0, 0,128, 8, 0,255,255,111,127, 0, 0, 0, 2,128, 0, 0, 0, 64, 4, 0,128,127,127,107,127, 0, 32, 0, 0, 0, 66, 0, 0, 0,136, 55, 63, 61, 63, 0, 0, 0, 2, 0, 64, 0,136, 0, 0, 60, 44,189, 60, 63, 63, 63, 59, 60, 60,172, 60, 0, 64, 3, 2, 3,131, 60, 44, 60, 60, 60, 60,188, 60, 56, 44, 60, 60, 3, 3,131, 2, 0, 32, 2, | ||
| 108 | }; | ||
| 109 | oled_write_raw_P(raw_logo, sizeof(raw_logo)); | ||
| 110 | } | ||
| 111 | /* Shows the name of the current layer and locks for the host (CAPS etc.) */ | ||
| 112 | static void render_layer(void) { | ||
| 113 | led_t led_state = host_keyboard_led_state(); | ||
| 114 | // clang-format off | ||
| 115 | static const char PROGMEM logo[][3][7] = { | ||
| 116 | {{0x97, 0x98, 0x99, 0x9A, 0}, {0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0}, {0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0}}, /* l num CB */ | ||
| 117 | {{0xB7, 0xB8, 0xB9, 0xBA, 0}, {0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0}, {0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0}}, /* 1 num CB */ | ||
| 118 | {{0xD7, 0xD8, 0xD9, 0xDA, 0}, {0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0}, {0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0}}, /* 1 cap CB */ | ||
| 119 | {{0xF7, 0xF8, 0xF9, 0xFA, 0}, {0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0}, {0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0}}, /* l cap CB */ | ||
| 120 | {{0xB7, 0xC0, 0xC1, 0xBA, 0}, {0xB7, 0xC2, 0xC3, 0xBA, 0}, {0xB7, 0xC4, 0xC5, 0xBA, 0}}, /* 2 3 4 */ | ||
| 121 | {{0xD7, 0xE0, 0xE1, 0xDA, 0}, {0xD7, 0xE2, 0xE3, 0xDA, 0}, {0xD7, 0xE4, 0xE5, 0xDA, 0}}, /* 2 3 4 */ | ||
| 122 | }; | ||
| 123 | // clang-format on | ||
| 124 | oled_set_cursor(0, 0); | ||
| 125 | oled_write_P(logo[0][0], false); | ||
| 126 | oled_set_cursor(0, 3); | ||
| 127 | oled_write_P(logo[3][0], false); | ||
| 128 | switch (get_highest_layer(layer_state)) { | ||
| 129 | case _HOME: | ||
| 130 | oled_set_cursor(0, 1); | ||
| 131 | oled_write_P(logo[1][0], false); | ||
| 132 | oled_set_cursor(0, 2); | ||
| 133 | oled_write_P(logo[2][0], false); | ||
| 134 | break; | ||
| 135 | case _FN2: | ||
| 136 | oled_set_cursor(0, 1); | ||
| 137 | oled_write_P(logo[4][0], false); | ||
| 138 | oled_set_cursor(0, 2); | ||
| 139 | oled_write_P(logo[5][0], false); | ||
| 140 | break; | ||
| 141 | case _FN3: | ||
| 142 | oled_set_cursor(0, 1); | ||
| 143 | oled_write_P(logo[4][1], false); | ||
| 144 | oled_set_cursor(0, 2); | ||
| 145 | oled_write_P(logo[5][1], false); | ||
| 146 | break; | ||
| 147 | case _FN4: | ||
| 148 | oled_set_cursor(0, 1); | ||
| 149 | oled_write_P(logo[4][2], false); | ||
| 150 | oled_set_cursor(0, 2); | ||
| 151 | oled_write_P(logo[5][2], false); | ||
| 152 | break; | ||
| 153 | default: | ||
| 154 | oled_set_cursor(0, 1); | ||
| 155 | oled_write_P(PSTR(" "), false); | ||
| 156 | oled_set_cursor(0, 2); | ||
| 157 | oled_write_P(PSTR(" "), false); | ||
| 158 | } | ||
| 159 | oled_set_cursor(8, 0); | ||
| 160 | oled_write_P(led_state.num_lock ? logo[0][1] : PSTR(" "), false); | ||
| 161 | oled_set_cursor(8, 1); | ||
| 162 | oled_write_P(led_state.num_lock ? logo[1][1] : PSTR(" "), false); | ||
| 163 | oled_set_cursor(8, 2); | ||
| 164 | oled_write_P(led_state.caps_lock ? logo[2][1] : PSTR(" "), false); | ||
| 165 | oled_set_cursor(8, 3); | ||
| 166 | oled_write_P(led_state.caps_lock ? logo[3][1] : PSTR(" "), false); | ||
| 167 | |||
| 168 | oled_set_cursor(16, 0); | ||
| 169 | oled_write_P(logo[0][2], false); | ||
| 170 | oled_set_cursor(16, 1); | ||
| 171 | oled_write_P(logo[1][2], false); | ||
| 172 | oled_set_cursor(16, 2); | ||
| 173 | oled_write_P(logo[2][2], false); | ||
| 174 | oled_set_cursor(16, 3); | ||
| 175 | oled_write_P(logo[3][2], false); | ||
| 176 | } | ||
| 177 | |||
| 178 | void oled_task_user(void) { | ||
| 179 | static bool finished_timer = false; | ||
| 180 | if (!finished_timer && (timer_elapsed(startup_timer) < 3000)) { | ||
| 181 | render_logo(); | ||
| 182 | } else { | ||
| 183 | if (!finished_timer) { | ||
| 184 | oled_clear(); | ||
| 185 | finished_timer = true; | ||
| 186 | } | ||
| 187 | render_layer(); | ||
| 188 | } | ||
| 189 | } | ||
| 190 | #endif | ||
| 191 | |||
| 192 | /* Resets via on eep reset - thank you drashna! */ | ||
| 193 | void eeconfig_init_kb(void) { | ||
| 194 | via_eeprom_set_valid(false); | ||
| 195 | via_init(); | ||
| 196 | eeconfig_init_user(); | ||
| 197 | } | ||
