static void *linuxraw_input_init(void) { struct sigaction sa = {{0}}; linuxraw_input_t *linuxraw = NULL; settings_t *settings = config_get_ptr(); /* Only work on terminals. */ if (!isatty(0)) return NULL; if (linux_terminal_grab_stdin(NULL)) { RARCH_WARN("stdin is already used for content loading. Cannot use stdin for input.\n"); return NULL; } linuxraw = (linuxraw_input_t*)calloc(1, sizeof(*linuxraw)); if (!linuxraw) return NULL; if (!linux_terminal_disable_input()) { linux_terminal_restore_input(); free(linuxraw); return NULL; } linuxraw->joypad = input_joypad_init_driver( settings->input.joypad_driver, linuxraw); input_keymaps_init_keyboard_lut(rarch_key_map_linux); linux_terminal_claim_stdin(); return linuxraw; }
static void *udev_input_init(const char *joypad_driver) { udev_input_t *udev = (udev_input_t*)calloc(1, sizeof(*udev)); if (!udev) return NULL; udev->udev = udev_new(); if (!udev->udev) { RARCH_ERR("Failed to create udev handle.\n"); goto error; } udev->monitor = udev_monitor_new_from_netlink(udev->udev, "udev"); if (udev->monitor) { udev_monitor_filter_add_match_subsystem_devtype(udev->monitor, "input", NULL); udev_monitor_enable_receiving(udev->monitor); } #ifdef HAVE_XKBCOMMON if (init_xkb(-1, 0) == -1) goto error; #endif if (!epoll_new(&udev->epfd)) { RARCH_ERR("Failed to create epoll FD.\n"); goto error; } if (!open_devices(udev, "ID_INPUT_KEYBOARD", udev_handle_keyboard)) { RARCH_ERR("Failed to open keyboard.\n"); goto error; } if (!open_devices(udev, "ID_INPUT_MOUSE", udev_handle_mouse)) { RARCH_ERR("Failed to open mouse.\n"); goto error; } if (!open_devices(udev, "ID_INPUT_TOUCHPAD", udev_handle_touchpad)) { RARCH_ERR("Failed to open touchpads.\n"); goto error; } /* If using KMS and we forgot this, * we could lock ourselves out completely. */ if (!udev->num_devices) RARCH_WARN("[udev]: Couldn't open any keyboard, mouse or touchpad. Are permissions set correctly for /dev/input/event*?\n"); udev->joypad = input_joypad_init_driver(joypad_driver, udev); input_keymaps_init_keyboard_lut(rarch_key_map_linux); linux_terminal_disable_input(); return udev; error: udev_input_free(udev); return NULL; }