keymap.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 "christmas_tree.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. #define _______ KC_TRNS
  27. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  28. /* Base
  29. * ,------.
  30. * | 1 |
  31. * ,------+------.
  32. * | 2 | 3 |
  33. * ,------+------+------.
  34. * | 4 | FUNC | 6 |
  35. * `--------------------'
  36. */
  37. [_BASE] = KEYMAP(KC_1, KC_2, KC_3, KC_4, MO(_FUNC), KC_6),
  38. /* Func
  39. * ,------.
  40. * |BCKLIT|
  41. * ,------+------.
  42. * | 8 | 9 |
  43. * ,------+------+------.
  44. * | 0 | FUNC | RESET|
  45. * `--------------------'
  46. */
  47. [_FUNC] = KEYMAP(BACKLIT, KC_8, KC_9, KC_0, _______, RESET)
  48. };
  49. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  50. switch (keycode) {
  51. case BACKLIT:
  52. if (record->event.pressed) {
  53. register_code(KC_RSFT);
  54. #ifdef BACKLIGHT_ENABLE
  55. register_code(KC_LSFT);
  56. backlight_step();
  57. #endif
  58. } else {
  59. unregister_code(KC_RSFT);
  60. unregister_code(KC_LSFT);
  61. }
  62. return false;
  63. break;
  64. }
  65. return true;
  66. }