keymap.c 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852
  1. /* Copyright 2021 Luis Moreno <acevice69@gmail.com>
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include QMK_KEYBOARD_H
  17. #include "keymap_spanish.h"
  18. // Insert key state definition (Insert/Overwrite Mode)
  19. static bool ins_state = true;
  20. // Git Commands
  21. static const char *sendstring_commands[] = {
  22. // Config
  23. "config //global",
  24. // Create
  25. "init",
  26. "clone",
  27. // Local changes
  28. "status",
  29. "diff",
  30. "add",
  31. "rm",
  32. "mv",
  33. "commit",
  34. "stash",
  35. "reset",
  36. "revert",
  37. // Branches and Tags
  38. "branch /b @",
  39. "switch",
  40. "checkout",
  41. "tag",
  42. // Update & Publish
  43. "remote",
  44. "fetch",
  45. "pull",
  46. "push",
  47. // Merge & Rebase
  48. "merge",
  49. "rebase",
  50. // Commit history
  51. "logg"
  52. };
  53. // Layers definition
  54. enum layers {
  55. _QWERTY_ES,
  56. _COLEMAK_ES,
  57. _SYMBOL,
  58. _FN_NUMPAD,
  59. _NAVIGATION,
  60. _GIT_CMDS,
  61. _SETTINGS
  62. };
  63. // Encoder Modes definition
  64. #ifdef ENCODER_ENABLE
  65. #define ENC_ALT_MAX_TIME 1250
  66. typedef enum {
  67. ENC_MODE_CHAR_LINE,
  68. ENC_MODE_WORD_PAGE,
  69. ENC_MODE_TABBING,
  70. ENC_MODE_VOLUME,
  71. ENC_MODE_LAST
  72. } encoder_mode_t;
  73. static encoder_mode_t enc_mode;
  74. void encoder_cycle_mode(bool up);
  75. #endif
  76. // Tap Dance declarations/definitions
  77. #ifdef TAP_DANCE_ENABLE
  78. #define ACTION_TAP_DANCE_FN_ADVANCED_USER(user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset, user_user_data) \
  79. { .fn = {user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset}, .user_data = (void *)user_user_data, }
  80. #define MAX_MOD 3 // Max number of modifiers: 0-Base, 1-Shift, 2-Ctrl
  81. typedef enum {
  82. TD_NONE,
  83. TD_UNKNOWN,
  84. TD_SINGLE_TAP,
  85. TD_SINGLE_HOLD,
  86. TD_DOUBLE_TAP
  87. } td_state_t;
  88. typedef struct {
  89. bool is_press_action;
  90. td_state_t state;
  91. } td_tap_t;
  92. typedef struct {
  93. uint16_t keycode; // Keycode:
  94. // - Tap if keycode != KC_NO
  95. uint8_t layer[MAX_MOD]; // Layer with modifiers (0-Base, 1-Shift, 2-Ctrl):
  96. // - Tap if keycode == KC_NO
  97. // - Single Hold: Activate while holding
  98. // - Double Tap: (Un)lock Layer
  99. } td_user_data_t;
  100. enum td_actions {
  101. TAB,
  102. ESC,
  103. SPC,
  104. ENT,
  105. LWR,
  106. RAI
  107. };
  108. static td_tap_t td_tap_state = {
  109. .is_press_action = true,
  110. .state = TD_NONE
  111. };
  112. td_state_t td_current (tap_dance_state_t *state);
  113. void td_kc_ly_finished(tap_dance_state_t *state, void *user_data);
  114. void td_kc_ly_reset (tap_dance_state_t *state, void *user_data);
  115. tap_dance_action_t tap_dance_actions[] = {
  116. [TAB] = ACTION_TAP_DANCE_DOUBLE(KC_TAB, KC_CAPS),
  117. [ESC] = ACTION_TAP_DANCE_FN_ADVANCED_USER(NULL, td_kc_ly_finished, td_kc_ly_reset,
  118. &((td_user_data_t) { KC_ESC, { _NAVIGATION, _QWERTY_ES, _QWERTY_ES }})),
  119. [SPC] = ACTION_TAP_DANCE_FN_ADVANCED_USER(NULL, td_kc_ly_finished, td_kc_ly_reset,
  120. &((td_user_data_t) { KC_SPC, { _SYMBOL , _QWERTY_ES, _QWERTY_ES }})),
  121. [ENT] = ACTION_TAP_DANCE_FN_ADVANCED_USER(NULL, td_kc_ly_finished, td_kc_ly_reset,
  122. &((td_user_data_t) { KC_ENT, { _SYMBOL , _QWERTY_ES, _QWERTY_ES }})),
  123. [LWR] = ACTION_TAP_DANCE_FN_ADVANCED_USER(NULL, td_kc_ly_finished, td_kc_ly_reset,
  124. &((td_user_data_t) { KC_NO, { _NAVIGATION, _GIT_CMDS , _QWERTY_ES }})),
  125. [RAI] = ACTION_TAP_DANCE_FN_ADVANCED_USER(NULL, td_kc_ly_finished, td_kc_ly_reset,
  126. &((td_user_data_t) { KC_NO, { _FN_NUMPAD , _GIT_CMDS , _QWERTY_ES }}))
  127. };
  128. #endif
  129. // Keycode definitions
  130. enum custom_keycodes {
  131. CK_QUOT = SAFE_RANGE, // Single/Double quote
  132. CK_BSDI, // Backspace/Delete/Insert
  133. CK_ENCM, // Encoder Mode (-)
  134. CK_ENCP, // Encoder Mode (+)
  135. CK_LYDF, // Activate Default Layer
  136. G_CONF, // Git Commands
  137. G_INIT,
  138. G_CLONE,
  139. G_STAT,
  140. G_DIFF,
  141. G_ADD,
  142. G_RM,
  143. G_MV,
  144. G_COMM,
  145. G_STASH,
  146. G_RESET,
  147. G_REVER,
  148. G_BRANC,
  149. G_SWTCH,
  150. G_CHECK,
  151. G_TAG,
  152. G_REMOT,
  153. G_FETCH,
  154. G_PULL,
  155. G_PUSH,
  156. G_MERGE,
  157. G_REBAS,
  158. G_LOG
  159. };
  160. #define LY_QWES DF(_QWERTY_ES)
  161. #define LY_CLES DF(_COLEMAK_ES)
  162. #ifdef TAP_DANCE_ENABLE
  163. #define TD_TBCP TD(TAB)
  164. #define TD_ESSY TD(ESC)
  165. #define TD_SPSY TD(SPC)
  166. #define TD_ENSY TD(ENT)
  167. #define TD_LOWR TD(LWR)
  168. #define TD_RAIS TD(RAI)
  169. #else
  170. #define TD_TBCP MT(MOD_LSFT, KC_TAB)
  171. #define TD_ESSY LT(_SYMBOL , KC_ESC)
  172. #define TD_SPSY KC_SPC
  173. #define TD_ENSY KC_ENT
  174. #define TD_LOWR TT(_NAVIGATION)
  175. #define TD_RAIS TT(_SYMBOL)
  176. #endif
  177. #define MO_LSFT OSM(MOD_LSFT)
  178. #define MO_LCTL OSM(MOD_LCTL)
  179. #define MO_LALT OSM(MOD_LALT)
  180. #define MT_RGUI MT(MOD_RGUI, KC_LEFT)
  181. #define MT_RALT MT(MOD_RALT, KC_DOWN)
  182. #define MT_RCTL MT(MOD_RCTL, KC_UP)
  183. #define MT_RSFT MT(MOD_RSFT, KC_RGHT)
  184. // Keymap definitions
  185. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  186. // clang-format off
  187. /*
  188. * Basic characters (QWERTY ES)
  189. *
  190. * ,-------------------------------------------. ,-------------------------------------------.
  191. * |Esc/LNav| Q | W | E | R | T | | Y | U | I | O | P |BS/Dl/In|
  192. * |--------+------+------+------+------+------| |------+------+------+------+------+--------|
  193. * |Tab/Caps| A | S | D | F | G | | H | J | K | L | Ñ | ´ ¨ |
  194. * |--------+------+------+------+------+------+-------------. ,-------------+------+------+------+------+------+--------|
  195. * |EncMode-| Z | X | C | V | B | LGit | | | | LGit | N | M | , ; | . : | - _ |EncMode+|
  196. * `-------------------------------------------| LNav | Space| | Enter|LFnNum|-------------------------------------------'
  197. * +--------------------+------+ / | | / +------+--------------------+
  198. * | Shift| Ctrl | Alt | GUI | LSym | | LSym | GUI | AltGr| Ctrl | Shift|
  199. * | | | | | | | | <- | v | ^ | -> |
  200. * `----------------------------------' `----------------------------------'
  201. */
  202. [_QWERTY_ES] = LAYOUT(
  203. TD_ESSY, ES_Q, ES_W, ES_E, ES_R, ES_T, ES_Y, ES_U, ES_I, ES_O, ES_P, CK_BSDI,
  204. TD_TBCP, ES_A, ES_S, ES_D, ES_F, ES_G, ES_H, ES_J, ES_K, ES_L, ES_NTIL, ES_ACUT,
  205. CK_ENCM, ES_Z, ES_X, ES_C, ES_V, ES_B, TD_LOWR, XXXXXXX, XXXXXXX, TD_RAIS, ES_N, ES_M, ES_COMM, ES_DOT, ES_MINS, CK_ENCP,
  206. MO_LSFT, MO_LCTL, MO_LALT, KC_LGUI, TD_SPSY, TD_ENSY, MT_RGUI, MT_RALT, MT_RCTL, MT_RSFT
  207. ),
  208. /*
  209. * Basic characters (COLEMAK ES)
  210. *
  211. * ,-------------------------------------------. ,-------------------------------------------.
  212. * |Esc/LNav| Q | W | F | P | G | | J | L | U | Y | Ñ |BS/Dl/In|
  213. * |--------+------+------+------+------+------| |------+------+------+------+------+--------|
  214. * |Tab/Caps| A | R | S | T | D | | H | N | E | I | O | ´ ¨ |
  215. * |--------+------+------+------+------+------+-------------. ,-------------+------+------+------+------+------+--------|
  216. * |EncMode-| Z | X | C | V | B | LGit | | | | LGit | K | M | , ; | . : | - _ |EncMode+|
  217. * `-------------------------------------------| LNav | Space| | Enter|LFnNum|-------------------------------------------'
  218. * +--------------------+------+ / | | / +------+--------------------+
  219. * | Shift| Ctrl | Alt | GUI | LSym | | LSym | GUI | AltGr| Ctrl | Shift|
  220. * | | | | | | | | <- | v | ^ | -> |
  221. * `----------------------------------' `----------------------------------'
  222. */
  223. [_COLEMAK_ES] = LAYOUT(
  224. TD_ESSY, ES_Q, ES_W, ES_F, ES_P, ES_G, ES_J, ES_L, ES_U, ES_Y, ES_NTIL, CK_BSDI,
  225. TD_TBCP, ES_A, ES_R, ES_S, ES_T, ES_D, ES_H, ES_N, ES_E, ES_I, ES_O, ES_ACUT,
  226. CK_ENCM, ES_Z, ES_X, ES_C, ES_V, ES_B, TD_LOWR, XXXXXXX, XXXXXXX, TD_RAIS, ES_K, ES_M, ES_COMM, ES_DOT, ES_MINS, CK_ENCP,
  227. MO_LSFT, MO_LCTL, MO_LALT, KC_LGUI, TD_SPSY, TD_ENSY, MT_RGUI, MT_RALT, MT_RCTL, MT_RSFT
  228. ),
  229. /*
  230. * Symbols
  231. *
  232. * ,-------------------------------------------. ,-------------------------------------------.
  233. * | | 1 ! | 2 " | 3 · | 4 $ | 5 % | | 6 & | 7 / | 8 ( | 9 ) | 0 = | |
  234. * |--------+------+------+------+------+------| |------+------+------+------+------+--------|
  235. * | | ¡ ¿ | ' " | º ª | \ | | ¡ | | ~ $ | + * | - _ | / | ' ? | ` ^ |
  236. * |--------+------+------+------+------+------+-------------. ,-------------+------+------+------+------+------+--------|
  237. * | | @ ⅛ | { | ( | [ ° | < > | | | | | | > | ] ¯ | ) | } ˘ | # £ | |
  238. * `----------------------+------+------+------+------+ | | +------+------+------+------+----------------------'
  239. * | | | | | | | | | | | |
  240. * | | | | | | | | | | | |
  241. * `----------------------------------' `----------------------------------'
  242. */
  243. [_SYMBOL] = LAYOUT(
  244. _______, ES_1, ES_2, ES_3, ES_4, ES_5, ES_6, ES_7, ES_8, ES_9, ES_0, _______,
  245. _______, ES_IEXL, CK_QUOT, ES_MORD, ES_BSLS, ES_PIPE, ES_TILD, ES_PLUS, ES_MINS, ES_SLSH, ES_QUOT, ES_GRV,
  246. _______, ES_AT, ES_LCBR, ES_LPRN, ES_LBRC, ES_LABK, _______, XXXXXXX, XXXXXXX, _______, ES_RABK, ES_RBRC, ES_RPRN, ES_RCBR, ES_HASH, _______,
  247. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
  248. ),
  249. /*
  250. * Function keys, NumPad keys
  251. *
  252. * ,-------------------------------------------. ,-------------------------------------------.
  253. * | | F1 | F2 | F3 | F4 | | | , ; | 7 / | 8 ( | 9 ) | * | |
  254. * |--------+------+------+------+------+------| |------+------+------+------+------+--------|
  255. * | | F5 | F6 | F7 | F8 | | | . : | 4 $ | 5 % | 6 & | - _ | + * |
  256. * |--------+------+------+------+------+------+-------------. ,-------------+------+------+------+------+------+--------|
  257. * | | F9 | F10 | F11 | F12 | | | | | | | 0 = | 1 ! | 2 " | 3 · | / | |
  258. * `----------------------+------+------+------+------+ | | +------+------+------+------+----------------------'
  259. * | | | | | | | | | | | |
  260. * | | | | | | | | | | | |
  261. * `----------------------------------' `----------------------------------'
  262. */
  263. [_FN_NUMPAD] = LAYOUT(
  264. _______, KC_F1, KC_F2, KC_F3, KC_F4, XXXXXXX, ES_COMM, ES_7, ES_8, ES_9, ES_ASTR, _______,
  265. _______, KC_F5, KC_F6, KC_F7, KC_F8, XXXXXXX, ES_DOT, ES_4, ES_5, ES_6, ES_MINS, ES_PLUS,
  266. _______, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX, _______, XXXXXXX, XXXXXXX, _______, ES_0, ES_1, ES_2, ES_3, ES_SLSH, _______,
  267. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
  268. ),
  269. /*
  270. * Navigation (Mouse deactivated for space saving)
  271. *
  272. * ,-------------------------------------------. ,-------------------------------------------.
  273. * | | | MBt1 | MUp | MBt2 | | | PgUp | Home | Up | End | PgUp | |
  274. * |--------+------+------+------+------+------| |------+------+------+------+------+--------|
  275. * | | Menu | MLeft| MDown|MRight| | | PgDn | Left | Down | Right| PgDn | |
  276. * |--------+------+------+------+------+------+-------------. ,-------------+------+------+------+------+------+--------|
  277. * | | | | | | | | | | | | |PrtScr|ScrLck| Pause| | |
  278. * `----------------------+------+------+------+------+ | | +------+------+------+------+----------------------'
  279. * | | | | | | | | | | | |
  280. * | | | | | | | | | | | |
  281. * `----------------------------------' `----------------------------------'
  282. */
  283. [_NAVIGATION] = LAYOUT(
  284. _______, XXXXXXX, KC_BTN1, KC_MS_U, KC_BTN2, XXXXXXX, KC_PGUP, KC_HOME, KC_UP, KC_END, KC_PGUP, _______,
  285. _______, KC_APP, KC_MS_L, KC_MS_D, KC_MS_R, XXXXXXX, KC_PGDN, KC_LEFT, KC_DOWN, KC_RGHT, KC_PGDN, _______,
  286. _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, XXXXXXX, XXXXXXX, _______, XXXXXXX, KC_PSCR, KC_SCRL, KC_PAUS, XXXXXXX, _______,
  287. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
  288. ),
  289. /*
  290. * Git Commands
  291. *
  292. * ,-------------------------------------------. ,-------------------------------------------.
  293. * | |Config| | | Init | | | | Clone| | | | |
  294. * |--------+------+------+------+------+------| |------+------+------+------+------+--------|
  295. * | | Diff | Add | Rm | Mv | | |Remote| Fetch| Pull | Push | Merge| Rebase |
  296. * |--------+------+------+------+------+------+-------------. ,-------------+------+------+------+------+------+--------|
  297. * | |Commit| Stash| Reset|Revert|Status| | | | | | Log |Branch|Switch|ChkOut| Tag | |
  298. * `----------------------+------+------+------+------+ | | +------+------+------+------+----------------------'
  299. * | | | | | | | | | | | |
  300. * | | | | | | | | | | | |
  301. * `----------------------------------' `----------------------------------'
  302. */
  303. [_GIT_CMDS] = LAYOUT(
  304. _______, G_CONF, XXXXXXX, XXXXXXX, G_INIT, XXXXXXX, XXXXXXX, G_CLONE, XXXXXXX, XXXXXXX, XXXXXXX, _______,
  305. _______, G_DIFF, G_ADD, G_RM, G_MV, XXXXXXX, G_REMOT, G_FETCH, G_PULL, G_PUSH, G_MERGE, G_REBAS,
  306. _______, G_COMM, G_STASH, G_RESET, G_REVER, G_STAT, _______, XXXXXXX, XXXXXXX, _______, G_LOG, G_BRANC, G_SWTCH, G_CHECK, G_TAG, _______,
  307. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
  308. ),
  309. /*
  310. * Settings (Default Layer, RGB, Media)
  311. *
  312. * ,-------------------------------------------. ,-------------------------------------------.
  313. * | |QWE_ES|CLM_ES| | | | | | | Vol+ | | | |
  314. * |--------+------+------+------+------+------| |------+------+------+------+------+--------|
  315. * | | TOG | HUE+ | SAT+ | VAL+ | MOD | | Mute | Prev | Play | Next | | |
  316. * |--------+------+------+------+------+------+-------------. ,-------------+------+------+------+------+------+--------|
  317. * | LDef | | HUE- | SAT- | VAL- | RMOD | | | | | | | | Vol- | | | LDef |
  318. * `----------------------+------+------+------+------+ | | +------+------+------+------+----------------------'
  319. * | | | | | | | | | | | |
  320. * | | | | | | | | | | | |
  321. * `----------------------------------' `----------------------------------'
  322. */
  323. [_SETTINGS] = LAYOUT(
  324. _______, LY_QWES, LY_CLES, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_VOLU, XXXXXXX, XXXXXXX, _______,
  325. _______, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, RGB_MOD, KC_MUTE, KC_MPRV, KC_MPLY, KC_MNXT, XXXXXXX, XXXXXXX,
  326. CK_LYDF, XXXXXXX, RGB_HUD, RGB_SAD, RGB_VAD, RGB_RMOD,_______, XXXXXXX, XXXXXXX, _______, XXXXXXX, XXXXXXX, KC_VOLD, XXXXXXX, XXXXXXX, CK_LYDF,
  327. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
  328. ),
  329. // /*
  330. // * Layer template
  331. // *
  332. // * ,-------------------------------------------. ,-------------------------------------------.
  333. // * | | | | | | | | | | | | | |
  334. // * |--------+------+------+------+------+------| |------+------+------+------+------+--------|
  335. // * | | | | | | | | | | | | | |
  336. // * |--------+------+------+------+------+------+-------------. ,-------------+------+------+------+------+------+--------|
  337. // * | | | | | | | | | | | | | | | | | |
  338. // * `----------------------+------+------+------+------+ | | +------+------+------+------+----------------------'
  339. // * | | | | | | | | | | | |
  340. // * | | | | | | | | | | | |
  341. // * `----------------------------------' `----------------------------------'
  342. // */
  343. // [_LAYERINDEX] = LAYOUT(
  344. // _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  345. // _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  346. // _______, _______, _______, _______, _______, _______, _______, XXXXXXX, XXXXXXX, _______, _______, _______, _______, _______, _______, _______,
  347. // _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
  348. // ),
  349. };
  350. // clang-format on
  351. /*
  352. * INITIALIZING FUNCTIONS
  353. */
  354. void matrix_init_user(void) {
  355. #ifdef ENCODER_ENABLE
  356. enc_mode = ENC_MODE_CHAR_LINE;
  357. #endif
  358. }
  359. /*
  360. * LAYER FUNCTIONS
  361. */
  362. layer_state_t layer_state_set_user(layer_state_t state) {
  363. // Activate Settings layer when both Symbol and Navigation layers are on
  364. return update_tri_layer_state(state, _SYMBOL, _NAVIGATION, _SETTINGS);
  365. }
  366. /*
  367. * MACRO FUNCTIONS
  368. */
  369. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  370. // Get current modifier status (Normal and One Shot)
  371. uint8_t mod_state = get_mods();
  372. uint8_t osm_state = get_oneshot_mods();
  373. // Process keycode
  374. switch (keycode) {
  375. case CK_QUOT: // Single/Double Quote
  376. if (record->event.pressed) {
  377. if ((mod_state | osm_state) & MOD_MASK_SHIFT) {
  378. register_code(ES_2); // Shift(2) -> "
  379. } else {
  380. register_code(ES_QUOT); // Single Quote -> '
  381. }
  382. } else {
  383. if ((mod_state | osm_state) & MOD_MASK_SHIFT) {
  384. unregister_code(ES_2); // Shift(2) -> "
  385. } else {
  386. unregister_code(ES_QUOT); // Single Quote -> '
  387. }
  388. }
  389. return false;
  390. break;
  391. case CK_BSDI: { // Backspace/Delete/Insert
  392. static bool delkey_registered = false;
  393. if (record->event.pressed) {
  394. // Ctrl -> Insert/Overwrite Mode
  395. // Shift -> Delete
  396. // Normal -> Backspace
  397. if ((mod_state | osm_state) & MOD_MASK_CTRL) {
  398. del_mods(MOD_MASK_CTRL);
  399. del_oneshot_mods(MOD_MASK_CTRL);
  400. tap_code(KC_INS);
  401. set_mods(mod_state);
  402. set_oneshot_mods(osm_state);
  403. ins_state = !ins_state;
  404. } else if ((mod_state | osm_state) & MOD_MASK_SHIFT) {
  405. delkey_registered = true;
  406. del_mods(MOD_MASK_SHIFT);
  407. del_oneshot_mods(MOD_MASK_SHIFT);
  408. register_code(KC_DEL);
  409. set_mods(mod_state);
  410. set_oneshot_mods(osm_state);
  411. } else {
  412. register_code(KC_BSPC);
  413. }
  414. } else {
  415. // Unregister keycode sent after the release of CK_BSDI
  416. if (delkey_registered) {
  417. unregister_code(KC_DEL);
  418. delkey_registered = false;
  419. } else {
  420. unregister_code(KC_BSPC);
  421. }
  422. }
  423. return false;
  424. }
  425. break;
  426. case CK_LYDF: // De-activate all layers and activate Default layer
  427. layer_move(get_highest_layer(default_layer_state));
  428. return false;
  429. break;
  430. case G_CONF ... G_LOG:
  431. if (record->event.pressed) {
  432. del_mods(MOD_MASK_SHIFT);
  433. del_oneshot_mods(MOD_MASK_SHIFT);
  434. SEND_STRING("git ");
  435. send_string(sendstring_commands[keycode - G_CONF]);
  436. set_mods(mod_state);
  437. set_oneshot_mods(osm_state);
  438. }
  439. break;
  440. #ifdef ENCODER_ENABLE
  441. case CK_ENCM: // Encoder Mode (-)
  442. if (record->event.pressed) {
  443. encoder_cycle_mode(false);
  444. }
  445. break;
  446. case CK_ENCP: // Encoder Mode (+)
  447. if (record->event.pressed) {
  448. encoder_cycle_mode(true);
  449. }
  450. break;
  451. #endif
  452. }
  453. return true;
  454. };
  455. /*
  456. * TAP DANCE FUNCTIONS
  457. */
  458. #ifdef TAP_DANCE_ENABLE
  459. td_state_t td_current(tap_dance_state_t *state) {
  460. switch (state->count) {
  461. case 1:
  462. return ((!state->pressed) ? TD_SINGLE_TAP : TD_SINGLE_HOLD);
  463. case 2:
  464. return TD_DOUBLE_TAP;
  465. default:
  466. return TD_UNKNOWN;
  467. }
  468. }
  469. void td_kc_ly_finished(tap_dance_state_t *state, void *user_data) {
  470. td_tap_state.state = td_current(state);
  471. uint16_t keycode = ((td_user_data_t *)user_data)->keycode;
  472. uint8_t *layer_arr = ((td_user_data_t *)user_data)->layer;
  473. uint8_t layer_sel = *(layer_arr + 0);
  474. // Get current modifier status (Normal and One Shot) and select layer
  475. uint8_t mod_state = get_mods();
  476. uint8_t osm_state = get_oneshot_mods();
  477. if ((mod_state | osm_state) & MOD_MASK_SHIFT) {
  478. if (*(layer_arr + 1) > _QWERTY_ES) {
  479. layer_sel = *(layer_arr + 1);
  480. }
  481. }
  482. if ((mod_state | osm_state) & MOD_MASK_CTRL) {
  483. if (*(layer_arr + 2) > _QWERTY_ES) {
  484. layer_sel = *(layer_arr + 2);
  485. }
  486. }
  487. switch (td_tap_state.state) {
  488. case TD_NONE:
  489. case TD_UNKNOWN:
  490. break;
  491. case TD_SINGLE_TAP:
  492. // Send keycode if available
  493. // Otherwise, Lock Layer (Base/Shift/Ctrl) and Unlock rest of selectable layers
  494. if (keycode != KC_NO) {
  495. tap_code(keycode);
  496. } else {
  497. uint8_t layer_aux;
  498. for (layer_aux = _GIT_CMDS; layer_aux >= _SYMBOL; layer_aux--) {
  499. if ((layer_aux == layer_sel) && (!layer_state_is(layer_aux))) {
  500. layer_on(layer_aux);
  501. } else {
  502. layer_off(layer_aux);
  503. }
  504. }
  505. }
  506. break;
  507. case TD_SINGLE_HOLD:
  508. // Lock Layer (Base/Shift/Ctrl) while Single Hold on the way
  509. layer_on(layer_sel);
  510. break;
  511. case TD_DOUBLE_TAP:
  512. // (Un)lock Layer (Base/Shift/Ctrl)
  513. if (layer_state_is(layer_sel)) {
  514. layer_off(layer_sel);
  515. } else {
  516. layer_on(layer_sel);
  517. }
  518. break;
  519. }
  520. }
  521. void td_kc_ly_reset(tap_dance_state_t *state, void *user_data) {
  522. uint8_t *layer_arr = ((td_user_data_t *)user_data)->layer;
  523. if (td_tap_state.state == TD_SINGLE_HOLD) {
  524. // Unlock any Layer (Base/Shift/Ctrl) when Single Hold finalizes
  525. uint8_t i;
  526. uint8_t layer_aux;
  527. for (i = 0; i < MAX_MOD; i++) {
  528. layer_aux = *(layer_arr + i);
  529. if ((layer_aux > _QWERTY_ES)) {
  530. layer_off(layer_aux);
  531. }
  532. }
  533. }
  534. td_tap_state.state = TD_NONE;
  535. }
  536. #endif
  537. /*
  538. * OLED FUNCTIONS
  539. */
  540. #ifdef OLED_DRIVER_ENABLE
  541. static void render_kyria_logo(void) {
  542. static const char PROGMEM kyria_logo[] = {
  543. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xe0, 0xf0, 0x78, 0x38, 0x1c, 0x1e, 0x0e,
  544. 0x8e, 0x86, 0x86, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x86,
  545. 0x86, 0x8e, 0x0e, 0x1e, 0x1c, 0x38, 0x78, 0xf0, 0xe0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00,
  546. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  547. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  548. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  549. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  550. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  551. 0x00, 0x00, 0xe0, 0xf0, 0xfc, 0x3e, 0x0f, 0x07, 0x83, 0xe1, 0xf0, 0xf8, 0xbc, 0x9e, 0x8f, 0x87,
  552. 0x87, 0x83, 0x81, 0x81, 0xe0, 0x78, 0x1f, 0x07, 0xff, 0xff, 0x07, 0x1f, 0x78, 0xe0, 0x81, 0x81,
  553. 0x83, 0x87, 0x87, 0x8f, 0x9e, 0xbc, 0xf8, 0xf0, 0xe1, 0x83, 0x07, 0x0f, 0x3e, 0xfc, 0xf0, 0xe0,
  554. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  555. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  556. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  557. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  558. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  559. 0x00, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x07, 0x07, 0x3f, 0x73, 0xc7, 0x8f, 0x8d,
  560. 0x89, 0x99, 0x99, 0xb1, 0xf7, 0xee, 0xf8, 0xf0, 0xff, 0xff, 0xf0, 0xf8, 0xee, 0xf7, 0xb1, 0x99,
  561. 0x99, 0x89, 0x8d, 0x8f, 0xc7, 0x73, 0x3f, 0x07, 0x07, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x03, 0xff,
  562. 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  563. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  564. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  565. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  566. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  567. 0x00, 0x3f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xe0, 0xe0, 0xfc, 0xce, 0xe3, 0xf1, 0xb1,
  568. 0x91, 0x99, 0x99, 0x8d, 0xef, 0x77, 0x1f, 0x0f, 0xff, 0xff, 0x0f, 0x1f, 0x77, 0xef, 0x8d, 0x99,
  569. 0x99, 0x91, 0xb1, 0xf1, 0xe3, 0xce, 0xfc, 0xe0, 0xe0, 0xff, 0x3f, 0x00, 0x00, 0x00, 0xc0, 0xff,
  570. 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  571. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  572. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  573. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  574. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  575. 0x00, 0x00, 0x07, 0x0f, 0x3f, 0x7c, 0xf0, 0xe0, 0xc1, 0x87, 0x0f, 0x1f, 0x3d, 0x79, 0xf1, 0xe1,
  576. 0xe1, 0xc1, 0x81, 0x81, 0x07, 0x1e, 0xf8, 0xe0, 0xff, 0xff, 0xe0, 0xf8, 0x1e, 0x07, 0x81, 0x81,
  577. 0xc1, 0xe1, 0xe1, 0xf1, 0x79, 0x3d, 0x1f, 0x0f, 0x87, 0xc1, 0xe0, 0xf0, 0x7c, 0x3f, 0x0f, 0x07,
  578. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  579. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  580. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  581. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  582. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  583. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x0f, 0x1e, 0x1c, 0x38, 0x78, 0x70,
  584. 0x71, 0x61, 0x61, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x61,
  585. 0x61, 0x71, 0x70, 0x78, 0x38, 0x1c, 0x1e, 0x0f, 0x07, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00,
  586. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  587. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  588. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  589. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  590. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  591. 0x00, 0x00, 0x00, 0x00, 0xc0, 0xfe, 0xfe, 0xfe, 0xc6, 0xe0, 0xf0, 0x70, 0x30, 0x10, 0x00, 0x70,
  592. 0xf0, 0xf0, 0x80, 0x00, 0xc0, 0xf0, 0xf0, 0x70, 0x10, 0xc0, 0xf0, 0xf0, 0xf0, 0x70, 0x30, 0x30,
  593. 0x30, 0xc0, 0xf6, 0xf6, 0xf6, 0x06, 0x00, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xf0, 0xf0, 0xe0, 0x00,
  594. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  595. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  596. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  597. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  598. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  599. 0x00, 0x00, 0x00, 0x10, 0x1f, 0x1f, 0x1f, 0x03, 0x0f, 0x1f, 0x1e, 0x18, 0x10, 0x00, 0xc0, 0xc0,
  600. 0xe7, 0xff, 0x7f, 0x3f, 0x0f, 0x03, 0x01, 0x00, 0x18, 0x1f, 0x1f, 0x1f, 0x00, 0x00, 0x00, 0x00,
  601. 0x18, 0x1f, 0x1f, 0x1f, 0x00, 0x0e, 0x1f, 0x1f, 0x1f, 0x19, 0x0d, 0x1f, 0x1f, 0x1f, 0x03, 0x00,
  602. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  603. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  604. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  605. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  606. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  607. };
  608. oled_write_raw_P(kyria_logo, sizeof(kyria_logo));
  609. }
  610. static void render_qmk_logo(void) {
  611. static const char PROGMEM qmk_logo[] = {
  612. 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94,
  613. 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4,
  614. 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4,
  615. 0
  616. };
  617. oled_write_P(qmk_logo, false);
  618. }
  619. static void render_status(void) {
  620. // Get current modifier status (Normal and One Shot)
  621. uint8_t mod_state = get_mods();
  622. uint8_t osm_state = get_oneshot_mods();
  623. uint8_t osl_state = get_oneshot_locked_mods();
  624. bool caps_lock = host_keyboard_led_state().caps_lock;
  625. // QMK Logo
  626. render_qmk_logo();
  627. #ifdef ENCODER_ENABLE
  628. // Host Keyboard Encoder Mode
  629. switch (enc_mode) {
  630. case ENC_MODE_CHAR_LINE:
  631. oled_write_P(PSTR("ENC \020 CHAR/LINE\n"), false);
  632. break;
  633. case ENC_MODE_WORD_PAGE:
  634. oled_write_P(PSTR("ENC \020 WORD/PAGE\n"), false);
  635. break;
  636. case ENC_MODE_TABBING:
  637. oled_write_P(PSTR("ENC \020 TABBING\n"), false);
  638. break;
  639. case ENC_MODE_VOLUME:
  640. case ENC_MODE_LAST:
  641. oled_write_P(PSTR("ENC \020 VOLUME\n"), false);
  642. break;
  643. }
  644. #else
  645. oled_write_P(PSTR("\n"), false);
  646. #endif
  647. // Host Keyboard Layer Status
  648. oled_write_P(PSTR("\n"), false);
  649. switch (get_highest_layer(layer_state)) {
  650. case _QWERTY_ES:
  651. oled_write_P(PSTR("L00 \020 QWERTY (ES)\n"), false);
  652. break;
  653. case _COLEMAK_ES:
  654. oled_write_P(PSTR("L00 \020 COLEMAK (ES)\n"), false);
  655. break;
  656. case _SYMBOL:
  657. oled_write_P(PSTR("L01 \020 SYMBOLS\n"), false);
  658. break;
  659. case _FN_NUMPAD:
  660. oled_write_P(PSTR("L02 \020 FN / NUMPAD\n"), false);
  661. break;
  662. case _NAVIGATION:
  663. oled_write_P(PSTR("L03 \020 NAVIGATION\n"), false);
  664. break;
  665. case _GIT_CMDS:
  666. oled_write_P(PSTR("L04 \020 GIT COMMANDS\n"), false);
  667. break;
  668. case _SETTINGS:
  669. oled_write_P(PSTR("L05 \020 SETTINGS\n"), false);
  670. break;
  671. }
  672. // Host Keyboard Locked Modifiers Status
  673. oled_write_P((osl_state & MOD_MASK_SHIFT) ? PSTR("LCK ") : PSTR(" ") , false);
  674. oled_write_P((osl_state & MOD_MASK_CTRL) ? PSTR("LCK ") : PSTR(" ") , false);
  675. oled_write_P((osl_state & MOD_MASK_ALT) ? PSTR("LCK ") : PSTR(" ") , false);
  676. oled_write_P( PSTR(" ") , false);
  677. oled_write_P((caps_lock) ? PSTR(" CAPS") : PSTR(" "), false);
  678. // Host Keyboard Modifiers Status
  679. oled_write_P(((mod_state | osm_state) & MOD_MASK_SHIFT) ? PSTR("SHF ") : PSTR(" ") , false);
  680. oled_write_P(((mod_state | osm_state) & MOD_MASK_CTRL) ? PSTR("CTR ") : PSTR(" ") , false);
  681. oled_write_P(((mod_state | osm_state) & MOD_MASK_ALT) ? PSTR("ALT ") : PSTR(" ") , false);
  682. oled_write_P(((mod_state | osm_state) & MOD_MASK_GUI) ? PSTR("GUI ") : PSTR(" ") , false);
  683. oled_write_P((ins_state) ? PSTR(" INS") : PSTR(" OWR"), false);
  684. }
  685. static void render_settings(void) {
  686. #ifdef RGBLIGHT_ENABLE
  687. char rgb_str[4];
  688. oled_write_P(PSTR("\n\n"), false);
  689. oled_write_P(PSTR("\020H: "), false);
  690. itoa(rgblight_get_hue(), rgb_str, 10);
  691. oled_write_ln(rgb_str, false);
  692. oled_write_P(PSTR("\020S: "), false);
  693. itoa(rgblight_get_sat(), rgb_str, 10);
  694. oled_write_ln(rgb_str, false);
  695. oled_write_P(PSTR("\020V: "), false);
  696. itoa(rgblight_get_val(), rgb_str, 10);
  697. oled_write_ln(rgb_str, false);
  698. #else
  699. oled_write_P(PSTR("\n\n\n\n\n"), false);
  700. #endif
  701. switch (get_highest_layer(default_layer_state)) {
  702. case _QWERTY_ES:
  703. oled_write_ln_P(PSTR(" \020QWERTY (ES)") , false);
  704. break;
  705. case _COLEMAK_ES:
  706. oled_write_P (PSTR(" \020COLEMAK (ES)"), false);
  707. break;
  708. }
  709. #ifdef RGBLIGHT_ENABLE
  710. oled_write_ln_P(PSTR(" RGB DEFAULT"), false);
  711. oled_write_ln_P(PSTR("SETTINGS LAYER "), false);
  712. #else
  713. oled_write_ln_P(PSTR(" DEFAULT"), false);
  714. oled_write_ln_P(PSTR(" LAYER "), false);
  715. #endif
  716. }
  717. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  718. return OLED_ROTATION_180;
  719. }
  720. void oled_task_user(void) {
  721. if (is_keyboard_master()) { // Main screen: Renders keyboard state (layer, modifiers) / RGB settings
  722. if (get_highest_layer(layer_state) != _SETTINGS) {
  723. render_status();
  724. } else {
  725. render_settings();
  726. }
  727. } else { // Auxiliar screen: Renders Kyria logo with scroll
  728. render_kyria_logo();
  729. oled_scroll_right();
  730. }
  731. }
  732. #endif
  733. /*
  734. * ENCODER FUNCTIONS
  735. */
  736. #ifdef ENCODER_ENABLE
  737. void encoder_cycle_mode(bool up) {
  738. if (enc_mode == 0 && !up) {
  739. enc_mode = ENC_MODE_LAST - 1;
  740. } else {
  741. enc_mode = (enc_mode + (up ? +1 : -1)) % ENC_MODE_LAST;
  742. }
  743. }
  744. bool encoder_update_user(uint8_t index, bool clockwise) {
  745. // Select encoder mode
  746. switch (enc_mode) {
  747. case ENC_MODE_CHAR_LINE:
  748. // Left Encoder: Character Left/Right. Right Encoder: Line Up/Down.
  749. tap_code(!clockwise ? (index == 0 ? KC_LEFT : KC_UP): (index == 0 ? KC_RGHT : KC_DOWN));
  750. break;
  751. case ENC_MODE_WORD_PAGE:
  752. // Left Encoder: Word Left/Right. Right Encoder: Page Up/Down.
  753. tap_code16(!clockwise ? (index == 0 ? C(KC_LEFT) : KC_PGUP): (index == 0 ? C(KC_RGHT) : KC_PGDN));
  754. break;
  755. case ENC_MODE_TABBING:
  756. // Left Encoder: Navigation Tabbing. Right Encoder: Editor Tabbing.
  757. tap_code16(!clockwise ? (index == 0 ? S(C(KC_TAB)) : C(KC_PGUP)): (index == 0 ? C(KC_TAB) : C(KC_PGDN)));
  758. break;
  759. case ENC_MODE_VOLUME:
  760. case ENC_MODE_LAST:
  761. // Volume control
  762. tap_code(clockwise ? KC_VOLU : KC_VOLD);
  763. break;
  764. }
  765. return true;
  766. }
  767. #endif