]> git.donarmstrong.com Git - qmk_firmware.git/blob - users/jarred/jarred.c
Keymap / userspace update (#5358)
[qmk_firmware.git] / users / jarred / jarred.c
1 /* Copyright 2018 Jarred Steenvoorden
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
17 #include "jarred.h"
18 #include "version.h"
19
20 __attribute__ ((weak))
21 bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
22   return true;
23 }
24
25 bool lowerPressed, raisePressed;
26
27 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
28
29   switch (keycode) {
30     case LOWER:
31     case RAISE:
32       // Both lower and raise activate the same layer
33       if (record->event.pressed) {
34         layer_on(_LW);
35       } else {
36         layer_off(_LW);
37       }
38       
39       // But keep track of each to active adjust layer
40       if (keycode == LOWER) {
41         lowerPressed = record->event.pressed;
42       } else {
43         raisePressed = record->event.pressed;
44       }
45       
46       // When both are pressed, activate adjust
47       if (lowerPressed && raisePressed) {
48         layer_on(_NP);
49       } else {
50         layer_off(_NP);
51       }
52       
53       break;
54     
55     case NUMPAD:
56         if (record->event.pressed) {
57           layer_on(_NP);
58         } else {
59           layer_off(_NP);
60         }
61         break;
62     
63     case NAVI:
64       if (record->event.pressed) {
65         layer_on(_NV);
66       } else {
67         layer_off(_NV);
68         
69         // Release mods set by ALT_TAB and CTL_TAB
70         unregister_code(KC_LALT);
71         unregister_code(KC_LCTL);
72       }
73       break;
74     
75     case VRSN: // Prints firmware version
76       if (record->event.pressed) {
77         send_string_with_delay_P(PSTR(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION ", Built on: " QMK_BUILDDATE), MACRO_TIMER);
78       }
79       break;
80       
81     case ALT_TAB:
82       if (record->event.pressed) {
83         register_code(KC_LALT);
84         tap_code(KC_TAB);
85       }
86       break;
87       
88     case CTL_TAB:
89       if (record->event.pressed) {
90         register_code(KC_LCTL);
91         tap_code(KC_TAB);
92       }
93       break;
94   }
95
96   return process_record_keymap(keycode, record);
97 }