drashna.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. /*
  2. Copyright 2017 Christopher Courtney <drashna@live.com> @drashna
  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. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #pragma once
  15. #include "quantum.h"
  16. #include "version.h"
  17. #include "eeprom.h"
  18. #include "send_unicode.h"
  19. #ifdef RGB_MATRIX_ENABLE
  20. #include "rgb_matrix.h"
  21. #endif
  22. // Define layer names
  23. enum userspace_layers {
  24. _QWERTY = 0,
  25. _NUMLOCK = 0,
  26. _COLEMAK,
  27. _DVORAK,
  28. _WORKMAN,
  29. _MODS,
  30. _GAMEPAD,
  31. _DIABLO,
  32. _MACROS,
  33. _MEDIA,
  34. _LOWER,
  35. _RAISE,
  36. _ADJUST,
  37. };
  38. //define modifiers
  39. #define MODS_SHIFT_MASK (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT))
  40. #define MODS_CTRL_MASK (MOD_BIT(KC_LCTL)|MOD_BIT(KC_RCTRL))
  41. #define MODS_ALT_MASK (MOD_BIT(KC_LALT)|MOD_BIT(KC_RALT))
  42. #define MODS_GUI_MASK (MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI))
  43. // RGB color codes are no longer located here anymore. Instead, you will want to
  44. // head to https://github.com/qmk/qmk_firmware/blob/master/quantum/rgblight_list.h
  45. extern bool rgb_layer_change;
  46. #ifdef RGBLIGHT_ENABLE
  47. void rgblight_sethsv_default_helper(uint8_t index);
  48. #endif // RGBLIGHT_ENABLE
  49. inline void tap(uint16_t keycode){ register_code(keycode); unregister_code(keycode); };
  50. bool mod_key_press_timer (uint16_t code, uint16_t mod_code, bool pressed);
  51. bool mod_key_press (uint16_t code, uint16_t mod_code, bool pressed, uint16_t this_timer);
  52. #define EECONFIG_USERSPACE (uint32_t *)19
  53. typedef union {
  54. uint32_t raw;
  55. struct {
  56. bool rgb_layer_change :1;
  57. bool is_overwatch :1;
  58. bool nuke_switch :1;
  59. uint8_t unicode_mod :4;
  60. };
  61. } userspace_config_t;
  62. #if defined(KEYMAP_SAFE_RANGE)
  63. #define PLACEHOLDER_SAFE_RANGE KEYMAP_SAFE_RANGE
  64. #else
  65. #define PLACEHOLDER_SAFE_RANGE SAFE_RANGE
  66. #endif
  67. enum userspace_custom_keycodes {
  68. EPRM = PLACEHOLDER_SAFE_RANGE, // Resets EEPROM do defaults (as in eeconfig_init)
  69. VRSN, // Prints QMK Firmware and board info
  70. KC_QWERTY, // Sets default layer to QWERTY
  71. KC_COLEMAK, // Sets default layer to COLEMAK
  72. KC_DVORAK, // Sets default layer to DVORAK
  73. KC_WORKMAN, // Sets default layer to WORKMAN
  74. KC_DIABLO_CLEAR, // Clears all Diablo Timers
  75. KC_OVERWATCH, // Toggles game macro input mode (so in OW, it defaults to game chat)
  76. KC_SALT, // See drashna.c for details
  77. KC_MORESALT,
  78. KC_SALTHARD,
  79. KC_GOODGAME,
  80. KC_SYMM,
  81. KC_JUSTGAME,
  82. KC_GLHF,
  83. KC_TORB,
  84. KC_AIM,
  85. KC_C9,
  86. KC_GGEZ,
  87. KC_MAKE, // Run keyboard's customized make command
  88. KC_RGB_T, // Toggles RGB Layer Indication mode
  89. KC_SECRET_1, // test1
  90. KC_SECRET_2, // test2
  91. KC_SECRET_3, // test3
  92. KC_SECRET_4, // test4
  93. KC_SECRET_5, // test5
  94. KC_CCCV, // Hold to copy, tap to paste
  95. KC_NUKE, // NUCLEAR LAUNCH DETECTED!!!
  96. UC_FLIP, // (ಠ痊ಠ)┻━┻
  97. UC_TABL, // ┬─┬ノ( º _ ºノ)
  98. UC_SHRG, // ¯\_(ツ)_/¯
  99. UC_DISA, // ಠ_ಠ
  100. NEW_SAFE_RANGE //use "NEWPLACEHOLDER for keymap specific codes
  101. };
  102. #define LOWER MO(_LOWER)
  103. #define RAISE MO(_RAISE)
  104. #define ADJUST MO(_ADJUST)
  105. #define TG_MODS TG(_MODS)
  106. #define TG_GAME TG(_GAMEPAD)
  107. #define KC_SEC1 KC_SECRET_1
  108. #define KC_SEC2 KC_SECRET_2
  109. #define KC_SEC3 KC_SECRET_3
  110. #define KC_SEC4 KC_SECRET_4
  111. #define KC_SEC5 KC_SECRET_5
  112. #define QWERTY KC_QWERTY
  113. #define DVORAK KC_DVORAK
  114. #define COLEMAK KC_COLEMAK
  115. #define WORKMAN KC_WORKMAN
  116. #define KC_RESET RESET
  117. #define KC_RST KC_RESET
  118. #ifdef SWAP_HANDS_ENABLE
  119. #define KC_C1R3 SH_TT
  120. #else // SWAP_HANDS_ENABLE
  121. #define KC_C1R3 KC_BSPC
  122. #endif // SWAP_HANDS_ENABLE
  123. #define BK_LWER LT(_LOWER, KC_BSPC)
  124. #define SP_LWER LT(_LOWER, KC_SPC)
  125. #define DL_RAIS LT(_RAISE, KC_DEL)
  126. #define ET_RAIS LT(_RAISE, KC_ENTER)
  127. // OSM keycodes, to keep things clean and easy to change
  128. #define KC_MLSF OSM(MOD_LSFT)
  129. #define KC_MRSF OSM(MOD_RSFT)
  130. #define OS_LGUI OSM(MOD_LGUI)
  131. #define OS_RGUI OSM(MOD_RGUI)
  132. #define OS_LSFT OSM(MOD_LSFT)
  133. #define OS_RSFT OSM(MOD_RSFT)
  134. #define OS_LCTL OSM(MOD_LCTL)
  135. #define OS_RCTL OSM(MOD_RCTL)
  136. #define OS_LALT OSM(MOD_LALT)
  137. #define OS_RALT OSM(MOD_RALT)
  138. #define ALT_APP ALT_T(KC_APP)
  139. #define MG_NKRO MAGIC_TOGGLE_NKRO
  140. #define UC_IRNY UC(0x2E2E)
  141. #define UC_CLUE UC(0x203D)
  142. #ifdef TAP_DANCE_ENABLE
  143. enum {
  144. TD_D3_1 = 0,
  145. TD_D3_2,
  146. TD_D3_3,
  147. TD_D3_4
  148. };
  149. #endif // TAP_DANCE_ENABLE
  150. // Custom Keycodes for Diablo 3 layer
  151. // But since TD() doesn't work when tap dance is disabled
  152. // We use custom codes here, so we can substitute the right stuff
  153. #ifdef TAP_DANCE_ENABLE
  154. #define KC_D3_1 TD(TD_D3_1)
  155. #define KC_D3_2 TD(TD_D3_2)
  156. #define KC_D3_3 TD(TD_D3_3)
  157. #define KC_D3_4 TD(TD_D3_4)
  158. #else // TAP_DANCE_ENABLE
  159. #define KC_D3_1 KC_1
  160. #define KC_D3_2 KC_2
  161. #define KC_D3_3 KC_3
  162. #define KC_D3_4 KC_4
  163. #endif // TAP_DANCE_ENABLE
  164. // Since our quirky block definitions are basically a list of comma separated
  165. // arguments, we need a wrapper in order for these definitions to be
  166. // expanded before being used as arguments to the LAYOUT_xxx macro.
  167. #if (!defined(LAYOUT) && defined(KEYMAP))
  168. #define LAYOUT KEYMAP
  169. #endif
  170. #define LAYOUT_ergodox_wrapper(...) LAYOUT_ergodox(__VA_ARGS__)
  171. #define LAYOUT_ergodox_pretty_wrapper(...) LAYOUT_ergodox_pretty(__VA_ARGS__)
  172. #define KEYMAP_wrapper(...) LAYOUT(__VA_ARGS__)
  173. #define LAYOUT_wrapper(...) LAYOUT(__VA_ARGS__)
  174. #define LAYOUT_ortho_4x12_wrapper(...) LAYOUT_ortho_4x12(__VA_ARGS__)
  175. // Blocks for each of the four major keyboard layouts
  176. // Organized so we can quickly adapt and modify all of them
  177. // at once, rather than for each keyboard, one at a time.
  178. // And this allows for much cleaner blocks in the keymaps.
  179. // For instance Tap/Hold for Control on all of the layouts
  180. // NOTE: These are all the same length. If you do a search/replace
  181. // then you need to add/remove underscores to keep the
  182. // lengths consistent.
  183. #define _________________QWERTY_L1_________________ KC_Q, KC_W, KC_E, KC_R, KC_T
  184. #define _________________QWERTY_L2_________________ KC_A, KC_S, KC_D, KC_F, KC_G
  185. #define _________________QWERTY_L3_________________ CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B
  186. #define _________________QWERTY_R1_________________ KC_Y, KC_U, KC_I, KC_O, KC_P
  187. #define _________________QWERTY_R2_________________ KC_H, KC_J, KC_K, KC_L, KC_SCLN
  188. #define _________________QWERTY_R3_________________ KC_N, KC_M, KC_COMM, KC_DOT, CTL_T(KC_SLASH)
  189. #define _________________COLEMAK_L1________________ KC_Q, KC_W, KC_F, KC_P, KC_G
  190. #define _________________COLEMAK_L2________________ KC_A, KC_R, KC_S, KC_T, KC_D
  191. #define _________________COLEMAK_L3________________ CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B
  192. #define _________________COLEMAK_R1________________ KC_J, KC_L, KC_U, KC_Y, KC_SCLN
  193. #define _________________COLEMAK_R2________________ KC_H, KC_N, KC_E, KC_I, KC_O
  194. #define _________________COLEMAK_R3________________ KC_K, KC_M, KC_COMM, KC_DOT, CTL_T(KC_SLASH)
  195. #define ______________COLEMAK_MOD_DH_L1____________ KC_Q, KC_W, KC_F, KC_P, KC_B
  196. #define ______________COLEMAK_MOD_DH_L2____________ KC_A, KC_R, KC_S, KC_T, KC_G
  197. #define ______________COLEMAK_MOD_DH_L3____________ CTL_T(KC_Z), KC_X, KC_C, KC_D, KC_V
  198. #define ______________COLEMAK_MOD_DH_R1____________ KC_J, KC_L, KC_U, KC_Y, KC_SCLN
  199. #define ______________COLEMAK_MOD_DH_R2____________ KC_M, KC_N, KC_E, KC_I, KC_O
  200. #define ______________COLEMAK_MOD_DH_R3____________ KC_K, KC_H, KC_COMM, KC_DOT, CTL_T(KC_SLASH)
  201. #define _________________DVORAK_L1_________________ KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y
  202. #define _________________DVORAK_L2_________________ KC_A, KC_O, KC_E, KC_U, KC_I
  203. #define _________________DVORAK_L3_________________ CTL_T(KC_SCLN),KC_Q, KC_J, KC_K, KC_X
  204. #define _________________DVORAK_R1_________________ KC_F, KC_G, KC_C, KC_R, KC_L
  205. #define _________________DVORAK_R2_________________ KC_D, KC_H, KC_T, KC_N, KC_S
  206. #define _________________DVORAK_R3_________________ KC_B, KC_M, KC_W, KC_V, CTL_T(KC_Z)
  207. #define _________________WORKMAN_L1________________ KC_Q, KC_D, KC_R, KC_W, KC_B
  208. #define _________________WORKMAN_L2________________ KC_A, KC_S, KC_H, KC_T, KC_G
  209. #define _________________WORKMAN_L3________________ CTL_T(KC_Z), KC_X, KC_M, KC_C, KC_V
  210. #define _________________WORKMAN_R1________________ KC_J, KC_F, KC_U, KC_P, KC_SCLN
  211. #define _________________WORKMAN_R2________________ KC_Y, KC_N, KC_E, KC_O, KC_I
  212. #define _________________WORKMAN_R3________________ KC_K, KC_L, KC_COMM, KC_DOT, CTL_T(KC_SLASH)
  213. #define _________________NORMAN_L1_________________ KC_Q, KC_W, KC_D, KC_F, KC_K
  214. #define _________________NORMAN_L2_________________ KC_A, KC_S, KC_E, KC_T, KC_G
  215. #define _________________NORMAN_L3_________________ CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B
  216. #define _________________NORMAN_R1_________________ KC_J, KC_U, KC_R, KC_L, KC_SCLN
  217. #define _________________NORMAN_R2_________________ KC_Y, KC_N, KC_I, KC_O, KC_U
  218. #define _________________NORMAN_R3_________________ KC_P, KC_M, KC_COMM, KC_DOT, CTL_T(KC_SLASH)
  219. #define _________________MALTRON_L1________________ KC_Q, KC_P, KC_Y, KC_C, KC_B
  220. #define _________________MALTRON_L2________________ KC_A, KC_N, KC_I, KC_S, KC_F
  221. #define _________________MALTRON_L3________________ CTL_T(KC_SCLN), KC_SLSH, KC_J KC_G, KC_COMM
  222. #define _________________MALTRON_R1________________ KC_V, KC_M, KC_U, KC_Z, KC_L
  223. #define _________________MALTRON_R2________________ KC_D, KC_T, KC_D, KC_O, KC_R
  224. #define _________________MALTRON_R3________________ KC_DOT, KC_W, KC_K, KC_MINS, CTL_T(KC_x)
  225. #define _________________EUCALYN_L1________________ KC_SLSH, KC_COMM, KC_DOT, KC_F, KC_Q
  226. #define _________________EUCALYN_L2________________ KC_A, KC_O, KC_E, KC_I, KC_U
  227. #define _________________EUCALYN_L3________________ CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_W
  228. #define _________________EUCALYN_R1________________ KC_M, KC_R, KC_D, KC_Y, KC_P
  229. #define _________________EUCALYN_R2________________ KC_G, KC_T, KC_K, KC_S, KC_N
  230. #define _________________EUCALYN_R3________________ KC_B, KC_H, KC_J, KC_L, CTL_T(KC_SCLN)
  231. #define _____________CARPLAX_QFMLWY_L1_____________ KC_Q, KC_F, KC_M, KC_L, KC_W
  232. #define _____________CARPLAX_QFMLWY_L2_____________ KC_D, KC_S, KC_T, KC_N, KC_R
  233. #define _____________CARPLAX_QFMLWY_L3_____________ CTL_T(KC_Z), KC_V, KC_G, KC_C, KC_X
  234. #define _____________CARPLAX_QFMLWY_R1_____________ KC_Y, KC_U, KC_O, KC_B, KC_J
  235. #define _____________CARPLAX_QFMLWY_R2_____________ KC_I, KC_A, KC_E, KC_H, KC_SCLN
  236. #define _____________CARPLAX_QFMLWY_R3_____________ KC_P, KC_K, KC_COMM, KC_DOT, CTL_T(KC_SLSH)
  237. #define _____________CARPLAX_QGMLWB_L1_____________ KC_Q, KC_G, KC_M, KC_L, KC_W
  238. #define _____________CARPLAX_QGMLWB_L2_____________ KC_D, KC_S, KC_T, KC_N, KC_R
  239. #define _____________CARPLAX_QGMLWB_L3_____________ CTL_T(KC_Z), KC_X, KC_C, KC_F, KC_J
  240. #define _____________CARPLAX_QGMLWB_R1_____________ KC_B, KC_Y, KC_U, KC_V, KC_SCLN
  241. #define _____________CARPLAX_QGMLWB_R2_____________ KC_I, KC_A, KC_E, KC_O, KC_H
  242. #define _____________CARPLAX_QGMLWB_R3_____________ KC_K, KC_P, KC_COMM, KC_DOT, CTL_T(KC_SLSH)
  243. #define _____________CARPLAX_QGMLWY_L1_____________ KC_Q, KC_G, KC_M, KC_L, KC_W
  244. #define _____________CARPLAX_QGMLWY_L2_____________ KC_D, KC_S, KC_T, KC_N, KC_R
  245. #define _____________CARPLAX_QGMLWY_L3_____________ CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_J
  246. #define _____________CARPLAX_QGMLWY_R1_____________ KC_Y, KC_F, KC_U, KC_B, KC_SCLN
  247. #define _____________CARPLAX_QGMLWY_R2_____________ KC_I, KC_A, KC_E, KC_O, KC_H
  248. #define _____________CARPLAX_QGMLWY_R3_____________ KC_K, KC_P, KC_COMM, KC_DOT, CTL_T(KC_SLSH)
  249. #define ________________NUMBER_LEFT________________ KC_1, KC_2, KC_3, KC_4, KC_5
  250. #define ________________NUMBER_RIGHT_______________ KC_6, KC_7, KC_8, KC_9, KC_0
  251. #define _________________FUNC_LEFT_________________ KC_F1, KC_F2, KC_F3, KC_F4, KC_F5
  252. #define _________________FUNC_RIGHT________________ KC_F6, KC_F7, KC_F8, KC_F9, KC_F10
  253. #define ___________________BLANK___________________ _______, _______, _______, _______, _______
  254. #define _________________LOWER_L1__________________ KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC
  255. #define _________________LOWER_L2__________________ _________________FUNC_LEFT_________________
  256. #define _________________LOWER_L3__________________ _________________FUNC_RIGHT________________
  257. #define _________________LOWER_R1__________________ KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN
  258. #define _________________LOWER_R2__________________ _______, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR
  259. #define _________________LOWER_R3__________________ _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
  260. #define _________________RAISE_L1__________________ ________________NUMBER_LEFT________________
  261. #define _________________RAISE_L2__________________ ___________________BLANK___________________
  262. #define _________________RAISE_L3__________________ ___________________BLANK___________________
  263. #define _________________RAISE_R1__________________ ________________NUMBER_RIGHT_______________
  264. #define _________________RAISE_R2__________________ _______, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC
  265. #define _________________RAISE_R3__________________ _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END
  266. #define _________________ADJUST_L1_________________ RGB_MOD, RGB_HUI, RGB_SAI, RGB_VAI, RGB_TOG
  267. #define _________________ADJUST_L2_________________ MU_TOG , CK_TOGG, AU_ON, AU_OFF, AG_NORM
  268. #define _________________ADJUST_L3_________________ RGB_RMOD,RGB_HUD,RGB_SAD, RGB_VAD, KC_RGB_T
  269. #define _________________ADJUST_R1_________________ KC_SEC1, KC_SEC2, KC_SEC3, KC_SEC4, KC_SEC5
  270. #define _________________ADJUST_R2_________________ AG_SWAP, QWERTY, COLEMAK, DVORAK, WORKMAN
  271. #define _________________ADJUST_R3_________________ MG_NKRO, KC_MUTE, KC_VOLD, KC_VOLU, KC_MNXT
  272. // Since we have 4 default layouts (QWERTY, DVORAK, COLEMAK and WORKMAN),
  273. // this allows us to quickly modify the bottom row for all of the layouts
  274. // so we don't have to alter it 4 times and hope that we haven't missed
  275. // anything
  276. #define ___________ERGODOX_BOTTOM_LEFT_____________ OSM(MOD_MEH), OSM(MOD_LGUI), KC_LBRC, KC_RBRC
  277. #define ___________ERGODOX_BOTTOM_RIGHT____________ KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
  278. #define ___________ORTHODOX_THUMP_TOP_____________ ALT_APP, OS_LGUI, KC_LALT, OS_RGUI
  279. #define ___________________ORTHODOX_THUMB_BOTTOM____________________ LOWER, KC_SPACE,KC_BSPC, KC_DEL, KC_ENT, RAISE
  280. #define __________________ERGODOX_THUMB_CLUSTER_____________________ ALT_T(KC_APP), OSM(MOD_LGUI), OSM(MOD_RGUI), CTL_T(KC_ESCAPE), \
  281. KC_HOME, KC_PGUP, \
  282. LT(_LOWER, KC_SPACE),KC_BSPC, KC_END, KC_PGDN, KC_DEL, LT(_RAISE, KC_ENTER)