OSD: F10 - start/stop Wiimote daemon.

This commit is contained in:
sorgelig
2019-04-29 02:10:23 +08:00
parent 98e768fb22
commit 5ce3f34f3a

View File

@@ -104,6 +104,8 @@ enum MENU
MENU_SCRIPTS,
MENU_SCRIPTS1,
MENU_BTPAIR,
MENU_WMPAIR,
MENU_WMPAIR1,
// Mist/atari specific pages
MENU_MIST_MAIN1,
@@ -507,6 +509,35 @@ static int has_bt()
return ret;
}
static int toggle_wminput()
{
if (access("/bin/wminput", F_OK) < 0 || access("/media/fat/linux/wiimote.cfg", F_OK) < 0) return -1;
FILE *fp;
static char out[1035];
fp = popen("pidof wminput", "r");
if (!fp) return -1;
int ret = -1;
if (fgets(out, sizeof(out) - 1, fp) != NULL)
{
if (strlen(out))
{
system("killall wminput");
ret = 0;
}
}
else
{
system("wminput --daemon --config /media/fat/linux/wiimote.cfg &");
ret = 1;
}
pclose(fp);
return ret;
}
static char* getNet(int spec)
{
int netType = 0;
@@ -768,6 +799,13 @@ void HandleUI(void)
}
break;
case KEY_F10:
if (user_io_osd_is_visible())
{
menustate = MENU_WMPAIR;
}
break;
// Within the menu the esc key acts as the menu key. problem:
// if the menu is left with a press of ESC, then the follwing
// break code for the ESC key when the key is released will
@@ -3538,6 +3576,29 @@ void HandleUI(void)
printSysInfo();
break;
case MENU_WMPAIR:
{
OsdSetTitle("Wiimote", 0);
int res = toggle_wminput();
menu_timer = GetTimer(2000);
for (int i = 0; i < OsdGetSize(); i++) OsdWrite(i);
if (res < 0) OsdWrite(7, " Cannot enable Wiimote");
else if (res == 0) OsdWrite(7, " Wiimote disabled");
else
{
OsdWrite(7, " Wiimote enabled");
OsdWrite(9, " Press 1+2 to connect");
menu_timer = GetTimer(3000);
}
menustate = MENU_WMPAIR1;
}
//fall through
case MENU_WMPAIR1:
if (CheckTimer(menu_timer)) menustate = MENU_NONE1;
break;
case MENU_BTPAIR:
OsdSetSize(16);
OsdEnable(DISABLE_KEYBOARD);