src/video/x11/SDL_x11xinput2.c
author Ryan C. Gordon <icculus@icculus.org>
Fri, 18 Oct 2013 10:56:45 -0400
changeset 7836 b7c1c84c33e3
parent 7827 a03ec8de0426
child 8019 5d85b2186aae
permissions -rw-r--r--
Fixed the XInput2 X11 symbols.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
     1
/*
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
     2
  Simple DirectMedia Layer
6885
700f1b25f77f Happy New Year!
Sam Lantinga <slouken@libsdl.org>
parents: 6877
diff changeset
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
     4
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
     5
  This software is provided 'as-is', without any express or implied
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
     7
  arising from the use of this software.
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
     8
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    11
  freely, subject to the following restrictions:
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    12
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    14
     claim that you wrote the original software. If you use this software
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    16
     appreciated but is not required.
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    18
     misrepresented as being the original software.
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    20
*/
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    21
#include "SDL_config.h"
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    22
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    23
#if SDL_VIDEO_DRIVER_X11
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    24
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    25
#include "SDL_x11video.h"
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    26
#include "SDL_x11xinput2.h"
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    27
#include "../../events/SDL_mouse_c.h"
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    28
#include "../../events/SDL_touch_c.h"
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    29
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    30
#define MAX_AXIS 16
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    31
6375
93f9a24d1c02 Fixed some minor compiler warnings.
Ryan C. Gordon <icculus@icculus.org>
parents: 6318
diff changeset
    32
#if SDL_VIDEO_DRIVER_X11_XINPUT2
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    33
static int xinput2_initialized = 0;
6375
93f9a24d1c02 Fixed some minor compiler warnings.
Ryan C. Gordon <icculus@icculus.org>
parents: 6318
diff changeset
    34
93f9a24d1c02 Fixed some minor compiler warnings.
Ryan C. Gordon <icculus@icculus.org>
parents: 6318
diff changeset
    35
#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    36
static int xinput2_multitouch_supported = 0;
6375
93f9a24d1c02 Fixed some minor compiler warnings.
Ryan C. Gordon <icculus@icculus.org>
parents: 6318
diff changeset
    37
#endif
93f9a24d1c02 Fixed some minor compiler warnings.
Ryan C. Gordon <icculus@icculus.org>
parents: 6318
diff changeset
    38
7827
a03ec8de0426 Don't supply duplicate X11 symbols inside SDL.
Ryan C. Gordon <icculus@icculus.org>
parents: 7679
diff changeset
    39
/* Opcode returned X11_XQueryExtension
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    40
 * It will be used in event processing
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    41
 * to know that the event came from
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6951
diff changeset
    42
 * this extension */
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    43
static int xinput2_opcode;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    44
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    45
static void parse_valuators(const double *input_values,unsigned char *mask,int mask_len,
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    46
                            double *output_values,int output_values_len) {
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    47
    int i = 0,z = 0;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    48
    int top = mask_len * 8;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    49
    if (top > MAX_AXIS)
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    50
        top = MAX_AXIS;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    51
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    52
    SDL_memset(output_values,0,output_values_len * sizeof(double));
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    53
    for (; i < top && z < output_values_len; i++) {
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    54
        if (XIMaskIsSet(mask, i)) {
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    55
            const int value = (int) *input_values;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    56
            output_values[z] = value;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    57
            input_values++;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    58
        }
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    59
        z++;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    60
    }
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    61
}
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    62
#endif /* SDL_VIDEO_DRIVER_X11_XINPUT2 */
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    63
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6951
diff changeset
    64
void
6877
7287d385e6b3 Don't crash if we have the extension but couldn't load the XInput shared library.
Sam Lantinga <slouken@libsdl.org>
parents: 6433
diff changeset
    65
