FIFO to communicate with MiSTer, implement FB resolution command.

This commit is contained in:
sorgelig
2019-05-29 22:23:27 +08:00
parent adcac43a39
commit 5e0f6e92b4
4 changed files with 75 additions and 7 deletions

View File

@@ -2373,7 +2373,9 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int
}
}
static struct pollfd pool[NUMDEV + 1];
#define CMD_FIFO "/dev/MiSTer_cmd"
static struct pollfd pool[NUMDEV + 2];
int input_test(int getchar)
{
@@ -2390,6 +2392,12 @@ int input_test(int getchar)
signal(SIGINT, INThandler);
pool[NUMDEV].fd = set_watch();
pool[NUMDEV].events = POLLIN;
unlink(CMD_FIFO);
mkfifo(CMD_FIFO, 0666);
pool[NUMDEV+1].fd = open(CMD_FIFO, O_RDONLY | O_NONBLOCK);
pool[NUMDEV+1].events = POLLIN;
state++;
}
@@ -2606,7 +2614,7 @@ int input_test(int getchar)
if (state == 2)
{
int return_value = poll(pool, NUMDEV + 1, (is_menu_core() && video_fb_state()) ? 500 : 0);
int return_value = poll(pool, NUMDEV + 2, (is_menu_core() && video_fb_state()) ? 500 : 0);
if (return_value < 0)
{
printf("ERR: poll\n");
@@ -2963,6 +2971,18 @@ int input_test(int getchar)
}
}
}
if ((pool[NUMDEV + 1].fd >= 0) && (pool[NUMDEV + 1].revents & POLLIN))
{
static char cmd[1024];
int len = read(pool[NUMDEV + 1].fd, cmd, sizeof(cmd) - 1);
if (len)
{
cmd[len] = 0;
printf("MiSTer_cmd: %s\n", cmd);
if (!strncmp(cmd, "fb_cmd", 6)) video_cmd(cmd);
}
}
}
if (cur_leds != leds_state)