annotate src/joystick/win32/SDL_dxjoystick.c @ 1662:782fd950bd46 SDL-1.3

Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API. WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid. The code is now run through a consistent indent format: indent -i4 -nut -nsc -br -ce The headers are being converted to automatically generate doxygen documentation.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 28 May 2006 13:04:16 +0000
parents 281d3f4870e5
children 4da1ee79c9af
rev   line source
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Lesser General Public License for more details.
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 #include "SDL_config.h"
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 #ifdef SDL_JOYSTICK_DINPUT
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 /* DirectInput joystick driver; written by Glenn Maynard, based on Andrei de
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 * A. Formiga's WINMM driver.
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 *
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 * Hats and sliders are completely untested; the app I'm writing this for mostly
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 * doesn't use them and I don't own any joysticks with them.
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 *
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 * We don't bother to use event notification here. It doesn't seem to work
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 * with polled devices, and it's fine to call IDirectInputDevice2_GetDeviceData and
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 * let it return 0 events. */
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 #include "SDL_error.h"
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 #include "SDL_events.h"
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 #include "SDL_joystick.h"
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 #include "../SDL_sysjoystick.h"
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 #include "../SDL_joystick_c.h"
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 #define WIN32_LEAN_AND_MEAN
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 #include <windows.h>
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 #define DIRECTINPUT_VERSION 0x0500
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 #include <dinput.h>
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
48 #define INPUT_QSIZE 32 /* Buffer up to 32 input messages */
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 extern HINSTANCE SDL_Instance;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
51 extern int DX5_Load ();
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
52 extern void DX5_Unload ();
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
53 extern HRESULT (WINAPI * DInputCreate) (HINSTANCE hinst, DWORD dwVersion,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
54 LPDIRECTINPUT * ppDI,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
55 LPUNKNOWN punkOuter);
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 static LPDIRECTINPUT dinput = NULL;
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 #define MAX_JOYSTICKS 8
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
60 #define MAX_INPUTS 256 /* each joystick can have up to 256 inputs */
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 #define AXIS_MIN -32768 /* minimum value for axis coordinate */
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 #define AXIS_MAX 32767 /* maximum value for axis coordinate */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
63 #define JOY_AXIS_THRESHOLD (((AXIS_MAX)-(AXIS_MIN))/100) /* 1% motion */
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
65 typedef enum Type
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
66 { BUTTON, AXIS, HAT } Type;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 /* array to hold joystick ID values */
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 static DIDEVICEINSTANCE SYS_Joystick[MAX_JOYSTICKS];
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
70 static int SYS_NumJoysticks;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 extern HWND SDL_Window;
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 typedef struct input_t
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
76 /* DirectInput offset for this input type: */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
77 DWORD ofs;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
79 /* Button, axis or hat: */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
80 Type type;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
82 /* SDL input offset: */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
83 Uint8 num;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 } input_t;
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 /* The private structure used to keep track of a joystick */
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 struct joystick_hwdata
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
89 LPDIRECTINPUTDEVICE2 InputDevice;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
90 int buffered;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
92 input_t Inputs[MAX_INPUTS];
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
93 int NumInputs;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 };
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 /* Convert a DirectInput return code to a text message */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
97 static void
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
98 SetDIerror (char *function, int code)
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
100 static char *error;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
101 static char errbuf[1024];
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
103 errbuf[0] = 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
104 switch (code) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
105 case DIERR_GENERIC:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
106 error = "Undefined error!";
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
107 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
108 case DIERR_OLDDIRECTINPUTVERSION:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
109 error = "Your version of DirectInput needs upgrading";
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
110 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
111 case DIERR_INVALIDPARAM:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
112 error = "Invalid parameters";
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
113 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
114 case DIERR_OUTOFMEMORY:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
115 error = "Out of memory";
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
116 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
117 case DIERR_DEVICENOTREG:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
118 error = "Device not registered";
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
119 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
120 case DIERR_NOINTERFACE:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
121 error = "Interface not supported";
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
122 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
123 case DIERR_NOTINITIALIZED:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
124 error = "Device not initialized";
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
125 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
126 default:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
127 sprintf (errbuf, "%s: Unknown DirectInput error: 0x%x",
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
128 function, code);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
129 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
130 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
131 if (!errbuf[0]) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
132 sprintf (errbuf, "%s: %s", function, error);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
133 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
134 SDL_SetError ("%s", errbuf);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
135 return;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 }
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
139 BOOL CALLBACK
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
140 EnumJoysticksCallback (const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
142 memcpy (&SYS_Joystick[SYS_NumJoysticks], pdidInstance,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
143 sizeof (DIDEVICEINSTANCE));
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
144 SYS_NumJoysticks++;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
146 if (SYS_NumJoysticks >= MAX_JOYSTICKS)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
147 return DIENUM_STOP;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
149 return DIENUM_CONTINUE;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 }
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
152 static BOOL CALLBACK
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
153 DIJoystick_EnumDevObjectsProc (LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef)
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
155 SDL_Joystick *joystick = (SDL_Joystick *) pvRef;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
156 HRESULT result;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
157 input_t *in = &joystick->hwdata->Inputs[joystick->hwdata->NumInputs];
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
158 const int SupportedMask = DIDFT_BUTTON | DIDFT_POV | DIDFT_AXIS;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
159 if (!(dev->dwType & SupportedMask))
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
160 return DIENUM_CONTINUE; /* unsupported */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
161
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
162 in->ofs = dev->dwOfs;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
164 if (dev->dwType & DIDFT_BUTTON) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
165 in->type = BUTTON;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
166 in->num = joystick->nbuttons;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
167 joystick->nbuttons++;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
168 } else if (dev->dwType & DIDFT_POV) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
169 in->type = HAT;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
170 in->num = joystick->nhats;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
171 joystick->nhats++;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
172 } else { /* dev->dwType & DIDFT_AXIS */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
173 DIPROPRANGE diprg;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
174 DIPROPDWORD dilong;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
175
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
176 in->type = AXIS;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
177 in->num = joystick->naxes;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
179 diprg.diph.dwSize = sizeof (diprg);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
180 diprg.diph.dwHeaderSize = sizeof (diprg.diph);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
181 diprg.diph.dwObj = dev->dwOfs;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
182 diprg.diph.dwHow = DIPH_BYOFFSET;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
183 diprg.lMin = AXIS_MIN;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
184 diprg.lMax = AXIS_MAX;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
185
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
186 result =
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
187 IDirectInputDevice2_SetProperty (joystick->hwdata->InputDevice,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
188 DIPROP_RANGE, &diprg.diph);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
189 if (result != DI_OK)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
190 return DIENUM_CONTINUE; /* don't use this axis */
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
192 /* Set dead zone to 0. */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
193 dilong.diph.dwSize = sizeof (dilong);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
194 dilong.diph.dwHeaderSize = sizeof (dilong.diph);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
195 dilong.diph.dwObj = dev->dwOfs;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
196 dilong.diph.dwHow = DIPH_BYOFFSET;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
197 dilong.dwData = 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
198 result =
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
199 IDirectInputDevice2_SetProperty (joystick->hwdata->InputDevice,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
200 DIPROP_DEADZONE, &dilong.diph);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
201 if (result != DI_OK)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
202 return DIENUM_CONTINUE; /* don't use this axis */
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
204 joystick->naxes++;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
205 }
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
207 joystick->hwdata->NumInputs++;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
209 if (joystick->hwdata->NumInputs == MAX_INPUTS)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
210 return DIENUM_STOP; /* too many */
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
212 return DIENUM_CONTINUE;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 }
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 /* Function to scan the system for joysticks.
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 * This function should set SDL_numjoysticks to the number of available
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 * joysticks. Joystick 0 should be the system default joystick.
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 * It should return 0, or -1 on an unrecoverable fatal error.
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
220 int
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
221 SDL_SYS_JoystickInit (void)
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
223 HRESULT result;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
225 SYS_NumJoysticks = 0;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
227 /* Create the DirectInput object */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
228 if (DX5_Load () < 0) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
229 SDL_SetError ("Couldn't load DirectInput");
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
230 return (-1);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
231 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
232 result = DInputCreate (SDL_Instance, DIRECTINPUT_VERSION, &dinput, NULL);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
233 if (result != DI_OK) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
234 DX5_Unload ();
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
235 SetDIerror ("DirectInputCreate", result);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
236 return (-1);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
237 }
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
239 result = IDirectInput_EnumDevices (dinput,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
240 DIDEVTYPE_JOYSTICK,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
241 EnumJoysticksCallback,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
242 NULL, DIEDFL_ATTACHEDONLY);
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
244 return SYS_NumJoysticks;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 }
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 /* Function to get the device-dependent name of a joystick */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
248 const char *
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
249 SDL_SYS_JoystickName (int index)
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
251 /***-> test for invalid index ? */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
252 return (SYS_Joystick[index].tszProductName);
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 }
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 /* Function to open a joystick for use.
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 The joystick to open is specified by the index field of the joystick.
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 This should fill the nbuttons and naxes fields of the joystick structure.
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 It returns 0, or -1 if there is an error.
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
260 int
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
261 SDL_SYS_JoystickOpen (SDL_Joystick * joystick)
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
263 HRESULT result;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
264 LPDIRECTINPUTDEVICE device;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
265
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
266 /* allocate memory for system specific hardware data */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
267 joystick->hwdata =
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
268 (struct joystick_hwdata *) malloc (sizeof (*joystick->hwdata));
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
269 if (joystick->hwdata == NULL) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
270 SDL_OutOfMemory ();
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
271 return (-1);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
272 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
273 memset (joystick->hwdata, 0, sizeof (*joystick->hwdata));
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
274 joystick->hwdata->buffered = 1;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
276 result =
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
277 IDirectInput_CreateDevice (dinput,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
278 &SYS_Joystick[joystick->index].
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
279 guidInstance, &device, NULL);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
280 if (result != DI_OK) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
281 SetDIerror ("DirectInput::CreateDevice", result);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
282 return (-1);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
283 }
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
285 result = IDirectInputDevice_QueryInterface (device,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
286 &IID_IDirectInputDevice2,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
287 (LPVOID *) & joystick->
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
288 hwdata->InputDevice);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
289 IDirectInputDevice_Release (device);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
290 if (result != DI_OK) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
291 SetDIerror ("DirectInputDevice::QueryInterface", result);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
292 return (-1);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
293 }
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
295 result =
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
296 IDirectInputDevice2_SetCooperativeLevel (joystick->hwdata->
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
297 InputDevice, SDL_Window,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
298 DISCL_NONEXCLUSIVE |
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
299 DISCL_BACKGROUND);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
300 if (result != DI_OK) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
301 SetDIerror ("DirectInputDevice::SetCooperativeLevel", result);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
302 return (-1);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
303 }
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
305 result =
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
306 IDirectInputDevice2_SetDataFormat (joystick->hwdata->InputDevice,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
307 &c_dfDIJoystick);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
308 if (result != DI_OK) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
309 SetDIerror ("DirectInputDevice::SetDataFormat", result);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
310 return (-1);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
311 }
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
313 IDirectInputDevice2_EnumObjects (joystick->hwdata->InputDevice,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
314 DIJoystick_EnumDevObjectsProc,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
315 joystick,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
316 DIDFT_BUTTON | DIDFT_AXIS | DIDFT_POV);
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
318 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
319 DIPROPDWORD dipdw;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
320 memset (&dipdw, 0, sizeof (dipdw));
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
321 dipdw.diph.dwSize = sizeof (dipdw);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
322 dipdw.diph.dwHeaderSize = sizeof (dipdw.diph);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
323 dipdw.diph.dwObj = 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
324 dipdw.diph.dwHow = DIPH_DEVICE;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
325 dipdw.dwData = INPUT_QSIZE;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
326 result =
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
327 IDirectInputDevice2_SetProperty (joystick->hwdata->InputDevice,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
328 DIPROP_BUFFERSIZE, &dipdw.diph);
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
330 if (result == DI_POLLEDDEVICE) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
331 /* This device doesn't support buffering, so we're forced
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
332 * to use less reliable polling. */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
333 joystick->hwdata->buffered = 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
334 } else if (result != DI_OK) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
335 SetDIerror ("DirectInputDevice::SetProperty", result);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
336 return (-1);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
337 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
338 }
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
340 return (0);
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 }
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
343 static Uint8
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
344 TranslatePOV (DWORD value)
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
346 const int HAT_VALS[] = {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
347 SDL_HAT_UP,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
348 SDL_HAT_UP | SDL_HAT_RIGHT,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
349 SDL_HAT_RIGHT,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
350 SDL_HAT_DOWN | SDL_HAT_RIGHT,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
351 SDL_HAT_DOWN,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
352 SDL_HAT_DOWN | SDL_HAT_LEFT,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
353 SDL_HAT_LEFT,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
354 SDL_HAT_UP | SDL_HAT_LEFT
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
355 };
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
357 if (LOWORD (value) == 0xFFFF)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
358 return SDL_HAT_CENTERED;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
360 /* Round the value up: */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
361 value += 4500 / 2;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
362 value %= 36000;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
363 value /= 4500;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
365 if (value >= 8)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
366 return SDL_HAT_CENTERED; /* shouldn't happen */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
367
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
368 return HAT_VALS[value];
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369 }
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 /* SDL_PrivateJoystick* doesn't discard duplicate events, so we need to
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372 * do it. */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
373 static int
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
374 SDL_PrivateJoystickAxis_Int (SDL_Joystick * joystick, Uint8 axis,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
375 Sint16 value)
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
377 if (joystick->axes[axis] != value)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
378 return SDL_PrivateJoystickAxis (joystick, axis, value);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
379 return 0;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
380 }
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
382 static int
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
383 SDL_PrivateJoystickHat_Int (SDL_Joystick * joystick, Uint8 hat, Uint8 value)
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
385 if (joystick->hats[hat] != value)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
386 return SDL_PrivateJoystickHat (joystick, hat, value);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
387 return 0;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 }
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
389
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
390 static int
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
391 SDL_PrivateJoystickButton_Int (SDL_Joystick * joystick, Uint8 button,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
392 Uint8 state)
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
393 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
394 if (joystick->buttons[button] != state)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
395 return SDL_PrivateJoystickButton (joystick, button, state);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
396 return 0;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
397 }
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
398
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
399 /* Function to update the state of a joystick - called as a device poll.
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
400 * This function shouldn't update the joystick structure directly,
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401 * but instead should call SDL_PrivateJoystick*() to deliver events
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
402 * and update joystick device state.
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403 */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
404 void
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
405 SDL_SYS_JoystickUpdate_Polled (SDL_Joystick * joystick)
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
407 DIJOYSTATE state;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
408 HRESULT result;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
409 int i;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
411 result =
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
412 IDirectInputDevice2_GetDeviceState (joystick->hwdata->InputDevice,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
413 sizeof (state), &state);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
414 if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
415 IDirectInputDevice2_Acquire (joystick->hwdata->InputDevice);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
416 result =
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
417 IDirectInputDevice2_GetDeviceState (joystick->hwdata->
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
418 InputDevice, sizeof (state),
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
419 &state);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
420 }
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
421
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
422 /* Set each known axis, button and POV. */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
423 for (i = 0; i < joystick->hwdata->NumInputs; ++i) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
424 const input_t *in = &joystick->hwdata->Inputs[i];
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
425
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
426 switch (in->type) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
427 case AXIS:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
428 switch (in->ofs) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
429 case DIJOFS_X:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
430 SDL_PrivateJoystickAxis_Int (joystick, in->num,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
431 (Sint16) state.lX);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
432 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
433 case DIJOFS_Y:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
434 SDL_PrivateJoystickAxis_Int (joystick, in->num,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
435 (Sint16) state.lY);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
436 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
437 case DIJOFS_Z:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
438 SDL_PrivateJoystickAxis_Int (joystick, in->num,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
439 (Sint16) state.lZ);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
440 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
441 case DIJOFS_RX:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
442 SDL_PrivateJoystickAxis_Int (joystick, in->num,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
443 (Sint16) state.lRx);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
444 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
445 case DIJOFS_RY:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
446 SDL_PrivateJoystickAxis_Int (joystick, in->num,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
447 (Sint16) state.lRy);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
448 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
449 case DIJOFS_RZ:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
450 SDL_PrivateJoystickAxis_Int (joystick, in->num,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
451 (Sint16) state.lRz);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
452 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
453 case DIJOFS_SLIDER (0):
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
454 SDL_PrivateJoystickAxis_Int (joystick, in->num,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
455 (Sint16) state.rglSlider[0]);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
456 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
457 case DIJOFS_SLIDER (1):
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
458 SDL_PrivateJoystickAxis_Int (joystick, in->num,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
459 (Sint16) state.rglSlider[0]);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
460 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
461 }
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
462
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
463 break;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
464
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
465 case BUTTON:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
466 SDL_PrivateJoystickButton_Int (joystick, in->num,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
467 (Uint8) (state.
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
468 rgbButtons[in->ofs -
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
469 DIJOFS_BUTTON0]
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
470 ? SDL_PRESSED :
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
471 SDL_RELEASED));
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
472 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
473 case HAT:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
474 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
475 Uint8 pos =
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
476 TranslatePOV (state.rgdwPOV[in->ofs - DIJOFS_POV (0)]);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
477 SDL_PrivateJoystickHat_Int (joystick, in->num, pos);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
478 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
479 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
480 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
481 }
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
482 }
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
483
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
484 void
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
485 SDL_SYS_JoystickUpdate_Buffered (SDL_Joystick * joystick)
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
486 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
487 int i;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
488 HRESULT result;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
489 DWORD numevents;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
490 DIDEVICEOBJECTDATA evtbuf[INPUT_QSIZE];
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
491
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
492 numevents = INPUT_QSIZE;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
493 result =
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
494 IDirectInputDevice2_GetDeviceData (joystick->hwdata->InputDevice,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
495 sizeof (DIDEVICEOBJECTDATA),
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
496 evtbuf, &numevents, 0);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
497 if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
498 IDirectInputDevice2_Acquire (joystick->hwdata->InputDevice);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
499 result =
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
500 IDirectInputDevice2_GetDeviceData (joystick->hwdata->
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
501 InputDevice,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
502 sizeof (DIDEVICEOBJECTDATA),
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
503 evtbuf, &numevents, 0);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
504 }
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
505
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
506 /* Handle the events */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
507 if (result != DI_OK)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
508 return;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
509
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
510 for (i = 0; i < (int) numevents; ++i) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
511 int j;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
512
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
513 for (j = 0; j < joystick->hwdata->NumInputs; ++j) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
514 const input_t *in = &joystick->hwdata->Inputs[j];
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
515
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
516 if (evtbuf[i].dwOfs != in->ofs)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
517 continue;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
518
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
519 switch (in->type) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
520 case AXIS:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
521 SDL_PrivateJoystickAxis (joystick, in->num,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
522 (Sint16) evtbuf[i].dwData);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
523 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
524 case BUTTON:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
525 SDL_PrivateJoystickButton (joystick, in->num,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
526 (Uint8) (evtbuf[i].
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
527 dwData ? SDL_PRESSED
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
528 : SDL_RELEASED));
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
529 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
530 case HAT:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
531 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
532 Uint8 pos = TranslatePOV (evtbuf[i].dwData);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
533 SDL_PrivateJoystickHat (joystick, in->num, pos);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
534 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
535 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
536 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
537 }
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
538 }
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
539
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
540 void
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
541 SDL_SYS_JoystickUpdate (SDL_Joystick * joystick)
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
542 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
543 HRESULT result;
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
544
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
545 result = IDirectInputDevice2_Poll (joystick->hwdata->InputDevice);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
546 if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
547 IDirectInputDevice2_Acquire (joystick->hwdata->InputDevice);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
548 IDirectInputDevice2_Poll (joystick->hwdata->InputDevice);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
549 }
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
550
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
551 if (joystick->hwdata->buffered)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
552 SDL_SYS_JoystickUpdate_Buffered (joystick);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
553 else
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
554 SDL_SYS_JoystickUpdate_Polled (joystick);
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
555 }
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
556
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
557 /* Function to close a joystick after use */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
558 void
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
559 SDL_SYS_JoystickClose (SDL_Joystick * joystick)
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
560 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
561 IDirectInputDevice2_Unacquire (joystick->hwdata->InputDevice);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
562 IDirectInputDevice2_Release (joystick->hwdata->InputDevice);
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
563
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
564 if (joystick->hwdata != NULL) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
565 /* free system specific hardware data */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
566 free (joystick->hwdata);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
567 }
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
568 }
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
569
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
570 /* Function to perform any system-specific joystick related cleanup */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
571 void
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
572 SDL_SYS_JoystickQuit (void)
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
573 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
574 IDirectInput_Release (dinput);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
575 dinput = NULL;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
576 DX5_Unload ();
1661
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
577 }
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
578
281d3f4870e5 Moved DirectInput joystick code to 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
579 #endif /* SDL_JOYSTICK_DINPUT */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1661
diff changeset
580 /* vi: set ts=4 sw=4 expandtab: */