Moved the directinput joystick hwdata stuff into a seperate header file. gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Wed, 06 Aug 2008 08:47:35 +0000
branchgsoc2008_force_feedback
changeset 2616acd5da848404
parent 2615 088907e9a2bb
child 2617 a168397d6549
Moved the directinput joystick hwdata stuff into a seperate header file.
src/joystick/win32/SDL_dxjoystick.c
src/joystick/win32/SDL_dxjoystick_c.h
     1.1 --- a/src/joystick/win32/SDL_dxjoystick.c	Wed Aug 06 07:59:03 2008 +0000
     1.2 +++ b/src/joystick/win32/SDL_dxjoystick.c	Wed Aug 06 08:47:35 2008 +0000
     1.3 @@ -38,20 +38,7 @@
     1.4  #include "SDL_joystick.h"
     1.5  #include "../SDL_sysjoystick.h"
     1.6  #include "../SDL_joystick_c.h"
     1.7 -
     1.8 -#define WIN32_LEAN_AND_MEAN
     1.9 -#include <windows.h>
    1.10 -
    1.11 -#define DIRECTINPUT_VERSION 0x0500
    1.12 -#include <dinput.h>
    1.13 -#ifdef _MSC_VER
    1.14 -    /* Used for the c_dfDIJoystick2 symbol (no imports are used) */
    1.15 -#   pragma comment (lib, "dinput.lib")
    1.16 -#endif
    1.17 -#include <dxerr.h>
    1.18 -#ifdef _MSC_VER
    1.19 -#   pragma comment (lib, "dxerr.lib")
    1.20 -#endif
    1.21 +#include "SDL_dxjoystick_c.h"
    1.22  
    1.23  /* an ISO hack for VisualC++ */
    1.24  #ifdef _MSC_VER
    1.25 @@ -60,7 +47,6 @@
    1.26  
    1.27  #define INPUT_QSIZE	32      /* Buffer up to 32 input messages */
    1.28  #define MAX_JOYSTICKS	8
    1.29 -#define MAX_INPUTS	256     /* each joystick can have up to 256 inputs */
    1.30  #define AXIS_MIN	-32768  /* minimum value for axis coordinate */
    1.31  #define AXIS_MAX	32767   /* maximum value for axis coordinate */
    1.32  #define JOY_AXIS_THRESHOLD	(((AXIS_MAX)-(AXIS_MIN))/100)   /* 1% motion */
    1.33 @@ -95,33 +81,6 @@
    1.34                                           Uint8 button, Uint8 state);
    1.35  
    1.36  
    1.37 -/* local types */
    1.38 -typedef enum Type
    1.39 -{ BUTTON, AXIS, HAT } Type;
    1.40 -
    1.41 -typedef struct input_t
    1.42 -{
    1.43 -    /* DirectInput offset for this input type: */
    1.44 -    DWORD ofs;
    1.45 -
    1.46 -    /* Button, axis or hat: */
    1.47 -    Type type;
    1.48 -
    1.49 -    /* SDL input offset: */
    1.50 -    Uint8 num;
    1.51 -} input_t;
    1.52 -
    1.53 -/* The private structure used to keep track of a joystick */
    1.54 -struct joystick_hwdata
    1.55 -{
    1.56 -    LPDIRECTINPUTDEVICE2 InputDevice;
    1.57 -    DIDEVCAPS Capabilities;
    1.58 -    int buffered;
    1.59 -
    1.60 -    input_t Inputs[MAX_INPUTS];
    1.61 -    int NumInputs;
    1.62 -};
    1.63 -
    1.64  /* Convert a DirectInput return code to a text message */
    1.65  static void
    1.66  SetDIerror(const char *function, HRESULT code)
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/joystick/win32/SDL_dxjoystick_c.h	Wed Aug 06 08:47:35 2008 +0000
     2.3 @@ -0,0 +1,82 @@
     2.4 +/*
     2.5 +    SDL - Simple DirectMedia Layer
     2.6 +    Copyright (C) 1997-2006 Sam Lantinga
     2.7 +
     2.8 +    This library is free software; you can redistribute it and/or
     2.9 +    modify it under the terms of the GNU Lesser General Public
    2.10 +    License as published by the Free Software Foundation; either
    2.11 +    version 2.1 of the License, or (at your option) any later version.
    2.12 +
    2.13 +    This library is distributed in the hope that it will be useful,
    2.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    2.16 +    Lesser General Public License for more details.
    2.17 +
    2.18 +    You should have received a copy of the GNU Lesser General Public
    2.19 +    License along with this library; if not, write to the Free Software
    2.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    2.21 +
    2.22 +    Sam Lantinga
    2.23 +    slouken@libsdl.org
    2.24 +*/
    2.25 +#include "SDL_config.h"
    2.26 +
    2.27 +#ifndef SDL_JOYSTICK_DINPUT_H
    2.28 +
    2.29 +/* DirectInput joystick driver; written by Glenn Maynard, based on Andrei de
    2.30 + * A. Formiga's WINMM driver. 
    2.31 + *
    2.32 + * Hats and sliders are completely untested; the app I'm writing this for mostly
    2.33 + * doesn't use them and I don't own any joysticks with them. 
    2.34 + *
    2.35 + * We don't bother to use event notification here.  It doesn't seem to work
    2.36 + * with polled devices, and it's fine to call IDirectInputDevice2_GetDeviceData and
    2.37 + * let it return 0 events. */
    2.38 +
    2.39 +#define WIN32_LEAN_AND_MEAN
    2.40 +#include <windows.h>
    2.41 +
    2.42 +#define DIRECTINPUT_VERSION 0x0500
    2.43 +#include <dinput.h>
    2.44 +#ifdef _MSC_VER
    2.45 +    /* Used for the c_dfDIJoystick2 symbol (no imports are used) */
    2.46 +#   pragma comment (lib, "dinput.lib")
    2.47 +#endif
    2.48 +#include <dxerr.h>
    2.49 +#ifdef _MSC_VER
    2.50 +#   pragma comment (lib, "dxerr.lib")
    2.51 +#endif
    2.52 +
    2.53 +
    2.54 +#define MAX_INPUTS	256     /* each joystick can have up to 256 inputs */
    2.55 +
    2.56 +
    2.57 +/* local types */
    2.58 +typedef enum Type
    2.59 +{ BUTTON, AXIS, HAT } Type;
    2.60 +
    2.61 +typedef struct input_t
    2.62 +{
    2.63 +    /* DirectInput offset for this input type: */
    2.64 +    DWORD ofs;
    2.65 +
    2.66 +    /* Button, axis or hat: */
    2.67 +    Type type;
    2.68 +
    2.69 +    /* SDL input offset: */
    2.70 +    Uint8 num;
    2.71 +} input_t;
    2.72 +
    2.73 +/* The private structure used to keep track of a joystick */
    2.74 +struct joystick_hwdata
    2.75 +{
    2.76 +    LPDIRECTINPUTDEVICE2 InputDevice;
    2.77 +    DIDEVCAPS Capabilities;
    2.78 +    int buffered;
    2.79 +
    2.80 +    input_t Inputs[MAX_INPUTS];
    2.81 +    int NumInputs;
    2.82 +};
    2.83 +
    2.84 +#endif /* SDL_JOYSTICK_DINPUT_H */
    2.85 +