static void *linuxraw_input_init(void) { // only work on terminals if (!isatty(0)) return NULL; linuxraw_input_t *linuxraw = (linuxraw_input_t*)calloc(1, sizeof(*linuxraw)); if (!linuxraw) return NULL; if (oldKbmd == 0xffff) { tcgetattr(0, &oldTerm); newTerm = oldTerm; newTerm.c_lflag &= ~(ECHO | ICANON | ISIG); newTerm.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON); newTerm.c_cc[VMIN] = 0; newTerm.c_cc[VTIME] = 0; if (ioctl(0, KDGKBMODE, &oldKbmd) != 0) return NULL; } tcsetattr(0, TCSAFLUSH, &newTerm); if (ioctl(0, KDSKBMODE, K_MEDIUMRAW) != 0) { linuxraw_resetKbmd(); return NULL; } struct sigaction sa; sa.sa_handler = linuxraw_exitGracefully; 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(linuxraw_resetKbmd); linuxraw->sdl = (sdl_input_t*)input_sdl.init(); if (!linuxraw->sdl) { linuxraw_resetKbmd(); free(linuxraw); return NULL; } init_lut(); linuxraw->sdl->use_keyboard = false; return linuxraw; }
static void linuxraw_input_free(void *data) { linuxraw_input_t *linuxraw = (linuxraw_input_t*)data; input_sdl.free(linuxraw->sdl); linuxraw_resetKbmd(); free(data); }
static void *linuxraw_input_init(void) { // only work on terminals if (!isatty(0)) return NULL; if (driver.stdin_claimed) { RARCH_WARN("stdin is already used for ROM loading. Cannot use stdin for input.\n"); return NULL; } linuxraw_input_t *linuxraw = (linuxraw_input_t*)calloc(1, sizeof(*linuxraw)); if (!linuxraw) return NULL; if (oldKbmd == 0xffff) { tcgetattr(0, &oldTerm); newTerm = oldTerm; newTerm.c_lflag &= ~(ECHO | ICANON | ISIG); newTerm.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON); newTerm.c_cc[VMIN] = 0; newTerm.c_cc[VTIME] = 0; if (ioctl(0, KDGKBMODE, &oldKbmd) != 0) return NULL; } tcsetattr(0, TCSAFLUSH, &newTerm); if (ioctl(0, KDSKBMODE, K_MEDIUMRAW) != 0) { linuxraw_resetKbmd(); return NULL; } struct sigaction sa; sa.sa_handler = linuxraw_exitGracefully; 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(linuxraw_resetKbmd); linuxraw->joypad = input_joypad_init_driver(g_settings.input.joypad_driver); init_lut(); driver.stdin_claimed = true; // We need to disable use of stdin command interface if stdin is supposed to be used for input. return linuxraw; }
static void linuxraw_input_free(void *data) { linuxraw_input_t *linuxraw = (linuxraw_input_t*)data; if (linuxraw->joypad) linuxraw->joypad->destroy(); linuxraw_resetKbmd(); free(data); }
static void linuxraw_exitGracefully(int sig) { linuxraw_resetKbmd(); kill(getpid(), sig); }