keymap.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "roadkit.h"
  2. #include "action_layer.h"
  3. #include "eeconfig.h"
  4. extern keymap_config_t keymap_config;
  5. // Each layer gets a name for readability, which is then used in the keymap matrix below.
  6. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
  7. // Layer names don't all need to be of the same length, obviously, and you can also skip them
  8. // entirely and just use numbers.
  9. #define _NP 0
  10. #define _L1 1
  11. // Macro name shortcuts
  12. #define NUMPAD M(_NP)
  13. #define LAYER1 M(_L1)
  14. // Fillers to make layering more clear
  15. #define _______ KC_TRNS
  16. #define XXXXXXX KC_NO
  17. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  18. [_NP] = /* Numpad */
  19. SINGLES_KEYMAP(KC_KP_7, KC_KP_8, KC_KP_9, KC_KP_PLUS, \
  20. KC_KP_4, KC_KP_5, KC_KP_6, KC_KP_MINUS, \
  21. KC_KP_1, KC_KP_2, KC_KP_3, KC_KP_ENTER, \
  22. KC_KP_0, KC_KP_DOT, TG(_L1), KC_BSPC),
  23. [_L1] = /* LAYER 1 */
  24. SINGLES_KEYMAP(KC_NUMLOCK, KC_TRNS, KC_TRNS, KC_VOLU, \
  25. KC_TRNS, KC_UP, KC_TRNS, KC_VOLD, \
  26. KC_LEFT, KC_DOWN, KC_RIGHT, KC_TRNS, \
  27. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
  28. };
  29. const uint16_t PROGMEM fn_actions[] = {
  30. };
  31. void persistant_default_layer_set(uint16_t default_layer) {
  32. eeconfig_update_default_layer(default_layer);
  33. default_layer_set(default_layer);
  34. }
  35. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
  36. {
  37. switch(id) {
  38. case _L1:
  39. if (record->event.pressed) {
  40. persistant_default_layer_set(1UL<<_L1);
  41. }
  42. break;
  43. case _NP:
  44. if (record->event.pressed) {
  45. persistant_default_layer_set(1UL<<_NP);
  46. }
  47. break;
  48. }
  49. return MACRO_NONE;
  50. };