|
@@ -283,22 +283,22 @@ static X11_PenHandle *X11_MaybeAddPen(SDL_VideoDevice *_this, const XIDeviceInfo
|
|
|
|
|
|
X11_PenHandle *X11_MaybeAddPenByDeviceID(SDL_VideoDevice *_this, int deviceid)
|
|
X11_PenHandle *X11_MaybeAddPenByDeviceID(SDL_VideoDevice *_this, int deviceid)
|
|
{
|
|
{
|
|
- if (!X11_Xinput2IsInitialized()) return NULL;
|
|
|
|
- SDL_VideoData *data = _this->internal;
|
|
|
|
- int num_device_info = 0;
|
|
|
|
- XIDeviceInfo *device_info = X11_XIQueryDevice(data->display, deviceid, &num_device_info);
|
|
|
|
- if (device_info) {
|
|
|
|
- SDL_assert(num_device_info == 1);
|
|
|
|
- X11_PenHandle *handle = X11_MaybeAddPen(_this, device_info);
|
|
|
|
- X11_XIFreeDeviceInfo(device_info);
|
|
|
|
- return handle;
|
|
|
|
|
|
+ if (X11_Xinput2IsInitialized()) {
|
|
|
|
+ SDL_VideoData *data = _this->internal;
|
|
|
|
+ int num_device_info = 0;
|
|
|
|
+ XIDeviceInfo *device_info = X11_XIQueryDevice(data->display, deviceid, &num_device_info);
|
|
|
|
+ if (device_info) {
|
|
|
|
+ SDL_assert(num_device_info == 1);
|
|
|
|
+ X11_PenHandle *handle = X11_MaybeAddPen(_this, device_info);
|
|
|
|
+ X11_XIFreeDeviceInfo(device_info);
|
|
|
|
+ return handle;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
void X11_RemovePenByDeviceID(int deviceid)
|
|
void X11_RemovePenByDeviceID(int deviceid)
|
|
{
|
|
{
|
|
- if (!X11_Xinput2IsInitialized()) return;
|
|
|
|
X11_PenHandle *handle = X11_FindPenByDeviceID(deviceid);
|
|
X11_PenHandle *handle = X11_FindPenByDeviceID(deviceid);
|
|
if (handle) {
|
|
if (handle) {
|
|
SDL_RemovePenDevice(0, handle->pen);
|
|
SDL_RemovePenDevice(0, handle->pen);
|
|
@@ -308,7 +308,10 @@ void X11_RemovePenByDeviceID(int deviceid)
|
|
|
|
|
|
void X11_InitPen(SDL_VideoDevice *_this)
|
|
void X11_InitPen(SDL_VideoDevice *_this)
|
|
{
|
|
{
|
|
- if (!X11_Xinput2IsInitialized()) return;
|
|
|
|
|
|
+ if (!X11_Xinput2IsInitialized()) {
|
|
|
|
+ return; // we need XIQueryDevice() for this.
|
|
|
|
+ }
|
|
|
|
+
|
|
SDL_VideoData *data = _this->internal;
|
|
SDL_VideoData *data = _this->internal;
|
|
|
|
|
|
#define LOOKUP_PEN_ATOM(X) X11_XInternAtom(data->display, X, False)
|
|
#define LOOKUP_PEN_ATOM(X) X11_XInternAtom(data->display, X, False)
|
|
@@ -338,7 +341,6 @@ static void X11_FreePenHandle(SDL_PenID instance_id, void *handle, void *userdat
|
|
|
|
|
|
void X11_QuitPen(SDL_VideoDevice *_this)
|
|
void X11_QuitPen(SDL_VideoDevice *_this)
|
|
{
|
|
{
|
|
- if (!X11_Xinput2IsInitialized()) return;
|
|
|
|
SDL_RemoveAllPenDevices(X11_FreePenHandle, NULL);
|
|
SDL_RemoveAllPenDevices(X11_FreePenHandle, NULL);
|
|
}
|
|
}
|
|
|
|
|