mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-21 20:28:28 +00:00
Added SDL_GetKeyboardName() and SDL_GetMouseName()
This commit is contained in:
parent
20a860c876
commit
c0f4565552
26 changed files with 239 additions and 110 deletions
|
@ -607,17 +607,22 @@ static SDL_Scancode SDL_EVDEV_translate_keycode(int keycode)
|
|||
|
||||
static int SDL_EVDEV_init_keyboard(SDL_evdevlist_item *item, int udev_class)
|
||||
{
|
||||
SDL_AddKeyboard((SDL_KeyboardID)item->fd, SDL_TRUE);
|
||||
SDL_AddKeyboard((SDL_KeyboardID)item->fd, NULL, SDL_TRUE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void SDL_EVDEV_destroy_keyboard(SDL_evdevlist_item *item)
|
||||
{
|
||||
SDL_RemoveKeyboard((SDL_KeyboardID)item->fd);
|
||||
}
|
||||
|
||||
static int SDL_EVDEV_init_mouse(SDL_evdevlist_item *item, int udev_class)
|
||||
{
|
||||
int ret;
|
||||
struct input_absinfo abs_info;
|
||||
|
||||
SDL_AddMouse((SDL_MouseID)item->fd, SDL_TRUE);
|
||||
SDL_AddMouse((SDL_MouseID)item->fd, NULL, SDL_TRUE);
|
||||
|
||||
ret = ioctl(item->fd, EVIOCGABS(ABS_X), &abs_info);
|
||||
if (ret < 0) {
|
||||
|
@ -640,6 +645,11 @@ static int SDL_EVDEV_init_mouse(SDL_evdevlist_item *item, int udev_class)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void SDL_EVDEV_destroy_mouse(SDL_evdevlist_item *item)
|
||||
{
|
||||
SDL_RemoveMouse((SDL_MouseID)item->fd);
|
||||
}
|
||||
|
||||
static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
|
||||
{
|
||||
int ret;
|
||||
|
@ -974,6 +984,10 @@ static int SDL_EVDEV_device_removed(const char *dev_path)
|
|||
}
|
||||
if (item->is_touchscreen) {
|
||||
SDL_EVDEV_destroy_touchscreen(item);
|
||||
} else if (item->udev_class & SDL_UDEV_DEVICE_MOUSE) {
|
||||
SDL_EVDEV_destroy_mouse(item);
|
||||
} else if (item->udev_class & SDL_UDEV_DEVICE_KEYBOARD) {
|
||||
SDL_EVDEV_destroy_keyboard(item);
|
||||
}
|
||||
close(item->fd);
|
||||
SDL_free(item->path);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue