diff options
Diffstat (limited to 'keyboards/zeal60/zeal60.c')
| -rw-r--r-- | keyboards/zeal60/zeal60.c | 88 |
1 files changed, 65 insertions, 23 deletions
diff --git a/keyboards/zeal60/zeal60.c b/keyboards/zeal60/zeal60.c index b3b5d03fd..5f93c571a 100644 --- a/keyboards/zeal60/zeal60.c +++ b/keyboards/zeal60/zeal60.c | |||
| @@ -94,6 +94,56 @@ void raw_hid_receive( uint8_t *data, uint8_t length ) | |||
| 94 | dynamic_keymap_reset(); | 94 | dynamic_keymap_reset(); |
| 95 | break; | 95 | break; |
| 96 | } | 96 | } |
| 97 | case id_dynamic_keymap_macro_get_count: | ||
| 98 | { | ||
| 99 | command_data[0] = dynamic_keymap_macro_get_count(); | ||
| 100 | break; | ||
| 101 | } | ||
| 102 | case id_dynamic_keymap_macro_get_buffer_size: | ||
| 103 | { | ||
| 104 | uint16_t size = dynamic_keymap_macro_get_buffer_size(); | ||
| 105 | command_data[0] = size >> 8; | ||
| 106 | command_data[1] = size & 0xFF; | ||
| 107 | break; | ||
| 108 | } | ||
| 109 | case id_dynamic_keymap_macro_get_buffer: | ||
| 110 | { | ||
| 111 | uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; | ||
| 112 | uint16_t size = command_data[2]; // size <= 28 | ||
| 113 | dynamic_keymap_macro_get_buffer( offset, size, &command_data[3] ); | ||
| 114 | break; | ||
| 115 | } | ||
| 116 | case id_dynamic_keymap_macro_set_buffer: | ||
| 117 | { | ||
| 118 | uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; | ||
| 119 | uint16_t size = command_data[2]; // size <= 28 | ||
| 120 | dynamic_keymap_macro_set_buffer( offset, size, &command_data[3] ); | ||
| 121 | break; | ||
| 122 | } | ||
| 123 | case id_dynamic_keymap_macro_reset: | ||
| 124 | { | ||
| 125 | dynamic_keymap_macro_reset(); | ||
| 126 | break; | ||
| 127 | } | ||
| 128 | case id_dynamic_keymap_get_layer_count: | ||
| 129 | { | ||
| 130 | command_data[0] = dynamic_keymap_get_layer_count(); | ||
| 131 | break; | ||
| 132 | } | ||
| 133 | case id_dynamic_keymap_get_buffer: | ||
| 134 | { | ||
| 135 | uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; | ||
| 136 | uint16_t size = command_data[2]; // size <= 28 | ||
| 137 | dynamic_keymap_get_buffer( offset, size, &command_data[3] ); | ||
| 138 | break; | ||
| 139 | } | ||
| 140 | case id_dynamic_keymap_set_buffer: | ||
| 141 | { | ||
| 142 | uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; | ||
| 143 | uint16_t size = command_data[2]; // size <= 28 | ||
| 144 | dynamic_keymap_set_buffer( offset, size, &command_data[3] ); | ||
| 145 | break; | ||
| 146 | } | ||
| 97 | #endif // DYNAMIC_KEYMAP_ENABLE | 147 | #endif // DYNAMIC_KEYMAP_ENABLE |
| 98 | #if RGB_BACKLIGHT_ENABLED | 148 | #if RGB_BACKLIGHT_ENABLED |
| 99 | case id_backlight_config_set_value: | 149 | case id_backlight_config_set_value: |
| @@ -160,6 +210,8 @@ void main_init(void) | |||
| 160 | #ifdef DYNAMIC_KEYMAP_ENABLE | 210 | #ifdef DYNAMIC_KEYMAP_ENABLE |
| 161 | // This resets the keymaps in EEPROM to what is in flash. | 211 | // This resets the keymaps in EEPROM to what is in flash. |
| 162 | dynamic_keymap_reset(); | 212 | dynamic_keymap_reset(); |
| 213 | // This resets the macros in EEPROM to nothing. | ||
| 214 | dynamic_keymap_macro_reset(); | ||
| 163 | #endif | 215 | #endif |
| 164 | // Save the magic number last, in case saving was interrupted | 216 | // Save the magic number last, in case saving was interrupted |
| 165 | eeprom_set_valid(true); | 217 | eeprom_set_valid(true); |
| @@ -238,7 +290,19 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) | |||
| 238 | return false; | 290 | return false; |
| 239 | break; | 291 | break; |
| 240 | } | 292 | } |
| 241 | 293 | ||
| 294 | #ifdef DYNAMIC_KEYMAP_ENABLE | ||
| 295 | // Handle macros | ||
| 296 | if (record->event.pressed) { | ||
| 297 | if ( keycode >= MACRO00 && keycode <= MACRO15 ) | ||
| 298 | { | ||
| 299 | uint8_t id = keycode - MACRO00; | ||
| 300 | dynamic_keymap_macro_send(id); | ||
| 301 | return false; | ||
| 302 | } | ||
| 303 | } | ||
| 304 | #endif //DYNAMIC_KEYMAP_ENABLE | ||
| 305 | |||
| 242 | return process_record_user(keycode, record); | 306 | return process_record_user(keycode, record); |
| 243 | } | 307 | } |
| 244 | 308 | ||
| @@ -263,28 +327,6 @@ uint16_t keymap_function_id_to_action( uint16_t function_id ) | |||
| 263 | } | 327 | } |
| 264 | } | 328 | } |
| 265 | 329 | ||
| 266 | #if USE_KEYMAPS_IN_EEPROM | ||
| 267 | |||
| 268 | #if 0 | ||
| 269 | // This is how to implement actions stored in EEPROM. | ||
| 270 | // Not yet implemented. Not sure if it's worth the trouble | ||
| 271 | // before we have a nice GUI for keymap editing. | ||
| 272 | if ( eeprom_is_valid() && | ||
| 273 | function_id < 32 ) // TODO: replace magic number | ||
| 274 | { | ||
| 275 | uint16_t action = keymap_action_load(function_id); | ||
| 276 | |||
| 277 | // If action is not "empty", return it, otherwise | ||
| 278 | // drop down to return the one in flash | ||
| 279 | if ( action != 0x0000 ) // TODO: replace magic number | ||
| 280 | { | ||
| 281 | return action; | ||
| 282 | } | ||
| 283 | } | ||
| 284 | #endif | ||
| 285 | |||
| 286 | #endif // USE_KEYMAPS_IN_EEPROM | ||
| 287 | |||
| 288 | return pgm_read_word(&fn_actions[function_id]); | 330 | return pgm_read_word(&fn_actions[function_id]); |
| 289 | } | 331 | } |
| 290 | 332 | ||
