diff --git a/src/video/dummy/SDL_nullvideo.c b/src/video/dummy/SDL_nullvideo.c index 228596cddb..58063e2b46 100644 --- a/src/video/dummy/SDL_nullvideo.c +++ b/src/video/dummy/SDL_nullvideo.c @@ -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