mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-02-13 07:13:35 +00:00
dummy: Only initialize evdev input devices in the evdev driver
This avoids some misleading error messages when running unit tests with the dummy driver: on a typical desktop Linux system, it's normal for opening keyboards and mouse in `/dev/input/*` to fail with `EACCES`, and in container technologies that share `/sys` but not `/dev` with the container, we can find that we fail to open them with `ENOENT`. Resolves: https://github.com/libsdl-org/SDL/issues/14872 Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
committed by
Sam Lantinga
parent
b1362f8a42
commit
9ceb982a63
@@ -52,8 +52,13 @@
|
||||
#define DUMMYVID_DRIVER_EVDEV_NAME "evdev"
|
||||
|
||||
// Initialization/Query functions
|
||||
static bool DUMMY_VideoInitCommon(SDL_VideoDevice *_this);
|
||||
static bool DUMMY_VideoInit(SDL_VideoDevice *_this);
|
||||
static void DUMMY_VideoQuit(SDL_VideoDevice *_this);
|
||||
#ifdef SDL_INPUT_LINUXEV
|
||||
static bool DUMMY_EVDEV_VideoInit(SDL_VideoDevice *_this);
|
||||
static void DUMMY_EVDEV_VideoQuit(SDL_VideoDevice *_this);
|
||||
#endif
|
||||
|
||||
static bool DUMMY_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
@@ -125,6 +130,21 @@ VideoBootStrap DUMMY_bootstrap = {
|
||||
|
||||
#ifdef SDL_INPUT_LINUXEV
|
||||
|
||||
static bool DUMMY_EVDEV_VideoInit(SDL_VideoDevice *_this)
|
||||
{
|
||||
if (!DUMMY_VideoInitCommon(_this)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_EVDEV_Init();
|
||||
return true;
|
||||
}
|
||||
|
||||
static void DUMMY_EVDEV_VideoQuit(SDL_VideoDevice *_this)
|
||||
{
|
||||
SDL_EVDEV_Quit();
|
||||
}
|
||||
|
||||
static void DUMMY_EVDEV_Poll(SDL_VideoDevice *_this)
|
||||
{
|
||||
(void)_this;
|
||||
@@ -135,6 +155,8 @@ static SDL_VideoDevice *DUMMY_EVDEV_CreateDevice(void)
|
||||
{
|
||||
SDL_VideoDevice *device = DUMMY_InternalCreateDevice(DUMMYVID_DRIVER_EVDEV_NAME);
|
||||
if (device) {
|
||||
device->VideoInit = DUMMY_EVDEV_VideoInit;
|
||||
device->VideoQuit = DUMMY_EVDEV_VideoQuit;
|
||||
device->PumpEvents = DUMMY_EVDEV_Poll;
|
||||
}
|
||||
return device;
|
||||
@@ -147,16 +169,14 @@ VideoBootStrap DUMMY_evdev_bootstrap = {
|
||||
false
|
||||
};
|
||||
|
||||
#else
|
||||
#endif // SDL_INPUT_LINUXEV
|
||||
|
||||
static bool DUMMY_SetRelativeMouseMode(bool enabled)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // SDL_INPUT_LINUXEV
|
||||
|
||||
bool DUMMY_VideoInit(SDL_VideoDevice *_this)
|
||||
bool DUMMY_VideoInitCommon(SDL_VideoDevice *_this)
|
||||
{
|
||||
SDL_DisplayMode mode;
|
||||
|
||||
@@ -169,21 +189,21 @@ bool DUMMY_VideoInit(SDL_VideoDevice *_this)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef SDL_INPUT_LINUXEV
|
||||
SDL_EVDEV_Init();
|
||||
#else
|
||||
SDL_GetMouse()->SetRelativeMouseMode = DUMMY_SetRelativeMouseMode;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
// We're done!
|
||||
bool DUMMY_VideoInit(SDL_VideoDevice *_this)
|
||||
{
|
||||
if (!DUMMY_VideoInitCommon(_this)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_GetMouse()->SetRelativeMouseMode = DUMMY_SetRelativeMouseMode;
|
||||
return true;
|
||||
}
|
||||
|
||||
void DUMMY_VideoQuit(SDL_VideoDevice *_this)
|
||||
{
|
||||
#ifdef SDL_INPUT_LINUXEV
|
||||
SDL_EVDEV_Quit();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // SDL_VIDEO_DRIVER_DUMMY
|
||||
|
||||
Reference in New Issue
Block a user