diff options
Diffstat (limited to 'keyboards/wilba_tech/wt_main.c')
-rw-r--r-- | keyboards/wilba_tech/wt_main.c | 92 |
1 files changed, 85 insertions, 7 deletions
diff --git a/keyboards/wilba_tech/wt_main.c b/keyboards/wilba_tech/wt_main.c index 23f07d7eb..de6d7b92c 100644 --- a/keyboards/wilba_tech/wt_main.c +++ b/keyboards/wilba_tech/wt_main.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include "quantum.h" | 17 | #include "quantum.h" |
18 | #include "keyboards/wilba_tech/wt_mono_backlight.h" | 18 | #include "keyboards/wilba_tech/wt_mono_backlight.h" |
19 | #include "keyboards/zeal60/zeal60_api.h" // Temporary hack | 19 | #include "keyboards/zeal60/zeal60_api.h" // Temporary hack |
20 | #include "keyboards/zeal60/zeal60_keycodes.h" // Temporary hack | ||
20 | 21 | ||
21 | #include "raw_hid.h" | 22 | #include "raw_hid.h" |
22 | #include "dynamic_keymap.h" | 23 | #include "dynamic_keymap.h" |
@@ -91,22 +92,57 @@ void raw_hid_receive( uint8_t *data, uint8_t length ) | |||
91 | dynamic_keymap_reset(); | 92 | dynamic_keymap_reset(); |
92 | break; | 93 | break; |
93 | } | 94 | } |
94 | #endif // DYNAMIC_KEYMAP_ENABLE | 95 | case id_dynamic_keymap_macro_get_count: |
95 | case id_backlight_config_set_value: | 96 | { |
97 | command_data[0] = dynamic_keymap_macro_get_count(); | ||
98 | break; | ||
99 | } | ||
100 | case id_dynamic_keymap_macro_get_buffer_size: | ||
101 | { | ||
102 | uint16_t size = dynamic_keymap_macro_get_buffer_size(); | ||
103 | command_data[0] = size >> 8; | ||
104 | command_data[1] = size & 0xFF; | ||
105 | break; | ||
106 | } | ||
107 | case id_dynamic_keymap_macro_get_buffer: | ||
108 | { | ||
109 | uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; | ||
110 | uint16_t size = command_data[2]; // size <= 28 | ||
111 | dynamic_keymap_macro_get_buffer( offset, size, &command_data[3] ); | ||
112 | break; | ||
113 | } | ||
114 | case id_dynamic_keymap_macro_set_buffer: | ||
115 | { | ||
116 | uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; | ||
117 | uint16_t size = command_data[2]; // size <= 28 | ||
118 | dynamic_keymap_macro_set_buffer( offset, size, &command_data[3] ); | ||
119 | break; | ||
120 | } | ||
121 | case id_dynamic_keymap_macro_reset: | ||
122 | { | ||
123 | dynamic_keymap_macro_reset(); | ||
124 | break; | ||
125 | } | ||
126 | case id_dynamic_keymap_get_layer_count: | ||
96 | { | 127 | { |
97 | //backlight_config_set_value(command_data); | 128 | command_data[0] = dynamic_keymap_get_layer_count(); |
98 | break; | 129 | break; |
99 | } | 130 | } |
100 | case id_backlight_config_get_value: | 131 | case id_dynamic_keymap_get_buffer: |
101 | { | 132 | { |
102 | //backlight_config_get_value(command_data); | 133 | uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; |
134 | uint16_t size = command_data[2]; // size <= 28 | ||
135 | dynamic_keymap_get_buffer( offset, size, &command_data[3] ); | ||
103 | break; | 136 | break; |
104 | } | 137 | } |
105 | case id_backlight_config_save: | 138 | case id_dynamic_keymap_set_buffer: |
106 | { | 139 | { |
107 | //backlight_config_save(); | 140 | uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; |
141 | uint16_t size = command_data[2]; // size <= 28 | ||
142 | dynamic_keymap_set_buffer( offset, size, &command_data[3] ); | ||
108 | break; | 143 | break; |
109 | } | 144 | } |
145 | #endif // DYNAMIC_KEYMAP_ENABLE | ||
110 | case id_eeprom_reset: | 146 | case id_eeprom_reset: |
111 | { | 147 | { |
112 | eeprom_reset(); | 148 | eeprom_reset(); |
@@ -151,6 +187,8 @@ void main_init(void) | |||
151 | #ifdef DYNAMIC_KEYMAP_ENABLE | 187 | #ifdef DYNAMIC_KEYMAP_ENABLE |
152 | // This resets the keymaps in EEPROM to what is in flash. | 188 | // This resets the keymaps in EEPROM to what is in flash. |
153 | dynamic_keymap_reset(); | 189 | dynamic_keymap_reset(); |
190 | // This resets the macros in EEPROM to nothing. | ||
191 | dynamic_keymap_macro_reset(); | ||
154 | #endif | 192 | #endif |
155 | // Save the magic number last, in case saving was interrupted | 193 | // Save the magic number last, in case saving was interrupted |
156 | eeprom_set_valid(true); | 194 | eeprom_set_valid(true); |
@@ -196,3 +234,43 @@ void matrix_scan_kb(void) | |||
196 | backlight_update_pwm_buffers(); | 234 | backlight_update_pwm_buffers(); |
197 | matrix_scan_user(); | 235 | matrix_scan_user(); |
198 | } | 236 | } |
237 | |||
238 | bool process_record_kb(uint16_t keycode, keyrecord_t *record) | ||
239 | { | ||
240 | switch(keycode) { | ||
241 | case FN_MO13: | ||
242 | if (record->event.pressed) { | ||
243 | layer_on(1); | ||
244 | update_tri_layer(1, 2, 3); | ||
245 | } else { | ||
246 | layer_off(1); | ||
247 | update_tri_layer(1, 2, 3); | ||
248 | } | ||
249 | return false; | ||
250 | break; | ||
251 | case FN_MO23: | ||
252 | if (record->event.pressed) { | ||
253 | layer_on(2); | ||
254 | update_tri_layer(1, 2, 3); | ||
255 | } else { | ||
256 | layer_off(2); | ||
257 | update_tri_layer(1, 2, 3); | ||
258 | } | ||
259 | return false; | ||
260 | break; | ||
261 | } | ||
262 | |||
263 | #ifdef DYNAMIC_KEYMAP_ENABLE | ||
264 | // Handle macros | ||
265 | if (record->event.pressed) { | ||
266 | if ( keycode >= MACRO00 && keycode <= MACRO15 ) | ||
267 | { | ||
268 | uint8_t id = keycode - MACRO00; | ||
269 | dynamic_keymap_macro_send(id); | ||
270 | return false; | ||
271 | } | ||
272 | } | ||
273 | #endif //DYNAMIC_KEYMAP_ENABLE | ||
274 | |||
275 | return process_record_user(keycode, record); | ||
276 | } | ||