keymap.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #include "../../crawlpad.h"
  2. enum custom_keycodes {
  3. BL1 = SAFE_RANGE,
  4. BL2,
  5. BL3,
  6. BL4
  7. };
  8. const uint8_t LED_PINS[] = LED_ROW_PINS;
  9. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  10. KEYMAP(
  11. KC_P7, KC_P8, KC_P9, KC_PPLS,
  12. KC_P4, KC_P5, KC_P6, KC_PMNS,
  13. KC_P1, KC_P2, KC_P3, KC_PAST,
  14. MO(1), KC_P0, KC_PDOT, KC_ENT),
  15. KEYMAP(
  16. KC_NLCK, BL1, KC_TRNS, KC_PSLS,
  17. RESET, BL2, KC_TRNS, KC_TRNS,
  18. KC_TRNS, BL3, KC_TRNS, KC_TRNS,
  19. KC_TRNS, BL4, KC_TRNS, KC_TRNS),
  20. };
  21. void set_led(int idx, bool enable) {
  22. uint8_t pin = LED_PINS[idx];
  23. if (enable) {
  24. _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF);
  25. } else {
  26. /* PORTx &= ~n */
  27. _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF);
  28. }
  29. }
  30. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
  31. return MACRO_NONE ;
  32. }
  33. void matrix_init_user(void) {
  34. /* set LED row pins to output and low */
  35. DDRB |= (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7);
  36. PORTB &= ~(1 << 4) & ~(1 << 5) & ~(1 << 6) & ~(1 << 7);
  37. }
  38. void matrix_scan_user(void) {
  39. }
  40. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  41. switch (keycode) {
  42. case BL1:
  43. if (record->event.pressed) {
  44. PORTB |= (1 << 4);
  45. } else {
  46. PORTB &= ~(1 << 4);
  47. }
  48. return false;
  49. case BL2:
  50. if (record->event.pressed) {
  51. PORTB |= (1 << 5);
  52. } else {
  53. PORTB &= ~(1 << 5);
  54. }
  55. return false;
  56. case BL3:
  57. if (record->event.pressed) {
  58. PORTB |= (1 << 6);
  59. } else {
  60. PORTB &= ~(1 << 6);
  61. }
  62. return false;
  63. case BL4:
  64. if (record->event.pressed) {
  65. PORTB |= (1 << 7);
  66. } else {
  67. PORTB &= ~(1 << 7);
  68. }
  69. return false;
  70. }
  71. return true;
  72. }
  73. void led_set_user(uint8_t usb_led) {
  74. if (usb_led & (1 << USB_LED_NUM_LOCK)) {
  75. } else {
  76. }
  77. if (usb_led & (1 << USB_LED_CAPS_LOCK)) {
  78. } else {
  79. }
  80. if (usb_led & (1 << USB_LED_SCROLL_LOCK)) {
  81. } else {
  82. }
  83. if (usb_led & (1 << USB_LED_COMPOSE)) {
  84. } else {
  85. }
  86. if (usb_led & (1 << USB_LED_KANA)) {
  87. } else {
  88. }
  89. }