Mercurial > sdl-ios-xcode
annotate src/joystick/win32/SDL_dxjoystick.c @ 2616:acd5da848404 gsoc2008_force_feedback
Moved the directinput joystick hwdata stuff into a seperate header file.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Wed, 06 Aug 2008 08:47:35 +0000 |
parents | 64fa227c01ce |
children | 6deba05725ac |
rev | line source |
---|---|
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 #ifdef SDL_JOYSTICK_DINPUT |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 /* DirectInput joystick driver; written by Glenn Maynard, based on Andrei de |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 * A. Formiga's WINMM driver. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 * Hats and sliders are completely untested; the app I'm writing this for mostly |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 * doesn't use them and I don't own any joysticks with them. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 * We don't bother to use event notification here. It doesn't seem to work |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 * with polled devices, and it's fine to call IDirectInputDevice2_GetDeviceData and |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 * let it return 0 events. */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 #include "SDL_error.h" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 #include "SDL_events.h" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 #include "SDL_joystick.h" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 #include "../SDL_sysjoystick.h" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 #include "../SDL_joystick_c.h" |
2616
acd5da848404
Moved the directinput joystick hwdata stuff into a seperate header file.
Edgar Simo <bobbens@gmail.com>
parents:
2580
diff
changeset
|
41 #include "SDL_dxjoystick_c.h" |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
42 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
43 /* an ISO hack for VisualC++ */ |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
44 #ifdef _MSC_VER |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
45 #define snprintf _snprintf |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
46 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 #define INPUT_QSIZE 32 /* Buffer up to 32 input messages */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 #define MAX_JOYSTICKS 8 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 #define AXIS_MIN -32768 /* minimum value for axis coordinate */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 #define AXIS_MAX 32767 /* maximum value for axis coordinate */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 #define JOY_AXIS_THRESHOLD (((AXIS_MAX)-(AXIS_MIN))/100) /* 1% motion */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
54 /* external variables referenced. */ |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
55 extern HINSTANCE SDL_Instance; |
2580
64fa227c01ce
Added the concept of the HelperWindow to help with DirectInput.
Edgar Simo <bobbens@gmail.com>
parents:
2579
diff
changeset
|
56 extern HWND SDL_HelperWindow; |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
57 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
58 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
59 /* local variables */ |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
60 static LPDIRECTINPUT dinput = NULL; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
61 extern HRESULT(WINAPI * DInputCreate) (HINSTANCE hinst, DWORD dwVersion, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
62 LPDIRECTINPUT * ppDI, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
63 LPUNKNOWN punkOuter); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
64 static DIDEVICEINSTANCE SYS_Joystick[MAX_JOYSTICKS]; /* array to hold joystick ID values */ |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
65 static int SYS_NumJoysticks; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
66 static HINSTANCE DInputDLL = NULL; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
67 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
68 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
69 /* local prototypes */ |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
70 static void SetDIerror(const char *function, HRESULT code); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
71 static BOOL CALLBACK EnumJoysticksCallback(const DIDEVICEINSTANCE * |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
72 pdidInstance, VOID * pContext); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
73 static BOOL CALLBACK EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE dev, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
74 LPVOID pvRef); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
75 static Uint8 TranslatePOV(DWORD value); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
76 static int SDL_PrivateJoystickAxis_Int(SDL_Joystick * joystick, Uint8 axis, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
77 Sint16 value); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
78 static int SDL_PrivateJoystickHat_Int(SDL_Joystick * joystick, Uint8 hat, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
79 Uint8 value); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
80 static int SDL_PrivateJoystickButton_Int(SDL_Joystick * joystick, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
81 Uint8 button, Uint8 state); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
82 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
83 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 /* Convert a DirectInput return code to a text message */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 static void |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
86 SetDIerror(const char *function, HRESULT code) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 { |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
88 SDL_SetError("%s() [%s]: %s", function, |
2579
bd2a6c70cb29
Used dxerr instead of dxerr9 in directinput joystick driver.
Edgar Simo <bobbens@gmail.com>
parents:
2577
diff
changeset
|
89 DXGetErrorString(code), DXGetErrorDescription(code)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 /* Function to scan the system for joysticks. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 * This function should set SDL_numjoysticks to the number of available |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 * joysticks. Joystick 0 should be the system default joystick. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 * It should return 0, or -1 on an unrecoverable fatal error. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 SDL_SYS_JoystickInit(void) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 HRESULT result; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 SYS_NumJoysticks = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
105 result = CoInitialize(NULL); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
106 if (FAILED(result)) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
107 SetDIerror("CoInitialize", result); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
111 result = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
112 &IID_IDirectInput, &dinput); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
113 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
114 if (FAILED(result)) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
115 SetDIerror("CoCreateInstance", result); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
116 return (-1); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
117 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
118 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
119 /* Because we used CoCreateInstance, we need to Initialize it, first. */ |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
120 result = |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
121 IDirectInput_Initialize(dinput, SDL_Instance, DIRECTINPUT_VERSION); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
122 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
123 if (FAILED(result)) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
124 SetDIerror("IDirectInput::Initialize", result); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
125 return (-1); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
126 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
127 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
128 /* Look for joysticks, wheels, head trackers, gamepads, etc.. */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 result = IDirectInput_EnumDevices(dinput, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 DIDEVTYPE_JOYSTICK, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 EnumJoysticksCallback, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 NULL, DIEDFL_ATTACHEDONLY); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 return SYS_NumJoysticks; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
137 static BOOL CALLBACK |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
138 EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext) |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
139 { |
2576
034440120c38
Converted some functions to SDL_mem*.
Edgar Simo <bobbens@gmail.com>
parents:
2198
diff
changeset
|
140 SDL_memcpy(&SYS_Joystick[SYS_NumJoysticks], pdidInstance, |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
141 sizeof(DIDEVICEINSTANCE)); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
142 SYS_NumJoysticks++; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
143 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
144 if (SYS_NumJoysticks >= MAX_JOYSTICKS) |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
145 return DIENUM_STOP; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
146 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
147 return DIENUM_CONTINUE; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
148 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
149 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 /* Function to get the device-dependent name of a joystick */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 const char * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 SDL_SYS_JoystickName(int index) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 /***-> test for invalid index ? */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 return (SYS_Joystick[index].tszProductName); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 /* Function to open a joystick for use. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 The joystick to open is specified by the index field of the joystick. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 This should fill the nbuttons and naxes fields of the joystick structure. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 It returns 0, or -1 if there is an error. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 SDL_SYS_JoystickOpen(SDL_Joystick * joystick) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 HRESULT result; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 LPDIRECTINPUTDEVICE device; |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
168 DIPROPDWORD dipdw; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
169 |
2576
034440120c38
Converted some functions to SDL_mem*.
Edgar Simo <bobbens@gmail.com>
parents:
2198
diff
changeset
|
170 SDL_memset(&dipdw, 0, sizeof(DIPROPDWORD)); |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
171 dipdw.diph.dwSize = sizeof(DIPROPDWORD); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
172 dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
173 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 /* allocate memory for system specific hardware data */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 joystick->hwdata = |
2577
72b17d80b426
Fixed some lone malloc and free.
Edgar Simo <bobbens@gmail.com>
parents:
2576
diff
changeset
|
177 (struct joystick_hwdata *) SDL_malloc(sizeof(struct joystick_hwdata)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 if (joystick->hwdata == NULL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 SDL_OutOfMemory(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 } |
2576
034440120c38
Converted some functions to SDL_mem*.
Edgar Simo <bobbens@gmail.com>
parents:
2198
diff
changeset
|
182 SDL_memset(joystick->hwdata, 0, sizeof(struct joystick_hwdata)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 joystick->hwdata->buffered = 1; |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
184 joystick->hwdata->Capabilities.dwSize = sizeof(DIDEVCAPS); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 result = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 IDirectInput_CreateDevice(dinput, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 &SYS_Joystick[joystick->index]. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 guidInstance, &device, NULL); |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
190 if (FAILED(result)) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
191 SetDIerror("IDirectInput::CreateDevice", result); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
195 /* Now get the IDirectInputDevice2 interface, instead. */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 result = IDirectInputDevice_QueryInterface(device, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 &IID_IDirectInputDevice2, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 (LPVOID *) & joystick-> |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 hwdata->InputDevice); |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
200 /* We are done with this object. Use the stored one from now on. */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 IDirectInputDevice_Release(device); |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
202 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
203 if (FAILED(result)) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
204 SetDIerror("IDirectInputDevice::QueryInterface", result); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
208 /* Aquire shared access. Exclusive access is required for forces, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
209 * though. */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 result = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 IDirectInputDevice2_SetCooperativeLevel(joystick->hwdata-> |
2580
64fa227c01ce
Added the concept of the HelperWindow to help with DirectInput.
Edgar Simo <bobbens@gmail.com>
parents:
2579
diff
changeset
|
212 InputDevice, SDL_HelperWindow, |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
213 DISCL_EXCLUSIVE | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 DISCL_BACKGROUND); |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
215 if (FAILED(result)) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
216 SetDIerror("IDirectInputDevice2::SetCooperativeLevel", result); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
220 /* Use the extended data structure: DIJOYSTATE2. */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 result = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 IDirectInputDevice2_SetDataFormat(joystick->hwdata->InputDevice, |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
223 &c_dfDIJoystick2); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
224 if (FAILED(result)) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
225 SetDIerror("IDirectInputDevice2::SetDataFormat", result); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
226 return (-1); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
227 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
228 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
229 /* Get device capabilities */ |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
230 result = |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
231 IDirectInputDevice2_GetCapabilities(joystick->hwdata->InputDevice, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
232 &joystick->hwdata->Capabilities); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
233 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
234 if (FAILED(result)) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
235 SetDIerror("IDirectInputDevice2::GetCapabilities", result); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
239 /* Force capable? */ |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
240 if (joystick->hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
241 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
242 result = IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
243 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
244 if (FAILED(result)) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
245 SetDIerror("IDirectInputDevice2::Acquire", result); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
246 return (-1); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
247 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
248 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
249 /* reset all accuators. */ |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
250 result = |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
251 IDirectInputDevice2_SendForceFeedbackCommand(joystick->hwdata-> |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
252 InputDevice, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
253 DISFFC_RESET); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
255 if (FAILED(result)) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
256 SetDIerror("IDirectInputDevice2::SendForceFeedbackCommand", |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
257 result); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
258 return (-1); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
259 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
260 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
261 result = IDirectInputDevice2_Unacquire(joystick->hwdata->InputDevice); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
262 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
263 if (FAILED(result)) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
264 SetDIerror("IDirectInputDevice2::Unacquire", result); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
265 return (-1); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
266 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
267 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
268 /* Turn on auto-centering for a ForceFeedback device (until told |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
269 * otherwise). */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 dipdw.diph.dwObj = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 dipdw.diph.dwHow = DIPH_DEVICE; |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
272 dipdw.dwData = DIPROPAUTOCENTER_ON; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
273 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 result = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice, |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
276 DIPROP_AUTOCENTER, &dipdw.diph); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
278 if (FAILED(result)) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
279 SetDIerror("IDirectInputDevice2::SetProperty", result); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
284 /* What buttons and axes does it have? */ |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
285 IDirectInputDevice2_EnumObjects(joystick->hwdata->InputDevice, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
286 EnumDevObjectsCallback, joystick, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
287 DIDFT_BUTTON | DIDFT_AXIS | DIDFT_POV); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
288 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
289 dipdw.diph.dwObj = 0; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
290 dipdw.diph.dwHow = DIPH_DEVICE; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
291 dipdw.dwData = INPUT_QSIZE; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
292 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
293 /* Set the buffer size */ |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
294 result = |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
295 IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
296 DIPROP_BUFFERSIZE, &dipdw.diph); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
297 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
298 if (result == DI_POLLEDDEVICE) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
299 /* This device doesn't support buffering, so we're forced |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
300 * to use less reliable polling. */ |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
301 joystick->hwdata->buffered = 0; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
302 } else if (FAILED(result)) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
303 SetDIerror("IDirectInputDevice2::SetProperty", result); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
304 return (-1); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
305 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
306 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 return (0); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 |
2198
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
310 static BOOL CALLBACK |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
311 EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef) |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
312 { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
313 SDL_Joystick *joystick = (SDL_Joystick *) pvRef; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
314 HRESULT result; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
315 input_t *in = &joystick->hwdata->Inputs[joystick->hwdata->NumInputs]; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
316 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
317 in->ofs = dev->dwOfs; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
318 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
319 if (dev->dwType & DIDFT_BUTTON) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
320 in->type = BUTTON; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
321 in->num = joystick->nbuttons; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
322 joystick->nbuttons++; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
323 } else if (dev->dwType & DIDFT_POV) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
324 in->type = HAT; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
325 in->num = joystick->nhats; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
326 joystick->nhats++; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
327 } else if (dev->dwType & DIDFT_AXIS) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
328 DIPROPRANGE diprg; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
329 DIPROPDWORD dilong; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
330 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
331 in->type = AXIS; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
332 in->num = joystick->naxes; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
333 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
334 diprg.diph.dwSize = sizeof(diprg); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
335 diprg.diph.dwHeaderSize = sizeof(diprg.diph); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
336 diprg.diph.dwObj = dev->dwOfs; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
337 diprg.diph.dwHow = DIPH_BYOFFSET; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
338 diprg.lMin = AXIS_MIN; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
339 diprg.lMax = AXIS_MAX; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
340 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
341 result = |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
342 IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
343 DIPROP_RANGE, &diprg.diph); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
344 if (FAILED(result)) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
345 return DIENUM_CONTINUE; /* don't use this axis */ |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
346 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
347 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
348 /* Set dead zone to 0. */ |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
349 dilong.diph.dwSize = sizeof(dilong); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
350 dilong.diph.dwHeaderSize = sizeof(dilong.diph); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
351 dilong.diph.dwObj = dev->dwOfs; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
352 dilong.diph.dwHow = DIPH_BYOFFSET; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
353 dilong.dwData = 0; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
354 result = |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
355 IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
356 DIPROP_DEADZONE, &dilong.diph); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
357 if (FAILED(result)) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
358 return DIENUM_CONTINUE; /* don't use this axis */ |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
359 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
360 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
361 joystick->naxes++; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
362 } else { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
363 /* not supported at this time */ |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
364 return DIENUM_CONTINUE; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
365 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
366 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
367 joystick->hwdata->NumInputs++; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
368 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
369 if (joystick->hwdata->NumInputs == MAX_INPUTS) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
370 return DIENUM_STOP; /* too many */ |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
371 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
372 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
373 return DIENUM_CONTINUE; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
374 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
375 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
376 /* Function to update the state of a joystick - called as a device poll. |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
377 * This function shouldn't update the joystick structure directly, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
378 * but instead should call SDL_PrivateJoystick*() to deliver events |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
379 * and update joystick device state. |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
380 */ |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
381 void |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
382 SDL_SYS_JoystickUpdate_Polled(SDL_Joystick * joystick) |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
383 { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
384 DIJOYSTATE2 state; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
385 HRESULT result; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
386 int i; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
387 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
388 result = |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
389 IDirectInputDevice2_GetDeviceState(joystick->hwdata->InputDevice, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
390 sizeof(DIJOYSTATE2), &state); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
391 if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
392 IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
393 result = |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
394 IDirectInputDevice2_GetDeviceState(joystick->hwdata->InputDevice, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
395 sizeof(DIJOYSTATE2), &state); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
396 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
397 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
398 /* Set each known axis, button and POV. */ |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
399 for (i = 0; i < joystick->hwdata->NumInputs; ++i) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
400 const input_t *in = &joystick->hwdata->Inputs[i]; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
401 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
402 switch (in->type) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
403 case AXIS: |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
404 switch (in->ofs) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
405 case DIJOFS_X: |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
406 SDL_PrivateJoystickAxis_Int(joystick, in->num, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
407 (Sint16) state.lX); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
408 break; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
409 case DIJOFS_Y: |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
410 SDL_PrivateJoystickAxis_Int(joystick, in->num, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
411 (Sint16) state.lY); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
412 break; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
413 case DIJOFS_Z: |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
414 SDL_PrivateJoystickAxis_Int(joystick, in->num, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
415 (Sint16) state.lZ); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
416 break; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
417 case DIJOFS_RX: |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
418 SDL_PrivateJoystickAxis_Int(joystick, in->num, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
419 (Sint16) state.lRx); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
420 break; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
421 case DIJOFS_RY: |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
422 SDL_PrivateJoystickAxis_Int(joystick, in->num, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
423 (Sint16) state.lRy); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
424 break; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
425 case DIJOFS_RZ: |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
426 SDL_PrivateJoystickAxis_Int(joystick, in->num, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
427 (Sint16) state.lRz); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
428 break; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
429 case DIJOFS_SLIDER(0): |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
430 SDL_PrivateJoystickAxis_Int(joystick, in->num, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
431 (Sint16) state.rglSlider[0]); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
432 break; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
433 case DIJOFS_SLIDER(1): |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
434 SDL_PrivateJoystickAxis_Int(joystick, in->num, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
435 (Sint16) state.rglSlider[1]); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
436 break; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
437 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
438 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
439 break; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
440 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
441 case BUTTON: |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
442 SDL_PrivateJoystickButton_Int(joystick, in->num, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
443 (Uint8) (state. |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
444 rgbButtons[in->ofs - |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
445 DIJOFS_BUTTON0] |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
446 ? SDL_PRESSED : |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
447 SDL_RELEASED)); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
448 break; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
449 case HAT: |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
450 { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
451 Uint8 pos = TranslatePOV(state.rgdwPOV[in->ofs - |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
452 DIJOFS_POV(0)]); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
453 SDL_PrivateJoystickHat_Int(joystick, in->num, pos); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
454 break; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
455 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
456 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
457 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
458 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
459 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
460 void |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
461 SDL_SYS_JoystickUpdate_Buffered(SDL_Joystick * joystick) |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
462 { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
463 int i; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
464 HRESULT result; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
465 DWORD numevents; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
466 DIDEVICEOBJECTDATA evtbuf[INPUT_QSIZE]; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
467 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
468 numevents = INPUT_QSIZE; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
469 result = |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
470 IDirectInputDevice2_GetDeviceData(joystick->hwdata->InputDevice, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
471 sizeof(DIDEVICEOBJECTDATA), evtbuf, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
472 &numevents, 0); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
473 if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
474 IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
475 result = |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
476 IDirectInputDevice2_GetDeviceData(joystick->hwdata->InputDevice, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
477 sizeof(DIDEVICEOBJECTDATA), |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
478 evtbuf, &numevents, 0); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
479 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
480 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
481 /* Handle the events or punt */ |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
482 if (FAILED(result)) |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
483 return; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
484 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
485 for (i = 0; i < (int) numevents; ++i) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
486 int j; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
487 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
488 for (j = 0; j < joystick->hwdata->NumInputs; ++j) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
489 const input_t *in = &joystick->hwdata->Inputs[j]; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
490 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
491 if (evtbuf[i].dwOfs != in->ofs) |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
492 continue; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
493 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
494 switch (in->type) { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
495 case AXIS: |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
496 SDL_PrivateJoystickAxis(joystick, in->num, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
497 (Sint16) evtbuf[i].dwData); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
498 break; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
499 case BUTTON: |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
500 SDL_PrivateJoystickButton(joystick, in->num, |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
501 (Uint8) (evtbuf[i]. |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
502 dwData ? SDL_PRESSED : |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
503 SDL_RELEASED)); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
504 break; |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
505 case HAT: |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
506 { |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
507 Uint8 pos = TranslatePOV(evtbuf[i].dwData); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
508 SDL_PrivateJoystickHat(joystick, in->num, pos); |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
509 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
510 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
511 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
512 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
513 } |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
514 |
fe19afb86473
Split acinclude.m4 into its component parts for easy updating
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
515 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
516 static Uint8 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
517 TranslatePOV(DWORD value) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
518 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
519 const int HAT_VALS[] = { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
520 SDL_HAT_UP, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
521 SDL_HAT_UP | SDL_HAT_RIGHT, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
522 SDL_HAT_RIGHT, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
523 SDL_HAT_DOWN | SDL_HAT_RIGHT, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
524 SDL_HAT_DOWN, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
525 SDL_HAT_DOWN | SDL_HAT_LEFT, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
526 SDL_HAT_LEFT, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
527 SDL_HAT_UP | SDL_HAT_LEFT |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
528 }; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
529 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
530 if (LOWORD(value) == 0xFFFF) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
531 return SDL_HAT_CENTERED; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
532 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
533 /* Round the value up: */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
534 value += 4500 / 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
535 value %= 36000; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
536 value /= 4500; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
537 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
538 if (value >= 8) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
539 return SDL_HAT_CENTERED; /* shouldn't happen */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
540 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
541 return HAT_VALS[value]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
542 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
543 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
544 /* SDL_PrivateJoystick* doesn't discard duplicate events, so we need to |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
545 * do it. */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
546 static int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
547 SDL_PrivateJoystickAxis_Int(SDL_Joystick * joystick, Uint8 axis, Sint16 value) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
548 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
549 if (joystick->axes[axis] != value) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
550 return SDL_PrivateJoystickAxis(joystick, axis, value); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
551 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
552 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
553 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
554 static int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
555 SDL_PrivateJoystickHat_Int(SDL_Joystick * joystick, Uint8 hat, Uint8 value) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
556 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
557 if (joystick->hats[hat] != value) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
558 return SDL_PrivateJoystickHat(joystick, hat, value); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
559 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
560 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
561 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
562 static int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
563 SDL_PrivateJoystickButton_Int(SDL_Joystick * joystick, Uint8 button, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
564 Uint8 state) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
565 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
566 if (joystick->buttons[button] != state) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
567 return SDL_PrivateJoystickButton(joystick, button, state); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
568 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
569 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
570 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
571 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
572 SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
573 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
574 HRESULT result; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
575 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
576 result = IDirectInputDevice2_Poll(joystick->hwdata->InputDevice); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
577 if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
578 IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
579 IDirectInputDevice2_Poll(joystick->hwdata->InputDevice); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
580 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
581 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
582 if (joystick->hwdata->buffered) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
583 SDL_SYS_JoystickUpdate_Buffered(joystick); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
584 else |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
585 SDL_SYS_JoystickUpdate_Polled(joystick); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
586 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
587 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
588 /* Function to close a joystick after use */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
589 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
590 SDL_SYS_JoystickClose(SDL_Joystick * joystick) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
591 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
592 IDirectInputDevice2_Unacquire(joystick->hwdata->InputDevice); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
593 IDirectInputDevice2_Release(joystick->hwdata->InputDevice); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
594 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
595 if (joystick->hwdata != NULL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
596 /* free system specific hardware data */ |
2577
72b17d80b426
Fixed some lone malloc and free.
Edgar Simo <bobbens@gmail.com>
parents:
2576
diff
changeset
|
597 SDL_free(joystick->hwdata); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
598 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
599 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
600 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
601 /* Function to perform any system-specific joystick related cleanup */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
602 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
603 SDL_SYS_JoystickQuit(void) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
604 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
605 IDirectInput_Release(dinput); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
606 dinput = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
607 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
608 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
609 #endif /* SDL_JOYSTICK_DINPUT */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
610 /* vi: set ts=4 sw=4 expandtab: */ |