mirror of
https://github.com/libretro/RetroArch.git
synced 2025-01-23 18:06:36 +00:00
Add grab_stdin function pointer to input driver - avoids threading
segfault at exit with linuxraw input driver to do with driver->stdin_claimed
This commit is contained in:
parent
d662ac187d
commit
3a7263020a
@ -52,14 +52,14 @@ static void event_init_command(void)
|
||||
if (!settings->stdin_cmd_enable && !settings->network_cmd_enable)
|
||||
return;
|
||||
|
||||
if (settings->stdin_cmd_enable && driver->stdin_claimed)
|
||||
if (settings->stdin_cmd_enable && input_driver_grab_stdin())
|
||||
{
|
||||
RARCH_WARN("stdin command interface is desired, but input driver has already claimed stdin.\n"
|
||||
"Cannot use this command interface.\n");
|
||||
}
|
||||
|
||||
if (!(driver->command = rarch_cmd_new(settings->stdin_cmd_enable
|
||||
&& !driver->stdin_claimed,
|
||||
&& !input_driver_grab_stdin(),
|
||||
settings->network_cmd_enable, settings->network_cmd_port)))
|
||||
RARCH_ERR("Failed to initialize command interface.\n");
|
||||
}
|
||||
|
1
driver.h
1
driver.h
@ -263,7 +263,6 @@ typedef struct driver
|
||||
#ifdef HAVE_COMMAND
|
||||
rarch_cmd_t *command;
|
||||
#endif
|
||||
bool stdin_claimed;
|
||||
bool block_hotkey;
|
||||
bool block_input;
|
||||
bool block_libretro_input;
|
||||
|
@ -1062,6 +1062,7 @@ input_driver_t input_android = {
|
||||
"android",
|
||||
|
||||
android_input_grab_mouse,
|
||||
NULL,
|
||||
android_input_set_rumble,
|
||||
android_input_get_joypad_driver,
|
||||
};
|
||||
|
@ -434,6 +434,7 @@ input_driver_t input_cocoa = {
|
||||
cocoa_input_get_capabilities,
|
||||
"cocoa",
|
||||
cocoa_input_grab_mouse,
|
||||
NULL,
|
||||
cocoa_input_set_rumble,
|
||||
cocoa_input_get_joypad_driver
|
||||
};
|
||||
|
@ -132,6 +132,7 @@ input_driver_t input_ctr = {
|
||||
ctr_input_get_capabilities,
|
||||
"ctr",
|
||||
ctr_input_grab_mouse,
|
||||
NULL,
|
||||
ctr_input_set_rumble,
|
||||
ctr_input_get_joypad_driver,
|
||||
};
|
||||
|
@ -685,6 +685,7 @@ input_driver_t input_dinput = {
|
||||
"dinput",
|
||||
|
||||
dinput_grab_mouse,
|
||||
NULL,
|
||||
dinput_set_rumble,
|
||||
dinput_get_joypad_driver,
|
||||
};
|
||||
|
@ -141,6 +141,7 @@ input_driver_t input_gx = {
|
||||
"gx",
|
||||
|
||||
gx_input_grab_mouse,
|
||||
NULL,
|
||||
gx_input_set_rumble,
|
||||
gx_input_get_joypad_driver,
|
||||
};
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "../input_joypad.h"
|
||||
|
||||
static long oldKbmd = 0xffff;
|
||||
static bool linuxraw_stdin_claimed = false;
|
||||
static struct termios oldTerm, newTerm;
|
||||
|
||||
typedef struct linuxraw_input
|
||||
@ -39,7 +40,6 @@ typedef struct linuxraw_input
|
||||
|
||||
static void linuxraw_reset_kbmd(void)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
if (oldKbmd != 0xffff)
|
||||
{
|
||||
ioctl(0, KDSKBMODE, oldKbmd);
|
||||
@ -47,7 +47,7 @@ static void linuxraw_reset_kbmd(void)
|
||||
oldKbmd = 0xffff;
|
||||
}
|
||||
|
||||
driver->stdin_claimed = false;
|
||||
linuxraw_stdin_claimed = false;
|
||||
}
|
||||
|
||||
static void linuxraw_exit_gracefully(int sig)
|
||||
@ -67,7 +67,7 @@ static void *linuxraw_input_init(void)
|
||||
if (!isatty(0))
|
||||
return NULL;
|
||||
|
||||
if (driver->stdin_claimed)
|
||||
if (linuxraw_stdin_claimed)
|
||||
{
|
||||
RARCH_WARN("stdin is already used for content loading. Cannot use stdin for input.\n");
|
||||
return NULL;
|
||||
@ -122,11 +122,16 @@ static void *linuxraw_input_init(void)
|
||||
|
||||
/* We need to disable use of stdin command interface if
|
||||
* stdin is supposed to be used for input. */
|
||||
driver->stdin_claimed = true;
|
||||
linuxraw_stdin_claimed = true;
|
||||
|
||||
return linuxraw;
|
||||
}
|
||||
|
||||
static bool linuxraw_grab_stdin(void *data)
|
||||
{
|
||||
return linuxraw_stdin_claimed;
|
||||
}
|
||||
|
||||
static bool linuxraw_key_pressed(linuxraw_input_t *linuxraw, int key)
|
||||
{
|
||||
unsigned sym = input_keymaps_translate_rk_to_keysym((enum retro_key)key);
|
||||
@ -282,6 +287,7 @@ input_driver_t input_linuxraw = {
|
||||
linuxraw_get_capabilities,
|
||||
"linuxraw",
|
||||
linuxraw_grab_mouse,
|
||||
linuxraw_grab_stdin,
|
||||
linuxraw_set_rumble,
|
||||
linuxraw_get_joypad_driver,
|
||||
};
|
||||
|
@ -97,5 +97,6 @@ input_driver_t input_null = {
|
||||
nullinput_get_capabilities,
|
||||
"null",
|
||||
nullinput_grab_mouse,
|
||||
NULL,
|
||||
nullinput_set_rumble,
|
||||
};
|
||||
|
@ -259,6 +259,7 @@ input_driver_t input_ps3 = {
|
||||
"ps3",
|
||||
|
||||
ps3_input_grab_mouse,
|
||||
NULL,
|
||||
ps3_input_set_rumble,
|
||||
ps3_input_get_joypad_driver,
|
||||
};
|
||||
|
@ -146,6 +146,7 @@ input_driver_t input_psp = {
|
||||
"psp",
|
||||
|
||||
psp_input_grab_mouse,
|
||||
NULL,
|
||||
psp_input_set_rumble,
|
||||
psp_input_get_joypad_driver,
|
||||
};
|
||||
|
@ -850,6 +850,7 @@ input_driver_t input_qnx = {
|
||||
qnx_input_get_capabilities,
|
||||
"qnx_input",
|
||||
qnx_input_grab_mouse,
|
||||
NULL,
|
||||
qnx_input_set_rumble,
|
||||
qnx_input_get_joypad_driver,
|
||||
};
|
||||
|
@ -237,5 +237,6 @@ input_driver_t input_rwebinput = {
|
||||
rwebinput_get_capabilities,
|
||||
"rwebinput",
|
||||
rwebinput_grab_mouse,
|
||||
NULL,
|
||||
rwebinput_set_rumble,
|
||||
};
|
||||
|
@ -395,6 +395,7 @@ input_driver_t input_sdl = {
|
||||
"sdl",
|
||||
#endif
|
||||
sdl_grab_mouse,
|
||||
NULL,
|
||||
sdl_set_rumble,
|
||||
sdl_get_joypad_driver,
|
||||
};
|
||||
|
@ -874,6 +874,7 @@ input_driver_t input_udev = {
|
||||
udev_input_get_capabilities,
|
||||
"udev",
|
||||
udev_input_grab_mouse,
|
||||
NULL,
|
||||
udev_input_set_rumble,
|
||||
udev_input_get_joypad_driver,
|
||||
};
|
||||
|
@ -396,6 +396,7 @@ input_driver_t input_x = {
|
||||
x_input_get_capabilities,
|
||||
"x",
|
||||
x_grab_mouse,
|
||||
NULL,
|
||||
x_set_rumble,
|
||||
x_get_joypad_driver,
|
||||
};
|
||||
|
@ -162,6 +162,7 @@ input_driver_t input_xinput = {
|
||||
xdk_input_get_capabilities,
|
||||
"xinput",
|
||||
xdk_input_grab_mouse,
|
||||
NULL,
|
||||
xdk_input_set_rumble,
|
||||
xdk_input_get_joypad_driver,
|
||||
};
|
||||
|
@ -131,5 +131,6 @@ input_driver_t input_xenon360 = {
|
||||
xenon360_input_get_capabilities,
|
||||
"xenon360",
|
||||
xenon360_input_grab_mouse,
|
||||
NULL,
|
||||
xenon360_input_set_rumble,
|
||||
};
|
||||
|
@ -290,6 +290,16 @@ bool input_driver_grab_mouse(bool state)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool input_driver_grab_stdin(void)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
const input_driver_t *input = input_get_ptr(driver);
|
||||
|
||||
if (input->grab_stdin)
|
||||
return input->grab_stdin(driver->input_data);
|
||||
return false;
|
||||
}
|
||||
|
||||
void *input_driver_init(void)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
|
@ -72,6 +72,7 @@ typedef struct input_driver
|
||||
const char *ident;
|
||||
|
||||
void (*grab_mouse)(void *data, bool state);
|
||||
bool (*grab_stdin)(void *data);
|
||||
bool (*set_rumble)(void *data, unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t state);
|
||||
const input_device_driver_t *(*get_joypad_driver)(void *data);
|
||||
@ -151,6 +152,8 @@ const input_device_driver_t * input_driver_get_joypad_driver(void);
|
||||
|
||||
bool input_driver_grab_mouse(bool state);
|
||||
|
||||
bool input_driver_grab_stdin(void);
|
||||
|
||||
void *input_driver_init(void);
|
||||
|
||||
void input_driver_free(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user