Don't crash if we have the extension but couldn't load the XInput shared library.
authorSam Lantinga <slouken@libsdl.org>
Thu, 14 Feb 2013 15:40:19 -0800
changeset 68777287d385e6b3
parent 6876 3a4f7453da33
child 6878 30579e86ac24
Don't crash if we have the extension but couldn't load the XInput shared library.
Xcode/TemplatesForXcodeTiger/SDL Application/English.lproj/InfoPlist.strings
Xcode/TemplatesForXcodeTiger/SDL Cocoa Application/English.lproj/InfoPlist.strings
Xcode/TemplatesForXcodeTiger/SDL OpenGL Application/English.lproj/InfoPlist.strings
src/video/x11/SDL_x11xinput2.c
     1.1 Binary file Xcode/TemplatesForXcodeTiger/SDL Application/English.lproj/InfoPlist.strings has changed
     2.1 Binary file Xcode/TemplatesForXcodeTiger/SDL Cocoa Application/English.lproj/InfoPlist.strings has changed
     3.1 Binary file Xcode/TemplatesForXcodeTiger/SDL OpenGL Application/English.lproj/InfoPlist.strings has changed
     4.1 --- a/src/video/x11/SDL_x11xinput2.c	Thu Feb 14 13:22:05 2013 -0800
     4.2 +++ b/src/video/x11/SDL_x11xinput2.c	Thu Feb 14 15:40:19 2013 -0800
     4.3 @@ -62,7 +62,8 @@
     4.4  #endif /* SDL_VIDEO_DRIVER_X11_XINPUT2 */
     4.5  
     4.6  void 
     4.7 -X11_InitXinput2(_THIS) {
     4.8 +X11_InitXinput2(_THIS)
     4.9 +{
    4.10  #if SDL_VIDEO_DRIVER_X11_XINPUT2
    4.11      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    4.12  
    4.13 @@ -83,7 +84,8 @@
    4.14      *
    4.15      * FIXME:event and err are not needed but if not passed XQueryExtension returns SegmentationFault
    4.16      */
    4.17 -    if (!XQueryExtension(data->display, "XInputExtension", &xinput2_opcode, &event, &err)) {
    4.18 +    if (!SDL_X11_HAVE_XINPUT2 ||
    4.19 +        !XQueryExtension(data->display, "XInputExtension", &xinput2_opcode, &event, &err)) {
    4.20          return;
    4.21      }
    4.22  
    4.23 @@ -122,7 +124,8 @@
    4.24  
    4.25  
    4.26  int 
    4.27 -X11_HandleXinput2Event(SDL_VideoData *videodata,XGenericEventCookie *cookie) {
    4.28 +X11_HandleXinput2Event(SDL_VideoData *videodata,XGenericEventCookie *cookie)
    4.29 +{
    4.30  #if SDL_VIDEO_DRIVER_X11_XINPUT2
    4.31      if(cookie->extension != xinput2_opcode) {
    4.32          return 0;
    4.33 @@ -175,7 +178,8 @@
    4.34  }
    4.35  
    4.36  void 
    4.37 -X11_InitXinput2Multitouch(_THIS) {
    4.38 +X11_InitXinput2Multitouch(_THIS)
    4.39 +{
    4.40  #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
    4.41      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    4.42      XIDeviceInfo *info;
    4.43 @@ -218,7 +222,8 @@
    4.44  }
    4.45  
    4.46  void 
    4.47 -X11_Xinput2SelectTouch(_THIS, SDL_Window *window) {
    4.48 +X11_Xinput2SelectTouch(_THIS, SDL_Window *window)
    4.49 +{
    4.50  #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
    4.51      if (!X11_Xinput2IsMultitouchSupported()) {
    4.52          return;
    4.53 @@ -243,7 +248,8 @@
    4.54  
    4.55  
    4.56  int 
    4.57 -X11_Xinput2IsInitialized() {
    4.58 +X11_Xinput2IsInitialized()
    4.59 +{
    4.60  #if SDL_VIDEO_DRIVER_X11_XINPUT2
    4.61      return xinput2_initialized;
    4.62  #else
    4.63 @@ -252,7 +258,8 @@
    4.64  }
    4.65  
    4.66  int
    4.67 -X11_Xinput2IsMultitouchSupported() {
    4.68 +X11_Xinput2IsMultitouchSupported()
    4.69 +{
    4.70  #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
    4.71      return xinput2_initialized && xinput2_multitouch_supported;
    4.72  #else