Skip to content

Commit 57b6e6c

Browse files
MasonRemaleyicculus
authored andcommitted
Checks if xinput is loaded before trying to call xinput functions
1 parent ac3ab02 commit 57b6e6c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/video/x11/SDL_x11pen.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ static X11_PenHandle *X11_MaybeAddPen(SDL_VideoDevice *_this, const XIDeviceInfo
283283

284284
X11_PenHandle *X11_MaybeAddPenByDeviceID(SDL_VideoDevice *_this, int deviceid)
285285
{
286+
if (!X11_Xinput2IsInitialized()) return NULL;
286287
SDL_VideoData *data = _this->internal;
287288
int num_device_info = 0;
288289
XIDeviceInfo *device_info = X11_XIQueryDevice(data->display, deviceid, &num_device_info);
@@ -297,6 +298,7 @@ X11_PenHandle *X11_MaybeAddPenByDeviceID(SDL_VideoDevice *_this, int deviceid)
297298

298299
void X11_RemovePenByDeviceID(int deviceid)
299300
{
301+
if (!X11_Xinput2IsInitialized()) return;
300302
X11_PenHandle *handle = X11_FindPenByDeviceID(deviceid);
301303
if (handle) {
302304
SDL_RemovePenDevice(0, handle->pen);
@@ -306,6 +308,7 @@ void X11_RemovePenByDeviceID(int deviceid)
306308

307309
void X11_InitPen(SDL_VideoDevice *_this)
308310
{
311+
if (!X11_Xinput2IsInitialized()) return;
309312
SDL_VideoData *data = _this->internal;
310313

311314
#define LOOKUP_PEN_ATOM(X) X11_XInternAtom(data->display, X, False)
@@ -335,6 +338,7 @@ static void X11_FreePenHandle(SDL_PenID instance_id, void *handle, void *userdat
335338

336339
void X11_QuitPen(SDL_VideoDevice *_this)
337340
{
341+
if (!X11_Xinput2IsInitialized()) return;
338342
SDL_RemoveAllPenDevices(X11_FreePenHandle, NULL);
339343
}
340344

0 commit comments

Comments
 (0)