move more code to linux_common.c

This commit is contained in:
twinaphex 2015-11-14 22:07:11 +01:00
parent bfec58154e
commit 8005585853
3 changed files with 9 additions and 28 deletions

View File

@ -92,25 +92,26 @@ static void linux_terminal_restore_signal(int sig)
kill(getpid(), sig);
}
void linux_terminal_disable_input(void)
bool linux_terminal_disable_input(void)
{
struct sigaction sa = {{0}};
/* Avoid accidentally typing stuff. */
if (!isatty(0))
return;
return false;
if (!linux_terminal_init())
{
linux_terminal_flush();
return;
return false;
}
sa.sa_handler = linux_terminal_restore_signal;
sa.sa_flags = SA_RESTART | SA_RESETHAND;
sigemptyset(&sa.sa_mask);
/* Trap some fatal signals. */
/* Trap some standard termination codes so we
* can restore the keyboard before we lose control. */
sigaction(SIGABRT, &sa, NULL);
sigaction(SIGBUS, &sa, NULL);
sigaction(SIGFPE, &sa, NULL);
@ -119,4 +120,6 @@ void linux_terminal_disable_input(void)
sigaction(SIGSEGV, &sa, NULL);
atexit(linux_terminal_restore_input);
return true;
}

View File

@ -28,6 +28,6 @@ void linux_terminal_claim_stdin(void);
bool linux_terminal_grab_stdin(void *data);
void linux_terminal_disable_input(void);
bool linux_terminal_disable_input(void);
#endif

View File

@ -37,12 +37,6 @@ typedef struct linuxraw_input
bool state[0x80];
} linuxraw_input_t;
static void linuxraw_exit_gracefully(int sig)
{
linux_terminal_restore_input();
kill(getpid(), sig);
}
static void *linuxraw_input_init(void)
{
struct sigaction sa = {{0}};
@ -64,29 +58,13 @@ static void *linuxraw_input_init(void)
if (!linuxraw)
return NULL;
if (!linux_terminal_init())
if (!linux_terminal_disable_input())
{
linux_terminal_restore_input();
free(linuxraw);
return NULL;
}
sa.sa_handler = linuxraw_exit_gracefully;
sa.sa_flags = SA_RESTART | SA_RESETHAND;
sigemptyset(&sa.sa_mask);
/* Trap some standard termination codes so we
* can restore the keyboard before we lose control. */
sigaction(SIGABRT, &sa, NULL);
sigaction(SIGBUS, &sa, NULL);
sigaction(SIGFPE, &sa, NULL);
sigaction(SIGILL, &sa, NULL);
sigaction(SIGQUIT, &sa, NULL);
sigaction(SIGSEGV, &sa, NULL);
atexit(linux_terminal_restore_input);
linuxraw->joypad = input_joypad_init_driver(
settings->input.joypad_driver, linuxraw);
input_keymaps_init_keyboard_lut(rarch_key_map_linux);