diff options
author | Wilba <Jason.S.Williams@gmail.com> | 2018-12-01 03:43:34 +1100 |
---|---|---|
committer | Drashna Jaelre <drashna@live.com> | 2018-11-30 08:43:34 -0800 |
commit | d7f1e072a859d7fcbaccd675b4bad7d02d214e52 (patch) | |
tree | fb24714b6f37ef58f265802897a5225abf171753 /keyboards/zeal60/zeal60.c | |
parent | b10aad45b60326c7e9f2d1fc67e45bd201341552 (diff) |
Added macros to Dynamic Keymaps, Zeal60 RGB backlight improvements (#4520)
* Refactored M6-B to use Zeal60 RGB backlight code
* Fixed M6-B LED co-ordinates
* Minor changes to RGB config for Zeal65
* Added dynamic keymaps to WT80-A, WT60-A, WT-80A, U80-A
* Macro implementation
* Implemented macros, API protocol version 8, RGB backlight fixes
* Improved radial effects for M6-B
* Fixed undefined references when building an RGB keyboard after M6-A
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 b3b5d03fd0..5f93c571ad 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 ) dynamic_keymap_reset(); break; } + case id_dynamic_keymap_macro_get_count: + { + command_data[0] = dynamic_keymap_macro_get_count(); + break; + } + case id_dynamic_keymap_macro_get_buffer_size: + { + uint16_t size = dynamic_keymap_macro_get_buffer_size(); + command_data[0] = size >> 8; + command_data[1] = size & 0xFF; + break; + } + case id_dynamic_keymap_macro_get_buffer: + { + uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; + uint16_t size = command_data[2]; // size <= 28 + dynamic_keymap_macro_get_buffer( offset, size, &command_data[3] ); + break; + } + case id_dynamic_keymap_macro_set_buffer: + { + uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; + uint16_t size = command_data[2]; // size <= 28 + dynamic_keymap_macro_set_buffer( offset, size, &command_data[3] ); + break; + } + case id_dynamic_keymap_macro_reset: + { + dynamic_keymap_macro_reset(); + break; + } + case id_dynamic_keymap_get_layer_count: + { + command_data[0] = dynamic_keymap_get_layer_count(); + break; + } + case id_dynamic_keymap_get_buffer: + { + uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; + uint16_t size = command_data[2]; // size <= 28 + dynamic_keymap_get_buffer( offset, size, &command_data[3] ); + break; + } + case id_dynamic_keymap_set_buffer: + { + uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; + uint16_t size = command_data[2]; // size <= 28 + dynamic_keymap_set_buffer( offset, size, &command_data[3] ); + break; + } #endif // DYNAMIC_KEYMAP_ENABLE #if RGB_BACKLIGHT_ENABLED case id_backlight_config_set_value: @@ -160,6 +210,8 @@ void main_init(void) #ifdef DYNAMIC_KEYMAP_ENABLE // This resets the keymaps in EEPROM to what is in flash. dynamic_keymap_reset(); + // This resets the macros in EEPROM to nothing. + dynamic_keymap_macro_reset(); #endif // Save the magic number last, in case saving was interrupted eeprom_set_valid(true); @@ -238,7 +290,19 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) return false; break; } - + +#ifdef DYNAMIC_KEYMAP_ENABLE + // Handle macros + if (record->event.pressed) { + if ( keycode >= MACRO00 && keycode <= MACRO15 ) + { + uint8_t id = keycode - MACRO00; + dynamic_keymap_macro_send(id); + return false; + } + } +#endif //DYNAMIC_KEYMAP_ENABLE + return process_record_user(keycode, record); } @@ -263,28 +327,6 @@ uint16_t keymap_function_id_to_action( uint16_t function_id ) } } -#if USE_KEYMAPS_IN_EEPROM - -#if 0 - // This is how to implement actions stored in EEPROM. - // Not yet implemented. Not sure if it's worth the trouble - // before we have a nice GUI for keymap editing. - if ( eeprom_is_valid() && - function_id < 32 ) // TODO: replace magic number - { - uint16_t action = keymap_action_load(function_id); - - // If action is not "empty", return it, otherwise - // drop down to return the one in flash - if ( action != 0x0000 ) // TODO: replace magic number - { - return action; - } - } -#endif - -#endif // USE_KEYMAPS_IN_EEPROM - return pgm_read_word(&fn_actions[function_id]); } |