video: dummy: Support evdev psuedo-device with no video.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h
index 6bfb60e..435ab12 100644
--- a/src/video/SDL_sysvideo.h
+++ b/src/video/SDL_sysvideo.h
@@ -454,6 +454,7 @@ extern VideoBootStrap RPI_bootstrap;
extern VideoBootStrap KMSDRM_bootstrap;
extern VideoBootStrap KMSDRM_LEGACY_bootstrap;
extern VideoBootStrap DUMMY_bootstrap;
+extern VideoBootStrap DUMMY_evdev_bootstrap;
extern VideoBootStrap Wayland_bootstrap;
extern VideoBootStrap NACL_bootstrap;
extern VideoBootStrap VIVANTE_bootstrap;
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 9868543..ecce551 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -130,6 +130,9 @@ static VideoBootStrap *bootstrap[] = {
#endif
#if SDL_VIDEO_DRIVER_DUMMY
&DUMMY_bootstrap,
+#if SDL_INPUT_LINUXEV
+ &DUMMY_evdev_bootstrap,
+#endif
#endif
NULL
};
diff --git a/src/video/dummy/SDL_nullvideo.c b/src/video/dummy/SDL_nullvideo.c
index 3e21151..df6c769 100644
--- a/src/video/dummy/SDL_nullvideo.c
+++ b/src/video/dummy/SDL_nullvideo.c
@@ -49,23 +49,36 @@
#include "SDL_hints.h"
#define DUMMYVID_DRIVER_NAME "dummy"
+#define DUMMYVID_DRIVER_EVDEV_NAME "evdev"
/* Initialization/Query functions */
static int DUMMY_VideoInit(_THIS);
static int DUMMY_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
static void DUMMY_VideoQuit(_THIS);
+#if SDL_INPUT_LINUXEV
+static int evdev = 0;
+static void DUMMY_EVDEV_Poll(_THIS);
+#endif
+
/* DUMMY driver bootstrap functions */
static int
DUMMY_Available(void)
{
const char *envr = SDL_GetHint(SDL_HINT_VIDEODRIVER);
- if ((envr) && (SDL_strcmp(envr, DUMMYVID_DRIVER_NAME) == 0)) {
- return (1);
+ if (envr) {
+ if (SDL_strcmp(envr, DUMMYVID_DRIVER_NAME) == 0) {
+ return 1;
+ }
+ #if SDL_INPUT_LINUXEV
+ if (SDL_strcmp(envr, DUMMYVID_DRIVER_EVDEV_NAME) == 0) {
+ evdev = 1;
+ return 1;
+ }
+ #endif
}
-
- return (0);
+ return 0;
}
static void
@@ -96,6 +109,11 @@ DUMMY_CreateDevice(void)
device->VideoQuit = DUMMY_VideoQuit;
device->SetDisplayMode = DUMMY_SetDisplayMode;
device->PumpEvents = DUMMY_PumpEvents;
+ #if SDL_INPUT_LINUXEV
+ if (evdev) {
+ device->PumpEvents = DUMMY_EVDEV_Poll;
+ }
+ #endif
device->CreateWindowFramebuffer = SDL_DUMMY_CreateWindowFramebuffer;
device->UpdateWindowFramebuffer = SDL_DUMMY_UpdateWindowFramebuffer;
device->DestroyWindowFramebuffer = SDL_DUMMY_DestroyWindowFramebuffer;
@@ -110,6 +128,19 @@ VideoBootStrap DUMMY_bootstrap = {
DUMMY_CreateDevice
};
+#if SDL_INPUT_LINUXEV
+VideoBootStrap DUMMY_evdev_bootstrap = {
+ DUMMYVID_DRIVER_EVDEV_NAME, "SDL dummy video driver with evdev",
+ DUMMY_CreateDevice
+};
+void SDL_EVDEV_Init(void);
+void SDL_EVDEV_Poll();
+void SDL_EVDEV_Quit(void);
+static void DUMMY_EVDEV_Poll(_THIS) {
+ (void) _this;
+ SDL_EVDEV_Poll();
+}
+#endif
int
DUMMY_VideoInit(_THIS)
@@ -129,6 +160,10 @@ DUMMY_VideoInit(_THIS)
SDL_AddDisplayMode(&_this->displays[0], &mode);
+ #if SDL_INPUT_LINUXEV
+ SDL_EVDEV_Init();
+ #endif
+
/* We're done! */
return 0;
}
@@ -139,9 +174,13 @@ DUMMY_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
return 0;
}
+
void
DUMMY_VideoQuit(_THIS)
{
+ #if SDL_INPUT_LINUXEV
+ SDL_EVDEV_Quit();
+ #endif
}
#endif /* SDL_VIDEO_DRIVER_DUMMY */