keymap.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* Copyright 2021 Stanrc85
  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. #include "stanrc85.h"
  18. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  19. [_QWERTY] = LAYOUT_alice(
  20. KC_ESC, 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,
  21. KC_PGUP, 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,
  22. KC_PGDN, KC_CTLE, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
  23. _______, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, MO(_FN2_60),
  24. KC_LCTL, KC_LALT, LT_BPCF, KC_LGUI, LT_SPCF, TD_TWIN, TD_TCTL
  25. ),
  26. [_DEFAULT] = LAYOUT_alice(
  27. KC_ESC, 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,
  28. KC_PGUP, 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,
  29. KC_PGDN, 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,
  30. _______, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, MO(_FN2_60),
  31. KC_LCTL, KC_LALT, KC_SPC, MO(_FN1_60), KC_SPC, KC_RALT, KC_RCTL
  32. ),
  33. [_FN1_60] = LAYOUT_alice(
  34. _______, KC_TILD, 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,
  35. _______, _______, _______, CA_QUOT, _______, CA_SCLN, KC_VOLU, KC_PGUP, KC_BSPC, KC_UP, KC_DEL, KC_PSCR, _______, _______, KC_INS,
  36. _______, KC_CAPS, _______, _______, KC_LCTL, KC_LSFT, KC_VOLD, KC_PGDN, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______,
  37. _______, _______, KC_RDP, _______, _______, _______, _______, _______, _______, KC_WBAK, KC_WFWD, _______, _______, _______, _______,
  38. _______, _______, _______, _______, _______, _______, _______
  39. ),
  40. [_FN2_60] = LAYOUT_alice(
  41. BL_TOGG, RGB_TOG, RGB_MOD, RGB_VAD, RGB_VAI, RGB_SAI, RGB_HUD, RGB_HUI, _______, _______, _______, _______, _______, _______, _______,
  42. BL_INC, VLK_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET,
  43. BL_DEC, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MAKE,
  44. _______, _______, _______, _______, _______, _______, _______, _______, NK_TOGG, _______, _______, _______, _______, _______, _______,
  45. _______, _______, _______, _______, _______, _______, TG(_DEFAULT)
  46. )
  47. };
  48. #ifdef OLED_DRIVER_ENABLE
  49. void oled_task_user(void) {
  50. static const char PROGMEM qmk_logo[] = {
  51. 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94,
  52. 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4,
  53. 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0x00
  54. };
  55. switch (get_highest_layer(layer_state)) {
  56. case _QWERTY:
  57. oled_write_P(qmk_logo, false);
  58. break;
  59. case _DEFAULT:
  60. oled_write_ln_P(PSTR(" Layer: Game\n\n"), false);
  61. break;
  62. case _FN1_60:
  63. oled_write_ln_P(PSTR(" Layer: FN\n\n"), false);
  64. break;
  65. case _FN2_60:
  66. oled_write_ln_P(PSTR(" Layer: RGB\n\n"), false);
  67. break;
  68. default:
  69. // Or use the write_ln shortcut over adding '\n' to the end of your string
  70. oled_write_ln_P(PSTR("Undefined"), false);
  71. }
  72. // Host Keyboard LED Status
  73. led_t led_state = host_keyboard_led_state();
  74. oled_write_P(led_state.num_lock ? PSTR("NUM ") : PSTR(" "), false);
  75. oled_write_P(led_state.caps_lock ? PSTR("CAP ") : PSTR(" "), false);
  76. oled_write_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR(" "), false);
  77. }
  78. #endif
  79. // Backlight timeout feature
  80. #define BACKLIGHT_TIMEOUT 20 // in minutes
  81. static uint16_t idle_timer = 0;
  82. static uint8_t halfmin_counter = 0;
  83. static bool led_on = true;
  84. static bool rgb_on = true;
  85. void matrix_scan_user(void) {
  86. // idle_timer needs to be set one time
  87. if (idle_timer == 0) idle_timer = timer_read();
  88. if ( (led_on && timer_elapsed(idle_timer) > 30000) || (rgb_on && timer_elapsed(idle_timer) > 30000)) {
  89. halfmin_counter++;
  90. idle_timer = timer_read();
  91. }
  92. if ( (led_on && halfmin_counter >= BACKLIGHT_TIMEOUT * 2) || (rgb_on && halfmin_counter >= BACKLIGHT_TIMEOUT * 2)) {
  93. rgblight_disable_noeeprom();
  94. led_on = false;
  95. rgb_on = false;
  96. halfmin_counter = 0;
  97. }
  98. };
  99. bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
  100. if (record->event.pressed) {
  101. if (led_on == false || rgb_on == false ) {
  102. rgblight_enable_noeeprom();
  103. led_on = true;
  104. rgb_on = true;
  105. }
  106. idle_timer = timer_read();
  107. halfmin_counter = 0;
  108. }
  109. return true;
  110. }