summaryrefslogtreecommitdiffstats
path: root/users/turbomech/backupturbomech.c
blob: aaea05df96c3079753c398fb56bd49f8db783a5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
/* Copyright 2017 @TurboMech /u/TurboMech <discord> @A9entOran9e#6134
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "turbomech.h"
#include "quantum.h"
//#include "action_layer.h"
#include "action.h"
//#include "rgblight.h"

__attribute__ ((weak))
void matrix_init_keymap(void) {}

__attribute__ ((weak))
void matrix_scan_keymap(void) {}

__attribute__ ((weak))
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
  return true;
}
__attribute__ ((weak))
uint32_t layer_state_set_keymap (uint32_t state) {
  return state;
}
__attribute__ ((weak))
void led_set_keymap(uint8_t usb_led) {}

//#define default_layer _QWERTY (0)
//extern keymap_config_t keymap_config;

extern rgblight_config_t rgblight_config;


//#ifdef RGBLIGHT_ENABLE
/*change the rgblight_setrgb(#, #, #) to what you want CAPS lock - currenlty red*/
 //#define rgblight_set_caps       rgblight_setrgb(255, 0, 0)
 //#define rgblight_base           rgblight_mode(RGB_current_mode)
//#endif
//
//bool rgb_layer_change = true;
//bool RGB_INIT = false;
//bool TOG_STATUS = false;
#ifdef RGBLIGHT_ENABLE
bool rgb_layer_change = true;
#endif
int RGB_current_mode;

/*void matrix_init_user(void) {
  #ifdef RGBLIGHT_ENABLE
  rgblight_enable();
  if (true) {
  eeconfig_read_rgblight();
  rgblight_get_mode();
  eeconfig_update_rgblight_default();


 // eeconfig_debug_rgblight();
  //rgblight_init();
  }
  #endif

}
*/

/*void matrix_init_user(void) {
  #ifdef RGBLIGHT_ENABLE
  eeconfig_read_rgblight();
  eeconfig_update_rgblight_default();
  //rgblight_init();
  //rgblight_mode(RGB_current_mode);
  //rgblight_mode(RGB_current_mode);
  //RGB_current_mode = rgblight_config.mode;
  #endif
}*/


void persistent_default_layer_set(uint16_t default_layer) {
  eeconfig_update_default_layer(default_layer);
  default_layer_set(default_layer);
  default_layer = _QWERTY;
 // eeconfig_update_rgblight(rgblight_config.raw);
}

 //Setting ADJUST layer RGB back to default
/*void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
  if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
    rgblight_mode(RGB_current_mode);
    layer_on(layer1);
  } else {
    layer_off(layer2);
  }
}*/


void matrix_init_user(void) {

  uint8_t default_layer = eeconfig_read_default_layer();

  rgblight_enable();

  if(true) {
   if (default_layer & (1UL << _QWERTY)) {
      //RGB_current_mode = rgblight_config.mode;
      rgblight_mode(11);
      }
 else {
      rgblight_mode (12);
      }

    /*else if (default_layer & (1UL << _DVORAK)) {
      rgblight_set_green;
    }
    //else if (default_layer & (1UL << _WORKMAN)) {
      rgblight_set_purple;
    }
    else {
      rgblight_set_teal;*/


  }


}

static bool is_capslocked = false;
void led_set_user(uint8_t usb_led) {
  if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
    is_capslocked = true;
   //     DDRB |= (1 << 2); PORTB &= ~(1 << 2);
  } else {
    is_capslocked = false;
  //  DDRB &= ~(1 << 2); PORTB &= ~(1 << 2);
  }
}
  //rgblight_set();


