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.

504 lines
23 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. /* Copyright 2020 Simon Paul Jackson, BEng.
  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. /* UPDATE:
  18. New build process requires: qmk compile
  19. THIS METHOD IS NOW DEFUNCT.
  20. make linux bootloader install via: (or use via if it's firmwared) => CHOICE
  21. cd qmk_firmware
  22. sudo make dz60:jacko_keys:dfu
  23. ^C
  24. // or the following if you want to program upto 4 layers only yourself.
  25. sudo make dz60:via:dfu
  26. */
  27. //Macro production rule for upper and lowers.
  28. //Limit of only first 128 indirect entries may form part of a shifted pair.
  29. //The **uint32_t** have all been allocated so no size change on edit code points.
  30. #define Z(x) XP(x##_L, x##_U)
  31. enum unicode_names {
  32. //ANSI/NAV Fn shift (14)
  33. INT_L, INT_U,
  34. DIF_L, DIF_U,
  35. ROOT_L, ROOT_U,
  36. DEG_L, DEG_U,
  37. PND_L, PND_U,
  38. OM_L, OM_U,
  39. MIC_L, MIC_U,
  40. //BQN 1 (26 + 14 = 40)
  41. GR_L, GR_U,
  42. N1_L, N1_U, N2_L, N2_U, N3_L, N3_U, N4_L, N4_U, N5_L, N5_U,
  43. N6_L, N6_U, N7_L, N7_U, N8_L, N8_U, N9_L, N9_U, N0_L, N0_U,
  44. MIN_L, MIN_U, EQ_L, EQ_U,
  45. //BQN 2 (24 + 40 = 64)
  46. Q_L, Q_U, W_L, W_U, E_L, E_U, R_L, R_U, T_L, T_U, Y_L, Y_U,
  47. U_L, U_U, I_L, I_U, O_L, O_U, P_L, P_U, LBR_L, LBR_U, RBR_L, RBR_U,
  48. //BQN 3 (22 + 64 = 86)
  49. A_L, A_U, S_L, S_U, D_L, D_U, F_L, F_U, G_L, G_U, H_L, H_U,
  50. J_L, J_U, K_L, K_U, L_L, L_U, SEMI_L, SEMI_U, QUOT_L, QUOT_U,
  51. //BQN 4 (22 + 86 = 108) - X is special so XX was needed to avoid errors.
  52. Z_L, Z_U, XX_L, XX_U, C_L, C_U, V_L, V_U, B_L, B_U, N_L, N_U,
  53. M_L, M_U, LESS_L, LESS_U, GRET_L, GRET_U, DIV_L, DIV_U,
  54. SPC_L, SPC_U,
  55. //Special control
  56. C1_L, C1_U, C3_L, C3_U, C4_L, C4_U, C5_L, C5_U,
  57. C7_L, C7_U, C8_L, C8_U, C9_L, C9_U, C0_L, C0_U,
  58. CEQ_L, CEQ_U, CES_L, CES_U,
  59. //End of shiftables
  60. //Control literals
  61. TAB, CR, LBS,
  62. //Control iconographs
  63. IAT, IA, IB, IC, ID, IE, IF, IG, IH, II, IJ, IK,
  64. IL, IM, IN, IO, IP, IQ, IR, IS, IT, IU, IV, IW,
  65. IX, IY, IZ, ILBR, IBSL, IRBR, ICAR, IUND,
  66. //Alt aplha
  67. A1, A2, A3, A4, A5, A6, A7, A8, A9, A0, AMIN, AEQ,
  68. AGR, ACOM, ADOT, ALBR, ARBR, ASEM, AAPO,
  69. AA, AB, AC, AD, AE, AF, AG, AH, AI, AJ, AK,
  70. AL, AM, AN, AO, AP, AQ, AR, AS, AT, AU, AV, AW,
  71. AX, AY, AZ, ABSL,
  72. };
  73. // PLACE BQN layer and Unicode character code points here.
  74. // _L is lower case
  75. // _U is upper (shifted) case
  76. const uint32_t PROGMEM unicode_map[] = {
  77. //ANSI/NAV FN shift
  78. [INT_L] = U'', [INT_U] = U'Σ',
  79. [DIF_L] = U'', [DIF_U] = U'',
  80. [ROOT_L] = U'', [ROOT_U] = U'',
  81. [DEG_L] = U'°', [DEG_U] = U'', //Plimsoil STP
  82. [PND_L] = U'£', [PND_U] = U'',
  83. [OM_L] = U'ω', [OM_U] = U'Ω',
  84. [MIC_L] = U'µ', [MIC_U] = U'',
  85. //BQN 1
  86. [GR_L] = U'˜', [GR_U] = U'¬',
  87. [N1_L] = U'˘', [N1_U] = U'', [N2_L] = U'¨', [N2_U] = U'',
  88. [N3_L] = U'', [N3_U] = U'', [N4_L] = U'', [N4_U] = U'',
  89. [N5_L] = U'´', [N5_U] = U'', [N6_L] = U'˝', [N6_U] = U'',
  90. [N7_L] = U' ', [N7_U] = U' ', [N8_L] = U'', [N8_U] = U' ',
  91. [N9_L] = U'¯', [N9_U] = U'', [N0_L] = U'', [N0_U] = U'',
  92. [MIN_L] = U'÷', [MIN_U] = U'', [EQ_L] = U'×', [EQ_U] = U'',
  93. //BQN 2
  94. [Q_L] = U'', [Q_U] = U' ', [W_L] = U'𝕨', [W_U] = U'𝕎',
  95. [E_L] = U'', [E_U] = U'', [R_L] = U'', [R_U] = U'𝕣',
  96. [T_L] = U'', [T_U] = U'', [Y_L] = U' ', [Y_U] = U' ',
  97. [U_L] = U'', [U_U] = U' ', [I_L] = U'', [I_U] = U'',
  98. [O_L] = U'', [O_U] = U'', [P_L] = U'π', [P_U] = U'',
  99. [LBR_L] = U'', [LBR_U] = U'', [RBR_L] = U'', [RBR_U] = U'',
  100. //BQN 3
  101. [A_L] = U'', [A_U] = U' ', [S_L] = U'𝕤', [S_U] = U'𝕊',
  102. [D_L] = U'', [D_U] = U' ', [F_L] = U'𝕗', [F_U] = U'𝔽',
  103. [G_L] = U'𝕘', [G_U] = U'𝔾', [H_L] = U'', [H_U] = U'«',
  104. [J_L] = U'', [J_U] = U' ', [K_L] = U'', [K_U] = U'',
  105. [L_L] = U'', [L_U] = U'»', [SEMI_L] = U'', [SEMI_U] = U'·',
  106. [QUOT_L] = U'', [QUOT_U] = U'˙',
  107. //BQN 4
  108. [Z_L] = U'', [Z_U] = U'', [XX_L] = U'𝕩', [XX_U] = U'𝕏',
  109. [C_L] = U'', [C_U] = U' ', [V_L] = U'', [V_U] = U'',
  110. [B_L] = U'', [B_U] = U'', [N_L] = U' ', [N_U] = U' ',
  111. [M_L] = U'', [M_U] = U'', [LESS_L] = U'', [LESS_U] = U'',
  112. [GRET_L] = U'', [GRET_U] = U'', [DIV_L] = U'', [DIV_U] = U'',
  113. [SPC_L] = U'', [SPC_U] = U' ',
  114. //ANSI Extended Shift
  115. //Special control (OSI and emojicons)
  116. [C1_L] = U'', [C1_U] = U'🕫', [C3_L] = U'👪', [C3_U] = U'🖃',
  117. [C4_L] = U'🏠', [C4_U] = U'🖅', [C5_L] = U'', [C5_U] = U'🖆',
  118. [C7_L] = U'😈', [C7_U] = U'🗏', [C8_L] = U'📐', [C8_U] = U'🕮',
  119. [C9_L] = U'😇', [C9_U] = U'📚', [C0_L] = U'', [C0_U] = U'🏫',
  120. [CEQ_L] = U'', [CEQ_U] = U'🖩', [CES_L] = U'🏃', [CES_U] = U'💁',
  121. //Control literals - (next commit rollback)
  122. [TAB] = U'', [CR] = U'', [LBS] = U'',
  123. //Control iconographs (ANSI 32 lowest codes)
  124. [IAT] = U'', [IA] = U'', [IB] = U'🗚', [IC] = U'🗐',
  125. [ID] = U'🔖', [IE] = U'🔎', [IF] = U'👍', [IG] = U'🔔',
  126. [IH] = U'', [II] = U'', [IJ] = U'', [IK] = U'⭿',
  127. [IL] = U'📇', [IM] = U'', [IN] = U'🗋', [IO] = U'🗁',
  128. [IP] = U'🐧', [IQ] = U'📤', [IR] = U'📥', [IS] = U'💾',
  129. [IT] = U'🌱', [IU] = U'👎', [IV] = U'📋', [IW] = U'🔑',
  130. [IX] = U'🗙', [IY] = U'🗜', [IZ] = U'', [ILBR] = U'',
  131. [IBSL] = U'🌍', [IRBR] = U'', [ICAR] = U'', [IUND] = U'',
  132. //BQN Fn Shift
  133. //Unicode layer
  134. //============================================================================
  135. // FILL IN AS REQUIRED
  136. //============================================================================
  137. [A1] = U'𝟙', [A2] = U'𝟚', [A3] = U'𝟛', [A4] = U'𝟜',
  138. [A5] = U'𝟝', [A6] = U'𝟞', [A7] = U'𝟟', [A8] = U'𝟠',
  139. [A9] = U'𝟡', [A0] = U'𝟘', [AMIN] = 0x2224, [AEQ] = U'',//incongruence
  140. [ACOM] = U',', [ADOT] = U'.', [ALBR] = U'',
  141. [ARBR] = U'', [ASEM] = U';', [AAPO] = U'\'',
  142. [AA] = U'A', [AB] = U'', [AC] = U'', [AD] = U'',
  143. [AE] = U'E', [AF] = U'', [AG] = U'', [AH] = U'H',
  144. [AI] = U'I', [AJ] = U'', [AK] = U'', [AL] = U'Ȧ',
  145. [AM] = U'Ȯ', [AN] = U'N', [AO] = U'O', [AP] = U'',
  146. [AQ] = U'', [AR] = U'Ė', [AS] = U'S', [AT] = U'T',
  147. [AU] = U'İ', [AV] = U'', [AW] = U'',
  148. [AX] = U'', [AY] = U'˙', [AZ] = U'·',
  149. [ABSL] = U'\\'
  150. //4060 bytes free - as space is allocated "quite literally" as ASCII 32 in a 32-bit field.
  151. //2021-11-28
  152. };
  153. //Some say the above should be converted to allow more in device shift states,
  154. //but that would be less compact (needing 4 NUL per key) so kind of works for free.
  155. //The Navigation CYAN mode macro key system
  156. //keycode name definitions
  157. enum custom_keycodes {
  158. QMKLAST = SAFE_RANGE - 1,//ready for define
  159. KM_1, KM_2, KM_3, KM_4, KM_5,
  160. KM_6, KM_7, KM_8, KM_9, KM_0,
  161. KM_Q, KM_W, KM_E, KM_R, KM_T,
  162. KM_Y, KM_U, KM_I, KM_O, KM_P,
  163. KM_A, KM_S, KM_D, KM_F, KM_G,
  164. KM_H, KM_J, KM_K, KM_L,
  165. KM_Z, KM_X, KM_C, KM_V,
  166. KM_B, KM_N, KM_M,
  167. };
  168. //The Navigation CYAN mode macro key system for UTF-8 emission.
  169. //fill in the four sections of each string KEEPING the NUL byte spacers.
  170. //Backslash is reserved as an escape and so needs a "\\" literal.
  171. //Unless the backslash is in the final print until string end.
  172. //An estimate of 35 characters per key action set 2021-11-24
  173. //A quirk in C does allow less space used by concatenation of This
  174. //data structure if control key acceptably indexes the "next letter" OK.
  175. const char* const PROGMEM macro_unicode[] = {
  176. //============================================================================
  177. // FILL IN AS REQUIRED
  178. //============================================================================
  179. // in (x, sx, cx, csx) modifier format with NUL terminal characters
  180. // can add (wx, wsx, wcx, wcsx) extra on end with \0 inbetween each
  181. // for more use of WIN modifier. ALT being used to hold layer.
  182. "ℤₚ\0F₄(q)\0\0",// KM_1
  183. "Aₙ\0G₂(p)\0\0",// KM_2
  184. "Aₙ(q)\0²Aₙ(q²)\0\0",// KM_3
  185. "Bₙ(q)\0²Dₙ(q²)\0\0",// KM_4
  186. "Cₙ(q)\0²E₆(q²)\0\0",// KM_5
  187. "Dₙ(q)\0³D₄(q³)\0\0",// KM_6
  188. "E₆(q)\0²B₂(2²ⁿ⁺¹)\0\0",// KM_7
  189. "E₇(q)\0²F₄(2²ⁿ⁺¹)\0\0",// KM_8
  190. "E₈(q)\0²G₂(3²ⁿ⁺¹)\0\0",// KM_9
  191. "\0²F₄(2)′\0\0",// KM_0
  192. "\0Fi₂₂\0\0",// KM_Q
  193. "\0J₄\0\0",// KM_W
  194. "\0J₂\0\0",// KM_E
  195. "\0HN\0\0",// KM_R
  196. "\0Th\0\0",// KM_T
  197. "\0B\0\0",// KM_Y
  198. "\0Fi₂₃\0\0",// KM_U
  199. "\0M₂₄\0\0",// KM_I
  200. "\0Co₃\0\0",// KM_O
  201. "\0Co₂\0\0",// KM_P
  202. "\0M₁₁\0\0",// KM_A
  203. "\0Ly\0\0",// KM_S
  204. "\0M₂₂\0\0",// KM_D
  205. "\0M₂₃\0\0",// KM_F
  206. "\0HS\0\0",// KM_G
  207. "\0J₃\0\0",// KM_H
  208. "\0McL\0\0",// KM_J
  209. "\0He\0\0",// KM_K
  210. "\0Ru\0\0",// KM_L
  211. "\0M\0\0",// KM_Z
  212. "\0Fi₂₄\0\0",// KM_X
  213. "\0J₁\0\0",// KM_C
  214. "\0Co₁\0\0",// KM_V
  215. "\0M₁₂\0\0",// KM_B
  216. "\0O'N\0\0",// KM_N
  217. "\0Suz\0\0",// KM_M
  218. };
  219. const uint16_t PROGMEM macro_keycode[] = {
  220. //index at A
  221. //only use alpha A-Z (26) escape sequences "\\A" etc. in macro strings
  222. KC_LEFT,//\\A
  223. };
  224. const char* const PROGMEM macro_subs[] = {
  225. //index at a
  226. //only use alpha a-z (26) escape sequences "\\a" etc. in macro strings
  227. "",//\\a
  228. };
  229. const char* modify_step(const char* ip) {
  230. while(*(ip++) != 0);
  231. return ip;
  232. }
  233. const char* modify_step2(const char* ip) {
  234. return modify_step(modify_step(ip));
  235. }
  236. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  237. if(keycode < KM_1 || keycode > KM_M) return true;//protection better
  238. if (record->event.pressed) {
  239. //press
  240. const char* ip = macro_unicode[keycode - KM_1];
  241. if(get_mods() & MOD_MASK_SHIFT) ip = modify_step(ip);
  242. if(get_mods() & MOD_MASK_CTRL) {//jump 2
  243. ip = modify_step2(ip);
  244. }
  245. if(get_mods() & MOD_MASK_GUI) {//jump 4 -- currently next macro key
  246. ip = modify_step2(modify_step2(ip));
  247. }
  248. while(*ip == '\\') {
  249. //process backslash macro effect, otherwise literal until end of string
  250. ip++;
  251. uint8_t idx = *ip - 'A';
  252. if(idx < 26) {//only use alphas
  253. tap_code16(macro_keycode[idx]);//16 for allow full moded codes
  254. ip++;
  255. continue;
  256. }
  257. idx = idx + 'A' - '0';//numbers
  258. if(idx < 10) {
  259. const char* ip_save = ip++;
  260. for(uint8_t i = 0; i < idx + 1; i++) {
  261. //so one step by default and numbers higher than 0 leave that may gaps in the skip.
  262. ip = modify_step(ip);//skip number of codes
  263. }
  264. send_unicode_string(ip);//should UTF-8
  265. ip = ip_save;//restore (only one level deep!!!!)
  266. continue;
  267. }
  268. idx = idx + '0' - 'a';//lower case subroutines
  269. if(idx < 26) {//only use alphas
  270. send_unicode_string(macro_subs[idx]);
  271. ip++;
  272. continue;
  273. }
  274. switch(*(ip++)) {
  275. //other cases of macro effects
  276. //======================================================================
  277. // FILL IN AS REQUIRED
  278. //======================================================================
  279. case('\\'):
  280. SEND_STRING("\\");//literal emit
  281. continue;
  282. default:
  283. break;//uknown escape
  284. }
  285. break;//bad escape sequence so ignore and literal
  286. }
  287. send_unicode_string(ip);//should UTF-8
  288. } else {
  289. //release
  290. }
  291. return true;
  292. };
  293. #define F_CTRL KC_OUT
  294. #define F_SHFT KC_OPER
  295. #define F_ALT KC_CLEAR_AGAIN
  296. #define F_GUI KC_CRSEL
  297. #define F_BOOM KC_EXSEL
  298. //a great C4 joke about adding 32 to the modifiers
  299. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  300. //=========================================================
  301. // PRIMARY UNSHIFTED MODES
  302. //=========================================================
  303. //ANSI lock mode 0 =================================================================================== ANSI lock mode 0
  304. // Standard ANSI 60 layout for worldwide ASCII compatibility,
  305. // This is the standard conformance layer and as such remain static.
  306. // MO(4) enters the function shift state.
  307. LAYOUT_60_ansi(
  308. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC,
  309. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS,
  310. KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
  311. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT,
  312. KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, KC_RCTL, MO(4)),//zero index start
  313. //Navigation lock mode 1 ======================================================================== Navigation lock mode 1
  314. // Removed ASCII 47 (/) and right ctrl/win/alt for cursor.
  315. // Backslash enters BQN entry mode
  316. // VirtualBox host key needs an Fn.
  317. // A basic easy cursor mode with easier BQN entry via \.
  318. LAYOUT_60_ansi(
  319. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC,
  320. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, OSL(3),//BQN shift
  321. KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
  322. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_RSFT,
  323. KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_LEFT, KC_DOWN, KC_RIGHT,MO(5)),
  324. //Macro lock mode 3 ================================================================================== Macro lock mode 2
  325. // A single finger macro launching board producing many modifier and function keys.
  326. // Lots of macros and shifts with an Fn
  327. LAYOUT_60_ansi(
  328. OSM(MOD_LCTL|MOD_LSFT), KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,OSM(MOD_LSFT|MOD_LCTL|MOD_LALT),
  329. OSM(MOD_LSFT|MOD_LALT), KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_F21, KC_F22, KC_F23, KC_F24, ALGR(KC_F24),
  330. OSM(MOD_LCTL|MOD_LALT), ALGR(KC_F1), ALGR(KC_F2), ALGR(KC_F3), ALGR(KC_F4), ALGR(KC_F5), ALGR(KC_F6), ALGR(KC_F7), ALGR(KC_F8), ALGR(KC_F9), ALGR(KC_F10), ALGR(KC_F11), ALGR(KC_F12),
  331. OSM(MOD_LSFT), ALGR(KC_F13), ALGR(KC_F14), ALGR(KC_F15), ALGR(KC_F16), ALGR(KC_F17), ALGR(KC_F18), ALGR(KC_F19), ALGR(KC_F20), ALGR(KC_F21), ALGR(KC_F22), ALGR(KC_F23),
  332. OSM(MOD_LCTL),OSM(MOD_LGUI),OSM(MOD_LALT), KC_SPC, LSA(KC_TAB),OSM(MOD_RGUI), LALT(KC_TAB),MO(6)),
  333. //BQN lock mode 4 ====================================================================================== BQN lock mode 3
  334. // BQN Unicode
  335. LAYOUT_60_ansi(
  336. Z(GR), Z(N1), Z(N2), Z(N3), Z(N4), Z(N5), Z(N6), Z(N7), Z(N8), Z(N9), Z(N0), Z(MIN), Z(EQ), TO(1),//escape
  337. KC_TAB, Z(Q), Z(W), Z(E), Z(R), Z(T), Z(Y), Z(U), Z(I), Z(O), Z(P), Z(LBR), Z(RBR), KC_BSLS,
  338. KC_CAPS, Z(A), Z(S), Z(D), Z(F), Z(G), Z(H), Z(J), Z(K), Z(L), Z(SEMI), Z(QUOT), KC_ENT,
  339. KC_LSFT, Z(Z), Z(XX), Z(C), Z(V), Z(B), Z(N), Z(M), Z(LESS), Z(GRET), Z(DIV), KC_RSFT,
  340. F_CTRL, F_GUI, F_ALT, Z(SPC), F_ALT, F_GUI, F_CTRL, TO(7)),//shift sticky
  341. //=========================================================
  342. // SECONDARY Fn SHIFTED MODES
  343. //=========================================================
  344. //ANSI shift mode 4 ================================================================================== ANSI shift mode 4
  345. // ISO characters such as £ and control of RGB/backlight and cursor.
  346. // Fn + P is power switch for shutdown.
  347. // This shift layer is standard for the kind of keyboard plus a few extensions.
  348. LAYOUT_60_ansi(
  349. KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL,
  350. LCA(KC_DEL), RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, KC_WHOM, KC_PWR, KC_HOME, KC_END, KC_INS,
  351. KC_SLCK, KC_WSCH, Z(INT), Z(DIF), KC_WFAV, Z(ROOT), KC_VOLD, KC_VOLU, Z(DEG), Z(PND), KC_PAUS, KC_PSCR, KC_APP,
  352. KC_TRNS, Z(OM), KC_MUTE, BL_DEC, BL_TOGG, BL_INC, BL_STEP, Z(MIC), KC_PGUP, KC_PGDN, KC_UP, KC_TRNS,
  353. MO(8), DF(2), DF(1), KC_SPC, KC_LEFT, KC_DOWN, KC_RIGHT,KC_TRNS),
  354. //Navigation shift mode 5 ====================================================================== Navigation shift mode 5
  355. // All function keys, so Home and End were sacrificed.
  356. // Also media player launch and control.
  357. // No APP menu as / is on the key, as / is ? key.
  358. LAYOUT_60_ansi(
  359. KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL,
  360. LCA(KC_DEL), KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_F21, KC_F22, KC_F23, KC_F24, KC_INS,
  361. KC_SLCK, KC_WSCH, Z(INT), Z(DIF), KC_WFAV, Z(ROOT), KC_VOLD, KC_VOLU, Z(DEG), Z(PND), KC_PAUS, KC_PSCR, KC_APP,
  362. KC_TRNS, Z(OM), KC_MUTE, KC_MPRV, KC_MPLY, KC_MNXT, KC_MSEL, Z(MIC), KC_PGUP, KC_PGDN, KC_QUES, KC_TRNS,
  363. DF(0), DF(2), MO(9), KC_SPC, KC_RALT, MT(MOD_RGUI,KC_SLSH),KC_RCTL, KC_TRNS),
  364. //Macro shift mode 6 ================================================================================ Macro shift mode 6
  365. // Same macro layer but different modifier grouping for more hot key combinations.
  366. LAYOUT_60_ansi(
  367. KC_ESC, KC_P1, KC_P2, KC_P3, KC_P4, KC_P5, KC_P6, KC_P7, KC_P8, KC_P9, KC_P0, KC_HAEN, KC_HANJ, KC_DEL,
  368. KC_TAB, KC_RO, KC_KANA, KC_JYEN, KC_HENK, KC_MHEN, KC_INT6, KC_INT7, KC_INT8, KC_INT9, KC_PWR, KC_HOME, KC_END, KC_INS,
  369. KC_NLCK, KC_WSCH, Z(INT), Z(DIF), KC_WFAV, Z(ROOT), KC_VOLD, KC_VOLU, Z(DEG), Z(PND), KC_PAUS, KC_PSCR, KC_ENT,
  370. OSM(MOD_LGUI|MOD_RGUI),KC_LANG3,KC_LANG4,KC_LANG5,KC_LANG6,KC_LANG7,KC_LANG8,KC_LANG9,KC_ACL0, KC_ACL1, KC_ACL2, OSM(MOD_RSFT),
  371. DF(0),OSM(MOD_LSFT|MOD_LGUI),DF(1), ALGR(KC_SPC), KC_TRNS, OSM(MOD_LSFT|MOD_RGUI),KC_TRNS, KC_TRNS),
  372. //BQN shift mode 7 ==================================================================================== BQN shift mode 7
  373. LAYOUT_60_ansi(
  374. KC_ESC, X(A1), X(A2), X(A3), X(A4), X(A5), X(A6), X(A7), X(A8), X(A9), X(A0), X(AMIN), X(AEQ), KC_BSPC,//allow backspace
  375. KC_TAB, X(AQ), X(AW), X(AE), X(AR), X(AT), X(AY), X(AU), X(AI), X(AO), X(AP), X(ALBR), X(ARBR), X(ABSL),
  376. KC_SLCK, X(AA), X(AS), X(AD), X(AF), X(AG), X(AH), X(AJ), X(AK), X(AL), X(ASEM), X(AAPO), KC_ENT,
  377. F_SHFT, X(AZ), X(AX), X(AC), X(AV), X(AB), X(AN), X(AM), X(ACOM), X(ADOT), KC_UP, F_SHFT,
  378. F_CTRL, F_GUI, F_ALT, KC_SPC, KC_LEFT, KC_DOWN, KC_RIGHT,TO(5)),//latching escape
  379. //=========================================================
  380. // EXTENDED Fn, MOD, Release Fn SHIFTED MODES
  381. //=========================================================
  382. //Control shift mode 8 ============================================================================ Control shift mode 8
  383. LAYOUT_60_ansi(
  384. Z(CES), Z(C1), X(IAT), Z(C3), Z(C4), Z(C5), X(ICAR), Z(C7), Z(C8), Z(C9), Z(C0), X(IUND), Z(CEQ), X(LBS),
  385. X(TAB), X(IQ), X(IW), X(IE), X(IR), X(IT), X(IY), X(IU), X(II), X(IO), X(IP), X(ILBR), X(IRBR), X(IBSL),
  386. KC_TRNS, X(IA), X(IS), X(ID), X(IF), X(IG), X(IH), X(IJ), X(IK), X(IL), LCTL(KC_PAUS),LCTL(KC_PSCR),X(CR),
  387. KC_LSFT, X(IZ), X(IX), X(IC), X(IV), X(IB), X(IN), X(IM), LCTL(KC_PGUP),LCTL(KC_PGDN),LCTL(KC_UP), KC_TRNS,
  388. KC_TRNS, LCTL(KC_LGUI), LCTL(KC_LALT), X(IAT), LCTL(KC_LEFT), LCTL(KC_DOWN),LCTL(KC_RIGHT),KC_TRNS),
  389. //Mouse shift mode 9 ================================================================================ Mouse shift mode 9
  390. // A utility layer for things like the mouse.
  391. LAYOUT_60_ansi(
  392. RESET, KM_1, KM_2, KM_3, KM_4, KM_5, KM_6, KM_7, KM_8, KM_9, KM_0, KC_BTN4, KC_BTN5, KC_DEL,
  393. KC_TAB, KM_Q, KM_W, KM_E, KM_R, KM_T, KM_Y, KM_U, KM_I, KM_O, KM_P, KC_HOME, KC_END, KC_SYSREQ,
  394. KC_LALT, KM_A, KM_S, KM_D, KM_F, KM_G, KM_H, KM_J, KM_K, KM_L, KC_BTN3, KC_BTN2, KC_ENT,
  395. KC_LSFT, KM_Z, KM_X, KM_C, KM_V, KM_B, KM_N, KM_M, KC_WH_U, KC_WH_D, KC_MS_U, KC_RSFT,
  396. KC_LCTL, KC_LGUI, KC_TRNS, KC_BTN1, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS),
  397. //============================================================================
  398. // FILL IN AS REQUIRED (FOR EXTRA LAYAERS IF NEEDED)
  399. //============================================================================
  400. };
  401. const rgblight_segment_t PROGMEM my_ansi[] = RGBLIGHT_LAYER_SEGMENTS(
  402. {11, 2, HSV_RED}
  403. );
  404. const rgblight_segment_t PROGMEM my_nav[] = RGBLIGHT_LAYER_SEGMENTS(
  405. {11, 2, HSV_GREEN}
  406. );
  407. const rgblight_segment_t PROGMEM my_macro[] = RGBLIGHT_LAYER_SEGMENTS(
  408. {11, 2, HSV_YELLOW}
  409. );
  410. const rgblight_segment_t PROGMEM my_bqn[] = RGBLIGHT_LAYER_SEGMENTS(
  411. {11, 2, HSV_BLUE}
  412. );
  413. const rgblight_segment_t PROGMEM my_losh[] = RGBLIGHT_LAYER_SEGMENTS(
  414. {11, 2, HSV_MAGENTA}
  415. );
  416. const rgblight_segment_t PROGMEM my_hish[] = RGBLIGHT_LAYER_SEGMENTS(
  417. {11, 2, HSV_CYAN}
  418. );
  419. const rgblight_segment_t PROGMEM my_caps[] = RGBLIGHT_LAYER_SEGMENTS(
  420. {8, 1, HSV_WHITE}
  421. );
  422. const rgblight_segment_t PROGMEM my_num[] = RGBLIGHT_LAYER_SEGMENTS(
  423. {15, 1, HSV_WHITE}
  424. );
  425. //MAX 8 LAYERS ====== NO MORE SAPCE. USE A NO COLOR MODE
  426. const rgblight_segment_t* const PROGMEM my_rgb_layers[] = RGBLIGHT_LAYERS_LIST(
  427. my_ansi,
  428. my_nav,
  429. my_macro,
  430. my_bqn,// Extended mode
  431. my_losh,
  432. my_hish,
  433. my_caps, // Overrides caps lock layer
  434. my_num
  435. );
  436. void keyboard_post_init_user(void) {
  437. // Enable the LED layers
  438. rgblight_layers = my_rgb_layers;
  439. }
  440. layer_state_t layer_state_set_user(layer_state_t state) {
  441. // Layers will light up if kb layers are active
  442. for(uint8_t i = 0; i < 4; i++)
  443. rgblight_set_layer_state(i, layer_state_cmp(state, i));//ANSI
  444. //rgblight_set_layer_state(2, layer_state_cmp(state, 1));//NAV
  445. //rgblight_set_layer_state(3, layer_state_cmp(state, 2));//Macro
  446. //rgblight_set_layer_state(4, layer_state_cmp(state, 3));//BQN
  447. rgblight_set_layer_state(4, layer_state_cmp(state, 4) || layer_state_cmp(state, 5) ||
  448. layer_state_cmp(state, 6) || layer_state_cmp(state, 7));//LO Shift
  449. rgblight_set_layer_state(5, layer_state_cmp(state, 8) ||
  450. layer_state_cmp(state, 9));//HI Shift
  451. return state;
  452. }
  453. bool led_update_user(led_t led_state) {
  454. // Caps lock etc
  455. rgblight_set_layer_state(6, led_state.caps_lock);
  456. // MULTI LOCK WITH INVERTED NUMLOCK
  457. rgblight_set_layer_state(7, led_state.scroll_lock || !led_state.num_lock ||
  458. led_state.compose || led_state.kana);
  459. return true;
  460. }