]> git.donarmstrong.com Git - qmk_firmware.git/blob - users/bocaj/bocaj.c
Refactoring M6-A, M6-B, Zeal60, Zeal65, WT60-A, WT65-A, WT80-A (#4417)
[qmk_firmware.git] / users / bocaj / bocaj.c
1 #include "bocaj.h"
2 #include "eeprom.h"
3 #include "version.h"
4 #include "tap_dances.h"
5
6 static uint16_t copy_paste_timer;
7 userspace_config_t userspace_config;
8
9 /* *** *** *** ***  *
10  * Helper Functions *
11  * *** *** *** ***  */
12 void tap(uint16_t keycode){ register_code(keycode); unregister_code(keycode); };
13
14 // Add reconfigurable functions here, for keymap customization
15 // This allows for a global, userspace functions, and continued
16 // customization of the keymap.  Use _keymap instead of _user
17 // functions in the keymaps
18 __attribute__ ((weak))
19 void matrix_init_keymap(void) {}
20
21 __attribute__ ((weak))
22 void startup_keymap(void) {}
23
24 __attribute__ ((weak))
25 void suspend_power_down_keymap(void) {}
26
27 __attribute__ ((weak))
28 void suspend_wakeup_init_keymap(void) {}
29
30 __attribute__ ((weak))
31 void matrix_scan_keymap(void) {}
32
33 __attribute__ ((weak))
34 bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
35   return true;
36 }
37
38 __attribute__ ((weak))
39 bool process_record_secrets(uint16_t keycode, keyrecord_t *record) {
40   return true;
41 }
42
43
44 __attribute__ ((weak))
45 uint32_t layer_state_set_keymap (uint32_t state) {
46   return state;
47 }
48
49 __attribute__ ((weak))
50 uint32_t default_layer_state_set_keymap (uint32_t state) {
51   return state;
52 }
53
54 __attribute__ ((weak))
55 void led_set_keymap(uint8_t usb_led) {}
56
57 // Call user matrix init, set default RGB colors and then
58 // call the keymap's init function
59 void matrix_init_user(void) {
60   userspace_config.raw = eeprom_read_byte(EECONFIG_USERSPACE);
61   matrix_init_keymap();
62 }
63
64 void startup_user (void) {
65   startup_keymap();
66 }
67
68 void suspend_power_down_user(void)
69 {
70     suspend_power_down_keymap();
71 }
72
73 void suspend_wakeup_init_user(void)
74 {
75   suspend_wakeup_init_keymap();
76   #ifdef KEYBOARD_ergodox_ez
77   wait_ms(10);
78   #endif
79 }
80
81 // No global matrix scan code, so just run keymap's matrix
82 // scan function
83 void matrix_scan_user(void) {
84   static bool has_ran_yet;
85   if (!has_ran_yet) {
86     has_ran_yet = true;
87     startup_user();
88   }
89
90 #ifdef TAP_DANCE_ENABLE  // Run Diablo 3 macro checking code.
91   run_diablo_macro_check();
92 #endif // TAP_DANCE_ENABLE
93
94   matrix_scan_keymap();
95 }
96
97 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
98   /* uint8_t default_layer = 0;
99   default_layer = eeconfig_read_default_layer(); */
100   switch (keycode) {
101     case JJ_COPY:
102       if (!record->event.pressed) {
103         SEND_STRING(SS_LGUI("c"));
104       }
105       return false;
106       break;
107     case JJ_PSTE:
108       if (!record->event.pressed) {
109         SEND_STRING(SS_LGUI("v"));
110       }
111       return false;
112       break;
113     case JJ_ARRW:
114       if (!record->event.pressed) {
115         SEND_STRING("->");
116       }
117       return false;
118       break; /*
119     case KC_SWRK:
120       if (!record->event.pressed) {
121         set_single_persistent_default_layer(_SWRKMN);
122         layer_move(default_layer);
123         //ergodox_blink_all_leds();
124         //ergodox_blink_all_leds();
125       }
126       return false;
127       break;
128     case KC_HWRK:
129       if (!record->event.pressed) {
130         set_single_persistent_default_layer(_HWRKMN);
131         layer_move(default_layer);
132         //ergodox_blink_all_leds();
133         //ergodox_blink_all_leds();
134       }
135       return false;
136       break;
137     case KC_EPRM:
138       if (!record->event.pressed) {
139         //ergodox_blink_all_leds();
140         eeconfig_init();
141       }
142       return false;
143       break;
144     case MC_LOCK:
145       if (!record->event.pressed) {
146         layer_move(default_layer);
147         SEND_STRING(SS_LCTRL(SS_LGUI("q")));
148       }
149       return false;
150       break; */
151     case KC_DCLR:
152 #ifdef TAP_DANCE_ENABLE
153       if (record->event.pressed) {
154         uint8_t dtime;
155         for (dtime = 0; dtime < 4; dtime++) {
156           diablo_key_time[dtime] = diablo_times[0];
157         }
158       }
159 #endif // !TAP_DANCE_ENABLE
160       return false;
161       break;
162     case KC_CCCV:
163       if (record->event.pressed) {
164         copy_paste_timer = timer_read();
165       } else {
166         if (timer_elapsed(copy_paste_timer) > TAPPING_TERM) { // Hold, copy
167           SEND_STRING(SS_LGUI("c"));
168         } else {
169           SEND_STRING(SS_LGUI("v"));
170         }
171       }
172       return false;
173       break;
174   }
175   return process_record_keymap(keycode, record);
176 }
177