src/joystick/windows/SDL_xinputjoystick.c
author Ryan C. Gordon <icculus@icculus.org>
Thu, 28 May 2015 01:02:03 -0400
changeset 9659 839c0c3bf555
parent 9658 9753468b5c0e
child 9660 b7188b6a6f2a
permissions -rw-r--r--
Patched to compile on MingW. (I think!)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8972
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
  Simple DirectMedia Layer
9619
b94b6d0bff0f Updated the copyright year to 2015
Sam Lantinga <slouken@libsdl.org>
parents: 8987
diff changeset
     3
  Copyright (C) 1997-2015 Sam Lantinga <slouken@libsdl.org>
8972
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
  This software is provided 'as-is', without any express or implied
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
  arising from the use of this software.
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
  freely, subject to the following restrictions:
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
     claim that you wrote the original software. If you use this software
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
     appreciated but is not required.
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
     misrepresented as being the original software.
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
*/
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
#include "../../SDL_internal.h"
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
9659
839c0c3bf555 Patched to compile on MingW.
Ryan C. Gordon <icculus@icculus.org>
parents: 9658
diff changeset
    23
#include "../SDL_sysjoystick.h"
839c0c3bf555 Patched to compile on MingW.
Ryan C. Gordon <icculus@icculus.org>
parents: 9658
diff changeset
    24
9658
9753468b5c0e Move tests from SDL_config higher up in Windows joystick/haptic code.
Ryan C. Gordon <icculus@icculus.org>
parents: 9619
diff changeset
    25
#if SDL_JOYSTICK_XINPUT
9753468b5c0e Move tests from SDL_config higher up in Windows joystick/haptic code.
Ryan C. Gordon <icculus@icculus.org>
parents: 9619
diff changeset
    26
