comparison src/joystick/win32/SDL_dxjoystick.c @ 2616:acd5da848404 gsoc2008_force_feedback

Moved the directinput joystick hwdata stuff into a seperate header file.
author Edgar Simo <bobbens@gmail.com>
date Wed, 06 Aug 2008 08:47:35 +0000
parents 64fa227c01ce
children 6deba05725ac
comparison
equal deleted inserted replaced
2615:088907e9a2bb 2616:acd5da848404
36 #include "SDL_error.h" 36 #include "SDL_error.h"
37 #include "SDL_events.h" 37 #include "SDL_events.h"
38 #include "SDL_joystick.h" 38 #include "SDL_joystick.h"
39 #include "../SDL_sysjoystick.h" 39 #include "../SDL_sysjoystick.h"
40 #include "../SDL_joystick_c.h" 40 #include "../SDL_joystick_c.h"
41 41 #include "SDL_dxjoystick_c.h"
42 #define WIN32_LEAN_AND_MEAN
43 #include <windows.h>
44
45 #define DIRECTINPUT_VERSION 0x0500
46 #include <dinput.h>
47 #ifdef _MSC_VER
48 /* Used for the c_dfDIJoystick2 symbol (no imports are used) */
49 # pragma comment (lib, "dinput.lib")
50 #endif
51 #include <dxerr.h>
52 #ifdef _MSC_VER
53 # pragma comment (lib, "dxerr.lib")
54 #endif
55 42
56 /* an ISO hack for VisualC++ */ 43 /* an ISO hack for VisualC++ */
57 #ifdef _MSC_VER 44 #ifdef _MSC_VER
58 #define snprintf _snprintf 45 #define snprintf _snprintf
59 #endif 46 #endif
60 47
61 #define INPUT_QSIZE 32 /* Buffer up to 32 input messages */ 48 #define INPUT_QSIZE 32 /* Buffer up to 32 input messages */
62 #define MAX_JOYSTICKS 8 49 #define MAX_JOYSTICKS 8
63 #define MAX_INPUTS 256 /* each joystick can have up to 256 inputs */
64 #define AXIS_MIN -32768 /* minimum value for axis coordinate */ 50 #define AXIS_MIN -32768 /* minimum value for axis coordinate */
65 #define AXIS_MAX 32767 /* maximum value for axis coordinate */ 51 #define AXIS_MAX 32767 /* maximum value for axis coordinate */
66 #define JOY_AXIS_THRESHOLD (((AXIS_MAX)-(AXIS_MIN))/100) /* 1% motion */ 52 #define JOY_AXIS_THRESHOLD (((AXIS_MAX)-(AXIS_MIN))/100) /* 1% motion */
67 53
68 /* external variables referenced. */ 54 /* external variables referenced. */
93 Uint8 value); 79 Uint8 value);
94 static int SDL_PrivateJoystickButton_Int(SDL_Joystick * joystick, 80 static int SDL_PrivateJoystickButton_Int(SDL_Joystick * joystick,
95 Uint8 button, Uint8 state); 81 Uint8 button, Uint8 state);
96 82
97 83
98 /* local types */
99 typedef enum Type
100 { BUTTON, AXIS, HAT } Type;
101
102 typedef struct input_t
103 {
104 /* DirectInput offset for this input type: */
105 DWORD ofs;
106
107 /* Button, axis or hat: */
108 Type type;
109
110 /* SDL input offset: */
111 Uint8 num;
112 } input_t;
113
114 /* The private structure used to keep track of a joystick */
115 struct joystick_hwdata
116 {
117 LPDIRECTINPUTDEVICE2 InputDevice;
118 DIDEVCAPS Capabilities;
119 int buffered;
120
121 input_t Inputs[MAX_INPUTS];
122 int NumInputs;
123 };
124
125 /* Convert a DirectInput return code to a text message */ 84 /* Convert a DirectInput return code to a text message */
126 static void 85 static void
127 SetDIerror(const char *function, HRESULT code) 86 SetDIerror(const char *function, HRESULT code)
128 { 87 {
129 SDL_SetError("%s() [%s]: %s", function, 88 SDL_SetError("%s() [%s]: %s", function,