diff --git a/MiSTer.ini b/MiSTer.ini index a14c937..aa803ff 100644 --- a/MiSTer.ini +++ b/MiSTer.ini @@ -171,3 +171,9 @@ log_file_entry=0 ; Some controllers have no automatic shutdown built in and will keep connection till battery dry out. ; 0 - don't disconnect automatically, otherwise it's amount of minutes. bt_auto_disconnect=0 + +; Reset Bluetooth dongle before pair dialog. +; Some dongles may have problem to pair if not explicitly reset. +; Some dongles (mostly CSR) have problem to pair with BLE if not reset in advance. +; Consequence of reset: some input devices get shutdown after reset. +bt_reset_before_pair=0 diff --git a/cfg.cpp b/cfg.cpp index 6c3beca..9161038 100644 --- a/cfg.cpp +++ b/cfg.cpp @@ -85,6 +85,7 @@ static const ini_var_t ini_vars[] = { "VFILTER_DEFAULT", (void*)(&(cfg.vfilter_default)), STRING, 0, sizeof(cfg.vfilter_default) - 1 }, { "LOG_FILE_ENTRY", (void*)(&(cfg.log_file_entry)), UINT8, 0, 1 }, { "BT_AUTO_DISCONNECT", (void*)(&(cfg.bt_auto_disconnect)), UINT32, 0, 180 }, + { "BT_RESET_BEFORE_PAIR", (void*)(&(cfg.bt_reset_before_pair)), UINT8, 0, 1 }, }; static const int nvars = (int)(sizeof(ini_vars) / sizeof(ini_var_t)); diff --git a/cfg.h b/cfg.h index 7144cfa..4b07324 100644 --- a/cfg.h +++ b/cfg.h @@ -54,6 +54,7 @@ typedef struct { uint8_t logo; uint8_t log_file_entry; int bt_auto_disconnect; + int bt_reset_before_pair; char bootcore[256]; char video_conf[1024]; char video_conf_pal[1024]; diff --git a/menu.cpp b/menu.cpp index 0841df9..f00856c 100644 --- a/menu.cpp +++ b/menu.cpp @@ -5999,7 +5999,16 @@ void HandleUI(void) CPU_SET(0, &set); CPU_SET(1, &set); sched_setaffinity(0, sizeof(set), &set); - script_pipe=popen((parentstate != MENU_BTPAIR) ? getFullPath(selPath) : "/usr/sbin/btpair", "r"); + if (parentstate == MENU_BTPAIR) + { + OsdUpdate(); + if(cfg.bt_reset_before_pair) system("hciconfig hci0 reset"); + script_pipe = popen("/usr/sbin/btpair", "r"); + } + else + { + script_pipe = popen(getFullPath(selPath), "r"); + } script_file = fileno(script_pipe); fcntl(script_file, F_SETFL, O_NONBLOCK); break;