X11_InitXinput2(_THIS)
7287d385e6b3 Don't crash if we have the extension but couldn't load the XInput shared library.
Sam Lantinga <slouken@libsdl.org>
parents: 6433
diff changeset
    66
{
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    67
#if SDL_VIDEO_DRIVER_X11_XINPUT2
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    68
    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    69
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    70
    XIEventMask eventmask;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    71
    unsigned char mask[3] = { 0,0,0 };
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    72
    int event, err;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    73
    int major = 2, minor = 0;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    74
    int outmajor,outminor;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    75
#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    76
    minor = 2;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    77
#endif
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    78
    /*
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    79
    * Initialize XInput 2
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    80
    * According to http://who-t.blogspot.com/2009/05/xi2-recipes-part-1.html its better
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6951
diff changeset
    81
    * to inform Xserver what version of Xinput we support.The server will store the version we support.
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6951
diff changeset
    82
    * "As XI2 progresses it becomes important that you use this call as the server may treat the client
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    83
    * differently depending on the supported version".
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    84
    *
7827
a03ec8de0426 Don't supply duplicate X11 symbols inside SDL.
Ryan C. Gordon <icculus@icculus.org>
parents: 7679
diff changeset
    85
    * FIXME:event and err are not needed but if not passed X11_XQueryExtension returns SegmentationFault
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    86
    */
6877
7287d385e6b3 Don't crash if we have the extension but couldn't load the XInput shared library.
Sam Lantinga <slouken@libsdl.org>
parents: 6433
diff changeset
    87
    if (!SDL_X11_HAVE_XINPUT2 ||
7827
a03ec8de0426 Don't supply duplicate X11 symbols inside SDL.
Ryan C. Gordon <icculus@icculus.org>
parents: 7679
diff changeset
    88
        !X11_XQueryExtension(data->display, "XInputExtension", &xinput2_opcode, &event, &err)) {
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    89
        return;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    90
    }
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    91
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    92
    outmajor = major;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    93
    outminor = minor;
7827
a03ec8de0426 Don't supply duplicate X11 symbols inside SDL.
Ryan C. Gordon <icculus@icculus.org>
parents: 7679
diff changeset
    94
    if (X11_XIQueryVersion(data->display, &outmajor, &outminor) != Success) {
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    95
        return;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    96
    }
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    97
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
    98
    /* Check supported version */
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
    99
    if(outmajor * 1000 + outminor < major * 1000 + minor) {
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   100
        /* X server does not support the version we want */
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   101
        return;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   102
    }
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   103
    xinput2_initialized = 1;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   104
#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   105
    /* XInput 2.2 */
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   106
    if(outmajor * 1000 + outminor >= major * 1000 + minor) {
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   107
        xinput2_multitouch_supported = 1;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   108
    }
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   109
#endif
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   110
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   111
    /* Enable  Raw motion events for this display */
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   112
    eventmask.deviceid = XIAllMasterDevices;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   113
    eventmask.mask_len = sizeof(mask);
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   114
    eventmask.mask = mask;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   115
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   116
    XISetMask(mask, XI_RawMotion);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6951
diff changeset
   117
7827
a03ec8de0426 Don't supply duplicate X11 symbols inside SDL.
Ryan C. Gordon <icculus@icculus.org>
parents: 7679
diff changeset
   118
    if (X11_XISelectEvents(data->display,DefaultRootWindow(data->display),&eventmask,1) != Success) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6951
diff changeset
   119
        return;
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   120
    }
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   121
#endif
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   122
}
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   123
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6951
diff changeset
   124
int
6877
7287d385e6b3 Don't crash if we have the extension but couldn't load the XInput shared library.
Sam Lantinga <slouken@libsdl.org>
parents: 6433
diff changeset
   125
