keymap.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. /* Copyright 2015-2017 Jack Humbert
  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 "muse.h"
  18. bool is_lgui_active = false;
  19. uint16_t lgui_timer = 0;
  20. enum planck_layers { _COLEMAK, _LOWER, _RAISE, _EXTEND, _MACRO, _ADJUST };
  21. enum planck_keycodes {
  22. KI_BSPC = SAFE_RANGE,
  23. KI_COMM,
  24. KI_DOT,
  25. KI_ESC,
  26. KI_QUOT,
  27. KI_SCLN,
  28. KI_SLSH,
  29. KI_TAB,
  30. KI_A,
  31. KI_B,
  32. KI_C,
  33. KI_D,
  34. KI_E,
  35. KI_F,
  36. KI_G,
  37. KI_H,
  38. KI_I,
  39. KI_J,
  40. KI_K,
  41. KI_L,
  42. KI_M,
  43. KI_N,
  44. KI_O,
  45. KI_P,
  46. KI_Q,
  47. KI_R,
  48. KI_S,
  49. KI_T,
  50. KI_U,
  51. KI_V,
  52. KI_W,
  53. KI_X,
  54. KI_Y,
  55. KI_Z,
  56. KI_WLFT,
  57. KI_WRGT,
  58. KI_WUP,
  59. KI_WDN
  60. };
  61. #define LOWER MO(_LOWER)
  62. #define RAISE MO(_RAISE)
  63. #define MACROS MO(_MACRO)
  64. #define EXTEND MO(_EXTEND)
  65. #define SPC_LOW LT(_LOWER, KC_SPC)
  66. #define SPC_RAI LT(_RAISE, KC_SPC)
  67. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  68. /* Colemak
  69. * ,------------------------------------------------------------------------------------.
  70. * | Tab | Q | W | F | P | G | J | L | U | Y | ; | Bksp |
  71. * |------+------+------+------+------+-------+-------+------+------+------+------+------|
  72. * | Esc | A | R | S | T | D | H | N | E | I | O | " |
  73. * |------+------+------+------+------+-------+-------+------+------+------+------+------|
  74. * | Shift| Z | X | C | V | B | K | M | , | . | / |Enter |
  75. * |------+------+------+------+------+-------+-------+------+------+------+------+------|
  76. * | Brite| Ctrl | Alt | GUI |Lower |SPC_LOW|SPC_RAI|Raise | Left | Down | Up |Right |
  77. * `-------------------------------------------------------------------------------------'
  78. */
  79. [_COLEMAK] = LAYOUT_planck_grid(
  80. KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC,
  81. EXTEND, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT,
  82. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT,
  83. MACROS, KC_LCTL, KC_LALT, KC_LGUI, LOWER, SPC_LOW, SPC_RAI, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
  84. ),
  85. /* Lower
  86. * ,-----------------------------------------------------------------------------------.
  87. * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
  88. * |------+------+------+------+------+------+------+------+------+------+------+------|
  89. * | | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | |
  90. * |------+------+------+------+------+------+------+------+------+------+------+------|
  91. * | | F7 | F8 | F9 | F10 | F11 | F12 |XXXXXX|XXXXXX| Home | End | |
  92. * |------+------+------+------+------+------+------+------+------+------+------+------|
  93. * | | | | | | | | | Next | Vol- | Vol+ | Play |
  94. * `-----------------------------------------------------------------------------------'
  95. */
  96. [_LOWER] = LAYOUT_planck_grid(
  97. KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC,
  98. _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE,
  99. _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX, XXXXXXX, KC_HOME, KC_END, _______,
  100. _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY
  101. ),
  102. /* Raise
  103. * ,-----------------------------------------------------------------------------------.
  104. * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
  105. * |------+------+------+------+------+------+------+------+------+------+------+------|
  106. * | | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ |
  107. * |------+------+------+------+------+------+------+------+------+------+------+------|
  108. * | | F7 | F8 | F9 | F10 | F11 | F12 |XXXXXX|XXXXXX|Pg Up |Pg Dn | |
  109. * |------+------+------+------+------+------+------+------+------+------+------+------|
  110. * | | | | | | | | | Next | Vol- | Vol+ | Play |
  111. * `-----------------------------------------------------------------------------------'
  112. */
  113. [_RAISE] = LAYOUT_planck_grid(
  114. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC,
  115. _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS,
  116. _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX, XXXXXXX, KC_PGUP, KC_PGDN, _______,
  117. _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY
  118. ),
  119. /* Extend
  120. * ,-----------------------------------------------------------------------------------.
  121. * | | Esc | WH_U | WBAK | WFWD | MS_U | PgUp | Home | Up | End | Del | Esc |
  122. * |------+------+------+------+------+------+------+------+------+------+------+------|
  123. * | | Alt | WH_D |Shift | Ctrl | MS_D | PgDn | Left | Down |Right | Bksp | Menu |
  124. * |------+------+------+------+------+------+------+------+------+------+------+------|
  125. * | WH_L | Undo | Cut | Copy |Paste |MS_B_1|MS_B_2|MS_B_3| MS_L | MS_R | WH_R | |
  126. * |------+------+------+------+------+------+------+------+------+------+------+------|
  127. * | | | | | | | | | | | | |
  128. * `-----------------------------------------------------------------------------------'
  129. */
  130. [_EXTEND] = LAYOUT_planck_grid(
  131. _______, KC_ESC, KC_WH_U, KC_WBAK, KC_WFWD, KC_MS_U, KC_PGUP, KC_HOME, KC_UP, KC_END, KC_DEL, KC_ESC,
  132. _______, KC_LALT, KC_WH_D, KC_LSFT, KC_LCTL, KC_MS_D, KC_PGDN, KC_LEFT, KC_DOWN, KC_RGHT, KC_BSPC, KC_APP,
  133. KC_WH_L, KC_UNDO, KC_CUT, KC_COPY, KC_PSTE, KC_BTN1, KC_BTN2, KC_BTN3, KC_MS_L, KC_MS_R, KC_WH_R, _______,
  134. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
  135. ),
  136. /* Macros
  137. * ,--------------------------------------------------------------------------------------.
  138. * |KI_TAB| KI_Q | KI_W | KI_F | KI_P | KI_G | KI_J | KI_L | KI_U | KI_Y |KI_SCLN|KI_BSPC|
  139. * |------+------+------+------+------+------+------+------+-------+------+-------+-------|
  140. * |KI_ESC| KI_A | KI_R | KI_S | KI_T | KI_D | KI_H | KI_N | KI_E | KI_I | KI_O |KI_QUOT|
  141. * |------+------+------+------+------+------+------+------+-------+------+-------+-------|
  142. * | | KI_Z | KI_X | KI_C | KI_V | KI_B | KI_K | KI_M |KI_COMM|KI_DOT|KI_SLSH| |
  143. * |------+------+------+------+------+------+------+------+-------+------+-------+-------|
  144. * | | | | | | | | |KI_WLFT|KI_WDN|KI_WUP |KI_WGRT|
  145. * `--------------------------------------------------------------------------------------'
  146. */
  147. [_MACRO] = LAYOUT_planck_grid(
  148. KI_TAB, KI_Q, KI_W, KI_F, KI_P, KI_G, KI_J, KI_L, KI_U, KI_Y, KI_SCLN, KI_BSPC,
  149. KI_ESC, KI_A, KI_R, KI_S, KI_T, KI_D, KI_H, KI_N, KI_E, KI_I, KI_O, KI_QUOT,
  150. _______, KI_Z, KI_X, KI_C, KI_V, KI_B, KI_K, KI_M, KI_COMM, KI_DOT, KI_SLSH, _______,
  151. _______, _______, _______, _______, _______, _______, _______, _______, KI_WLFT, KI_WDN, KI_WUP, KI_WRGT
  152. ),
  153. /* Adjust (Lower + Raise)
  154. * ,-----------------------------------------------------------------------------------.
  155. * | | Reset| Debug| | | | | | | | | |
  156. * |------+------+------+------+------+------+------+------+------+------+------+------|
  157. * | | | | | |AGnorm|AGswap| |Colemk| | | |
  158. * |------+------+------+------+------+------+------+------+------+------+------+------|
  159. * | | | | | | | |TermOn|TrmOff| | | |
  160. * |------+------+------+------+------+------+------+------+------+------+------+------|
  161. * | | | | | | | | | | | | |
  162. * `-----------------------------------------------------------------------------------'
  163. */
  164. [_ADJUST] = LAYOUT_planck_grid(
  165. _______, RESET, DEBUG, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  166. _______, _______, _______, _______, _______, AG_NORM, AG_SWAP, _______, _______, _______, _______, _______,
  167. _______, _______, _______, _______, _______, _______, _______, TERM_ON, TERM_OFF, _______, _______, _______,
  168. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
  169. )
  170. };
  171. layer_state_t layer_state_set_user(layer_state_t state) { return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST); }
  172. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  173. switch (keycode)
  174. //
  175. // Non-Alpha Macros
  176. //
  177. // 'Backspace' Macro
  178. case KI_BSPC:
  179. if (record->event.pressed) {
  180. // Reserved for future use
  181. //SEND_STRING("RESERVED Backspace");
  182. } else {
  183. }
  184. return false; // Skip all further processing of this key
  185. break;
  186. // 'Comma' Macro
  187. case KI_COMM:
  188. if (record->event.pressed) {
  189. // Reserved for future use
  190. //SEND_STRING("RESERVED Comma");
  191. } else {
  192. }
  193. return false; // Skip all further processing of this key
  194. break;
  195. // 'Dot' Macro
  196. case KI_DOT:
  197. if (record->event.pressed) {
  198. // Reserved for future use
  199. //SEND_STRING("RESERVED Dot");
  200. } else {
  201. }
  202. return false; // Skip all further processing of this key
  203. break;
  204. // 'Escape' Macro
  205. case KI_ESC:
  206. if (record->event.pressed) {
  207. // Reserved for future use
  208. //SEND_STRING("RESERVED Escape");
  209. } else {
  210. }
  211. // 'Quote' Macro
  212. case KI_QUOT:
  213. if (record->event.pressed) {
  214. // Reserved for future use
  215. //SEND_STRING("RESERVED Quote");
  216. } else {
  217. }
  218. return false; // Skip all further processing of this key
  219. break;
  220. // 'Semicolon' Macro
  221. case KI_SCLN:
  222. if (record->event.pressed) {
  223. // Reserved for future use
  224. //SEND_STRING("RESERVED Semicolon");
  225. } else {
  226. }
  227. return false; // Skip all further processing of this key
  228. break;
  229. // 'Slash' Macro
  230. case KI_SLSH:
  231. if (record->event.pressed) {
  232. // Reserved for future use
  233. //SEND_STRING("RESERVED Slash");
  234. } else {
  235. }
  236. return false; // Skip all further processing of this key
  237. break;
  238. // 'Tab' Macro
  239. case KI_TAB:
  240. if (record->event.pressed) {
  241. // Reserved for future use
  242. //SEND_STRING("RESERVED Tab");
  243. } else {
  244. }
  245. return false; // Skip all further processing of this key
  246. break;
  247. //
  248. // Alpha Macros
  249. //
  250. // 'A' Macro
  251. case KI_A:
  252. if (record->event.pressed) {
  253. // Reserved for future use
  254. //SEND_STRING("RESERVED A");
  255. } else {
  256. }
  257. return false; // Skip all further processing of this key
  258. break;
  259. // 'B' Macro
  260. case KI_B:
  261. if (record->event.pressed) {
  262. // Reserved for future use
  263. //SEND_STRING("RESERVED B");
  264. } else {
  265. }
  266. return false; // Skip all further processing of this key
  267. break;
  268. // 'C' Macro
  269. case KI_C:
  270. if (record->event.pressed) {
  271. // Reserved for future use
  272. //SEND_STRING("RESERVED C");
  273. } else {
  274. }
  275. return false; // Skip all further processing of this key
  276. break;
  277. // 'D' Macro
  278. case KI_D:
  279. if (record->event.pressed) {
  280. // Reserved for future use
  281. //SEND_STRING("RESERVED D");
  282. } else {
  283. }
  284. return false; // Skip all further processing of this key
  285. break;
  286. // 'E' Macro
  287. case KI_E:
  288. if (record->event.pressed) {
  289. // Reserved for future use
  290. //SEND_STRING("RESERVED E");
  291. } else {
  292. }
  293. return false; // Skip all further processing of this key
  294. break;
  295. // 'F' Macro
  296. case KI_F:
  297. if (record->event.pressed) {
  298. // Reserved for future use
  299. //SEND_STRING("RESERVED F");
  300. } else {
  301. }
  302. return false; // Skip all further processing of this key
  303. break;
  304. // 'G' Macro
  305. case KI_G:
  306. if (record->event.pressed) {
  307. // Reserved for future use
  308. //SEND_STRING("RESERVED G");
  309. } else {
  310. }
  311. return false; // Skip all further processing of this key
  312. break;
  313. // 'H' Macro
  314. case KI_H:
  315. if (record->event.pressed) {
  316. // Reserved for future use
  317. //SEND_STRING("RESERVED H");
  318. } else {
  319. }
  320. return false; // Skip all further processing of this key
  321. break;
  322. // 'I' Macro
  323. case KI_I:
  324. if (record->event.pressed) {
  325. // Reserved for future use
  326. //SEND_STRING("RESERVED I");
  327. } else {
  328. }
  329. return false; // Skip all further processing of this key
  330. break;
  331. // 'J' Macro
  332. case KI_J:
  333. if (record->event.pressed) {
  334. // Reserved for future use
  335. //SEND_STRING("RESERVED J");
  336. } else {
  337. }
  338. return false; // Skip all further processing of this key
  339. break;
  340. // 'K' Macro
  341. case KI_K:
  342. if (record->event.pressed) {
  343. // Reserved for future use
  344. //SEND_STRING("RESERVED K");
  345. } else {
  346. }
  347. return false; // Skip all further processing of this key
  348. break;
  349. // 'L' Macro
  350. case KI_L:
  351. if (record->event.pressed) {
  352. // Reserved for future use
  353. //SEND_STRING("RESERVED L");
  354. } else {
  355. }
  356. return false; // Skip all further processing of this key
  357. break;
  358. // 'M' Macro
  359. case KI_M:
  360. if (record->event.pressed) {
  361. // Reserved for future use
  362. //SEND_STRING("RESERVED M");
  363. } else {
  364. }
  365. return false; // Skip all further processing of this key
  366. break;
  367. // 'N' Macro
  368. case KI_N:
  369. if (record->event.pressed) {
  370. // Reserved for future use
  371. //SEND_STRING("RESERVED N");
  372. } else {
  373. }
  374. return false; // Skip all further processing of this key
  375. break;
  376. // 'O' Macro
  377. case KI_O:
  378. if (record->event.pressed) {
  379. // Reserved for future use
  380. //SEND_STRING("RESERVED O");
  381. } else {
  382. }
  383. return false; // Skip all further processing of this key
  384. break;
  385. // 'P' Macro
  386. case KI_P:
  387. if (record->event.pressed) {
  388. // Reserved for future use
  389. //SEND_STRING("RESERVED P");
  390. } else {
  391. }
  392. return false; // Skip all further processing of this key
  393. break;
  394. // 'Q' Macro
  395. case KI_Q:
  396. if (record->event.pressed) {
  397. // Reserved for future use
  398. //SEND_STRING("RESERVED Q");
  399. } else {
  400. }
  401. return false; // Skip all further processing of this key
  402. break;
  403. // 'R' Macro
  404. case KI_R:
  405. if (record->event.pressed) {
  406. // Reserved for future use
  407. //SEND_STRING("RESERVED R");
  408. } else {
  409. }
  410. return false; // Skip all further processing of this key
  411. break;
  412. // 'S' Macro
  413. case KI_S:
  414. if (record->event.pressed) {
  415. // Reserved for future use
  416. //SEND_STRING("RESERVED S");
  417. } else {
  418. }
  419. return false; // Skip all further processing of this key
  420. break;
  421. // 'T' Macro
  422. case KI_T:
  423. if (record->event.pressed) {
  424. // Reserved for future use
  425. //SEND_STRING("RESERVED T");
  426. } else {
  427. }
  428. return false; // Skip all further processing of this key
  429. break;
  430. // 'U' Macro
  431. case KI_U:
  432. if (record->event.pressed) {
  433. // Reserved for future use
  434. //SEND_STRING("RESERVED U");
  435. } else {
  436. }
  437. return false; // Skip all further processing of this key
  438. break;
  439. // 'V' Macro
  440. case KI_V:
  441. if (record->event.pressed) {
  442. // Reserved for future use
  443. //SEND_STRING("RESERVED V");
  444. } else {
  445. }
  446. return false; // Skip all further processing of this key
  447. break;
  448. // 'W' Macro
  449. case KI_W:
  450. if (record->event.pressed) {
  451. // Reserved for future use
  452. //SEND_STRING("RESERVED W");
  453. } else {
  454. }
  455. return false; // Skip all further processing of this key
  456. break;
  457. // 'X' Macro
  458. case KI_X:
  459. if (record->event.pressed) {
  460. // Reserved for future use
  461. //SEND_STRING("RESERVED X");
  462. } else {
  463. }
  464. return false; // Skip all further processing of this key
  465. break;
  466. // 'Y' Macro
  467. case KI_Y:
  468. if (record->event.pressed) {
  469. // Reserved for future use
  470. //SEND_STRING("RESERVED Y");
  471. } else {
  472. }
  473. return false; // Skip all further processing of this key
  474. break;
  475. // 'Z' Macro
  476. case KI_Z:
  477. if (record->event.pressed) {
  478. // Reserved for future use
  479. //SEND_STRING("RESERVED Z");
  480. } else {
  481. }
  482. return false; // Skip all further processing of this key
  483. break;
  484. //
  485. // Arrow key macros
  486. //
  487. // Windows Win+Left tap to move window without resetting KC_LGUI
  488. // Additional code is in matrix_scan_user()
  489. case KI_WLFT:
  490. if (record->event.pressed) {
  491. if (!is_lgui_active) {
  492. is_lgui_active = true;
  493. register_code(KC_LGUI);
  494. }
  495. lgui_timer = timer_read();
  496. tap_code(KC_LEFT);
  497. } else {
  498. }
  499. return false; // Skip all further processing of this key
  500. break;
  501. // Windows Win+Right tap to move window without resetting KC_LGUI
  502. // Additional code is in matrix_scan_user()
  503. case KI_WRGT:
  504. if (record->event.pressed) {
  505. if (!is_lgui_active) {
  506. is_lgui_active = true;
  507. register_code(KC_LGUI);
  508. }
  509. lgui_timer = timer_read();
  510. tap_code(KC_RIGHT);
  511. } else {
  512. }
  513. return false; // Skip all further processing of this key
  514. break;
  515. // Windows Win+Up tap to move window without resetting KC_LGUI
  516. // Additional code is in matrix_scan_user()
  517. case KI_WUP:
  518. if (record->event.pressed) {
  519. if (!is_lgui_active) {
  520. is_lgui_active = true;
  521. register_code(KC_LGUI);
  522. }
  523. lgui_timer = timer_read();
  524. tap_code(KC_UP);
  525. } else {
  526. }
  527. return false; // Skip all further processing of this key
  528. break;
  529. // Windows Win+Down tap to move window without resetting KC_LGUI
  530. // Additional code is in matrix_scan_user()
  531. case KI_WDN:
  532. if (record->event.pressed) {
  533. if (!is_lgui_active) {
  534. is_lgui_active = true;
  535. register_code(KC_LGUI);
  536. }
  537. lgui_timer = timer_read();
  538. tap_code(KC_DOWN);
  539. } else {
  540. }
  541. return false; // Skip all further processing of this key
  542. break;
  543. default:
  544. return true; // Process all other keycodes normally
  545. break;
  546. }
  547. return true;
  548. }
  549. void matrix_scan_user(void) {
  550. // Check if KC_LGUI is active in KI_WLFT, KI_WRGT, KI_WUP
  551. if (is_lgui_active) {
  552. if (timer_elapsed(lgui_timer) > 1000) {
  553. unregister_code(KC_LGUI);
  554. is_lgui_active = false;
  555. }
  556. }
  557. }