keymap.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #include QMK_KEYBOARD_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. [0] = LAYOUT_ortho_4x4(
  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. ),
  16. [1] = LAYOUT_ortho_4x4(
  17. KC_NLCK, BL1, KC_TRNS, KC_PSLS,
  18. RESET, BL2, KC_TRNS, KC_TRNS,
  19. KC_TRNS, BL3, KC_TRNS, KC_TRNS,
  20. KC_TRNS, BL4, KC_TRNS, KC_TRNS
  21. ),
  22. };
  23. void set_led(int idx, bool enable) {
  24. uint8_t pin = LED_PINS[idx];
  25. if (enable) {
  26. _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF);
  27. } else {
  28. /* PORTx &= ~n */
  29. _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF);
  30. }
  31. }
  32. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  33. switch (keycode) {
  34. case BL1:
  35. if (record->event.pressed) {
  36. PORTB |= (1 << 4);
  37. } else {
  38. PORTB &= ~(1 << 4);
  39. }
  40. return false;
  41. case BL2:
  42. if (record->event.pressed) {
  43. PORTB |= (1 << 5);
  44. } else {
  45. PORTB &= ~(1 << 5);
  46. }
  47. return false;
  48. case BL3:
  49. if (record->event.pressed) {
  50. PORTB |= (1 << 6);
  51. } else {
  52. PORTB &= ~(1 << 6);
  53. }
  54. return false;
  55. case BL4:
  56. if (record->event.pressed) {
  57. PORTB |= (1 << 7);
  58. } else {
  59. PORTB &= ~(1 << 7);
  60. }
  61. return false;
  62. }
  63. return true;
  64. }
  65. void matrix_init_user(void) {
  66. /* set LED row pins to output and low */
  67. DDRB |= (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7);
  68. PORTB &= ~(1 << 4) & ~(1 << 5) & ~(1 << 6) & ~(1 << 7);
  69. }
  70. void matrix_scan_user(void) {
  71. }
  72. void led_set_user(uint8_t usb_led) {
  73. if (usb_led & (1 << USB_LED_NUM_LOCK)) {
  74. } else {
  75. }
  76. if (usb_led & (1 << USB_LED_CAPS_LOCK)) {
  77. } else {
  78. }
  79. if (usb_led & (1 << USB_LED_SCROLL_LOCK)) {
  80. } else {
  81. }
  82. if (usb_led & (1 << USB_LED_COMPOSE)) {
  83. } else {
  84. }
  85. if (usb_led & (1 << USB_LED_KANA)) {
  86. } else {
  87. }
  88. }