X11_HandleXinput2Event(SDL_VideoData *videodata,XGenericEventCookie *cookie)
7287d385e6b3 Don't crash if we have the extension but couldn't load the XInput shared library.
Sam Lantinga <slouken@libsdl.org>
parents: 6433
diff changeset
   126
{
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   127
#if SDL_VIDEO_DRIVER_X11_XINPUT2
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   128
    if(cookie->extension != xinput2_opcode) {
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   129
        return 0;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   130
    }
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   131
    switch(cookie->evtype) {
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   132
        case XI_RawMotion: {
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   133
            const XIRawEvent *rawev = (const XIRawEvent*)cookie->data;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   134
            SDL_Mouse *mouse = SDL_GetMouse();
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   135
            double relative_cords[2];
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   136
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   137
            if (!mouse->relative_mode) {
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   138
                return 0;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   139
            }
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   140
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   141
            parse_valuators(rawev->raw_values,rawev->valuators.mask,
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   142
                            rawev->valuators.mask_len,relative_cords,2);
6950
1ddb72193079 Added a mouse ID to the mouse events, which set to the special value SDL_TOUCH_MOUSEID for mouse events simulated by touch input.
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   143
            SDL_SendMouseMotion(mouse->focus,mouse->mouseID,1,(int)relative_cords[0],(int)relative_cords[1]);
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   144
            return 1;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   145
            }
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   146
            break;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   147
#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   148
        case XI_TouchBegin: {
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   149
            const XIDeviceEvent *xev = (const XIDeviceEvent *) cookie->data;
6951
7833f01322b3 Updated touch API
Sam Lantinga <slouken@libsdl.org>
parents: 6950
diff changeset
   150
            SDL_SendTouch(xev->sourceid,xev->detail,
7833f01322b3 Updated touch API
Sam Lantinga <slouken@libsdl.org>
parents: 6950
diff changeset
   151
                      SDL_TRUE, xev->event_x, xev->event_y, 1.0);
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   152
            return 1;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   153
            }
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   154
            break;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   155
        case XI_TouchEnd: {
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   156
            const XIDeviceEvent *xev = (const XIDeviceEvent *) cookie->data;
6951
7833f01322b3 Updated touch API
Sam Lantinga <slouken@libsdl.org>
parents: 6950
diff changeset
   157
            SDL_SendTouch(xev->sourceid,xev->detail,
7833f01322b3 Updated touch API
Sam Lantinga <slouken@libsdl.org>
parents: 6950
diff changeset
   158
                      SDL_FALSE, xev->event_x, xev->event_y, 1.0);
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   159
            return 1;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   160
            }
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   161
            break;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   162
        case XI_TouchUpdate: {
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   163
            const XIDeviceEvent *xev = (const XIDeviceEvent *) cookie->data;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   164
            SDL_SendTouchMotion(xev->sourceid,xev->detail,
6951
7833f01322b3 Updated touch API
Sam Lantinga <slouken@libsdl.org>
parents: 6950
diff changeset
   165
                                xev->event_x, xev->event_y, 1.0);
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   166
            return 1;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   167
            }
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   168
            break;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   169
#endif
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   170
    }
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   171
#endif
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   172
    return 0;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   173
}
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   174
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6951
diff changeset
   175
void
6877
7287d385e6b3 Don't crash if we have the extension but couldn't load the XInput shared library.
Sam Lantinga <slouken@libsdl.org>
parents: 6433
diff changeset
   176
X11_InitXinput2Multitouch(_THIS)
7287d385e6b3 Don't crash if we have the extension but couldn't load the XInput shared library.
Sam Lantinga <slouken@libsdl.org>
parents: 6433
diff changeset
   177
{
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   178
#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   179
    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   180
    XIDeviceInfo *info;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   181
    int ndevices,i,j;
7836
b7c1c84c33e3 Fixed the XInput2 X11 symbols.
Ryan C. Gordon <icculus@icculus.org>
parents: 7827
diff changeset
   182
    info = X11_XIQueryDevice(data->display, XIAllMasterDevices, &ndevices);
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   183
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   184
    for (i = 0; i < ndevices; i++) {
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   185
        XIDeviceInfo *dev = &info[i];
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   186
        for (j = 0; j < dev->num_classes; j++) {
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   187
            SDL_TouchID touchId;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   188
            XIAnyClassInfo *class = dev->classes[j];
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   189
            XITouchClassInfo *t = (XITouchClassInfo*)class;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   190
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   191
            /* Only touch devices */
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   192
            if (class->type != XITouchClass)
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   193
                continue;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   194
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   195
            touchId = t->sourceid;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   196
            if (!SDL_GetTouch(touchId)) {
6951
7833f01322b3 Updated touch API
Sam Lantinga <slouken@libsdl.org>
parents: 6950
diff changeset
   197
                SDL_AddTouch(touchId, dev->name);
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   198
            }
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   199
        }
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   200
    }
7836
b7c1c84c33e3 Fixed the XInput2 X11 symbols.
Ryan C. Gordon <icculus@icculus.org>
parents: 7827
diff changeset
   201
    X11_XIFreeDeviceInfo(info);
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   202
#endif
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   203
}
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   204
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6951
diff changeset
   205
void
6877
7287d385e6b3 Don't crash if we have the extension but couldn't load the XInput shared library.
Sam Lantinga <slouken@libsdl.org>
parents: 6433
diff changeset
   206
