aboutsummaryrefslogtreecommitdiff
path: root/keyboards/crawlpad/keymaps/default/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/crawlpad/keymaps/default/keymap.c')
-rwxr-xr-xkeyboards/crawlpad/keymaps/default/keymap.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/keyboards/crawlpad/keymaps/default/keymap.c b/keyboards/crawlpad/keymaps/default/keymap.c
new file mode 100755
index 000000000..c81bb56bd
--- /dev/null
+++ b/keyboards/crawlpad/keymaps/default/keymap.c
@@ -0,0 +1,78 @@
1#include QMK_KEYBOARD_H
2
3enum custom_keycodes {
4 BL1 = SAFE_RANGE,
5 BL2,
6 BL3,
7 BL4
8};
9
10const uint8_t LED_PINS[] = LED_ROW_PINS;
11
12const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
13
14 [0] = LAYOUT_ortho_4x4(
15 KC_P7, KC_P8, KC_P9, KC_PPLS,
16 KC_P4, KC_P5, KC_P6, KC_PMNS,
17 KC_P1, KC_P2, KC_P3, KC_PAST,
18 MO(1), KC_P0, KC_PDOT, KC_ENT
19 ),
20
21 [1] = LAYOUT_ortho_4x4(
22 KC_NLCK, BL1, KC_TRNS, KC_PSLS,
23 RESET, BL2, KC_TRNS, KC_TRNS,
24 KC_TRNS, BL3, KC_TRNS, KC_TRNS,
25 KC_TRNS, BL4, KC_TRNS, KC_TRNS
26 ),
27
28};
29
30void set_led(int idx, bool enable) {
31 uint8_t pin = LED_PINS[idx];
32 if (enable) {
33 _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF);
34 } else {
35 /* PORTx &= ~n */
36 _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF);
37 }
38}
39
40bool 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
74void matrix_init_user(void) {
75 /* set LED row pins to output and low */
76 DDRB |= (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7);
77 PORTB &= ~(1 << 4) & ~(1 << 5) & ~(1 << 6) & ~(1 << 7);
78}