8972
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
#include "SDL_assert.h"
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
#include "SDL_hints.h"
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
#include "SDL_windowsjoystick_c.h"
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
#include "SDL_xinputjoystick_c.h"
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
/*
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
 * Internal stuff.
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
 */
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
static SDL_bool s_bXInputEnabled = SDL_TRUE;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
static SDL_bool
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
SDL_XInputUseOldJoystickMapping()
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
{
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
    static int s_XInputUseOldJoystickMapping = -1;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
    if (s_XInputUseOldJoystickMapping < 0) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
        const char *hint = SDL_GetHint(SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
        s_XInputUseOldJoystickMapping = (hint && *hint == '1') ? 1 : 0;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
    }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
    return (s_XInputUseOldJoystickMapping > 0);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
}
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
SDL_bool SDL_XINPUT_Enabled(void)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
{
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
    return s_bXInputEnabled;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
}
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
int
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
SDL_XINPUT_JoystickInit(void)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    56
{
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
    const char *env = SDL_GetHint(SDL_HINT_XINPUT_ENABLED);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
    if (env && !SDL_atoi(env)) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
        s_bXInputEnabled = SDL_FALSE;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
    }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
    if (s_bXInputEnabled && WIN_LoadXInputDLL() < 0) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
        s_bXInputEnabled = SDL_FALSE;  /* oh well. */
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
    }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    65
    return 0;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    66
}
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
static char *
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
GetXInputName(const Uint8 userid, BYTE SubType)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
{
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
    char name[32];
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    72
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
    if (SDL_XInputUseOldJoystickMapping()) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
        SDL_snprintf(name, sizeof(name), "X360 Controller #%u", 1 + userid);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
    } else {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
        switch (SubType) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
        case XINPUT_DEVSUBTYPE_GAMEPAD:
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
            SDL_snprintf(name, sizeof(name), "XInput Controller #%u", 1 + userid);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
            break;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
        case XINPUT_DEVSUBTYPE_WHEEL:
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
            SDL_snprintf(name, sizeof(name), "XInput Wheel #%u", 1 + userid);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
            break;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
        case XINPUT_DEVSUBTYPE_ARCADE_STICK:
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
            SDL_snprintf(name, sizeof(name), "XInput ArcadeStick #%u", 1 + userid);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
            break;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
        case XINPUT_DEVSUBTYPE_FLIGHT_STICK:
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
            SDL_snprintf(name, sizeof(name), "XInput FlightStick #%u", 1 + userid);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
            break;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    89
        case XINPUT_DEVSUBTYPE_DANCE_PAD:
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
            SDL_snprintf(name, sizeof(name), "XInput DancePad #%u", 1 + userid);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
            break;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
        case XINPUT_DEVSUBTYPE_GUITAR:
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
        case XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE:
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
        case XINPUT_DEVSUBTYPE_GUITAR_BASS:
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
            SDL_snprintf(name, sizeof(name), "XInput Guitar #%u", 1 + userid);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    96
            break;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
        case XINPUT_DEVSUBTYPE_DRUM_KIT:
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
            SDL_snprintf(name, sizeof(name), "XInput DrumKit #%u", 1 + userid);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
            break;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
        case XINPUT_DEVSUBTYPE_ARCADE_PAD:
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
            SDL_snprintf(name, sizeof(name), "XInput ArcadePad #%u", 1 + userid);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   102
            break;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   103
        default:
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   104
            SDL_snprintf(name, sizeof(name), "XInput Device #%u", 1 + userid);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   105
            break;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   106
        }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   107
    }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   108
    return SDL_strdup(name);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   109
}
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   110
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   111
static void
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   112
AddXInputDevice(const Uint8 userid, BYTE SubType, JoyStick_DeviceData **pContext)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   113
{
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   114
    JoyStick_DeviceData *pPrevJoystick = NULL;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   115
    JoyStick_DeviceData *pNewJoystick = *pContext;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   116
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   117
    if (SDL_XInputUseOldJoystickMapping() && SubType != XINPUT_DEVSUBTYPE_GAMEPAD)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   118
        return;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   119
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   120
    if (SubType == XINPUT_DEVSUBTYPE_UNKNOWN)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   121
        return;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   122
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   123
    while (pNewJoystick) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
        if (pNewJoystick->bXInputDevice && (pNewJoystick->XInputUserId == userid) && (pNewJoystick->SubType == SubType)) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   125
            /* if we are replacing the front of the list then update it */
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   126
            if (pNewJoystick == *pContext) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   127
                *pContext = pNewJoystick->pNext;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   128
            } else if (pPrevJoystick) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   129
                pPrevJoystick->pNext = pNewJoystick->pNext;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   130
            }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   131
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   132
            pNewJoystick->pNext = SYS_Joystick;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   133
            SYS_Joystick = pNewJoystick;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   134
            return;   /* already in the list. */
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   135
        }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
        pPrevJoystick = pNewJoystick;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   138
        pNewJoystick = pNewJoystick->pNext;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   139
    }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   140
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   141
    pNewJoystick = (JoyStick_DeviceData *)SDL_malloc(sizeof(JoyStick_DeviceData));
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   142
    if (!pNewJoystick) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   143
        return; /* better luck next time? */
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   144
    }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   145
    SDL_zerop(pNewJoystick);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   146
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   147
    pNewJoystick->joystickname = GetXInputName(userid, SubType);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   148
    if (!pNewJoystick->joystickname) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   149
        SDL_free(pNewJoystick);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   150
        return; /* better luck next time? */
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   151
    }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   152
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   153
    pNewJoystick->bXInputDevice = SDL_TRUE;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   154
    if (SDL_XInputUseOldJoystickMapping()) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   155
        SDL_zero(pNewJoystick->guid);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   156
    } else {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   157
        pNewJoystick->guid.data[0] = 'x';
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   158
        pNewJoystick->guid.data[1] = 'i';
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   159
        pNewJoystick->guid.data[2] = 'n';
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   160
        pNewJoystick->guid.data[3] = 'p';
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   161
        pNewJoystick->guid.data[4] = 'u';
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   162
        pNewJoystick->guid.data[5] = 't';
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   163
        pNewJoystick->guid.data[6] = SubType;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   164
    }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   165
    pNewJoystick->SubType = SubType;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   166
    pNewJoystick->XInputUserId = userid;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   167
    SDL_SYS_AddJoystickDevice(pNewJoystick);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   168
}
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   169
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   170
void
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   171
SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   172
{
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   173
    int iuserid;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   174
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   175
    if (!s_bXInputEnabled) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   176
        return;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   177
    }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   178
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   179
    /* iterate in reverse, so these are in the final list in ascending numeric order. */
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   180
    for (iuserid = XUSER_MAX_COUNT - 1; iuserid >= 0; iuserid--) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   181
        const Uint8 userid = (Uint8)iuserid;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   182
        XINPUT_CAPABILITIES capabilities;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   183
        if (XINPUTGETCAPABILITIES(userid, XINPUT_FLAG_GAMEPAD, &capabilities) == ERROR_SUCCESS) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   184
            AddXInputDevice(userid, capabilities.SubType, pContext);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   185
        }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   186
    }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   187
}
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   188
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   189
int
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   190
SDL_XINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickdevice)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   191
{
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   192
    const Uint8 userId = joystickdevice->XInputUserId;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   193
    XINPUT_CAPABILITIES capabilities;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   194
    XINPUT_VIBRATION state;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   195
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   196
    SDL_assert(s_bXInputEnabled);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   197
    SDL_assert(XINPUTGETCAPABILITIES);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   198
    SDL_assert(XINPUTSETSTATE);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   199
    SDL_assert(userId < XUSER_MAX_COUNT);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   200
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   201
    joystick->hwdata->bXInputDevice = SDL_TRUE;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   202
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   203
    if (XINPUTGETCAPABILITIES(userId, XINPUT_FLAG_GAMEPAD, &capabilities) != ERROR_SUCCESS) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   204
        SDL_free(joystick->hwdata);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   205
        joystick->hwdata = NULL;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   206
        return SDL_SetError("Failed to obtain XInput device capabilities. Device disconnected?");
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   207
    }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   208
    SDL_zero(state);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   209
    joystick->hwdata->bXInputHaptic = (XINPUTSETSTATE(userId, &state) == ERROR_SUCCESS);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   210
    joystick->hwdata->userid = userId;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   211
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   212
    /* The XInput API has a hard coded button/axis mapping, so we just match it */
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   213
    if (SDL_XInputUseOldJoystickMapping()) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   214
        joystick->naxes = 6;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   215
        joystick->nbuttons = 15;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   216
    } else {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   217
        joystick->naxes = 6;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   218
        joystick->nbuttons = 11;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   219
        joystick->nhats = 1;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   220
    }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   221
    return 0;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   222
}
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   223
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   224
static void
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   225
UpdateXInputJoystickState_OLD(SDL_Joystick * joystick, XINPUT_STATE_EX *pXInputState)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   226
{
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   227
    static WORD s_XInputButtons[] = {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   228
        XINPUT_GAMEPAD_DPAD_UP, XINPUT_GAMEPAD_DPAD_DOWN, XINPUT_GAMEPAD_DPAD_LEFT, XINPUT_GAMEPAD_DPAD_RIGHT,
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   229
        XINPUT_GAMEPAD_START, XINPUT_GAMEPAD_BACK, XINPUT_GAMEPAD_LEFT_THUMB, XINPUT_GAMEPAD_RIGHT_THUMB,
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   230
        XINPUT_GAMEPAD_LEFT_SHOULDER, XINPUT_GAMEPAD_RIGHT_SHOULDER,
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   231
        XINPUT_GAMEPAD_A, XINPUT_GAMEPAD_B, XINPUT_GAMEPAD_X, XINPUT_GAMEPAD_Y,
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   232
        XINPUT_GAMEPAD_GUIDE
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   233
    };
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   234
    WORD wButtons = pXInputState->Gamepad.wButtons;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   235
    Uint8 button;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   236
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   237
    SDL_PrivateJoystickAxis(joystick, 0, (Sint16)pXInputState->Gamepad.sThumbLX);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   238
    SDL_PrivateJoystickAxis(joystick, 1, (Sint16)(-SDL_max(-32767, pXInputState->Gamepad.sThumbLY)));
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   239
    SDL_PrivateJoystickAxis(joystick, 2, (Sint16)pXInputState->Gamepad.sThumbRX);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   240
    SDL_PrivateJoystickAxis(joystick, 3, (Sint16)(-SDL_max(-32767, pXInputState->Gamepad.sThumbRY)));
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   241
    SDL_PrivateJoystickAxis(joystick, 4, (Sint16)(((int)pXInputState->Gamepad.bLeftTrigger * 65535 / 255) - 32768));
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   242
    SDL_PrivateJoystickAxis(joystick, 5, (Sint16)(((int)pXInputState->Gamepad.bRightTrigger * 65535 / 255) - 32768));
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   243
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   244
    for (button = 0; button < SDL_arraysize(s_XInputButtons); ++button) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   245
        SDL_PrivateJoystickButton(joystick, button, (wButtons & s_XInputButtons[button]) ? SDL_PRESSED : SDL_RELEASED);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   246
    }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   247
}
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   248
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   249
static void
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   250
UpdateXInputJoystickState(SDL_Joystick * joystick, XINPUT_STATE_EX *pXInputState)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   251
{
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   252
    static WORD s_XInputButtons[] = {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   253
        XINPUT_GAMEPAD_A, XINPUT_GAMEPAD_B, XINPUT_GAMEPAD_X, XINPUT_GAMEPAD_Y,
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   254
        XINPUT_GAMEPAD_LEFT_SHOULDER, XINPUT_GAMEPAD_RIGHT_SHOULDER, XINPUT_GAMEPAD_BACK, XINPUT_GAMEPAD_START,
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   255
        XINPUT_GAMEPAD_LEFT_THUMB, XINPUT_GAMEPAD_RIGHT_THUMB,
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   256
        XINPUT_GAMEPAD_GUIDE
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   257
    };
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   258
    WORD wButtons = pXInputState->Gamepad.wButtons;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   259
    Uint8 button;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   260
    Uint8 hat = SDL_HAT_CENTERED;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   261
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   262
    SDL_PrivateJoystickAxis(joystick, 0, (Sint16)pXInputState->Gamepad.sThumbLX);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   263
    SDL_PrivateJoystickAxis(joystick, 1, (Sint16)(-SDL_max(-32767, pXInputState->Gamepad.sThumbLY)));
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   264
    SDL_PrivateJoystickAxis(joystick, 2, (Sint16)(((int)pXInputState->Gamepad.bLeftTrigger * 65535 / 255) - 32768));
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   265
    SDL_PrivateJoystickAxis(joystick, 3, (Sint16)pXInputState->Gamepad.sThumbRX);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   266
    SDL_PrivateJoystickAxis(joystick, 4, (Sint16)(-SDL_max(-32767, pXInputState->Gamepad.sThumbRY)));
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   267
    SDL_PrivateJoystickAxis(joystick, 5, (Sint16)(((int)pXInputState->Gamepad.bRightTrigger * 65535 / 255) - 32768));
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   268
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   269
    for (button = 0; button < SDL_arraysize(s_XInputButtons); ++button) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   270
        SDL_PrivateJoystickButton(joystick, button, (wButtons & s_XInputButtons[button]) ? SDL_PRESSED : SDL_RELEASED);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   271
    }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   272
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   273
    if (wButtons & XINPUT_GAMEPAD_DPAD_UP) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   274
        hat |= SDL_HAT_UP;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   275
    }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   276
    if (wButtons & XINPUT_GAMEPAD_DPAD_DOWN) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   277
        hat |= SDL_HAT_DOWN;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   278
    }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   279
    if (wButtons & XINPUT_GAMEPAD_DPAD_LEFT) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   280
        hat |= SDL_HAT_LEFT;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   281
    }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   282
    if (wButtons & XINPUT_GAMEPAD_DPAD_RIGHT) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   283
        hat |= SDL_HAT_RIGHT;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   284
    }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   285
    SDL_PrivateJoystickHat(joystick, 0, hat);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   286
}
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   287
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   288
void
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   289
SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   290
{
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   291
    HRESULT result;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   292
    XINPUT_STATE_EX XInputState;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   293
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   294
    if (!XINPUTGETSTATE)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   295
        return;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   296
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   297
    result = XINPUTGETSTATE(joystick->hwdata->userid, &XInputState);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   298
    if (result == ERROR_DEVICE_NOT_CONNECTED) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   299
        joystick->hwdata->send_remove_event = SDL_TRUE;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   300
        joystick->hwdata->removed = SDL_TRUE;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   301
        return;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   302
    }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   303
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   304
    /* only fire events if the data changed from last time */
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   305
    if (XInputState.dwPacketNumber && XInputState.dwPacketNumber != joystick->hwdata->dwPacketNumber) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   306
        if (SDL_XInputUseOldJoystickMapping()) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   307
            UpdateXInputJoystickState_OLD(joystick, &XInputState);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   308
        } else {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   309
            UpdateXInputJoystickState(joystick, &XInputState);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   310
        }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   311
        joystick->hwdata->dwPacketNumber = XInputState.dwPacketNumber;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   312
    }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   313
}
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   314
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   315
void
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   316
SDL_XINPUT_JoystickClose(SDL_Joystick * joystick)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   317
{
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   318
}
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   319
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   320
void
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   321
SDL_XINPUT_JoystickQuit(void)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   322
{
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   323
    if (s_bXInputEnabled) {
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   324
        WIN_UnloadXInputDLL();
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   325
    }
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   326
}
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   327
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   328
SDL_bool
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   329
SDL_SYS_IsXInputGamepad_DeviceIndex(int device_index)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   330
{
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   331
    JoyStick_DeviceData *device = SYS_Joystick;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   332
    int index;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   333
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   334
    for (index = device_index; index > 0; index--)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   335
        device = device->pNext;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   336
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   337
    return (device->SubType == XINPUT_DEVSUBTYPE_GAMEPAD);
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   338
}
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   339
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   340
#else /* !SDL_JOYSTICK_XINPUT */
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   341
9659
839c0c3bf555 Patched to compile on MingW.
Ryan C. Gordon <icculus@icculus.org>
parents: 9658
diff changeset
   342
struct JoyStick_DeviceData;
8972
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   343
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   344
SDL_bool SDL_XINPUT_Enabled(void)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   345
{
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   346
    return SDL_FALSE;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   347
}
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   348
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   349
int
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   350
SDL_XINPUT_JoystickInit(void)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   351
{
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   352
    return 0;
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   353
}
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   354
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   355
void
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   356
SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   357
{
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   358
}
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   359
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   360
int
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   361
SDL_XINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickdevice)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   362
{
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   363
    return SDL_Unsupported();
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   364
}
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   365
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   366
void
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   367
SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   368
{
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   369
}
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   370
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   371
void
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   372
SDL_XINPUT_JoystickClose(SDL_Joystick * joystick)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   373
{
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   374
}
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   375
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   376
void
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   377
SDL_XINPUT_JoystickQuit(void)
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   378
{
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   379
}
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   380
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   381
#endif /* SDL_JOYSTICK_XINPUT */
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   382
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   383
/* vi: set ts=4 sw=4 expandtab: */