keymap.c 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* Copyright 2020 Leon Anavi <leon@anavi.org>
  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. #define _MAIN 0
  18. #define _FN 1
  19. #define KC_X0 LT(_FN, KC_ESC)
  20. #ifdef RGBLIGHT_ENABLE
  21. // How long (in ms) to wait between animation steps for the rainbow mode
  22. const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[] PROGMEM = {60, 30, 15};
  23. // How long (in milliseconds) to wait between animation steps for each of the "Swirling rainbow" animations
  24. const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[] PROGMEM = {20, 10, 4};
  25. #endif
  26. /*
  27. * This keymap contains the following shortcuts for OBS:
  28. *
  29. * - Shortcuts useful for switching scenes on the 1st row:
  30. * Hold Left Control, Shift, Alt and GUI and press F9
  31. * Hold Left Control, Shift, Alt and GUI and press F10
  32. * Hold Left Control, Shift, Alt and GUI and press F11
  33. * Hold Left Control, Shift, Alt and GUI and press F12
  34. * - Center to screen: Ctrl+D
  35. * - Fit to screen: Ctrl+F
  36. * - Move source to top of sources list: Ctrl+Home
  37. */
  38. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  39. [_MAIN] = LAYOUT_ortho_2x4(
  40. HYPR(KC_F9), HYPR(KC_F10), HYPR(KC_F11), HYPR(KC_F12),
  41. LCTL(KC_D), LCTL(KC_F), LCTL(KC_HOME), MO(_FN)
  42. ),
  43. [_FN] = LAYOUT_ortho_2x4(
  44. RGB_TOG, RGB_MOD, RGB_M_R, RGB_M_SN,
  45. BL_TOGG, BL_STEP, BL_BRTG, _______
  46. )
  47. };
  48. #ifdef OLED_DRIVER_ENABLE
  49. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  50. return OLED_ROTATION_180; // flips the display 180 degrees if offhand
  51. }
  52. void oled_task_user(void) {
  53. // Host Keyboard Layer Status
  54. oled_write_ln_P(PSTR("ANAVI Macro Pad 8"), false);
  55. oled_write_P(PSTR("Active layer: "), false);
  56. switch (get_highest_layer(layer_state)) {
  57. case _MAIN:
  58. oled_write_ln_P(PSTR("OBS"), false);
  59. break;
  60. case _FN:
  61. oled_write_ln_P(PSTR("FN"), false);
  62. break;
  63. default:
  64. // Or use the write_ln shortcut over adding '\n' to the end of your string
  65. oled_write_ln_P(PSTR("N/A"), false);
  66. }
  67. // Host Keyboard LED Status
  68. led_t led_state = host_keyboard_led_state();
  69. oled_write_P(PSTR("Num Lock: "), false);
  70. oled_write_ln_P(led_state.num_lock ? PSTR("On") : PSTR("Off"), false);
  71. oled_write_P(PSTR("Caps Lock: "), false);
  72. oled_write_ln_P(led_state.caps_lock ? PSTR("On") : PSTR("Off"), false);
  73. oled_write_P(PSTR("Scroll Lock: "), false);
  74. oled_write_ln_P(led_state.scroll_lock ? PSTR("On") : PSTR("Off"), false);
  75. oled_write_P(PSTR("Backlit: "), false);
  76. oled_write_ln_P(is_backlight_enabled() ? PSTR("On") : PSTR("Off"), false);
  77. #ifdef RGBLIGHT_ENABLE
  78. static char rgbStatusLine1[26] = {0};
  79. snprintf(rgbStatusLine1, sizeof(rgbStatusLine1), "RGB Mode: %d", rgblight_get_mode());
  80. oled_write_ln(rgbStatusLine1, false);
  81. static char rgbStatusLine2[26] = {0};
  82. snprintf(rgbStatusLine2, sizeof(rgbStatusLine2), "h:%d s:%d v:%d", rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val());
  83. oled_write_ln(rgbStatusLine2, false);
  84. #endif
  85. }
  86. #endif