Peter's keyboard firmware (QMK) https://qmk.fm/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

keymap.c 33KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  1. /*
  2. This is the keymap for the keyboard
  3. Copyright 2012 Jun Wako <wakojun@gmail.com>
  4. Copyright 2015 Jack Humbert
  5. Copyright 2017 Art Ortenburger
  6. This program is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  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. #include "debug.h"
  19. #include "action_layer.h"
  20. #include "version.h"
  21. #include "keymap_german.h"
  22. #include "keymap_nordic.h"
  23. // Define layer names
  24. #define QWERTY 0
  25. #define COLEMAK 1
  26. #define DVORAK 2
  27. #define SYMB 3
  28. #define OVERWATCH 4
  29. #define DIABLO 5
  30. #define MOUS 6
  31. //define modifiers
  32. #define MODS_SHIFT_MASK (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT))
  33. #define MODS_CTRL_MASK (MOD_BIT(KC_LCTL)|MOD_BIT(KC_RCTRL))
  34. #define MODS_ALT_MASK (MOD_BIT(KC_LALT)|MOD_BIT(KC_RALT))
  35. //define macro keycodes
  36. #define M_VERSION M(0)
  37. #define M_MAKE M(1)
  38. //define layer change stuff for underglow indicator
  39. bool skip_leds = false;
  40. #define rgblight_set_blue rgblight_sethsv (0xFF, 0xFF, 0xFF);
  41. #define rgblight_set_red rgblight_sethsv(0x00, 0xFF, 0xFF);
  42. #define rgblight_set_green rgblight_sethsv (0x78, 0xFF, 0xFF);
  43. #define rgblight_set_orange rgblight_sethsv (0x1E, 0xFF, 0xFF);
  44. #define rgblight_set_teal rgblight_sethsv (0xC3, 0xFF, 0xFF);
  45. #define rgblight_set_magenta rgblight_sethsv (0x12C, 0xFF, 0xFF);
  46. #define rgblight_set_urine rgblight_sethsv (0x3C, 0xFF, 0xFF);
  47. //This is both for underglow, and Diablo 3 macros
  48. static uint8_t current_layer = 0;
  49. //define diablo macro timer variables
  50. static uint16_t diablo_timer[4];
  51. static uint8_t diablo_times[] = {0, 1, 3, 5, 10, 30};
  52. static uint8_t diablo_key_time[4];
  53. bool check_dtimer(uint8_t dtimer) {
  54. // has the correct number of seconds elapsed (as defined by diablo_times)
  55. return (timer_elapsed(diablo_timer[dtimer]) < ( diablo_key_time[dtimer] * 1000 ) ) ? false : true;
  56. };
  57. enum custom_keycodes {
  58. PLACEHOLDER = SAFE_RANGE, // can always be here
  59. EPRM,
  60. VRSN,
  61. RGB_SLD,
  62. RGB_0000FF,
  63. RGB_008000,
  64. RGB_FF0000,
  65. RGB_800080,
  66. RGB_00FF90,
  67. KC_DIABLO_CLEAR,
  68. KC_QWERTY,
  69. KC_COLEMAK,
  70. KC_DVORAK
  71. };
  72. #ifdef TAP_DANCE_ENABLE
  73. enum {
  74. TD_FLSH = 0,
  75. TD_DIABLO_1,
  76. TD_DIABLO_2,
  77. TD_DIABLO_3,
  78. TD_DIABLO_4
  79. };
  80. // on each tap, light up one led, from right to left
  81. // on the forth tap, turn them off from right to left
  82. void dance_flsh_each(qk_tap_dance_state_t *state, void *user_data) {
  83. if (!skip_leds) {
  84. ergodox_board_led_off();
  85. ergodox_right_led_1_off();
  86. ergodox_right_led_2_off();
  87. ergodox_right_led_3_off();
  88. skip_leds = true;
  89. }
  90. switch (state->count) {
  91. case 1:
  92. ergodox_right_led_1_on();
  93. break;
  94. case 2:
  95. ergodox_right_led_2_on();
  96. break;
  97. case 3:
  98. ergodox_right_led_3_on();
  99. break;
  100. case 4:
  101. ergodox_right_led_1_off();
  102. _delay_ms(50);
  103. ergodox_right_led_2_off();
  104. _delay_ms(50);
  105. ergodox_right_led_3_off();
  106. }
  107. }
  108. // on the fourth tap, set the keyboard on flash state
  109. // and set the underglow to red, because red == bad
  110. void dance_flsh_finished(qk_tap_dance_state_t *state, void *user_data) {
  111. if (state->count >= 4) {
  112. rgblight_enable();
  113. rgblight_mode(1);
  114. rgblight_setrgb(0xff,0x00,0x00);
  115. reset_keyboard();
  116. reset_tap_dance(state);
  117. }
  118. }
  119. // Cycle through the times for the macro, starting at 0, for disabled.
  120. // Max of six values, so don't exceed
  121. void diablo_tapdance_master (qk_tap_dance_state_t *state, void *user_data, uint8_t diablo_key) {
  122. if (state->count >= 7) {
  123. diablo_key_time[diablo_key] = diablo_times[0];
  124. reset_tap_dance(state);
  125. } else {
  126. diablo_key_time[diablo_key] = diablo_times[state->count - 1];
  127. }
  128. }
  129. // Would rather have one function for all of this, but no idea how to do that...
  130. void diablo_tapdance1 (qk_tap_dance_state_t *state, void *user_data) {
  131. diablo_tapdance_master (state, user_data, 0);
  132. }
  133. void diablo_tapdance2 (qk_tap_dance_state_t *state, void *user_data) {
  134. diablo_tapdance_master (state, user_data, 1);
  135. }
  136. void diablo_tapdance3 (qk_tap_dance_state_t *state, void *user_data) {
  137. diablo_tapdance_master (state, user_data, 2);
  138. }
  139. void diablo_tapdance4 (qk_tap_dance_state_t *state, void *user_data) {
  140. diablo_tapdance_master (state, user_data, 3);
  141. }
  142. // if the flash state didnt happen, then turn off leds, left to right
  143. void dance_flsh_reset(qk_tap_dance_state_t *state, void *user_data) {
  144. _delay_ms(200);
  145. ergodox_right_led_3_off();
  146. _delay_ms(200);
  147. ergodox_right_led_2_off();
  148. _delay_ms(200);
  149. ergodox_right_led_1_off();
  150. _delay_ms(500);
  151. skip_leds = false;
  152. }
  153. //Tap Dance Definitions
  154. qk_tap_dance_action_t tap_dance_actions[] = {
  155. //Once for Blue, Twice for Green, Thrice for Red, and four to flash
  156. [TD_FLSH] = ACTION_TAP_DANCE_FN_ADVANCED (dance_flsh_each, dance_flsh_finished, dance_flsh_reset),
  157. // tap once to disable, and more to enable timed micros
  158. [TD_DIABLO_1] = ACTION_TAP_DANCE_FN(diablo_tapdance1),
  159. [TD_DIABLO_2] = ACTION_TAP_DANCE_FN(diablo_tapdance2),
  160. [TD_DIABLO_3] = ACTION_TAP_DANCE_FN(diablo_tapdance3),
  161. [TD_DIABLO_4] = ACTION_TAP_DANCE_FN(diablo_tapdance4),
  162. };
  163. #endif
  164. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  165. /* Keymap 0: Basic layer
  166. *
  167. *
  168. * ,--------------------------------------------------. ,--------------------------------------------------.
  169. * | = + | 1 ! | 2 @ | 3 # | 4 $ | 5 % | TG(4)| | TG(4)| 6 ^ | 7 & | 8 * | 9 ( | 0 ) | - _ |
  170. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  171. * | TAB | Q | W | E | R | T | TG(3)| |TG(3) | Y | U | I | O | P | \ | |
  172. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  173. * | Bksp | A | S | D | F | G |------| |------| H | J | K | L | ; | ' " |
  174. * |--------+------+------+------+------+------| TG(2)| | TG(2)|------+------+------+------+------+--------|
  175. * | Shift | Z | X | C | V | B | | | | N | M | , < | . > | ? / | Shift |
  176. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  177. * | `/SYM| ' " | LGUI | [ { | ] } | | LEFT | DOWN | UP |RIGHT | SYMB |
  178. * `----------------------------------' `----------------------------------'
  179. * ,--------------. ,--------------.
  180. * |Alt/Ap| Win | | Alt |Ctl/Esc|
  181. * ,------|------|-------| |------+-------+------.
  182. * | | | Home | | PgUp | | |
  183. * | Space| Bksp |-------| |------| DEL |Enter |
  184. * | | | End | | PgDn | | |
  185. * `---------------------' `---------------------'
  186. */
  187. [QWERTY] = KEYMAP(
  188. KC_EQUAL, KC_1, KC_2, KC_3, KC_4, KC_5, TG(MOUS),
  189. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(DIABLO),
  190. KC_BSPACE, KC_A, KC_S, KC_D, KC_F, KC_G,
  191. KC_LSHIFT, CTL_T(KC_Z),KC_X, KC_C, KC_V, KC_B, TG(OVERWATCH),
  192. LT(SYMB,KC_GRAVE),KC_QUOTE, KC_LGUI, KC_LBRACKET,KC_RBRACKET,
  193. ALT_T(KC_APPLICATION), KC_LGUI,
  194. KC_HOME,
  195. KC_SPACE, KC_BSPACE, KC_END,
  196. TG(SYMB), KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINUS,
  197. TG(DVORAK), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLASH,
  198. KC_H, KC_J, KC_K, KC_L, KC_SCOLON, GUI_T(KC_QUOTE),
  199. TG(COLEMAK), KC_N, KC_M, KC_COMMA, KC_DOT, CTL_T(KC_SLASH),KC_RSHIFT,
  200. KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_FN1,
  201. KC_LALT, CTL_T(KC_ESCAPE),
  202. KC_PGUP,
  203. KC_PGDOWN, KC_DELETE, KC_ENTER
  204. ),
  205. /* Keymap 1: Basic layer
  206. *
  207. * ,--------------------------------------------------. ,--------------------------------------------------.
  208. * | = | 1 | 2 | 3 | 4 | 5 | LEFT | | RIGHT| 6 | 7 | 8 | 9 | 0 | - |
  209. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  210. * | Del | Q | W | F | P | G | L1 | | L1 | J | L | U | Y | ; | \ |
  211. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  212. * | BkSp | A | R | S | T | D |------| |------| H | N | E | I |O / L2| ' |
  213. * |--------+------+------+------+------+------| OVER | | Meh |------+------+------+------+------+--------|
  214. * | LShift |Z/Ctrl| X | C | V | B | | | | K | M | , | . |//Ctrl| RShift |
  215. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  216. * |Grv/L1| '" |AltShf| Left | Right| | Up | Down | [ | ] | ~L1 |
  217. * `----------------------------------' `----------------------------------'
  218. * ,-------------. ,-------------.
  219. * | App | LGui | | Alt |Ctrl/Esc|
  220. * ,------|------|------| |------+--------+------.
  221. * | | | Home | | PgUp | | |
  222. * | Space|Backsp|------| |------| Tab |Enter |
  223. * | |ace | End | | PgDn | | |
  224. * `--------------------' `----------------------'
  225. */
  226. // If it accepts an argument (i.e, is a function), it doesn't need KC_.
  227. // Otherwise, it needs KC_*
  228. [COLEMAK] = KEYMAP(
  229. // left hand
  230. KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, TG(MOUS),
  231. KC_DELT, KC_Q, KC_W, KC_F, KC_P, KC_G, TG(DIABLO),
  232. KC_BSPC, KC_A, KC_R, KC_S, KC_T, KC_D,
  233. KC_LSFT, CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, TG(OVERWATCH),
  234. LT(SYMB,KC_GRV),KC_QUOT, KC_LGUI, KC_LBRACKET,KC_RBRACKET,
  235. ALT_T(KC_APP), KC_LGUI,
  236. KC_HOME,
  237. KC_SPC,KC_BSPC,KC_END,
  238. // right hand
  239. KC_TRNS, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
  240. TG(DVORAK), KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSLS,
  241. KC_H, KC_N, KC_E, KC_I, LT(MOUS, KC_O), KC_QUOTE,
  242. TG(COLEMAK), KC_K, KC_M, KC_COMM,KC_DOT, CTL_T(KC_SLASH),KC_RSHIFT,
  243. KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_FN1,
  244. KC_LALT, CTL_T(KC_ESC),
  245. KC_PGUP,
  246. KC_PGDN,KC_TAB, KC_ENT
  247. ),
  248. /* Keymap 2: Basic layer
  249. *
  250. * ,--------------------------------------------------. ,--------------------------------------------------.
  251. * | = | 1 | 2 | 3 | 4 | 5 | LEFT | | RIGHT| 6 | 7 | 8 | 9 | 0 | \ |
  252. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  253. * | Del | ' | , | . | P | Y | L1 | | L1 | F | G | C | R | L | / |
  254. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  255. * | BkSp | A | O | E | U | I |------| |------| D | H | T | N |S / L2| - |
  256. * |--------+------+------+------+------+------| Hyper| | Meh |------+------+------+------+------+--------|
  257. * | LShift |:/Ctrl| Q | J | K | X | | | | B | M | W | V |Z/Ctrl| RShift |
  258. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  259. * |Grv/L1| '" |AltShf| Left | Right| | Up | Down | [ | ] | ~L1 |
  260. * `----------------------------------' `----------------------------------'
  261. * ,-------------. ,-------------.
  262. * | App | LGui | | Alt |Ctrl/Esc|
  263. * ,------|------|------| |------+--------+------.
  264. * | | | Home | | PgUp | | |
  265. * | Space|Backsp|------| |------| Tab |Enter |
  266. * | |ace | End | | PgDn | | |
  267. * `--------------------' `----------------------'
  268. */
  269. // If it accepts an argument (i.e, is a function), it doesn't need KC_.
  270. // Otherwise, it needs KC_*
  271. [DVORAK] = KEYMAP(
  272. // left hand
  273. KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, TG(MOUS),
  274. KC_DELT, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, TG(DIABLO),
  275. KC_BSPC, KC_A, KC_O, KC_E, KC_U, KC_I,
  276. KC_LSFT, CTL_T(KC_SCLN), KC_Q, KC_J, KC_K, KC_X, TG(OVERWATCH),
  277. LT(SYMB,KC_GRV),KC_QUOT, KC_LGUI, KC_LBRACKET, KC_RBRACKET,
  278. ALT_T(KC_APP), KC_LGUI,
  279. KC_HOME,
  280. KC_SPC,KC_BSPC,KC_END,
  281. // right hand
  282. KC_TRNS, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSLS,
  283. TG(DVORAK), KC_F, KC_G, KC_C, KC_R, KC_L, KC_SLSH,
  284. KC_D, KC_H, KC_T, KC_N, LT(MOUS, KC_S), KC_MINS,
  285. TG(COLEMAK), KC_B, KC_M, KC_W, KC_V, CTL_T(KC_Z), KC_RSHIFT,
  286. KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_FN1,
  287. KC_LALT, CTL_T(KC_ESC),
  288. KC_PGUP,
  289. KC_PGDN,KC_TAB, KC_ENT
  290. ),
  291. /* Keymap 3: Symbol Layer
  292. *
  293. * ,--------------------------------------------------. ,--------------------------------------------------.
  294. * | ESC | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | F11 |
  295. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  296. * | VERSION| ! | @ | { | } | | | | | | + | 7 | 8 | 9 | * | F12 |
  297. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  298. * | MAKE | # | $ | ( | ) | ` |------| |------| - | 4 | 5 | 6 | / | PrtSc |
  299. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  300. * | RESET | % | ^ | [ | ] | ~ | | | | NUM | 1 | 2 | 3 | = | PAUSE |
  301. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  302. * | LT0 | & | * | : | ; | | | 0 | NUM. | ENT | ENT |
  303. * `----------------------------------' `----------------------------------'
  304. * ,-------------. ,-------------.
  305. * | RGBM | RED | | OFF | SOLID|
  306. * ,------|------|------| |------+------+------.
  307. * | | | GREEN| | | | |
  308. * | RGB | RGB |------| |------| NUM0 | NUME |
  309. * | DARK |BRITE | BLUE | | | | |
  310. * `--------------------' `--------------------'
  311. */
  312. [SYMB] = KEYMAP(
  313. KC_ESCAPE,KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS,
  314. M_VERSION, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE, KC_TRNS,
  315. M_MAKE, KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_GRAVE,
  316. TD(TD_FLSH), KC_PERC, KC_CIRC, KC_LBRACKET,KC_RBRACKET,KC_TILD, KC_TRNS,
  317. KC_NO, KC_AMPR, KC_ASTR, KC_COLN, KC_SCOLON,
  318. KC_TRNS, KC_TRNS,
  319. KC_TRNS,
  320. KC_TRNS, KC_TRNS, KC_TRNS,
  321. KC_QWERTY, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
  322. KC_DVORAK, KC_KP_PLUS, KC_KP_7, KC_KP_8, KC_KP_9, KC_KP_ASTERISK, KC_F12,
  323. KC_KP_MINUS, KC_KP_4, KC_KP_5, KC_KP_6, KC_KP_SLASH,KC_PSCREEN,
  324. KC_COLEMAK, KC_NUMLOCK, KC_KP_1, KC_KP_2, KC_KP_3, KC_EQUAL, KC_PAUSE,
  325. KC_KP_0, KC_KP_0, KC_KP_DOT, KC_KP_ENTER, KC_TRNS,
  326. RGB_TOG, RGB_SLD,
  327. KC_NO,
  328. KC_KP_DOT, KC_KP_0, KC_KP_ENTER
  329. ),
  330. /* Keymap 4: Customized Overwatch Layout
  331. *
  332. * ,--------------------------------------------------. ,--------------------------------------------------.
  333. * | ESC | | | | | | | | | F9 | F10 | F11 | F12 | | |
  334. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  335. * | F1 | K | Q | W | E | R | T | | | | | | | | |
  336. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  337. * | TAB | G | A | S | D | F |------| |------| | | | | | |
  338. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  339. * | LCTR | LSHFT| Z | X | C | V | | | | N | M | | | | |
  340. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  341. * | J | U | I | Y | T | | | | | | |
  342. * `----------------------------------' `----------------------------------'
  343. * ,-------------. ,-------------.
  344. * | O | P | | | |
  345. * ,------|------|------| |------+------+------.
  346. * | | | LGUI | | | | |
  347. * | V | SPACE|------ |------| | Enter|
  348. * | | | H | | | | |
  349. * `--------------------' `--------------------'
  350. */
  351. [OVERWATCH] = KEYMAP(
  352. KC_ESCAPE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  353. KC_F1, KC_K, KC_Q, KC_W, KC_E, KC_R, KC_T,
  354. KC_TAB, KC_G, KC_A, KC_S, KC_D, KC_F,
  355. KC_LCTL, KC_LSHIFT, KC_Z, KC_X, KC_C, KC_V, KC_TRNS,
  356. KC_G, KC_U, KC_I, KC_Y, KC_T,
  357. KC_O, KC_P,
  358. KC_LGUI,
  359. KC_V, KC_SPACE, KC_H,
  360. KC_NO, KC_F9, KC_F10, KC_F11, KC_F12, KC_NO, KC_NO,
  361. KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
  362. KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
  363. KC_NO, KC_N, KC_M, KC_NO, KC_NO, KC_NO, KC_NO,
  364. KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
  365. KC_NO, KC_NO,
  366. KC_NO,
  367. KC_PGDOWN, KC_DELETE, KC_ENTER
  368. ),
  369. /* Keymap 3:
  370. *
  371. * ,--------------------------------------------------. ,--------------------------------------------------.
  372. * | ESC | V | D | ALT | | | | | | | | | | | |
  373. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  374. * | TAB | S | I | F | M | T | | | | | | | | | |
  375. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  376. * | Q | 1 | 2 | 3 | 4 | G |------| |------| | | | | | |
  377. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  378. * | NUMLOCK| NUM1 | NUM2 | NUM3 | NUM4 | Z | | | | | | | | | |
  379. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  380. * | LCTL | MAC1 | MAC2 | MAC3 | MAC4 | | | | | | |
  381. * `----------------------------------' `----------------------------------'
  382. * ,-------------. ,-------------.
  383. * | L | J | | | |
  384. * ,------|------|------| |------+------+------.
  385. * | | | G | | | | |
  386. * | SPACE| Q |------ |------| | |
  387. * | SHIFT| ALT | 0MAC | | | | |
  388. * `--------------------' `--------------------'
  389. */
  390. [DIABLO] = KEYMAP(
  391. KC_ESCAPE, KC_V, KC_D, KC_LALT, KC_NO, KC_NO, KC_NO,
  392. KC_TAB, KC_S, KC_F, KC_I, KC_M, KC_T, KC_TRNS,
  393. KC_Q, KC_1, KC_2, KC_3, KC_4, KC_G,
  394. KC_LCTL, TD(TD_DIABLO_1), TD(TD_DIABLO_2), TD(TD_DIABLO_3), TD(TD_DIABLO_4), KC_Z, KC_NO,
  395. KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
  396. KC_L, KC_J,
  397. KC_F,
  398. SFT_T(KC_SPACE), ALT_T(KC_Q), KC_DIABLO_CLEAR,
  399. KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
  400. KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
  401. KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
  402. KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
  403. KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
  404. KC_NO, KC_NO,
  405. KC_NO,
  406. KC_NO, KC_NO, KC_NO
  407. ),
  408. /* Keymap 4: Media and mouse keys
  409. *
  410. * ,--------------------------------------------------. ,--------------------------------------------------.
  411. * | | | | | | | | | | | | | | | |
  412. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  413. * | | | MsUp | | | | | | | | | | | | |
  414. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  415. * | |MsLeft|MsDown|MsRght| | |------| |------| | | Acc0 | Acc1 | Acc2 | |
  416. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  417. * | | Acc0 | Acc1 | Acc2 | | | | | | Play | Stop | Mute |VolDn |VolUp | |
  418. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  419. * | | | | | | | | | | | |
  420. * `----------------------------------' `----------------------------------'
  421. * ,-------------. ,-------------.
  422. * | | | | | |
  423. * ,------|------|------| |------+------+------.
  424. * | | | MWUp | | | | |
  425. * | Lclk | Rclk |------| |------| MBn4 | MBn4 |
  426. * | | | MWDn | | Mclk | | |
  427. * `--------------------' `--------------------'
  428. */
  429. [MOUS] = KEYMAP(
  430. KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_TRNS,
  431. KC_NO, KC_NO, KC_MS_UP, KC_NO, KC_NO, KC_NO, KC_TRNS,
  432. KC_NO, KC_MS_LEFT, KC_MS_DOWN, KC_MS_RIGHT,KC_NO, KC_NO,
  433. KC_NO, KC_MS_ACCEL0,KC_MS_ACCEL1,KC_MS_ACCEL2,KC_NO, KC_NO, KC_TRNS,
  434. KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
  435. KC_NO,KC_NO,
  436. KC_MS_WH_UP,
  437. KC_MS_BTN1,KC_MS_BTN2,KC_MS_WH_DOWN,
  438. KC_TRNS,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,
  439. KC_TRNS,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,
  440. KC_NO,KC_NO,KC_MS_ACCEL0,KC_MS_ACCEL1,KC_MS_ACCEL2,KC_NO,KC_NO,
  441. KC_TRNS,KC_MEDIA_PLAY_PAUSE,KC_MEDIA_STOP,KC_AUDIO_MUTE,KC_AUDIO_VOL_DOWN,KC_AUDIO_VOL_UP,KC_NO,
  442. KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,
  443. KC_NO,KC_NO,
  444. KC_NO,
  445. KC_MS_BTN3,KC_MS_BTN4,KC_MS_BTN5
  446. ),
  447. };
  448. const uint16_t PROGMEM fn_actions[] = {
  449. [1] = ACTION_LAYER_TAP_TOGGLE(SYMB),
  450. // FN1 - Momentary Layer 1 (Symbols)
  451. };
  452. void action_function(keyrecord_t *event, uint8_t id, uint8_t opt)
  453. {
  454. }
  455. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
  456. {
  457. switch(id) {
  458. case 0:
  459. if (record->event.pressed) {
  460. // Output Keyboard Firmware info
  461. SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
  462. return false;
  463. }
  464. case 1:
  465. if (record->event.pressed) {
  466. // make ergodox-ez-drashna-custom-teensy
  467. return MACRO(I(5), T(M), T(A), T(K), T(E), T(SPACE), T(E), T(R), T(G), T(O), T(D), T(O), T(X), D(LSFT), T(MINUS), U(LSFT), T(E), T(Z), T(MINUS), T(D), T(R), T(A), T(S), T(H), T(N), T(A), T(MINUS), T(C), T(U), T(S), T(T), T(O), T(M), T(MINUS), T(T), T(E), T(E), T(N), T(S), T(Y), T(ENTER), END);
  468. }
  469. }
  470. return MACRO_NONE;
  471. };
  472. void persistent_default_layer_set(uint16_t default_layer) {
  473. eeconfig_update_default_layer(default_layer);
  474. default_layer_set(default_layer);
  475. }
  476. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  477. switch (keycode) {
  478. // dynamically generate these.
  479. case EPRM:
  480. if (record->event.pressed) {
  481. eeconfig_init();
  482. }
  483. return false;
  484. break;
  485. case VRSN:
  486. if (record->event.pressed) {
  487. SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
  488. }
  489. return false;
  490. break;
  491. case RGB_SLD:
  492. if (record->event.pressed) {
  493. rgblight_mode(1);
  494. }
  495. return false;
  496. break;
  497. case RGB_0000FF:
  498. if (record->event.pressed) {
  499. #ifdef RGBLIGHT_ENABLE
  500. rgblight_enable();
  501. rgblight_mode(1);
  502. rgblight_setrgb(0x00,0x00,0xff);
  503. #endif
  504. }
  505. return false;
  506. break;
  507. case RGB_008000:
  508. if (record->event.pressed) {
  509. #ifdef RGBLIGHT_ENABLE
  510. rgblight_enable();
  511. rgblight_mode(1);
  512. rgblight_setrgb(0x00,0x80,0x00);
  513. #endif
  514. }
  515. return false;
  516. break;
  517. case RGB_FF0000:
  518. if (record->event.pressed) {
  519. #ifdef RGBLIGHT_ENABLE
  520. rgblight_enable();
  521. rgblight_mode(1);
  522. rgblight_setrgb(0xff,0x00,0x00);
  523. #endif
  524. }
  525. return false;
  526. break;
  527. case RGB_800080:
  528. if (record->event.pressed) {
  529. #ifdef RGBLIGHT_ENABLE
  530. rgblight_enable();
  531. rgblight_mode(1);
  532. rgblight_setrgb(0x80,0x00,0x80);
  533. #endif
  534. }
  535. return false;
  536. break;
  537. case RGB_00FF90:
  538. if (record->event.pressed) {
  539. #ifdef RGBLIGHT_ENABLE
  540. rgblight_enable();
  541. rgblight_mode(1);
  542. rgblight_setrgb(0x00,0xff,0x90);
  543. #endif
  544. }
  545. return false;
  546. break;
  547. case KC_DIABLO_CLEAR: // reset all Diable timers, disabling them
  548. if (record->event.pressed) {
  549. uint8_t dtime;
  550. for (dtime = 0; dtime < 4; dtime++) {
  551. diablo_key_time[dtime] = diablo_times[0];
  552. }
  553. }
  554. return false;
  555. break;
  556. case KC_QWERTY:
  557. if (record->event.pressed) {
  558. persistent_default_layer_set(1UL << QWERTY);
  559. }
  560. return false;
  561. break;
  562. case KC_COLEMAK:
  563. if (record->event.pressed) {
  564. persistent_default_layer_set(1UL << COLEMAK);
  565. }
  566. return false;
  567. break;
  568. case KC_DVORAK:
  569. if (record->event.pressed) {
  570. persistent_default_layer_set(1UL << DVORAK);
  571. }
  572. return false;
  573. break;
  574. }
  575. return true;
  576. }
  577. // Sends the key press to system, but only if on the Diablo layer
  578. void send_diablo_keystroke (uint8_t diablo_key) {
  579. if (current_layer == DIABLO) {
  580. switch (diablo_key) {
  581. case 0:
  582. SEND_STRING("1");
  583. break;
  584. case 1:
  585. SEND_STRING("2");
  586. break;
  587. case 2:
  588. SEND_STRING("3");
  589. break;
  590. case 3:
  591. SEND_STRING("4");
  592. break;
  593. }
  594. }
  595. }
  596. // Checks each of the 4 timers/keys to see if enough time has elapsed
  597. // Runs the "send string" command if enough time has passed, and resets the timer.
  598. void run_diablo_macro_check(void) {
  599. uint8_t dtime;
  600. for (dtime = 0; dtime < 4; dtime++) {
  601. if (check_dtimer(dtime) && diablo_key_time[dtime]) {
  602. diablo_timer[dtime] = timer_read();
  603. send_diablo_keystroke(dtime);
  604. }
  605. }
  606. }
  607. void matrix_init_user(void) { // Runs boot tasks for keyboard
  608. };
  609. void matrix_scan_user(void) { // runs frequently to update info
  610. uint8_t modifiders = get_mods();
  611. uint8_t layer = biton32(layer_state);
  612. bool l_dvorak = false;
  613. bool l_colemak = false;
  614. static bool has_layer_changed = true;
  615. if (!skip_leds) {
  616. ergodox_board_led_off();
  617. ergodox_right_led_1_off();
  618. ergodox_right_led_2_off();
  619. ergodox_right_led_3_off();
  620. // Since we're not using the LEDs here for layer indication anymore,
  621. // then lets use them for modifier indicators. Shame we don't have 4...
  622. // Also, no "else", since we want to know each, independantly.
  623. if ( modifiders & MODS_SHIFT_MASK) {
  624. ergodox_right_led_1_on();
  625. }
  626. if ( modifiders & MODS_CTRL_MASK) {
  627. ergodox_right_led_2_on();
  628. }
  629. if ( modifiders & MODS_ALT_MASK) {
  630. ergodox_right_led_3_on();
  631. }
  632. }
  633. if (layer != current_layer) {
  634. has_layer_changed = true;
  635. current_layer = layer;
  636. }
  637. // Check layer, and apply color if its changed since last check
  638. if (has_layer_changed) {
  639. uint8_t default_layer = 0;
  640. default_layer = eeconfig_read_default_layer();
  641. if (default_layer & (1UL << DVORAK)) {
  642. l_dvorak = true;
  643. }
  644. else if (default_layer & (1UL << COLEMAK)) {
  645. l_colemak = true;
  646. }
  647. switch (layer) {
  648. case SYMB:
  649. rgblight_set_blue;
  650. rgblight_mode(2);
  651. break;
  652. case OVERWATCH:
  653. rgblight_set_orange;
  654. rgblight_mode(17);
  655. break;
  656. case DIABLO:
  657. rgblight_set_red;
  658. rgblight_mode(5);
  659. break;
  660. case MOUS:
  661. rgblight_set_urine;
  662. break;
  663. case COLEMAK:
  664. rgblight_set_magenta;
  665. break;
  666. case DVORAK:
  667. rgblight_set_green;
  668. break;
  669. case 7:
  670. rgblight_sethsv (255,255,255);
  671. break;
  672. default:
  673. if (l_colemak) {
  674. rgblight_set_magenta;
  675. }
  676. else if (l_dvorak) {
  677. rgblight_set_green;
  678. }
  679. else {
  680. rgblight_set_teal;
  681. }
  682. rgblight_mode(1);
  683. break;
  684. }
  685. has_layer_changed = false;
  686. }
  687. // Run Diablo 3 macro checking code.
  688. run_diablo_macro_check();
  689. };