From f93920a4f16c4d16f6cd3797191e7894542dac4b Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sat, 10 Aug 2024 15:55:00 +0300
Subject: [PATCH] video, x11: fix linkage if SDL_VIDEO_DRIVER_X11_XINPUT2 isn't
defined.
---
src/video/x11/SDL_x11pen.c | 16 ++++++++++++++--
src/video/x11/SDL_x11pen.h | 17 ++++++++---------
2 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/src/video/x11/SDL_x11pen.c b/src/video/x11/SDL_x11pen.c
index 0c3f92e0afb3b..4cc7337c165f5 100644
--- a/src/video/x11/SDL_x11pen.c
+++ b/src/video/x11/SDL_x11pen.c
@@ -20,14 +20,14 @@
*/
#include "../../SDL_internal.h"
-#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2
-
#include "../../events/SDL_pen_c.h"
#include "../SDL_sysvideo.h"
#include "SDL_x11pen.h"
#include "SDL_x11video.h"
#include "SDL_x11xinput2.h"
+#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2
+
/* Does this device have a valuator for pressure sensitivity? */
static SDL_bool X11_XInput2DeviceIsPen(SDL_VideoDevice *_this, const XIDeviceInfo *dev)
{
@@ -416,5 +416,17 @@ void X11_PenAxesFromValuators(const X11_PenHandle *pen,
X11_XInput2NormalizePenAxes(pen, axis_values);
}
+#else
+
+void X11_InitPen(SDL_VideoDevice *_this)
+{
+ (void) _this;
+}
+
+void X11_QuitPen(SDL_VideoDevice *_this)
+{
+ (void) _this;
+}
+
#endif // SDL_VIDEO_DRIVER_X11_XINPUT2
diff --git a/src/video/x11/SDL_x11pen.h b/src/video/x11/SDL_x11pen.h
index 71a60739970f0..b5e0be01162af 100644
--- a/src/video/x11/SDL_x11pen.h
+++ b/src/video/x11/SDL_x11pen.h
@@ -25,11 +25,17 @@
// Pressure-sensitive pen support for X11.
-#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2
-
#include "SDL_x11video.h"
#include "../../events/SDL_pen_c.h"
+// Prep pen support (never fails; pens simply won't be added if there's a problem).
+extern void X11_InitPen(SDL_VideoDevice *_this);
+
+// Clean up pen support.
+extern void X11_QuitPen(SDL_VideoDevice *_this);
+
+#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2
+
// Forward definition for SDL_x11video.h
struct SDL_VideoData;
@@ -47,12 +53,6 @@ typedef struct X11_PenHandle
float axis_max[SDL_PEN_NUM_AXES];
} X11_PenHandle;
-// Prep pen support (never fails; pens simply won't be added if there's a problem).
-extern void X11_InitPen(SDL_VideoDevice *_this);
-
-// Clean up pen support.
-extern void X11_QuitPen(SDL_VideoDevice *_this);
-
// Converts XINPUT2 valuators into pen axis information, including normalisation.
extern void X11_PenAxesFromValuators(const X11_PenHandle *pen,
const double *input_values, const unsigned char *mask, const int mask_len,
@@ -70,4 +70,3 @@ extern X11_PenHandle *X11_FindPenByDeviceID(int deviceid);
#endif // SDL_VIDEO_DRIVER_X11_XINPUT2
#endif // SDL_x11pen_h_
-