]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/scarletbandana/keymaps/default/keymap.c
Add user-overridable callback for cancelling UCIS input (#5564)
[qmk_firmware.git] / keyboards / scarletbandana / keymaps / default / keymap.c
1 /* Copyright 2019 Cole Markham
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 QMK_KEYBOARD_H
17
18 #ifdef RGBLIGHT_ENABLE
19 //Following line allows macro to read current RGB settings
20 extern rgblight_config_t rgblight_config;
21 #endif
22
23 #define _QWERTY 0
24 #define _COLEMAK 1
25 #define _DVORAK 2
26 #define _LOWER 3
27 #define _RAISE 4
28 #define _ADJUST 16
29
30 enum custom_keycodes {
31   QWERTY = SAFE_RANGE,
32   COLEMAK,
33   DVORAK,
34   LOWER,
35   RAISE,
36   ADJUST,
37 };
38
39 // define variables for reactive RGB
40 bool TOG_STATUS = false;
41 int RGB_current_mode;
42
43 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
44         [_QWERTY] = LAYOUT_all(
45         KC_F1, KC_F2,   KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6,KC_7,KC_8,KC_9,KC_0,KC_MINS,KC_EQL,KC_BSPC, KC_DEL, KC_PGUP,\
46         KC_F3, KC_F4,   KC_TAB,KC_Q,KC_W,KC_E,KC_R,KC_T,KC_Y,KC_U,KC_I,KC_O,KC_P,KC_LBRC,KC_RBRC,KC_BSLS, KC_PGDN,\
47         KC_F5, KC_F6,   KC_CAPS,KC_A,KC_S,KC_D,KC_F, KC_G, KC_H,KC_J,KC_K,KC_L, KC_SCLN,KC_QUOT,KC_ENT, KC_HOME,\
48         KC_F7, KC_F8,   KC_LSFT,KC_Z,KC_X,KC_C,KC_V,KC_B,KC_N,KC_M,KC_COMM,KC_DOT,KC_SLASH,KC_RSFT,KC_UP,KC_END,\
49         KC_F9, KC_F10,  KC_LCTL,KC_LGUI,KC_LALT, RAISE, KC_SPACE, LOWER, KC_RALT,KC_APP,KC_RCTRL,KC_LEFT,KC_DOWN,KC_RIGHT),
50
51         [_RAISE] = LAYOUT_all(
52         RGB_MOD, _______,   _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, _______,\
53         _______, _______,   _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,\
54         _______, _______,   _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,\
55         _______, _______,   _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,\
56         _______, _______,  _______,_______,_______, _______, _______, _______, _______,_______,_______,_______,_______,_______),
57
58         [_LOWER] = LAYOUT_all(
59         RGB_MOD, _______,   _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, _______,\
60         _______, _______,   _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,\
61         _______, _______,   _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,  _______,\
62         _______, _______,   _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,\
63         _______, _______,  _______,_______,_______, _______, _______, _______, _______,_______,_______,_______,_______,_______),
64
65         [_ADJUST] = LAYOUT_all(
66         RESET, _______,   _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, _______,\
67         _______, _______,   _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,\
68         _______, _______,   _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,  _______,\
69         _______, _______,   _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,\
70         _______, _______,  _______,_______,_______, _______, _______, _______, _______,_______,_______,_______,_______,_______)
71 };
72
73 // Setting ADJUST layer RGB back to default
74 void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
75   if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
76 #ifdef RGBLIGHT_ENABLE
77     rgblight_mode(RGB_current_mode);
78 #endif
79     layer_on(layer3);
80   } else {
81     layer_off(layer3);
82   }
83 }
84
85 const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
86 {
87   // MACRODOWN only works in this function
88       switch(id) {
89         case 0:
90           if (record->event.pressed) {
91             register_code(KC_RSFT);
92           } else {
93             unregister_code(KC_RSFT);
94           }
95         break;
96       }
97     return MACRO_NONE;
98 };
99
100 #ifdef AUDIO_ENABLE
101
102   float tone_qwerty[][2]     = SONG(QWERTY_SOUND);
103 #endif
104
105 void matrix_init_user(void) {
106
107 }
108
109 void matrix_scan_user(void) {
110
111 }
112
113 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
114   switch (keycode) {
115     case LOWER:
116         if (record->event.pressed) {
117             //not sure how to have keyboard check mode and set it to a variable, so my work around
118             //uses another variable that would be set to true after the first time a reactive key is pressed.
119             if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
120             } else {
121                 TOG_STATUS = !TOG_STATUS;
122 #ifdef RGBLIGHT_ENABLE
123                 rgblight_mode(16);
124 #endif
125             }
126             layer_on(_LOWER);
127             update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
128         } else {
129 #ifdef RGBLIGHT_ENABLE
130             rgblight_mode(RGB_current_mode);   // revert RGB to initial mode prior to RGB mode change
131 #endif
132             TOG_STATUS = false;
133             layer_off(_LOWER);
134             update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
135         }
136         return false;
137         break;
138     case RAISE:
139         if (record->event.pressed) {
140             //not sure how to have keyboard check mode and set it to a variable, so my work around
141             //uses another variable that would be set to true after the first time a reactive key is pressed.
142             if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
143             } else {
144                 TOG_STATUS = !TOG_STATUS;
145 #ifdef RGBLIGHT_ENABLE
146                 rgblight_mode(15);
147 #endif
148             }
149             layer_on(_RAISE);
150             update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
151         } else {
152 #ifdef RGBLIGHT_ENABLE
153             rgblight_mode(RGB_current_mode);  // revert RGB to initial mode prior to RGB mode change
154 #endif
155             layer_off(_RAISE);
156             TOG_STATUS = false;
157             update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
158         }
159         return false;
160         break;
161     case ADJUST:
162         // FIXME add RGB feedback
163         if (record->event.pressed) {
164             layer_on(_ADJUST);
165         } else {
166             layer_off(_ADJUST);
167         }
168         return false;
169         break;
170         break;
171         //led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released
172 #ifdef RGBLIGHT_ENABLE
173     case RGB_MOD:
174         if (record->event.pressed) {
175             rgblight_mode(RGB_current_mode);
176             rgblight_step();
177             RGB_current_mode = rgblight_config.mode;
178         }
179         return false;
180         break;
181 #endif
182   }
183   return true;
184 }
185
186 void led_set_user(uint8_t usb_led) {
187
188 }