]> git.donarmstrong.com Git - qmk_firmware.git/blob - users/turbomech/turbomech.c
Remove more commented out MCUs
[qmk_firmware.git] / users / turbomech / turbomech.c
1 /* Copyright 2017 @TurboMech /u/TurboMech <discord> @A9entOran9e#6134
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 //**!! Currently after reboot the set rgb mode does not persist after reboot.  Need to find a way to "save" the rgb mode.  Color remains after reboot though.
18
19 #include "turbomech.h"
20 #include "quantum.h"
21 #include "action_layer.h"
22 #include "action.h"
23 #include "rgblight.h"
24 //#include "process_unicode.h"
25
26 extern keymap_config_t keymap_config;
27 extern rgblight_config_t rgblight_config;
28 bool RGB_INIT = false;
29 bool TOG_STATUS = false;
30 bool caps_is_active = false;
31 int RGB_current_mode;
32
33 void matirx_scan_kb (void) {
34   if (RGB_INIT) {}
35   else {
36     RGB_current_mode = rgblight_config.mode;
37     RGB_INIT = true;
38         }
39   rgblight_mode(RGB_current_mode);   // revert RGB to initial mode prior to RGB mode change
40   TOG_STATUS = false;
41 }
42
43 void persistent_default_layer_set(uint16_t default_layer) {
44   eeconfig_update_default_layer(default_layer);
45   default_layer_set(default_layer);
46 }
47 /*void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
48   if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
49     rgblight_mode(RGB_current_mode);
50     layer_on(layer3);
51   } else {
52     layer_off(layer3);
53   }
54 }*/
55
56 __attribute__ ((weak))
57 bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
58   return true;
59 }
60
61 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
62   switch (keycode) {
63     case KC_CAPS:
64      if (record->event.pressed) {
65         register_code(KC_CAPS);
66         caps_is_active = !caps_is_active;
67       if (caps_is_active) {
68         rgblight_mode(14);
69       }
70       else if (!caps_is_active) {
71         unregister_code(KC_CAPS);
72         rgblight_mode(RGB_current_mode);
73       }
74     }
75     return false;
76     break;
77
78     case RGB_MOD:
79     //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
80     if (record->event.pressed) {
81       rgblight_mode(RGB_current_mode);
82       rgblight_step();
83       RGB_current_mode = rgblight_config.mode;
84       // rgblight_set();
85     }
86     return false;
87     break;
88
89     case KC_RESET:
90     if (record->event.pressed) {
91       rgblight_enable();
92       rgblight_mode(1);
93       rgblight_setrgb(255, 255, 255);
94       //_delay_ms(2000);
95       reset_keyboard();
96     }
97     return false;
98     break;
99
100     /*case _FLIP:  //(╯°□°)╯︵ ┻━┻
101       if (record->event.pressed) {
102        register_code(KC_LPRN);
103        unregister_code(KC_LPRN);
104        register_code(X(0x00B0));
105        unregister_code(X(0x00B0));
106
107         UC(0x256F);
108         PROCESS_UNICODE(UC(0x00B0));
109         SEND_TAP(UC(0x25A1));
110         SEND_TAP(UC(0x00B0));
111         SEND_STRING(")");
112         SEND_TAP(UC(0x256F));
113         SEND_TAP(UC(0xFE35));
114         SEND_TAP(UC(0x253B));
115         SEND_TAP(UC(0x2501));
116         SEND_TAP(UC(0x253B));
117                         }
118                         return false;
119                         break;*/
120
121   return true;
122   break;
123   }
124 return process_record_keymap(keycode, record);
125 }