src/joystick/windows/SDL_windowsjoystick_c.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 07 Jul 2014 10:26:28 -0700
changeset 8976 1a5d959d7b32
parent 8972 dfc759d7486f
child 9619 b94b6d0bff0f
permissions -rw-r--r--
Fixed mingw64 build and warnings
slouken@2713
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@8149
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
slouken@2713
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@2713
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@2713
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@2713
    20
*/
icculus@8093
    21
#include "../../SDL_internal.h"
slouken@2713
    22
slouken@8972
    23
#include "SDL_events.h"
slouken@8972
    24
#include "../SDL_sysjoystick.h"
slouken@5090
    25
#include "../../core/windows/SDL_windows.h"
slouken@8972
    26
#include "../../core/windows/SDL_directx.h"
slouken@2713
    27
slouken@7191
    28
#define MAX_INPUTS  256     /* each joystick can have up to 256 inputs */
slouken@2713
    29
slouken@8972
    30
typedef struct JoyStick_DeviceData
slouken@8972
    31
{
slouken@8972
    32
    SDL_JoystickGUID guid;
slouken@8972
    33
    char *joystickname;
slouken@8972
    34
    Uint8 send_add_event;
slouken@8972
    35
    SDL_JoystickID nInstanceID;
slouken@8972
    36
    SDL_bool bXInputDevice;
slouken@8972
    37
    BYTE SubType;
slouken@8972
    38
    Uint8 XInputUserId;
slouken@8972
    39
    DIDEVICEINSTANCE dxdevice;
slouken@8972
    40
    struct JoyStick_DeviceData *pNext;
slouken@8972
    41
} JoyStick_DeviceData;
slouken@2713
    42
slouken@8972
    43
extern JoyStick_DeviceData *SYS_Joystick;    /* array to hold joystick ID values */
slouken@8972
    44
slouken@2713
    45
typedef enum Type
slouken@8972
    46
{
slouken@8972
    47
    BUTTON,
slouken@8972
    48
    AXIS,
slouken@8972
    49
    HAT
slouken@8972
    50
} Type;
slouken@2713
    51
slouken@2713
    52
typedef struct input_t
slouken@2713
    53
{
slouken@2713
    54
    /* DirectInput offset for this input type: */
slouken@2713
    55
    DWORD ofs;
slouken@2713
    56
slouken@2713
    57
    /* Button, axis or hat: */
slouken@2713
    58
    Type type;
slouken@2713
    59
slouken@2713
    60
    /* SDL input offset: */
slouken@2713
    61
    Uint8 num;
slouken@2713
    62
} input_t;
slouken@2713
    63
slouken@2713
    64
/* The private structure used to keep track of a joystick */
slouken@2713
    65
struct joystick_hwdata
slouken@2713
    66
{
slouken@8972
    67
    SDL_JoystickGUID guid;
slouken@8972
    68
    SDL_bool removed;
slouken@8972
    69
    SDL_bool send_remove_event;
slouken@8972
    70
slouken@8972
    71
#if SDL_JOYSTICK_DINPUT
icculus@6716
    72
    LPDIRECTINPUTDEVICE8 InputDevice;
slouken@2713
    73
    DIDEVCAPS Capabilities;
slouken@8972
    74
    SDL_bool buffered;
slouken@2713
    75
    input_t Inputs[MAX_INPUTS];
slouken@2713
    76
    int NumInputs;
slouken@7191
    77
    int NumSliders;
slouken@8972
    78
#endif
slouken@8972
    79
slouken@8972
    80
    SDL_bool bXInputDevice; /* SDL_TRUE if this device supports using the xinput API rather than DirectInput */
slouken@8972
    81
    SDL_bool bXInputHaptic; /* Supports force feedback via XInput. */
slouken@7191
    82
    Uint8 userid; /* XInput userid index for this joystick */
slouken@8972
    83
    DWORD dwPacketNumber;
slouken@2713
    84
};
slouken@2713
    85
slouken@8972
    86
extern void SDL_SYS_AddJoystickDevice(JoyStick_DeviceData *device);
slouken@8972
    87
slouken@8972
    88
/* vi: set ts=4 sw=4 expandtab: */