X11_Xinput2SelectTouch(_THIS, SDL_Window *window)
7287d385e6b3 Don't crash if we have the extension but couldn't load the XInput shared library.
Sam Lantinga <slouken@libsdl.org>
parents: 6433
diff changeset
   207
{
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   208
#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
7679
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
   209
    SDL_VideoData *data = NULL;
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
   210
    XIEventMask eventmask;
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
   211
    unsigned char mask[3] = { 0,0,0 };
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
   212
    SDL_WindowData *window_data = NULL;
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
   213
    
6433
8bbb5ff8788f Don't call XInput2 multitouch APIs if they aren't supported.
Ryan C. Gordon <icculus@icculus.org>
parents: 6432
diff changeset
   214
    if (!X11_Xinput2IsMultitouchSupported()) {
8bbb5ff8788f Don't call XInput2 multitouch APIs if they aren't supported.
Ryan C. Gordon <icculus@icculus.org>
parents: 6432
diff changeset
   215
        return;
8bbb5ff8788f Don't call XInput2 multitouch APIs if they aren't supported.
Ryan C. Gordon <icculus@icculus.org>
parents: 6432
diff changeset
   216
    }
8bbb5ff8788f Don't call XInput2 multitouch APIs if they aren't supported.
Ryan C. Gordon <icculus@icculus.org>
parents: 6432
diff changeset
   217
7679
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
   218
    data = (SDL_VideoData *) _this->driverdata;
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
   219
    window_data = (SDL_WindowData*)window->driverdata;
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   220
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   221
    eventmask.deviceid = XIAllMasterDevices;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   222
    eventmask.mask_len = sizeof(mask);
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   223
    eventmask.mask = mask;
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   224
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   225
    XISetMask(mask, XI_TouchBegin);
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   226
    XISetMask(mask, XI_TouchUpdate);
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   227
    XISetMask(mask, XI_TouchEnd);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6951
diff changeset
   228
7827
a03ec8de0426 Don't supply duplicate X11 symbols inside SDL.
Ryan C. Gordon <icculus@icculus.org>
parents: 7679
diff changeset
   229
    X11_XISelectEvents(data->display,window_data->xwindow,&eventmask,1);
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   230
#endif
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   231
}
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   232
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   233
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6951
diff changeset
   234
int
6877
7287d385e6b3 Don't crash if we have the extension but couldn't load the XInput shared library.
Sam Lantinga <slouken@libsdl.org>
parents: 6433
diff changeset
   235
X11_Xinput2IsInitialized()
7287d385e6b3 Don't crash if we have the extension but couldn't load the XInput shared library.
Sam Lantinga <slouken@libsdl.org>
parents: 6433
diff changeset
   236
{
6375
93f9a24d1c02 Fixed some minor compiler warnings.
Ryan C. Gordon <icculus@icculus.org>
parents: 6318
diff changeset
   237
#if SDL_VIDEO_DRIVER_X11_XINPUT2
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   238
    return xinput2_initialized;
6375
93f9a24d1c02 Fixed some minor compiler warnings.
Ryan C. Gordon <icculus@icculus.org>
parents: 6318
diff changeset
   239
#else
93f9a24d1c02 Fixed some minor compiler warnings.
Ryan C. Gordon <icculus@icculus.org>
parents: 6318
diff changeset
   240
    return 0;
93f9a24d1c02 Fixed some minor compiler warnings.
Ryan C. Gordon <icculus@icculus.org>
parents: 6318
diff changeset
   241
#endif
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   242
}
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   243
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   244
int
6877
7287d385e6b3 Don't crash if we have the extension but couldn't load the XInput shared library.
Sam Lantinga <slouken@libsdl.org>
parents: 6433
diff changeset
   245
X11_Xinput2IsMultitouchSupported()
7287d385e6b3 Don't crash if we have the extension but couldn't load the XInput shared library.
Sam Lantinga <slouken@libsdl.org>
parents: 6433
diff changeset
   246
{
6375
93f9a24d1c02 Fixed some minor compiler warnings.
Ryan C. Gordon <icculus@icculus.org>
parents: 6318
diff changeset
   247
#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   248
    return xinput2_initialized && xinput2_multitouch_supported;
6375
93f9a24d1c02 Fixed some minor compiler warnings.
Ryan C. Gordon <icculus@icculus.org>
parents: 6318
diff changeset
   249
#else
93f9a24d1c02 Fixed some minor compiler warnings.
Ryan C. Gordon <icculus@icculus.org>
parents: 6318
diff changeset
   250
    return 0;
93f9a24d1c02 Fixed some minor compiler warnings.
Ryan C. Gordon <icculus@icculus.org>
parents: 6318
diff changeset
   251
#endif
6316
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   252
}
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   253
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   254
#endif /* SDL_VIDEO_DRIVER_X11 */
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   255
a89c79a3f0cd 1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
diff changeset
   256
/* vi: set ts=4 sw=4 expandtab: */