]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/handwired/woodpad/keymaps/default/keymap.c
Update keyboards/kbdfans/kbd67/readme.md
[qmk_firmware.git] / keyboards / handwired / woodpad / keymaps / default / keymap.c
1 /* Copyright 2017 REPLACE_WITH_YOUR_NAME
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 "woodpad.h"
17
18 // Each layer gets a name for readability, which is then used in the keymap matrix below.
19 // The underscores don't mean anything - you can have a layer called STUFF or any other name.
20 // Layer names don't all need to be of the same length, obviously, and you can also skip them
21 // entirely and just use numbers.
22 #define _NUMLOCK 0
23 #define _NAV 1
24 #define _ALT 2
25 #define _ADJUST 3
26
27 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
28 [_NUMLOCK] = KEYMAP( /* Base */
29   KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS,\
30     KC_P7,  KC_P8, KC_P9, KC_PPLS,   \
31     KC_P4,  KC_P5, KC_P6, KC_PEQL,   \
32     KC_P1,  KC_P2, KC_P3, KC_COMM,   \
33     KC_LALT,  KC_P0, KC_PDOT, KC_PENT   \
34 ),
35 [_NAV] = KEYMAP( /* Base */
36   _______, _______, _______, _______,\
37     KC_HOME,  KC_UP, KC_PGUP, _______,   \
38     KC_LEFT,  XXXXXXX, KC_RIGHT, _______,   \
39     KC_END,  KC_DOWN, KC_PGDN, _______,   \
40     _______,  KC_INS, KC_DEL, _______   \
41 ),
42 [_ALT] = KEYMAP( /* Base */
43   _______, KC_MUTE, KC_VOLD, KC_VOLU,\
44     _______,  _______, _______, _______,   \
45     _______,  _______, _______, _______,   \
46     _______,  _______, _______, _______,   \
47     _______,  _______, _______, _______   \
48 ),
49 [_ADJUST] = KEYMAP( /* Base */
50   _______, KC_A, _______, RESET,\
51     _______,  _______, _______, _______,   \
52     _______,  _______, _______, _______,   \
53     _______,  _______, _______, _______,   \
54     _______,  _______, _______, _______   \
55 ),
56 };
57
58 void numlock_led_on(void) {
59   PORTF |= (1<<7);
60 }
61
62 void numlock_led_off(void) {
63   PORTF &= ~(1<<7);
64 }
65
66 static bool numlock_down = false;
67
68 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
69   switch (keycode) {
70           case KC_NLCK:
71       if (record->event.pressed) {
72                   numlock_down = true;
73                   if (IS_LAYER_ON(_ALT)) {
74                           layer_on(_ADJUST);
75                   }
76           } else{
77                 if(!IS_LAYER_ON(_ADJUST)) {
78                   if (!IS_LAYER_ON(_NAV)){
79                           numlock_led_off();
80                     layer_on(_NAV);
81                   } else {
82                           numlock_led_on();
83                     layer_off(_NAV);
84                   }
85                 } else {
86                         layer_off(_ADJUST);
87                 }
88                 numlock_down = false;
89           } 
90       return false;
91       break;
92           case KC_LALT:
93       if (record->event.pressed) {
94                   if (numlock_down) {
95                           layer_on(_ADJUST);
96                   } else {
97                           layer_on(_ALT);
98                   }
99           } else {
100                   if(IS_LAYER_ON(_ADJUST)) {
101                       layer_off(_ADJUST);
102                   } else {
103                           layer_off(_ALT);
104                   }
105           }
106           // Allow normal processing of ALT?
107       return false;
108       break;
109   }
110   return true;
111 }
112
113 void matrix_init_user(void) {
114   // set Numlock LED to output and low
115     DDRF |= (1<<7);
116     PORTF &= ~(1<<7);
117
118 }
119
120 void matrix_scan_user(void) {
121
122 }
123
124
125 void led_set_user(uint8_t usb_led) {
126
127 }