keymap.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* Copyright 2019 merlin04
  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. // Defines names for use in layer keycodes and the keymap
  18. enum layer_names {
  19. _BASE,
  20. _FN
  21. };
  22. // Defines the keycodes used by our macros in process_record_user
  23. /*enum custom_keycodes {
  24. };*/
  25. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  26. /* Base */
  27. [_BASE] = LAYOUT(
  28. KC_PGUP, KC_UP, KC_PGDN,
  29. KC_LEFT, KC_DOWN, KC_RIGHT,
  30. MO(_FN), KC_MUTE, BL_TOGG
  31. ),
  32. [_FN] = LAYOUT(
  33. KC_HOME, KC_CALC, KC_END,
  34. BL_STEP, KC_ESC, KC_SLEP,
  35. KC_TRNS, KC_MPLY, RESET
  36. )
  37. };
  38. void encoder_update_user(uint8_t index, bool clockwise) {
  39. switch (biton32(layer_state)) {
  40. case _BASE:
  41. if (clockwise) {
  42. tap_code(KC_VOLU);
  43. } else {
  44. tap_code(KC_VOLD);
  45. }
  46. break;
  47. case _FN:
  48. if (clockwise) {
  49. tap_code(KC_MNXT);
  50. } else {
  51. tap_code(KC_MPRV);
  52. }
  53. }
  54. }
  55. #ifdef OLED_DRIVER_ENABLE
  56. void oled_task_user(void) {
  57. // Host Keyboard Layer Status
  58. oled_write_P(PSTR("Layer: "), false);
  59. switch (biton32(layer_state)) {
  60. case _BASE:
  61. oled_write_P(PSTR("Default\n"), false);
  62. break;
  63. case _FN:
  64. oled_write_P(PSTR("FN\n"), false);
  65. break;
  66. default:
  67. // Or use the write_ln shortcut over adding '\n' to the end of your string
  68. oled_write_ln_P(PSTR("Undefined"), false);
  69. }
  70. // Host Keyboard LED Status
  71. uint8_t usb_led = host_keyboard_leds();
  72. oled_write_P(IS_LED_ON(usb_led, USB_LED_NUM_LOCK) ? PSTR("NUMLCK ") : PSTR(" "), false);
  73. oled_write_P(IS_LED_ON(usb_led, USB_LED_CAPS_LOCK) ? PSTR("CAPLCK ") : PSTR(" "), false);
  74. oled_write_P(IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK) ? PSTR("SCRLCK ") : PSTR(" "), false);
  75. }
  76. #endif