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.

122 lines
5.5 KiB

  1. /* Copyright 2022 charlesrocket
  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. enum alt_keycodes {
  18. U_T_AUTO = SAFE_RANGE, //USB Extra Port Toggle Auto Detect / Always Active
  19. U_T_AGCR, //USB Toggle Automatic GCR control
  20. DBG_TOG, //DEBUG Toggle On / Off
  21. DBG_MTRX, //DEBUG Toggle Matrix Prints
  22. DBG_KBD, //DEBUG Toggle Keyboard Prints
  23. DBG_MOU, //DEBUG Toggle Mouse Prints
  24. MD_BOOT, //Restart into bootloader after hold timeout
  25. };
  26. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  27. [0] = LAYOUT_65_ansi_blocker(
  28. KC_ESC, 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_DEL,
  29. 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_HOME,
  30. 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, KC_PGUP,
  31. 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, KC_PGDN,
  32. KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_LEFT, KC_DOWN, KC_RGHT
  33. ),
  34. [1] = LAYOUT_65_ansi_blocker(
  35. KC_GRV, 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_MUTE,
  36. _______, RGB_SPD, RGB_VAI, RGB_SPI, RGB_HUI, RGB_SAI, _______, U_T_AUTO,U_T_AGCR,_______, KC_PSCR, KC_SLCK, KC_PAUS, _______, KC_END,
  37. _______, RGB_RMOD,RGB_VAD, RGB_MOD, RGB_HUD, RGB_SAD, _______, _______, _______, _______, _______, _______, _______, KC_VOLU,
  38. _______, RGB_TOG, _______, _______, _______, MD_BOOT, NK_TOGG, DBG_TOG, _______, _______, _______, _______, KC_PGUP, KC_VOLD,
  39. _______, LAG_SWP, LAG_NRM, _______, KC_APP, _______, KC_HOME, KC_PGDN, KC_END
  40. ),
  41. };
  42. #define MODS_SHIFT (get_mods() & MOD_BIT(KC_LSHIFT) || get_mods() & MOD_BIT(KC_RSHIFT))
  43. #define MODS_CTRL (get_mods() & MOD_BIT(KC_LCTL) || get_mods() & MOD_BIT(KC_RCTRL))
  44. #define MODS_ALT (get_mods() & MOD_BIT(KC_LALT) || get_mods() & MOD_BIT(KC_RALT))
  45. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  46. static uint32_t key_timer;
  47. switch (keycode) {
  48. case U_T_AUTO:
  49. if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
  50. TOGGLE_FLAG_AND_PRINT(usb_extra_manual, "USB extra port manual mode");
  51. }
  52. return false;
  53. case U_T_AGCR:
  54. if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
  55. TOGGLE_FLAG_AND_PRINT(usb_gcr_auto, "USB GCR auto mode");
  56. }
  57. return false;
  58. case DBG_TOG:
  59. if (record->event.pressed) {
  60. TOGGLE_FLAG_AND_PRINT(debug_enable, "Debug mode");
  61. }
  62. return false;
  63. case DBG_MTRX:
  64. if (record->event.pressed) {
  65. TOGGLE_FLAG_AND_PRINT(debug_matrix, "Debug matrix");
  66. }
  67. return false;
  68. case DBG_KBD:
  69. if (record->event.pressed) {
  70. TOGGLE_FLAG_AND_PRINT(debug_keyboard, "Debug keyboard");
  71. }
  72. return false;
  73. case DBG_MOU:
  74. if (record->event.pressed) {
  75. TOGGLE_FLAG_AND_PRINT(debug_mouse, "Debug mouse");
  76. }
  77. return false;
  78. case MD_BOOT:
  79. if (record->event.pressed) {
  80. key_timer = timer_read32();
  81. } else {
  82. if (timer_elapsed32(key_timer) >= 500) {
  83. reset_keyboard();
  84. }
  85. }
  86. return false;
  87. case RGB_TOG:
  88. if (record->event.pressed) {
  89. switch (rgb_matrix_get_flags()) {
  90. case LED_FLAG_ALL: {
  91. rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR);
  92. rgb_matrix_set_color_all(0, 0, 0);
  93. }
  94. break;
  95. case (LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR): {
  96. rgb_matrix_set_flags(LED_FLAG_UNDERGLOW);
  97. rgb_matrix_set_color_all(0, 0, 0);
  98. }
  99. break;
  100. case LED_FLAG_UNDERGLOW: {
  101. rgb_matrix_set_flags(LED_FLAG_NONE);
  102. rgb_matrix_disable_noeeprom();
  103. }
  104. break;
  105. default: {
  106. rgb_matrix_set_flags(LED_FLAG_ALL);
  107. rgb_matrix_enable_noeeprom();
  108. }
  109. break;
  110. }
  111. }
  112. return false;
  113. default:
  114. return true;
  115. }
  116. }