keymap.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. #include QMK_KEYBOARD_H
  2. enum ctrl_keycodes {
  3. L_BRI = SAFE_RANGE, //LED Brightness Increase //Working
  4. L_BRD, //LED Brightness Decrease //Working
  5. L_EDG_I, //LED Edge Brightness Increase
  6. L_EDG_D, //LED Edge Brightness Decrease
  7. L_EDG_M, //LED Edge lighting mode
  8. L_PTN, //LED Pattern Select Next //Working
  9. L_PTP, //LED Pattern Select Previous //Working
  10. L_PSI, //LED Pattern Speed Increase //Working
  11. L_PSD, //LED Pattern Speed Decrease //Working
  12. L_RATIOD,
  13. L_RATIOI,
  14. L_T_MD, //LED Toggle Mode //Working
  15. L_T_ONF, //LED Toggle On / Off //Broken
  16. L_ON, //LED On //Broken
  17. L_OFF, //LED Off //Broken
  18. L_T_BR, //LED Toggle Breath Effect //Working
  19. L_T_PTD, //LED Toggle Scrolling Pattern Direction //Working
  20. U_T_AGCR, //USB Toggle Automatic GCR control //Working
  21. DBG_TOG, //DEBUG Toggle On / Off //
  22. DBG_MTRX, //DEBUG Toggle Matrix Prints //
  23. DBG_KBD, //DEBUG Toggle Keyboard Prints //
  24. DBG_MOU, //DEBUG Toggle Mouse Prints //
  25. DBG_FAC, //DEBUG Factory light testing (All on white)
  26. MD_BOOT //Restart into bootloader after hold timeout //Working
  27. };
  28. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  29. [0] = LAYOUT(
  30. 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_PSCR, KC_SCRL, KC_PAUS,
  31. 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, KC_INS, KC_HOME, KC_PGUP,
  32. 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, KC_DEL, KC_END, KC_PGDN,
  33. 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,
  34. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP,
  35. KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, MO(1), KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
  36. ),
  37. [1] = LAYOUT(
  38. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MUTE, _______, _______,
  39. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPLY, KC_MSTP, KC_VOLU,
  40. L_T_BR, L_PSD, L_BRI, L_PSI, L_EDG_I, _______, _______, _______, U_T_AGCR,_______, _______, _______, _______, _______, KC_MPRV, KC_MNXT, KC_VOLD,
  41. L_T_PTD, L_PTP, L_BRD, L_PTN, L_EDG_D, _______, _______, _______, _______, _______, _______, _______, _______,
  42. _______, L_T_MD, L_T_ONF, _______, L_EDG_M, MD_BOOT, NK_TOGG, _______, _______, _______, _______, _______, _______,
  43. _______, _______, _______, DBG_FAC, _______, _______, _______, _______, _______, _______, _______
  44. ),
  45. /*
  46. [X] = LAYOUT(
  47. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  48. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  49. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  50. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  51. _______, _______, _______, _______, _______, _______, NK_TOGG, _______, _______, _______, _______, _______, _______,
  52. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
  53. ),
  54. */
  55. };
  56. // Runs just one time when the keyboard initializes.
  57. void matrix_init_user(void) {
  58. };
  59. // Runs constantly in the background, in a loop.
  60. void matrix_scan_user(void) {
  61. };
  62. #define MODS_SHIFT (get_mods() & MOD_BIT(KC_LSFT) || get_mods() & MOD_BIT(KC_RSFT))
  63. #define MODS_CTRL (get_mods() & MOD_BIT(KC_LCTL) || get_mods() & MOD_BIT(KC_RCTL))
  64. #define MODS_ALT (get_mods() & MOD_BIT(KC_LALT) || get_mods() & MOD_BIT(KC_RALT))
  65. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  66. static uint32_t key_timer;
  67. static uint8_t scroll_effect = 0;
  68. switch (keycode) {
  69. case L_BRI:
  70. if (record->event.pressed) {
  71. if (LED_GCR_STEP > LED_GCR_MAX - gcr_desired) gcr_desired = LED_GCR_MAX;
  72. else gcr_desired += LED_GCR_STEP;
  73. if (led_animation_breathing) gcr_breathe = gcr_desired;
  74. }
  75. return false;
  76. case L_BRD:
  77. if (record->event.pressed) {
  78. if (LED_GCR_STEP > gcr_desired) gcr_desired = 0;
  79. else gcr_desired -= LED_GCR_STEP;
  80. if (led_animation_breathing) gcr_breathe = gcr_desired;
  81. }
  82. return false;
  83. case L_EDG_M:
  84. if (record->event.pressed) {
  85. led_edge_mode++;
  86. if (led_edge_mode > LED_EDGE_MODE_MAX) {
  87. led_edge_mode = LED_EDGE_MODE_ALL;
  88. }
  89. }
  90. return false;
  91. case L_EDG_I:
  92. if (record->event.pressed) {
  93. led_edge_brightness += 0.1;
  94. if (led_edge_brightness > 1) { led_edge_brightness = 1; }
  95. }
  96. return false;
  97. case L_EDG_D:
  98. if (record->event.pressed) {
  99. led_edge_brightness -= 0.1;
  100. if (led_edge_brightness < 0) { led_edge_brightness = 0; }
  101. }
  102. return false;
  103. case L_RATIOI:
  104. if (record->event.pressed) {
  105. led_ratio_brightness += 0.2;
  106. if (led_ratio_brightness > 2.0) { led_ratio_brightness = 2.0; }
  107. }
  108. return false;
  109. case L_RATIOD:
  110. if (record->event.pressed) {
  111. led_ratio_brightness -= 0.2;
  112. if (led_ratio_brightness < 0.0) { led_ratio_brightness = 0.0; }
  113. }
  114. return false;
  115. case L_PTN:
  116. if (record->event.pressed) {
  117. if (led_animation_id == led_setups_count - 1) led_animation_id = 0;
  118. else led_animation_id++;
  119. }
  120. return false;
  121. case L_PTP:
  122. if (record->event.pressed) {
  123. if (led_animation_id == 0) led_animation_id = led_setups_count - 1;
  124. else led_animation_id--;
  125. }
  126. return false;
  127. case L_PSI:
  128. if (record->event.pressed) {
  129. led_animation_speed += ANIMATION_SPEED_STEP;
  130. }
  131. return false;
  132. case L_PSD:
  133. if (record->event.pressed) {
  134. led_animation_speed -= ANIMATION_SPEED_STEP;
  135. if (led_animation_speed < 0) led_animation_speed = 0;
  136. }
  137. return false;
  138. case L_T_MD:
  139. if (record->event.pressed) {
  140. led_lighting_mode++;
  141. if (led_lighting_mode > LED_MODE_MAX_INDEX) led_lighting_mode = LED_MODE_NORMAL;
  142. }
  143. return false;
  144. case L_T_ONF:
  145. if (record->event.pressed) {
  146. led_enabled = !led_enabled;
  147. I2C3733_Control_Set(led_enabled);
  148. }
  149. return false;
  150. case L_ON:
  151. if (record->event.pressed) {
  152. led_enabled = 1;
  153. I2C3733_Control_Set(led_enabled);
  154. }
  155. return false;
  156. case L_OFF:
  157. if (record->event.pressed) {
  158. led_enabled = 0;
  159. I2C3733_Control_Set(led_enabled);
  160. }
  161. return false;
  162. case L_T_BR:
  163. if (record->event.pressed) {
  164. led_animation_breathing = !led_animation_breathing;
  165. if (led_animation_breathing) {
  166. gcr_breathe = gcr_desired;
  167. led_animation_breathe_cur = BREATHE_MIN_STEP;
  168. breathe_dir = 1;
  169. }
  170. }
  171. return false;
  172. case L_T_PTD:
  173. if (record->event.pressed) {
  174. scroll_effect++;
  175. if (scroll_effect == 1) { //Patterns with scroll move horizontal (Right to left)
  176. led_animation_direction = 1;
  177. led_animation_orientation = 0;
  178. led_animation_circular = 0;
  179. } else if (scroll_effect == 2) { //Patterns with scroll move vertical (Top to bottom)
  180. led_animation_direction = 1;
  181. led_animation_orientation = 1;
  182. led_animation_circular = 0;
  183. } else if (scroll_effect == 3) { //Patterns with scroll move vertical (Bottom to top)
  184. led_animation_direction = 0;
  185. led_animation_orientation = 1;
  186. led_animation_circular = 0;
  187. } else if (scroll_effect == 4) { //Patterns with scroll explode from center
  188. led_animation_direction = 0;
  189. led_animation_orientation = 0;
  190. led_animation_circular = 1;
  191. } else if (scroll_effect == 5) { //Patterns with scroll implode on center
  192. led_animation_direction = 1;
  193. led_animation_orientation = 0;
  194. led_animation_circular = 1;
  195. } else { //Patterns with scroll move horizontal (Left to right)
  196. scroll_effect = 0;
  197. led_animation_direction = 0;
  198. led_animation_orientation = 0;
  199. led_animation_circular = 0;
  200. }
  201. }
  202. return false;
  203. case U_T_AGCR:
  204. if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
  205. TOGGLE_FLAG_AND_PRINT(usb_gcr_auto, "USB GCR auto mode");
  206. }
  207. return false;
  208. case DBG_FAC:
  209. if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
  210. led_lighting_mode = LED_MODE_NORMAL;
  211. led_edge_brightness = 1;
  212. led_edge_mode = LED_EDGE_MODE_ALL;
  213. led_animation_breathing = 0;
  214. led_animation_id = 7; //led_programs.c led_setups leds_white index
  215. gcr_desired = LED_GCR_MAX;
  216. led_enabled = 1;
  217. I2C3733_Control_Set(led_enabled);
  218. }
  219. return false;
  220. case DBG_TOG:
  221. if (record->event.pressed) {
  222. TOGGLE_FLAG_AND_PRINT(debug_enable, "Debug mode");
  223. }
  224. return false;
  225. case DBG_MTRX:
  226. if (record->event.pressed) {
  227. TOGGLE_FLAG_AND_PRINT(debug_matrix, "Debug matrix");
  228. }
  229. return false;
  230. case DBG_KBD:
  231. if (record->event.pressed) {
  232. TOGGLE_FLAG_AND_PRINT(debug_keyboard, "Debug keyboard");
  233. }
  234. return false;
  235. case DBG_MOU:
  236. if (record->event.pressed) {
  237. TOGGLE_FLAG_AND_PRINT(debug_mouse, "Debug mouse");
  238. }
  239. return false;
  240. case MD_BOOT:
  241. if (record->event.pressed) {
  242. key_timer = timer_read32();
  243. } else {
  244. if (timer_elapsed32(key_timer) >= 500) {
  245. reset_keyboard();
  246. }
  247. }
  248. return false;
  249. default:
  250. return true; //Process all other keycodes normally
  251. }
  252. }
  253. led_instruction_t led_instructions[] = {
  254. //Please see ../default_md/keymap.c for examples
  255. //All LEDs use the user's selected pattern (this is the factory default)
  256. { .flags = LED_FLAG_USE_ROTATE_PATTERN },
  257. //end must be set to 1 to indicate end of instruction set
  258. { .end = 1 }
  259. };