mirror of
https://github.com/libretro/RetroArch
synced 2025-02-02 23:54:06 +00:00
Push to msg_queue when device is hotplugged.
This commit is contained in:
parent
66a1c01419
commit
0653a8b5c2
7
Makefile
7
Makefile
@ -78,7 +78,7 @@ endif
|
|||||||
ifneq ($(findstring Linux,$(OS)),)
|
ifneq ($(findstring Linux,$(OS)),)
|
||||||
LIBS += -lrt
|
LIBS += -lrt
|
||||||
OBJ += input/linuxraw_input.o input/linuxraw_joypad.o
|
OBJ += input/linuxraw_input.o input/linuxraw_joypad.o
|
||||||
JOYCONFIG_OBJ += input/linuxraw_joypad.o
|
JOYCONFIG_OBJ += tools/linuxraw_joypad.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(HAVE_RGUI), 1)
|
ifeq ($(HAVE_RGUI), 1)
|
||||||
@ -342,6 +342,7 @@ ifeq ($(NOUNUSED_VARIABLE), yes)
|
|||||||
CFLAGS += -Wno-unused-variable
|
CFLAGS += -Wno-unused-variable
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
all: $(TARGET) config.mk
|
all: $(TARGET) config.mk
|
||||||
|
|
||||||
config.mk: configure qb/*
|
config.mk: configure qb/*
|
||||||
@ -368,6 +369,10 @@ tools/retrolaunch/retrolaunch: $(RETROLAUNCH_OBJ)
|
|||||||
@$(if $(Q), $(shell echo echo CC $<),)
|
@$(if $(Q), $(shell echo echo CC $<),)
|
||||||
$(Q)$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
|
$(Q)$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
|
||||||
|
|
||||||
|
tools/linuxraw_joypad.o: input/linuxraw_joypad.c
|
||||||
|
@$(if $(Q), $(shell echo echo CC $<),)
|
||||||
|
$(Q)$(CC) $(CFLAGS) $(DEFINES) -DNO_MSG_QUEUE -c -o $@ $<
|
||||||
|
|
||||||
%.o: %.S config.h config.mk $(HEADERS)
|
%.o: %.S config.h config.mk $(HEADERS)
|
||||||
@$(if $(Q), $(shell echo echo AS $<),)
|
@$(if $(Q), $(shell echo echo AS $<),)
|
||||||
$(Q)$(CC) $(CFLAGS) $(ASFLAGS) $(DEFINES) -c -o $@ $<
|
$(Q)$(CC) $(CFLAGS) $(ASFLAGS) $(DEFINES) -c -o $@ $<
|
||||||
|
@ -42,6 +42,10 @@ static struct linuxraw_joypad g_pads[MAX_PLAYERS];
|
|||||||
static int g_notify;
|
static int g_notify;
|
||||||
static int g_epoll;
|
static int g_epoll;
|
||||||
|
|
||||||
|
#ifndef NO_MSG_QUEUE
|
||||||
|
static bool g_hotplug;
|
||||||
|
#endif
|
||||||
|
|
||||||
static void poll_pad(struct linuxraw_joypad *pad)
|
static void poll_pad(struct linuxraw_joypad *pad)
|
||||||
{
|
{
|
||||||
struct js_event event;
|
struct js_event event;
|
||||||
@ -80,7 +84,19 @@ static void linuxraw_joypad_init_pad(const char *path, struct linuxraw_joypad *p
|
|||||||
if (pad->fd >= 0)
|
if (pad->fd >= 0)
|
||||||
{
|
{
|
||||||
if (ioctl(pad->fd, JSIOCGNAME(sizeof(g_settings.input.device_names[0])), pad->ident) >= 0)
|
if (ioctl(pad->fd, JSIOCGNAME(sizeof(g_settings.input.device_names[0])), pad->ident) >= 0)
|
||||||
|
{
|
||||||
RARCH_LOG("[Joypad]: Found pad: %s on %s.\n", pad->ident, path);
|
RARCH_LOG("[Joypad]: Found pad: %s on %s.\n", pad->ident, path);
|
||||||
|
|
||||||
|
#ifndef NO_MSG_QUEUE
|
||||||
|
if (g_hotplug)
|
||||||
|
{
|
||||||
|
char msg[512];
|
||||||
|
snprintf(msg, sizeof(msg), "Joypad #%u (%s) connected.", (unsigned)(pad - g_pads), pad->ident);
|
||||||
|
msg_queue_push(g_extern.msg_queue, msg, 0, 60);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
RARCH_ERR("[Joypad]: Didn't find ident of %s.\n", path);
|
RARCH_ERR("[Joypad]: Didn't find ident of %s.\n", path);
|
||||||
|
|
||||||
@ -120,6 +136,15 @@ static void handle_plugged_pad(void)
|
|||||||
{
|
{
|
||||||
if (g_pads[index].fd >= 0)
|
if (g_pads[index].fd >= 0)
|
||||||
{
|
{
|
||||||
|
#ifndef NO_MSG_QUEUE
|
||||||
|
if (g_hotplug)
|
||||||
|
{
|
||||||
|
char msg[512];
|
||||||
|
snprintf(msg, sizeof(msg), "Joypad #%u (%s) disconnected.", index, g_pads[index].ident);
|
||||||
|
msg_queue_push(g_extern.msg_queue, msg, 0, 60);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
RARCH_LOG("[Joypad]: Joypad %s disconnected.\n", g_pads[index].ident);
|
RARCH_LOG("[Joypad]: Joypad %s disconnected.\n", g_pads[index].ident);
|
||||||
close(g_pads[index].fd);
|
close(g_pads[index].fd);
|
||||||
memset(g_pads[index].buttons, 0, sizeof(g_pads[index].buttons));
|
memset(g_pads[index].buttons, 0, sizeof(g_pads[index].buttons));
|
||||||
@ -198,6 +223,10 @@ static bool linuxraw_joypad_init(void)
|
|||||||
epoll_ctl(g_epoll, EPOLL_CTL_ADD, g_notify, &event);
|
epoll_ctl(g_epoll, EPOLL_CTL_ADD, g_notify, &event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NO_MSG_QUEUE
|
||||||
|
g_hotplug = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,6 +249,10 @@ static void linuxraw_joypad_destroy(void)
|
|||||||
if (g_epoll >= 0)
|
if (g_epoll >= 0)
|
||||||
close(g_epoll);
|
close(g_epoll);
|
||||||
g_epoll = -1;
|
g_epoll = -1;
|
||||||
|
|
||||||
|
#ifndef NO_MSG_QUEUE
|
||||||
|
g_hotplug = false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool linuxraw_joypad_button(unsigned port, uint16_t joykey)
|
static bool linuxraw_joypad_button(unsigned port, uint16_t joykey)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user