//static uint8_t is_capslocked = false;
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  switch (keycode) {
    case _QWERTY:
      persistent_default_layer_set(1UL << _QWERTY);
      return false;
      break;
    case KC_MAKE_ALU84:
      if (!record->event.pressed) {
        SEND_STRING("make alu84:TurboMech:dfu");
        SEND_STRING(SS_TAP(X_ENTER));
    }
    return false;
    break;
    case KC_QMK:
      if (!record->event.pressed) {
        SEND_STRING("cd QMK/qmk_firmware");
        SEND_STRING(SS_TAP(X_ENTER));
      }
      return false;
      break;
    case KC_RESET:
      if (!record->event.pressed) {
        #ifdef RGBLIGHT_ENABLE
          rgblight_enable();
          rgblight_mode(1);
          rgblight_setrgb(255, 255, 255);
        #endif
        //_delay_ms(2000);
        reset_keyboard();
      }
      return false;
      break;
    /*case RGB_MOD:
      //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
      if (record->event.pressed) {
       rgblight_mode(RGB_current_mode);
       RGB_current_mode = rgblight_config.mode;
        rgblight_step();
       // rgblight_mode(RGB_current_mode);
     //RGB_current_mode = rgblight_config.mode;
        // _delay_ms(50);
       // rgblight_set();
        RGB_current_mode = rgblight_config.mode;
    }
      else //if (rgblight_config.enable)
      {
        _delay_ms(50);
        rgblight_set();
        //rgblight_mode(rgblight_config.mode);
      // eeconfig_update_rgblight(rgblight_config.raw);
      }

     return true;
      break;*/

    /*case MO(1):
      if (record->event.realeased) {
        rgblight_mode(1);
        rgblight_set_red;
      }
      return true;
      break;*/

   /*case KC_CAPS:
     if (record->event.pressed) {
        rgblight_mode(RGB_current_mode);
       register_code(KC_CAPS);
        rgblight_mode(1);
        rgblight_set_red;
      }
      else {
        unregister_code(KC_CAPS);
        rgblight_mode(RGB_current_mode);

      }
      return false;
       break;*/

       /* rgblight_mode(RGB_current_mode);
        register_code(KC_CAPS);
        rgblight_mode(1);
        rgblight_set_red;
      }
      else {
        unregister_code(KC_CAPS);
        rgblight_mode(RGB_current_mode);*/

    //  }
    //  return true;
     //  break;
    /*case KC_RESET:
      if (record->event.pressed) {
      layer_off(_FUNCTION);
      rgblight_mode(RGB_current_mode);
     RGB_current_mode = rgblight_config.mode;
      layer_clear();
      _delay_ms(1000);
        reset_keyboard();
     }
     else{
      //layer_off(_FUNCTION);
     _delay_ms(1000);
     rgblight_mode(RGB_current_mode);
     RGB_current_mode = rgblight_config.mode;

     //eeconfig_update_rgblight_default();
      }

      return false;
      break;
    }*/


      return true;
      break;





/*case RGB_MOD:
case RGB_HUI:
case RGB_HUD:
case RGB_SAI:
case RGB_SAD:
case RGB_VAI:
case RGB_VAD:
case RGB_MODE_PLAIN:
case RGB_MODE_BREATHE:
case RGB_MODE_RAINBOW:
case RGB_MODE_SWIRL:
case RGB_MODE_SNAKE:
case RGB_MODE_KNIGHT:
case RGB_MODE_XMAS:
case RGB_MODE_GRADIENT:
    if (record->event.pressed) {
      rgb_layer_change = false;
    }
    break;
  }
  return true;*/
  }


 return process_record_keymap(keycode, record);

}

layer_state_t layer_state_set_user(layer_state_t state) {
#ifdef RGBLIGHT_ENABLE
  uint8_t default_layer = eeconfig_read_default_layer();
  if (rgb_layer_change) {
    switch (biton32(state)) {
    case _FUNCTION:
      rgblight_set_blue;
     rgblight_mode(1);
     break;
    case _QWERTY:

      rgblight_mode(11);
      break;
  // case _MOUS:
    //  rgblight_set_yellow;
    //  rgblight_mode(1);
   //   break;
    //case _MACROS:
      //rgblight_set_orange;
      //is_overwatch ? rgblight_mode(17) : rgblight_mode(18);
      //break;
    //case _MEDIA:
      //rgblight_set_green;
      //rgblight_mode(22);
      //break;
    default:
      if (is_capslocked) {
        rgblight_mode(1);
        rgblight_set_red;
      }
        else { if (default_layer & (1UL << _QWERTY)) {
        rgblight_mode(11);
        }

        else if (default_layer & (1UL << _FUNCTION)) {
         rgblight_set_cyan;
        }
        //else if (default_layer & (1UL << _WORKMAN)) {
        //  rgblight_set_purple;
       // }
        else {
          rgblight_set_orange;
        }
      }
      rgblight_mode(1);
      break;
    }
  }
#endif
  return state;
}


!!** possible for later

void set_single_persistent_default_layer(uint8_t default_layer);

void set_single_persistent_default_layer(uint8_t default_layer) {
  #if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS)
    PLAY_SONG(default_layer_songs[default_layer]);
  #endif
  eeconfig_update_default_layer(1U<<default_layer);
  default_layer_set(1U<<default_layer);

void matrix_init_kb(void);

void matrix_init_user(void);

!!** line 31

__attribute__ ((weak))
void matrix_init_keymap(void) {}

__attribute__ ((weak))
void matrix_scan_keymap(void) {}

__attribute__ ((weak))
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
  return true;
}
__attribute__ ((weak))
uint32_t layer_state_set_keymap (uint32_t state) {
  return state;
}
__attribute__ ((weak))
void led_set_keymap(uint8_t usb_led) {}

Alt +30C4
¯\_(ツ)_/¯

Alt +00AF