keymap.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* Copyright 2015-2017 Jack Humbert
  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. extern keymap_config_t keymap_config;
  18. enum layers {
  19. _BASE,
  20. _FUNC
  21. };
  22. enum custom_keycodes {
  23. FUNC = SAFE_RANGE,
  24. BACKLIT
  25. };
  26. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  27. /* Base
  28. * ,------.
  29. * | 1 |
  30. * ,------+------.
  31. * | 2 | 3 |
  32. * ,------+------+------.
  33. * | 4 | FUNC | 6 |
  34. * `--------------------'
  35. */
  36. [_BASE] = LAYOUT(
  37. KC_1,
  38. KC_2, KC_3,
  39. KC_4, MO(_FUNC), KC_6
  40. ),
  41. /* Func
  42. * ,------.
  43. * |BCKLIT|
  44. * ,------+------.
  45. * | 8 | 9 |
  46. * ,------+------+------.
  47. * | 0 | FUNC | RESET|
  48. * `--------------------'
  49. */
  50. [_FUNC] = LAYOUT(
  51. BACKLIT,
  52. KC_8, KC_9,
  53. KC_0, _______, RESET
  54. )
  55. };
  56. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  57. switch (keycode) {
  58. case BACKLIT:
  59. if (record->event.pressed) {
  60. register_code(KC_RSFT);
  61. #ifdef BACKLIGHT_ENABLE
  62. register_code(KC_LSFT);
  63. backlight_step();
  64. #endif
  65. } else {
  66. unregister_code(KC_RSFT);
  67. unregister_code(KC_LSFT);
  68. }
  69. return false;
  70. break;
  71. }
  72. return true;
  73. }