diff options
Diffstat (limited to 'keyboards/lily58/keymaps/druotoni/keymap.c')
| -rw-r--r-- | keyboards/lily58/keymaps/druotoni/keymap.c | 253 |
1 files changed, 253 insertions, 0 deletions
diff --git a/keyboards/lily58/keymaps/druotoni/keymap.c b/keyboards/lily58/keymaps/druotoni/keymap.c new file mode 100644 index 000000000..2db32047e --- /dev/null +++ b/keyboards/lily58/keymaps/druotoni/keymap.c | |||
| @@ -0,0 +1,253 @@ | |||
| 1 | // Copyright 2021 Nicolas Druoton (druotoni) | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include QMK_KEYBOARD_H | ||
| 5 | #include "keymap_french.h" | ||
| 6 | #include "transactions.h" | ||
| 7 | |||
| 8 | // global | ||
| 9 | #include "gui_state.h" | ||
| 10 | #include "boot.h" | ||
| 11 | #include "navi_logo.h" | ||
| 12 | |||
| 13 | #include "draw_helper.h" | ||
| 14 | #include "fast_random.h" | ||
| 15 | |||
| 16 | // left side | ||
| 17 | #include "layer_frame.h" | ||
| 18 | #include "burst.h" | ||
| 19 | |||
| 20 | // right side | ||
| 21 | #include "ring.h" | ||
| 22 | |||
| 23 | // clang-format off | ||
| 24 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 25 | /* QWERTY | ||
| 26 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 27 | * | ESC | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | DEL | | ||
| 28 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 29 | * | Tab | Q | W | E | R | T | | Y | U | I | O | P | ^ | | ||
| 30 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 31 | * |LShift| A | S | D | F | G |-------. ,-------| H | J | K | L | ; |RShift| | ||
| 32 | * |------+------+------+------+------+------| " | | ) |------+------+------+------+------+------| | ||
| 33 | * |LCTRL | Z | X | C | V | B |-------| |-------| N | M | , | . | / | $ | | ||
| 34 | * `-----------------------------------------/ / \ \-----------------------------------------' | ||
| 35 | * | LAlt | SPE | Space| / NAV / \Enter \ |BackSP| ] | RGUI | | ||
| 36 | * | | | |/ / \ \ | | | | | ||
| 37 | * `----------------------------' '------''--------------------' | ||
| 38 | */ | ||
| 39 | [_QWERTY] = LAYOUT( | ||
| 40 | KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DELETE, | ||
| 41 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, FR_CIRC, | ||
| 42 | KC_LSFT, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_RSFT, | ||
| 43 | KC_LCTRL, KC_Z, KC_X, KC_C, KC_V, KC_B, S(KC_Z), FR_RPRN, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_QUOT, | ||
| 44 | KC_LALT, TT(_RAISE), KC_SPC, TT(_LOWER), KC_ENT, KC_BSPC, KC_RBRC, KC_RGUI | ||
| 45 | ), | ||
| 46 | |||
| 47 | /* LOWER | ||
| 48 | * ,---------------------------------------------. ,------------------------------------------------. | ||
| 49 | * | ESC | F1 | F2 | F3 | F4 | F5 | | F6 | F7 | F8 | F9 | F10 | DEL | | ||
| 50 | * |------+-------+-------+------+-------+-------| |--------+--------+--------+-------+------+------| | ||
| 51 | * | RST | F11 | F12 | DEL | paste | copy | | home | pg up | print | redo | w | | | ||
| 52 | * |------+-------+-------+------+-------+-------| |--------+--------+--------+-------+------+------| | ||
| 53 | * | | all | | SAV | undo | BackSP|-------. ,-------| left | down | up | right | | | | ||
| 54 | * |------+-------+-------+------+-------+-------| enter| | |--------+--------+--------+-------+------+------| | ||
| 55 | * | F9 | F11 | F10 | F5 | TAB | cut |-------| |-------| end | pg dw | | | | | | ||
| 56 | * `---------------------------------------------/ / \ \-----------------------------------------------' | ||
| 57 | * | | SPE | | / / \ \ | | MENU | | | ||
| 58 | * | | | |/ / \ \ | | | | | ||
| 59 | * `--------------------------------' '-------''--------------------' | ||
| 60 | */ | ||
| 61 | [_LOWER] = LAYOUT( | ||
| 62 | KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_DELETE, | ||
| 63 | RESET, KC_F11, KC_F12, KC_DELETE, RCTL(FR_V), RCTL(FR_C), KC_HOME, KC_PGUP, KC_PSCR, RCTL(FR_Y), RCTL(KC_RIGHT), _______, | ||
| 64 | _______,RCTL(FR_A), _______,RCTL(FR_S), RCTL(FR_Z), KC_BSPC, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, _______, _______, | ||
| 65 | KC_F9, KC_F11, KC_F10, KC_F5, LALT(KC_TAB), RCTL(FR_X), KC_ENT, _______, KC_END, KC_PGDN, _______, _______, _______, _______, | ||
| 66 | _______,TT(_RAISE), _______, _______, _______, _______, KC_APP, _______), | ||
| 67 | |||
| 68 | /* RAISE | ||
| 69 | * ,-----------------------------------------. ,-------------------------------------------. | ||
| 70 | * | | | | | | | | | | / | * | - | RGB TOG| | ||
| 71 | * |------+------+------+------+------+------| |------+------+------+------+-----+--------| | ||
| 72 | * | ` | [ | ] | | | | | ^ | 7 | 8 | 9 | + | RGB HUI| | ||
| 73 | * |------+------+------+------+------+------| |------+------+------+------+-----+--------| | ||
| 74 | * | | @ | | | & | € | # |-------. ,-------| $ | 4 | 5 | 6 | | | | ||
| 75 | * |------+------+------+------+------+------| | | |------+------+------+------+-----+--------| | ||
| 76 | * | F7 | F8 | F9 | F10 | # | F12 |-------| |-------| | 1 | 2 | 3 | | | | ||
| 77 | * `-----------------------------------------/ / \ \------------------------------------------' | ||
| 78 | * | | | | / / \ \ | | 0 | . | | ||
| 79 | * | | | |/ / \ \ | | | | | ||
| 80 | * `----------------------------' '------''---------------------' | ||
| 81 | */ | ||
| 82 | [_RAISE] = LAYOUT( | ||
| 83 | _______, _______, _______, _______, _______, _______, _______, _______, KC_PSLS, KC_PAST, KC_PMNS, RGB_TOG, | ||
| 84 | KC_GRV, FR_LBRC, FR_RBRC, _______, _______, _______, FR_EQL, KC_KP_7, KC_KP_8, KC_KP_9, KC_PPLS, RGB_HUI, | ||
| 85 | _______, FR_AT, FR_PIPE, ALGR(KC_1), FR_EURO, FR_HASH, S(FR_EQL), KC_KP_4, KC_KP_5, KC_KP_6, _______, _______, | ||
| 86 | KC_F7, KC_F8, KC_F9, KC_F10, FR_HASH, KC_F12, _______, _______, _______, KC_KP_1, KC_KP_2, KC_KP_3, _______, _______, | ||
| 87 | _______, _______, _______, _______, _______, _______, KC_KP_0, KC_KP_DOT) | ||
| 88 | }; | ||
| 89 | // clang-format on | ||
| 90 | |||
| 91 | // sync transport | ||
| 92 | typedef struct _sync_keycode_t { | ||
| 93 | uint16_t keycode; | ||
| 94 | } sync_keycode_t; | ||
| 95 | |||
| 96 | // force rigth side to update | ||
| 97 | bool b_sync_need_send = false; | ||
| 98 | |||
| 99 | // last keycode typed | ||
| 100 | sync_keycode_t last_keycode; | ||
| 101 | |||
| 102 | oled_rotation_t oled_init_user(oled_rotation_t rotation) { | ||
| 103 | // vertical orientation | ||
| 104 | return OLED_ROTATION_270; | ||
| 105 | } | ||
| 106 | |||
| 107 | void render(gui_state_t t) { | ||
| 108 | // logo | ||
| 109 | render_logo(t); | ||
| 110 | |||
| 111 | #if IS_LEFT | ||
| 112 | // left side | ||
| 113 | render_layer_frame(t); | ||
| 114 | render_gears(); | ||
| 115 | |||
| 116 | decay_scope(); | ||
| 117 | render_scope(t); | ||
| 118 | #endif | ||
| 119 | |||
| 120 | #if IS_RIGHT | ||
| 121 | // right side | ||
| 122 | render_circle(t); | ||
| 123 | #endif | ||
| 124 | } | ||
| 125 | |||
| 126 | void update(uint16_t keycode) { | ||
| 127 | #if IS_LEFT | ||
| 128 | update_scope(); | ||
| 129 | #endif | ||
| 130 | |||
| 131 | #if IS_RIGHT | ||
| 132 | update_circle(keycode); | ||
| 133 | #endif | ||
| 134 | } | ||
| 135 | |||
| 136 | void reset(void) { | ||
| 137 | #if IS_LEFT | ||
| 138 | reset_scope(); | ||
| 139 | #endif | ||
| 140 | |||
| 141 | #if IS_RIGHT | ||
| 142 | reset_ring(); | ||
| 143 | #endif | ||
| 144 | } | ||
| 145 | |||
| 146 | void set_wackingup_mode_clean(void) { | ||
| 147 | oled_clear(); | ||
| 148 | reset(); | ||
| 149 | } | ||
| 150 | |||
| 151 | bool oled_task_user(void) { | ||
| 152 | gui_state_t t = get_gui_state(); | ||
| 153 | |||
| 154 | // in sleep mode => turn display off | ||
| 155 | if (t == _SLEEP) { | ||
| 156 | oled_off(); | ||
| 157 | return false; | ||
| 158 | } | ||
| 159 | |||
| 160 | // not in sleep mode => screen is on | ||
| 161 | oled_on(); | ||
| 162 | |||
| 163 | #ifdef WITH_BOOT | ||
| 164 | // in booting mode => display booting animation | ||
| 165 | if (t == _BOOTING) { | ||
| 166 | bool boot_finished = render_boot(); | ||
| 167 | if (boot_finished) { | ||
| 168 | // end of the boot : wacking up | ||
| 169 | set_wackingup_mode_clean(); | ||
| 170 | update_gui_state(); | ||
| 171 | } | ||
| 172 | return false; | ||
| 173 | } | ||
| 174 | #endif | ||
| 175 | |||
| 176 | // in halting mode => display booting animation | ||
| 177 | if (t == _HALTING) { | ||
| 178 | render_halt(); | ||
| 179 | return false; | ||
| 180 | } | ||
| 181 | |||
| 182 | render(t); | ||
| 183 | return false; | ||
| 184 | } | ||
| 185 | |||
| 186 | void process_key(uint16_t keycode) { | ||
| 187 | // update screen with the new key | ||
| 188 | update(keycode); | ||
| 189 | |||
| 190 | gui_state_t t = get_gui_state(); | ||
| 191 | |||
| 192 | if (t == _IDLE) { | ||
| 193 | // wake up animation | ||
| 194 | reset(); | ||
| 195 | } | ||
| 196 | |||
| 197 | if (t == _BOOTING || t == _HALTING) { | ||
| 198 | // cancel booting or halting : waking_up | ||
| 199 | set_wackingup_mode_clean(); | ||
| 200 | } | ||
| 201 | |||
| 202 | if (t == _SLEEP) { | ||
| 203 | // boot sequence | ||
| 204 | set_wackingup_mode_clean(); | ||
| 205 | reset_boot(); | ||
| 206 | } | ||
| 207 | |||
| 208 | update_gui_state(); | ||
| 209 | } | ||
| 210 | |||
| 211 | void user_sync_a_slave_handler(uint8_t in_buflen, const void* in_data, uint8_t out_buflen, void* out_data) { | ||
| 212 | const sync_keycode_t* m2s = (const sync_keycode_t*)in_data; | ||
| 213 | // get the last char typed on left side and update the right side | ||
| 214 | process_key(m2s->keycode); | ||
| 215 | } | ||
| 216 | |||
| 217 | void keyboard_post_init_user(void) { | ||
| 218 | // callback for tranport sync data | ||
| 219 | transaction_register_rpc(USER_SYNC_A, user_sync_a_slave_handler); | ||
| 220 | } | ||
| 221 | |||
| 222 | void housekeeping_task_user(void) { | ||
| 223 | // only for master side | ||
| 224 | if (!is_keyboard_master()) return; | ||
| 225 | |||
| 226 | // only if a new char was typed | ||
| 227 | if (!b_sync_need_send) return; | ||
| 228 | |||
| 229 | // send the char to the slave side : sync is done | ||
| 230 | if (transaction_rpc_send(USER_SYNC_A, sizeof(last_keycode), &last_keycode)) { | ||
| 231 | b_sync_need_send = false; | ||
| 232 | } | ||
| 233 | } | ||
| 234 | |||
| 235 | bool process_record_user(uint16_t keycode, keyrecord_t* record) { | ||
| 236 | if (record->event.pressed) { | ||
| 237 | // master : store keycode to sent to the other side to be process_key | ||
| 238 | last_keycode.keycode = keycode; | ||
| 239 | b_sync_need_send = true; | ||
| 240 | |||
| 241 | // gui process the input | ||
| 242 | process_key(keycode); | ||
| 243 | } | ||
| 244 | return true; | ||
| 245 | } | ||
| 246 | |||
| 247 | #if IS_LEFT | ||
| 248 | layer_state_t layer_state_set_user(layer_state_t state) { | ||
| 249 | // update the frame with the layer name | ||
| 250 | update_layer_frame(state); | ||
| 251 | return state; | ||
| 252 | } | ||
| 253 | #endif | ||
