1515#include "system/fs.h"
1616#include "adapter/gameid.h"
1717#include "bluetooth/mon.h"
18+ #include "system/manager.h"
1819
1920struct config config ;
2021struct hw_config hw_config = {
@@ -113,6 +114,7 @@ static uint32_t config_version_magic[] = {
113114static uint8_t config_default_combo [BR_COMBO_CNT ] = {
114115 PAD_LM , PAD_RM , PAD_MM , PAD_RB_UP , PAD_RB_LEFT , PAD_RB_RIGHT , PAD_RB_DOWN , PAD_LD_UP , PAD_LD_DOWN , PAD_MS
115116};
117+ static bool config_rst_bare_core = false;
116118
117119static void config_init_struct (struct config * data );
118120static void config_init_nvs_patch (struct config * data );
@@ -384,6 +386,36 @@ static int32_t config_store_on_file(struct config *data, char *filename) {
384386 return ret ;
385387}
386388
389+ static bool config_is_rst_required (void ) {
390+ static uint32_t magic = 0 ;
391+ static uint8_t multitap_cfg = 0 ;
392+ static uint8_t dev_mode [WIRED_MAX_DEV ] = {0 };
393+ bool ret = false;
394+
395+ if (multitap_cfg != config .global_cfg .multitap_cfg ) {
396+ ret = true;
397+ }
398+ multitap_cfg = config .global_cfg .multitap_cfg ;
399+
400+ for (uint32_t i = 0 ; i < WIRED_MAX_DEV ; i ++ ) {
401+ if (dev_mode [i ] != config .out_cfg [i ].dev_mode ) {
402+ ret = true;
403+ }
404+ dev_mode [i ] = config .out_cfg [i ].dev_mode ;
405+ }
406+
407+ if (magic != config .magic ) {
408+ ret = false;
409+ }
410+ magic = config .magic ;
411+
412+ return ret ;
413+ }
414+
415+ void IRAM_ATTR config_set_rst_bare_core (bool value ) {
416+ config_rst_bare_core = value ;
417+ }
418+
387419void hw_config_patch (void ) {
388420 esp_err_t err ;
389421 nvs_handle_t nvs ;
@@ -427,6 +459,10 @@ void config_init(uint32_t src) {
427459 }
428460
429461 config_load_from_file (& config , filename );
462+ if (config_rst_bare_core && config_is_rst_required ()) {
463+ sys_mgr_cmd (SYS_MGR_CMD_WIRED_RST );
464+ printf ("# %s: Reloaded wired core cfg: %s\n" , __FUNCTION__ , filename );
465+ }
430466}
431467
432468void config_update (uint32_t dst ) {
@@ -442,6 +478,10 @@ void config_update(uint32_t dst) {
442478 }
443479
444480 config_store_on_file (& config , filename );
481+ if (config_rst_bare_core && config_is_rst_required ()) {
482+ sys_mgr_cmd (SYS_MGR_CMD_WIRED_RST );
483+ printf ("# %s: Reloaded wired core cfg: %s\n" , __FUNCTION__ , filename );
484+ }
445485}
446486
447487uint32_t config_get_src (void ) {
0 commit comments