gourdo1.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. /* Copyright 2021 Jonavin Eng @Jonavin
  2. Copyright 2022 gourdo1 <gourdo1@outlook.com>
  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. #include QMK_KEYBOARD_H
  15. #include "gourdo1.h"
  16. #include "custom_double_taps.h"
  17. // Tap once for shift, twice for Caps Lock but only if Win Key is not disabled (also disabled by user.config variable)
  18. void dance_LSFT_each_tap(qk_tap_dance_state_t * state, void * user_data) {
  19. if (user_config.double_tap_shift_for_capslock) {
  20. if (state -> count == 1 || keymap_config.no_gui) {
  21. register_code(KC_LSFT);
  22. } else {
  23. register_code(KC_CAPS);
  24. }
  25. } else {
  26. register_code(KC_LSFT);
  27. }
  28. }
  29. void dance_LSFT_reset(qk_tap_dance_state_t * state, void * user_data) {
  30. if (state -> count == 1 || keymap_config.no_gui) {
  31. unregister_code(KC_LSFT);
  32. } else {
  33. unregister_code(KC_CAPS);
  34. unregister_code(KC_LSFT);
  35. }
  36. }
  37. // Tap Dance definitions
  38. qk_tap_dance_action_t tap_dance_actions[] = {
  39. // Tap once for shift, twice for Caps Lock
  40. [TD_LSFT_CAPS_WIN] = ACTION_TAP_DANCE_FN_ADVANCED(dance_LSFT_each_tap, NULL, dance_LSFT_reset)
  41. };
  42. // RGB NIGHT MODE
  43. #ifdef RGB_MATRIX_ENABLE
  44. static bool rgb_nightmode = false;
  45. // Turn on/off NUM LOCK if current state is different
  46. void activate_rgb_nightmode(bool turn_on) {
  47. if (rgb_nightmode != turn_on) {
  48. rgb_nightmode = !rgb_nightmode;
  49. }
  50. }
  51. bool get_rgb_nightmode(void) {
  52. return rgb_nightmode;
  53. }
  54. #endif // RGB_MATRIX_ENABLE
  55. // TIMEOUTS
  56. #ifdef IDLE_TIMEOUT_ENABLE
  57. static uint16_t timeout_timer = 0;
  58. static uint16_t timeout_counter = 0; //in minute intervals
  59. static uint16_t timeout_threshold = TIMEOUT_THRESHOLD_DEFAULT;
  60. uint16_t get_timeout_threshold(void) {
  61. return timeout_threshold;
  62. }
  63. void timeout_reset_timer(void) {
  64. timeout_timer = timer_read();
  65. timeout_counter = 0;
  66. };
  67. void timeout_update_threshold(bool increase) {
  68. if (increase && timeout_threshold < TIMEOUT_THRESHOLD_MAX) timeout_threshold++;
  69. if (!increase && timeout_threshold > 0) timeout_threshold--;
  70. };
  71. void timeout_tick_timer(void) {
  72. if (timeout_threshold > 0) {
  73. if (timer_elapsed(timeout_timer) >= 60000) { // 1 minute tick
  74. timeout_counter++;
  75. timeout_timer = timer_read();
  76. }
  77. #ifdef RGB_MATRIX_ENABLE
  78. if (timeout_threshold > 0 && timeout_counter >= timeout_threshold) {
  79. rgb_matrix_disable_noeeprom();
  80. }
  81. #endif
  82. } // timeout_threshold = 0 will disable timeout
  83. }
  84. #endif // IDLE_TIMEOUT_ENABLE
  85. #if defined(ALTTAB_SCROLL_ENABLE) || defined(IDLE_TIMEOUT_ENABLE) // timer features
  86. __attribute__((weak)) void matrix_scan_keymap(void) {}
  87. void matrix_scan_user(void) {
  88. #ifdef ALTTAB_SCROLL_ENABLE
  89. encoder_tick_alttabscroll();
  90. #endif
  91. #ifdef IDLE_TIMEOUT_ENABLE
  92. timeout_tick_timer();
  93. #endif
  94. matrix_scan_keymap();
  95. }
  96. #endif // ALTTAB_SCROLL_ENABLE or IDLE_TIMEOUT_ENABLE
  97. // Initialize variable holding the binary representation of active modifiers.
  98. uint8_t mod_state;
  99. // ============================================= PROCESS KEY CODES =============================================
  100. __attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t * record) {
  101. return true;
  102. }
  103. bool process_record_user(uint16_t keycode, keyrecord_t * record) {
  104. mod_state = get_mods();
  105. if (!process_record_keymap(keycode, record)) { return false; }
  106. if (!process_capsnum(keycode, record)) { return false; }
  107. if (!process_esc_to_base(keycode, record)) { return false; }
  108. // Key macros ...
  109. switch (keycode) {
  110. // User configuration toggles
  111. case PRNCONF: // Print verbose status of all user_config toggles (open a text editor before engaging!!)
  112. if (record->event.pressed) {
  113. //send_string("Left bracket with alt numcodes "SS_LALT(SS_TAP(X_KP_0) SS_TAP(X_KP_0) SS_TAP(X_KP_9) SS_TAP(X_KP_1))"\n");
  114. send_string("\n\x2D\x2D\x2D\x2D\x2D\x2D\x2D\x2D\x2D\x3C\x3C\x3C\x3C\x3C\x3C\x3C\x3C\x3C");
  115. send_string(" gourdo1\x27s GMMK Pro User Settings ");
  116. send_string("\x3E\x3E\x3E\x3E\x3E\x3E\x3E\x3E\x3E\x2D\x2D\x2D\x2D\x2D\x2D\x2D\x2D\x2D\n");
  117. send_string("Hold \x5B \bFn\x5D and the number corresponding to a setting below to toggle.\n");
  118. send_string("Re-print this screen with \x5B \bFn\x5D \x5B`\x5D to see your changes reflected.\n");
  119. send_string("Config also visible as RGB under number keys by holding \x5B \bFn\x5D.\n");
  120. send_string("\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d");
  121. send_string("\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d");
  122. send_string("\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d");
  123. send_string("\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\n");
  124. send_string("1. CapsLock RGB highlight alpha keys................ ");
  125. if (user_config.rgb_hilite_caps) {
  126. send_string("\x5BON\x5D\n");
  127. } else {
  128. send_string("\x5BOFF\x5D\n");
  129. }
  130. send_string("2. Numpad RGB highlight layer keys.................. ");
  131. if (user_config.rgb_hilite_numpad) {
  132. send_string("\x5BON\x5D\n");
  133. } else {
  134. send_string("\x5BOFF\x5D\n");
  135. }
  136. send_string("3. Double tap ESC to revert to BASE layer........... ");
  137. if (user_config.esc_double_tap_to_baselyr) {
  138. send_string("\x5BON\x5D\n");
  139. } else {
  140. send_string("\x5BOFF\x5D\n");
  141. }
  142. send_string("4. DEL \x26 HOME key locations......................... ");
  143. if (user_config.del_right_home_top) {
  144. send_string("\x5BHOME on F13\x3B DEL right of BKSPC\x5D\n");
  145. } else {
  146. send_string("\x5B \bDEL on F13\x3B HOME right of BKSPC\x5D\n");
  147. }
  148. send_string("5. Numpad on CapsLock\x3B double tap LSHIFT for Caps... ");
  149. if (user_config.double_tap_shift_for_capslock) {
  150. send_string("\x5BON\x5D\n");
  151. } else {
  152. send_string("\x5BOFF\x5D\n");
  153. }
  154. send_string("6. Encoder button function.......................... ");
  155. if (user_config.encoder_press_mute_or_media) {
  156. send_string("\x5BMUTE\x5D\n");
  157. } else {
  158. send_string("\x5BMEDIA PLAY\x2FPAUSE\x5D\n");
  159. }
  160. send_string("7. Insert function accessed with.................... ");
  161. if (user_config.ins_on_shft_bkspc_or_del) {
  162. send_string("\x5BSHIFT\x2D \bBKSPC\x5D\n");
  163. } else {
  164. send_string("\x5BSHIFT\x2D \bDEL\x5D\n");
  165. }
  166. send_string("8. Force SHIFT \x26 CTRL\x2DSPACE to function like SPACE.. ");
  167. if (user_config.disable_space_mods) {
  168. send_string("\x5BON\x5D\n");
  169. } else {
  170. send_string("\x5BOFF\x5D\n");
  171. }
  172. send_string("\nThe latest firmware updates are always here\x3a https\x3a\x2F\x2Fgithub.com\x2Fgourdo1\x2Fgmmkpro\x2Dmedia\n");
  173. }
  174. break;
  175. case TG_CAPS: // Toggle RGB highlighting of Capslock state
  176. if (record->event.pressed) {
  177. user_config.rgb_hilite_caps ^= 1; // Toggles the status
  178. eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM
  179. }
  180. break;
  181. case TG_PAD: // Toggle RGB highlighting of Numpad state
  182. if (record->event.pressed) {
  183. user_config.rgb_hilite_numpad ^= 1; // Toggles the status
  184. eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM
  185. }
  186. break;
  187. case TG_ESC: // Toggle alternate ESC functionality
  188. if (record->event.pressed) {
  189. user_config.esc_double_tap_to_baselyr ^= 1; // Toggles the status
  190. eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM
  191. }
  192. break;
  193. case TG_DEL: // Toggle alternate placement of DEL and HOME keys
  194. if (record->event.pressed) {
  195. user_config.del_right_home_top ^= 1; // Toggles the status
  196. eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM
  197. }
  198. break;
  199. case TG_TDCAP: // Toggle alternate Capslock/Numpad functionality
  200. if (record->event.pressed) {
  201. user_config.double_tap_shift_for_capslock ^= 1; // Toggles the status
  202. eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM
  203. }
  204. break;
  205. case TG_ENC: // Toggle Encoder function
  206. if (record->event.pressed) {
  207. user_config.encoder_press_mute_or_media ^= 1; // Toggles the status
  208. eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM
  209. }
  210. break;
  211. case TG_INS: // Toggle Encoder function
  212. if (record->event.pressed) {
  213. user_config.ins_on_shft_bkspc_or_del ^= 1; // Toggles the status
  214. eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM
  215. }
  216. break;
  217. case TG_SPCMOD: // Toggle forcing SHIFT&CTRL-SPACE to function like SPACE
  218. if (record->event.pressed) {
  219. user_config.disable_space_mods ^= 1; // Toggles the status
  220. eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM
  221. }
  222. break;
  223. //return false;
  224. // Key to the left of encoder function (default HOME)
  225. case LEFTOFENC:
  226. if (!(user_config.del_right_home_top)) {
  227. if (!(user_config.ins_on_shft_bkspc_or_del)) {
  228. static bool inskey_registered;
  229. if (record -> event.pressed) {
  230. // Detect the activation of either shift keys
  231. if (mod_state & MOD_MASK_SHIFT) {
  232. // First temporarily canceling both shifts so that
  233. // shift isn't applied to the KC_INS keycode
  234. del_mods(MOD_MASK_SHIFT);
  235. register_code(KC_INS);
  236. // Update the boolean variable to reflect the status of KC_INS
  237. inskey_registered = true;
  238. // Reapplying modifier state so that the held shift key(s)
  239. // still work even after having tapped the key.
  240. set_mods(mod_state);
  241. return false;
  242. } else {
  243. register_code(KC_DEL);
  244. return false;
  245. }
  246. } else { // on release of KC_DEL
  247. // In case KC_INS is still being sent even after the release of KC_DEL
  248. if (inskey_registered) {
  249. unregister_code(KC_INS);
  250. inskey_registered = false;
  251. return false;
  252. } else {
  253. unregister_code(KC_DEL);
  254. return false;
  255. }
  256. }
  257. } else {
  258. if (record -> event.pressed) {
  259. register_code(KC_DEL);
  260. return false;
  261. } else {
  262. unregister_code(KC_DEL);
  263. return false;
  264. }
  265. }
  266. } else {
  267. if (record -> event.pressed) {
  268. register_code(KC_HOME);
  269. return false;
  270. } else {
  271. unregister_code(KC_HOME);
  272. return false;
  273. }
  274. }
  275. break;
  276. // Key below encoder function (default DEL)
  277. case BELOWENC:
  278. if (user_config.del_right_home_top) {
  279. if (!(user_config.ins_on_shft_bkspc_or_del)) {
  280. static bool inskey_registered;
  281. if (record -> event.pressed) {
  282. // Detect the activation of either shift keys
  283. if (mod_state & MOD_MASK_SHIFT) {
  284. // First temporarily canceling both shifts so that
  285. // shift isn't applied to the KC_INS keycode
  286. del_mods(MOD_MASK_SHIFT);
  287. register_code(KC_INS);
  288. // Update the boolean variable to reflect the status of KC_INS
  289. inskey_registered = true;
  290. // Reapplying modifier state so that the held shift key(s)
  291. // still work even after having tapped the key.
  292. set_mods(mod_state);
  293. return false;
  294. } else {
  295. register_code(KC_DEL);
  296. return false;
  297. }
  298. } else { // on release of KC_DEL
  299. // In case KC_INS is still being sent even after the release of KC_DEL
  300. if (inskey_registered) {
  301. unregister_code(KC_INS);
  302. inskey_registered = false;
  303. return false;
  304. } else {
  305. unregister_code(KC_DEL);
  306. return false;
  307. }
  308. }
  309. } else {
  310. if (record -> event.pressed) {
  311. register_code(KC_DEL);
  312. return false;
  313. } else {
  314. unregister_code(KC_DEL);
  315. return false;
  316. }
  317. }
  318. } else {
  319. if (record -> event.pressed) {
  320. register_code(KC_HOME);
  321. return false;
  322. } else {
  323. unregister_code(KC_HOME);
  324. return false;
  325. }
  326. }
  327. break;
  328. // Encoder button function
  329. case ENCFUNC:
  330. if (user_config.encoder_press_mute_or_media) {
  331. if (record -> event.pressed) {
  332. register_code(KC_MUTE);
  333. } else unregister_code16(keycode);
  334. }
  335. else {
  336. if (record -> event.pressed) {
  337. register_code(KC_MPLY);
  338. } else unregister_code16(keycode);
  339. }
  340. break;
  341. // DotCom domain macros
  342. case DOTCOM:
  343. if (record -> event.pressed) {
  344. send_string(".com");
  345. } else {
  346. // when keycode is released
  347. }
  348. break;
  349. case YAHOO:
  350. if (record -> event.pressed) {
  351. send_string("yahoo.com");
  352. } else {
  353. // when keycode is released
  354. }
  355. break;
  356. case OUTLOOK:
  357. if (record -> event.pressed) {
  358. send_string("outlook.com");
  359. } else {
  360. // when keycode is released
  361. }
  362. break;
  363. case GMAIL:
  364. if (record -> event.pressed) {
  365. send_string("gmail.com");
  366. } else {
  367. // when keycode is released
  368. }
  369. break;
  370. case HOTMAIL:
  371. if (record -> event.pressed) {
  372. send_string("hotmail.com");
  373. } else {
  374. // when keycode is released
  375. }
  376. break;
  377. // Windows Key lockout
  378. case WINLOCK:
  379. if (record -> event.pressed) {
  380. keymap_config.no_gui = !keymap_config.no_gui; //toggle status
  381. } else unregister_code16(keycode);
  382. break;
  383. // Double Zero
  384. case KC_00:
  385. if (record -> event.pressed) {
  386. // when keycode KC_00 is pressed
  387. send_string("00");
  388. } else unregister_code16(keycode);
  389. break;
  390. // Treat Control & Shift-Space as if regular Space
  391. case KC_SPC:
  392. if (user_config.disable_space_mods) {
  393. // Initialize a boolean variable that keeps track of the space key status: registered or not?
  394. static bool spckey_registered;
  395. if (record -> event.pressed) {
  396. // Detect the activation of either ctrl keys
  397. if (mod_state & MOD_MASK_CTRL) {
  398. // First temporarily canceling both ctrls so that
  399. // ctrl isn't applied to the KC_SPC keycode
  400. del_mods(MOD_MASK_CTRL);
  401. register_code(KC_SPC);
  402. // Update the boolean variable to reflect the status of KC_SPC
  403. spckey_registered = true;
  404. // Reapplying modifier state so that the held ctrl key(s)
  405. // still work even after having tapped the Space key.
  406. set_mods(mod_state);
  407. return false;
  408. }
  409. else if (mod_state & MOD_MASK_SHIFT) {
  410. // First temporarily canceling both shifts so that
  411. // shift isn't applied to the KC_SPC keycode
  412. del_mods(MOD_MASK_SHIFT);
  413. register_code(KC_SPC);
  414. // Update the boolean variable to reflect the status of KC_SPC
  415. spckey_registered = true;
  416. // Reapplying modifier state so that the held shift key(s)
  417. // still work even after having tapped the Space key.
  418. set_mods(mod_state);
  419. return false;
  420. }
  421. } else { // on release of KC_SPC
  422. // In case KC_SPC is still being sent even after the release of KC_SPC
  423. if (spckey_registered) {
  424. unregister_code(KC_SPC);
  425. spckey_registered = false;
  426. return false;
  427. }
  428. }
  429. }
  430. break;
  431. // INS as SHIFT-modified BackSpace key
  432. case KC_BSPC: {
  433. if (user_config.ins_on_shft_bkspc_or_del) {
  434. // Initialize a boolean variable that keeps track of the ins key status: registered or not?
  435. static bool inskey_registered;
  436. if (record -> event.pressed) {
  437. // Detect the activation of either shift keys
  438. if (mod_state & MOD_MASK_SHIFT) {
  439. // First temporarily canceling both shifts so that
  440. // shift isn't applied to the KC_INS keycode
  441. del_mods(MOD_MASK_SHIFT);
  442. register_code(KC_INS);
  443. // Update the boolean variable to reflect the status of KC_INS
  444. inskey_registered = true;
  445. // Reapplying modifier state so that the held shift key(s)
  446. // still work even after having tapped the key.
  447. set_mods(mod_state);
  448. return false;
  449. }
  450. } else { // on release of KC_BSPC
  451. // In case KC_INS is still being sent even after the release of KC_BSPC
  452. if (inskey_registered) {
  453. unregister_code(KC_INS);
  454. inskey_registered = false;
  455. return false;
  456. }
  457. }
  458. }
  459. }
  460. break;
  461. #ifdef IDLE_TIMEOUT_ENABLE
  462. case RGB_TOI:
  463. if (record -> event.pressed) {
  464. timeout_update_threshold(true);
  465. } else unregister_code16(keycode);
  466. break;
  467. case RGB_TOD:
  468. if (record -> event.pressed) {
  469. timeout_update_threshold(false); //decrease timeout
  470. } else unregister_code16(keycode);
  471. break;
  472. #endif // IDLE_TIMEOUT_ENABLE
  473. #ifdef RGB_MATRIX_ENABLE
  474. case RGB_NITE:
  475. if (record -> event.pressed) {
  476. rgb_nightmode = !rgb_nightmode;
  477. } else unregister_code16(keycode);
  478. break;
  479. #endif // RGB_MATRIX_ENABLE
  480. #ifdef EMOTICON_ENABLE
  481. case EMO_SHRUG:
  482. if (record -> event.pressed) send_string("`\\_(\"/)_/`");
  483. else unregister_code16(keycode);
  484. break;
  485. case EMO_CONFUSE:
  486. if (record -> event.pressed) send_string("(*_*)");
  487. else unregister_code16(keycode);
  488. break;
  489. case EMO_TEARS:
  490. if (record -> event.pressed) send_string("(T_T)");
  491. else unregister_code16(keycode);
  492. break;
  493. case EMO_NERVOUS:
  494. if (record -> event.pressed) send_string("(~_~;)");
  495. else unregister_code16(keycode);
  496. break;
  497. case EMO_JOY:
  498. if (record -> event.pressed) send_string("(^o^)");
  499. else unregister_code16(keycode);
  500. break;
  501. case EMO_SAD:
  502. if (record -> event.pressed) send_string(":'-(");
  503. else unregister_code16(keycode);
  504. break;
  505. #endif // EMOTICON_ENABLE
  506. #ifdef ALTTAB_SCROLL_ENABLE
  507. case KC_TSTOG:
  508. if (record -> event.pressed) encoder_toggle_alttabscroll();
  509. else unregister_code16(keycode);
  510. break;
  511. #endif // ALTTAB_SCROLL_ENABLE
  512. default:
  513. if (record -> event.pressed) {
  514. #ifdef RGB_MATRIX_ENABLE
  515. rgb_matrix_enable();
  516. #endif
  517. #ifdef IDLE_TIMEOUT_ENABLE
  518. timeout_reset_timer(); //reset activity timer
  519. #endif
  520. }
  521. break;
  522. }
  523. return true;
  524. };
  525. // Define custom Caps Word continuity characters
  526. bool caps_word_press_user(uint16_t keycode) {
  527. switch (keycode) {
  528. // Keycodes that continue Caps Word, with shift applied.
  529. case KC_A ... KC_Z:
  530. case KC_TILD:
  531. case KC_UNDS:
  532. case KC_DQT:
  533. case KC_COLN:
  534. case KC_RSFT:
  535. case LSFTCAPSWIN:
  536. add_weak_mods(MOD_BIT(KC_LSFT)); // Apply shift to next key.
  537. return true;
  538. // Keycodes that continue Caps Word, without shifting.
  539. case KC_1 ... KC_0:
  540. case KC_GRV:
  541. case KC_MINS:
  542. case KC_QUOT:
  543. case KC_SCLN:
  544. case KC_BSPC:
  545. case KC_DEL:
  546. return true;
  547. default:
  548. return false; // Deactivate Caps Word.
  549. }
  550. }
  551. // Turn on/off NUM LOCK if current state is different
  552. void activate_numlock(bool turn_on) {
  553. if (IS_HOST_LED_ON(USB_LED_NUM_LOCK) != turn_on) {
  554. tap_code(KC_NUMLOCK);
  555. }
  556. }
  557. // INITIAL STARTUP
  558. __attribute__((weak)) void keyboard_post_init_keymap(void) {
  559. }
  560. void keyboard_post_init_user(void) {
  561. // Read the user config from EEPROM
  562. user_config.raw = eeconfig_read_user();
  563. keyboard_post_init_keymap();
  564. #ifdef STARTUP_NUMLOCK_ON
  565. activate_numlock(true); // turn on Num lock by default so that the numpad layer always has predictable results
  566. #endif // STARTUP_NUMLOCK_ON
  567. #ifdef IDLE_TIMEOUT_ENABLE
  568. timeout_timer = timer_read(); // set initial time for idle timeout
  569. #endif
  570. }
  571. /* Set defaults for EEPROM user configuration variables */
  572. void eeconfig_init_user(void) {
  573. user_config.raw = 0;
  574. user_config.rgb_hilite_caps = true;
  575. user_config.rgb_hilite_numpad = true;
  576. user_config.double_tap_shift_for_capslock = true;
  577. user_config.del_right_home_top = true;
  578. user_config.encoder_press_mute_or_media = true;
  579. user_config.esc_double_tap_to_baselyr = true;
  580. user_config.ins_on_shft_bkspc_or_del = true;
  581. user_config.disable_space_mods = true;
  582. eeconfig_update_user(user_config.raw);
  583. }