annotate src/haptic/win32/SDL_syshaptic.c @ 2551:f010e1d4e431 gsoc2008_force_feedback

First version of the windows haptic port, won't compile yet.
author Edgar Simo <bobbens@gmail.com>
date Wed, 30 Jul 2008 11:54:08 +0000
parents
children 3696b9ce8a37
rev   line source
2551
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
3 Copyright (C) 2008 Edgar Simo
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
4
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
9
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
13 Lesser General Public License for more details.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
14
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
18
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
19 Sam Lantinga
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
20 slouken@libsdl.org
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
21 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
22 #include "SDL_config.h"
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
23
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
24 #ifdef SDL_HAPTIC_DINPUT
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
25
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
26 #include "SDL_haptic.h"
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
27 #include "../SDL_syshaptic.h"
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
28 #include "SDL_joystick.h"
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
29 #include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
30 /*#include "../../joystick/win32/SDL_sysjoystick_c.h"*/ /* For joystick hwdata */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
31
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
32 #define WIN32_LEAN_AND_MEAN
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
33 #include <windows.h>
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
34
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
35 #define DIRECTINPUT_VERSION 0x0500
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
36 #include <dinput.h>
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
37 #include <dxerr9.h> /* From DirectX SDK 9c */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
38 #ifdef _MSC_VER
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
39 # pragma comment (lib, "dxerr9.lib")
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
40 #endif /* _MSC_VER */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
41
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
42 /* an ISO hack for VisualC++ */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
43 #ifdef _MSC_VER
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
44 #define snprintf _snprintf
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
45 #endif /* _MSC_VER */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
46
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
47
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
48 #define MAX_HAPTICS 32
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
49
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
50
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
51 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
52 * List of available haptic devices.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
53 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
54 static struct
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
55 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
56 DIDEVICEINSTANCE instance;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
57 SDL_Haptic *haptic;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
58 } SDL_hapticlist[MAX_HAPTICS];
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
59
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
60
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
61 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
62 * Haptic system hardware data.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
63 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
64 struct haptic_hwdata
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
65 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
66 LPDIRECTINPUTDEVICE2 device;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
67 DIDEVCAPS capabilities;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
68 };
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
69
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
70
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
71 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
72 * Haptic system effect data.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
73 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
74 struct haptic_hweffect
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
75 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
76 DIEFFECT effect;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
77 };
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
78
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
79
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
80 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
81 * Internal stuff.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
82 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
83 static LPDIRECTINPUT dinput = NULL;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
84
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
85
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
86 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
87 * Prototypes.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
88 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
89 static BOOL CALLBACK EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
90
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
91
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
92 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
93 * Like SDL_SetError but for DX error codes.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
94 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
95 static void
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
96 DI_SetError(const char *str, HRESULT err)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
97 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
98 SDL_SetError( "Haptic: %s - %s: %s", str,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
99 DXGetErrorString9(err),
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
100 DXGetErrorDescription9(err));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
101 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
102
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
103
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
104 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
105 * Initializes the haptic subsystem.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
106 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
107 int
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
108 SDL_SYS_HapticInit(void)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
109 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
110 HRESULT ret;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
111
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
112 if (dinput != NULL) { /* Already open. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
113 SDL_SetError("Haptic: SubSystem already open.");
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
114 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
115 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
116
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
117 /* Clear all the memory. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
118 SDL_memset(SDL_hapticlist, 0, sizeof(SDL_hapticlist));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
119
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
120 SDL_numhaptics = 0;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
121
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
122 ret = CoInitialize(NULL);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
123 if (FAILED(ret)) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
124 DI_SetError("Coinitialize",ret);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
125 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
126 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
127
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
128 ret = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
129 &IID_IDirectInput, &dinput);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
130 if (FAILED(ret)) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
131 DI_SetError("CoCreateInstance",ret);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
132 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
133 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
134
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
135 /* Because we used CoCreateInstance, we need to Initialize it, first. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
136 ret = IDirectInput_Initialize(dinput, SDL_Instance, DIRECTINPUT_VERSION);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
137 if (FAILED(ret)) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
138 DI_SetError("Initializing DirectInput device",ret);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
139 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
140 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
141
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
142 /* Look for haptic devices. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
143 ret = IDirectInput_EnumDevices( dinput,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
144 DIDEVTYPE_ALL,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
145 EnumJoysticksCallback,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
146 NULL, DIEDFL_FORCEFEEDBACK | DIEDFL_ATTACHEDONLY);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
147 if (FAILED(ret)) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
148 DI_SetError("Enumerating DirectInput devices",ret);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
149 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
150 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
151
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
152 return SDL_numhaptics;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
153 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
154
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
155 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
156 * Callback to find the haptic devices.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
157 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
158 static BOOL CALLBACK
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
159 EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
160 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
161 memcpy(&SDL_hapticlist[SDL_numhaptics].instance, pdidInstance,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
162 sizeof(DIDEVICEINSTANCE));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
163 SDL_numhaptics++;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
164
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
165 if (SDL_numhaptics >= MAX_HAPTICS)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
166 return DIENUM_STOP;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
167
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
168 return DIENUM_CONTINUE;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
169 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
170
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
171
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
172 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
173 * Return the name of a haptic device, does not need to be opened.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
174 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
175 const char *
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
176 SDL_SYS_HapticName(int index)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
177 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
178 return SDL_hapticlist[index].instance.tszProductName;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
179 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
180
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
181
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
182 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
183 * Callback to get all supported effects.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
184 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
185 #define EFFECT_TEST(e,s) \
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
186 if (pei->guid == (e)) \
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
187 haptic->supported |= (s)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
188 static BOOL CALLBACK
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
189 DI_EffectCallback(LPCDIEffectInfo pei, LPVOID pv)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
190 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
191 /* Prepare the haptic device. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
192 SDL_Haptic *haptic = (SDL_Haptic*) pv;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
193 haptic->supported = 0;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
194
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
195 /* Get supported. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
196 EFFECT_TEST(GUID_Spring, SDL_HAPTIC_SPRING);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
197 EFFECT_TEST(GUID_Damper, SDL_HAPTIC_DAMPER);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
198 EFFECT_TEST(GUID_Inertia, SDL_HAPTIC_INERTIA);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
199 EFFECT_TEST(GUID_Friction, SDL_HAPTIC_FRICTION);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
200 EFFECT_TEST(GUID_ConstantForce, SDL_HAPTIC_CONSTANT);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
201 EFFECT_TEST(GUID_CustomForce, SDL_HAPTIC_CUSTOM);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
202 EFFECT_TEST(GUID_Sine, SDL_HAPTIC_SINE);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
203 EFFECT_TEST(GUID_Square, SDL_HAPTIC_SQUARE);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
204 EFFECT_TEST(GUID_Triangle, SDL_HAPTIC_TRIANGLE);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
205 EFFECT_TEST(GUID_SawtoothUp, SDL_HAPTIC_SAWTOOTHUP);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
206 EFFECT_TEST(GUID_SawtoothDown, SDL_HAPTIC_SAWTOOTHDOWN);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
207 EFFECT_TEST(GUID_RampForce, SDL_HAPTIC_RAMP);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
208
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
209 /* Check for more. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
210 return DIENUM_CONTINUE;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
211 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
212
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
213
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
214 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
215 * Opens the haptic device from the file descriptor.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
216 *
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
217 * Steps:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
218 * - Open temporary DirectInputDevice interface.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
219 * - Create DirectInputDevice2 interface.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
220 * - Release DirectInputDevice interface.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
221 * - Acquire exclusiveness.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
222 * - Reset actuators.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
223 * - Get supported featuers.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
224 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
225 static int
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
226 SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
227 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
228 HRESULT ret;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
229 LPDIRECTINPUTDEVICE device;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
230 DIPROPDWORD dipdw;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
231
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
232 /* Allocate the hwdata */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
233 haptic->hwdata = (struct haptic_hwdata *)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
234 SDL_malloc(sizeof(*haptic->hwdata));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
235 if (haptic->hwdata == NULL) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
236 SDL_OutOfMemory();
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
237 goto creat_err;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
238 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
239 SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
240
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
241 /* Open the device */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
242 ret = IDirectInput_CreateDevice( dinput, &instance,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
243 guidInstance, &device, NULL);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
244 if (FAILED(ret)) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
245 DI_SetError("Creating DirectInput device",ret);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
246 goto creat_err;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
247 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
248
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
249 /* Now get the IDirectInputDevice2 interface, instead. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
250 ret = IDirectInputDevice_QueryInterface( device,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
251 &IID_IDirectInputDevice2,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
252 haptic->hwdata->device );
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
253 /* Done with the temporary one now. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
254 IDirectInputDevice_Release(device);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
255 if (FAILED(ret)) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
256 DI_SetError("Querying DirectInput interface",ret);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
257 goto creat_err;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
258 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
259
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
260 /* Acquire the device. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
261 ret = IDirectInputDevice2_Acquire(haptic->hwdata->device);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
262 if (FAILED(ret)) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
263 DI_SetError("Acquiring DirectInput device",ret);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
264 goto query_err;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
265 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
266
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
267 /* Grab it exclusively to use force feedback stuff. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
268 ret =IDirectInputDevice2_SetCooperativeLevel( haptic->hwdata->device,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
269 SDL_Window,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
270 DISCL_EXCLUSIVE | DISCL_BACKGROUND );
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
271 if (FAILED(ret)) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
272 DI_SetError("Setting cooperative level to exclusive",ret);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
273 goto acquire_err;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
274 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
275
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
276 /* Reset all actuators - just in case. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
277 ret = IDirectInputDevice2_SendForceFeedbackCommand( haptic->hwdata->device,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
278 DISFFC_RESET );
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
279 if (FAILED(ret)) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
280 DI_SetError("Resetting device",ret);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
281 goto acquire_err;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
282 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
283
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
284
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
285 /* Enabling actuators. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
286 ret = IDirectInputDevice2_SendForceFeedbackCommand( haptic->hwdata->device,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
287 DISFFC_SETACTUATORSON );
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
288 if (FAILED(ret)) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
289 DI_SetError("Enabling actuators",ret);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
290 goto acquire_err;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
291 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
292
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
293
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
294 /* Get capabilities. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
295 ret = IDirectInputDevice2_GetCapabilities( haptic->hwdata->device,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
296 haptic->hwdata->capabilities );
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
297 if (FAILED(ret)) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
298 DI_SetError("Getting device capabilities",ret);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
299 goto acquire_err;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
300 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
301
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
302
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
303 /* Get supported effects. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
304 ret = IDirectInput_EnumEffects( DI_EffectCallback, haptic, DIEFT_ALL);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
305 if (FAILED(ret)) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
306 DI_SetError("Enumerating supported effects",ret);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
307 goto acquire_err;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
308 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
309 if (haptic->supported == 0) { /* Error since device supports nothing. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
310 SDL_SetError("Haptic: Internal error on finding supported effects.");
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
311 goto acquire_err;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
312 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
313
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
314 /* Check autogain and autocenter. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
315 dipdw.diph.dwSize = sizeof(DIPROPDWORD);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
316 dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
317 dipdw.diph.dwObj = 0;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
318 dipdw.diph.dwHow = DIPH_DEVICE;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
319 dipdw.dwData = 10000;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
320 ret = IDirectInputDevice2_SetProperty( haptic->hwdata->device,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
321 DIPROP_FFGAIN, &dipdw.diph );
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
322 if (FAILED(ret)) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
323 if (ret != DIERR_UNSUPPORTED) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
324 DI_SetError("Checking gain",ret);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
325 goto acquire_err;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
326 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
327 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
328 else { /* Gain is supported. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
329 haptic->supported |= SDL_HAPTIC_GAIN;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
330 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
331 dipdw.dwData = DIPROPAUTOCENTER_OFF;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
332 ret = IDirectInputDevice2_SetProperty( haptic->hwdata->device,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
333 DIPROP_AUTOCENTER, &dipdw.diph );
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
334 if (FAILED(ret)) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
335 if (ret != DIERR_UNSUPPORTED) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
336 DI_SetError("Checking autocenter",ret);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
337 goto acquire_err;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
338 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
339 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
340 else { /* Autocenter is supported. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
341 haptic->supported |= SDL_HAPTIC_AUTOCENTER;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
342 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
343
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
344
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
345 /* Check maximum effects. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
346 haptic->neffects = 128; /* TODO actually figure this out. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
347 haptic->nplaying = 128;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
348
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
349
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
350 /* Prepare effects memory. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
351 haptic->effects = (struct haptic_effect *)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
352 SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
353 if (haptic->effects == NULL) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
354 SDL_OutOfMemory();
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
355 goto acquire_err;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
356 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
357 /* Clear the memory */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
358 SDL_memset(haptic->effects, 0,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
359 sizeof(struct haptic_effect) * haptic->neffects);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
360
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
361 return 0;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
362
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
363 /* Error handling */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
364 open_err:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
365 IDirectInputDevice_Release(device);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
366 goto creat_err;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
367 acquire_err:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
368 IDirectInputDevice2_Unacquire(haptic->hwdata->device);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
369 query_err:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
370 IDirectInputDevice2_Release(haptic->hwdata->device);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
371 creat_err:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
372 if (haptic->hwdata != NULL) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
373 free(haptic->hwdata);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
374 haptic->hwdata = NULL;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
375 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
376 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
377
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
378 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
379
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
380
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
381 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
382 * Opens a haptic device for usage.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
383 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
384 int
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
385 SDL_SYS_HapticOpen(SDL_Haptic * haptic)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
386 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
387 return SDL_SYS_HapticOpenFromInstance( haptic,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
388 SDL_hapticlist[haptic->index].instance );
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
389 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
390
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
391
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
392 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
393 * Opens a haptic device from first mouse it finds for usage.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
394 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
395 int
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
396 SDL_SYS_HapticMouse(void)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
397 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
398 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
399 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
400
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
401
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
402 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
403 * Checks to see if a joystick has haptic features.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
404 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
405 int
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
406 SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
407 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
408 return SDL_FALSE;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
409 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
410
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
411
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
412 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
413 * Checks to see if the haptic device and joystick and in reality the same.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
414 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
415 int
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
416 SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
417 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
418 return 0;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
419 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
420
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
421
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
422 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
423 * Opens a SDL_Haptic from a SDL_Joystick.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
424 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
425 int
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
426 SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
427 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
428 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
429 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
430
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
431
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
432 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
433 * Closes the haptic device.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
434 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
435 void
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
436 SDL_SYS_HapticClose(SDL_Haptic * haptic)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
437 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
438 int i;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
439
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
440 if (haptic->hwdata) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
441
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
442 /* Free the effects. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
443 for (i=0; i<haptic->neffects; i++) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
444 if (haptic->effects[i].hweffect != NULL) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
445 SDL_SYS_HapticFreeFFEFFECT( &haptic->effects[i].hweffect->effect,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
446 haptic->effects[i].effect.type );
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
447 SDL_free(haptic->effects[i].hweffect);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
448 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
449 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
450 SDL_free(haptic->effects);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
451 haptic->neffects = 0;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
452
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
453 /* Clean up */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
454 IDirectInputDevice2_Unacquire(haptic->hwdata->device);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
455 IDirectInputDevice2_Release(haptic->hwdata->device);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
456
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
457 /* Free */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
458 SDL_free(haptic->hwdata);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
459 haptic->hwdata = NULL;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
460 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
461 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
462
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
463
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
464 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
465 * Clean up after system specific haptic stuff
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
466 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
467 void
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
468 SDL_SYS_HapticQuit(void)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
469 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
470 IDirectInput_Release(dinput);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
471 dinput = NULL;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
472 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
473
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
474
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
475 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
476 * Sets the direction.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
477 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
478 static int
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
479 SDL_SYS_SetDirection( FFEFFECT * effect, SDL_HapticDirection *dir, int naxes )
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
480 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
481 LONG *rglDir;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
482
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
483 /* Handle no axes a part. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
484 if (naxes == 0) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
485 effect->rglDirection = NULL;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
486 return 0;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
487 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
488
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
489 /* Has axes. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
490 rglDir = SDL_malloc( sizeof(LONG) * naxes );
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
491 if (rglDir == NULL) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
492 SDL_OutOfMemory();
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
493 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
494 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
495 SDL_memset( rglDir, 0, sizeof(LONG) * naxes );
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
496 effect->rglDirection = rglDir;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
497
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
498 switch (dir->type) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
499 case SDL_HAPTIC_POLAR:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
500 effect->dwFlags |= FFEFF_POLAR;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
501 rglDir[0] = dir->dir[0];
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
502 return 0;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
503 case SDL_HAPTIC_CARTESIAN:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
504 effect->dwFlags |= FFEFF_CARTESIAN;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
505 rglDir[0] = dir->dir[0];
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
506 rglDir[1] = dir->dir[1];
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
507 rglDir[2] = dir->dir[2];
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
508 return 0;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
509 case SDL_HAPTIC_SPHERICAL:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
510 effect->dwFlags |= FFEFF_SPHERICAL;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
511 rglDir[0] = dir->dir[0];
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
512 rglDir[1] = dir->dir[1];
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
513 rglDir[2] = dir->dir[2];
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
514 return 0;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
515
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
516 default:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
517 SDL_SetError("Haptic: Unknown direction type.");
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
518 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
519 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
520 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
521
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
522 #define CONVERT(x) (((x)*10000) / 0xFFFF )
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
523 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
524 * Creates the FFEFFECT from a SDL_HapticEffect.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
525 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
526 static int
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
527 SDL_SYS_ToFFEFFECT( SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src )
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
528 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
529 int i;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
530 FFCONSTANTFORCE *constant;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
531 FFPERIODIC *periodic;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
532 FFCONDITION *condition; /* Actually an array of conditions - one per axis. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
533 FFRAMPFORCE *ramp;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
534 FFCUSTOMFORCE *custom;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
535 FFENVELOPE *envelope;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
536 SDL_HapticConstant *hap_constant;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
537 SDL_HapticPeriodic *hap_periodic;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
538 SDL_HapticCondition *hap_condition;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
539 SDL_HapticRamp *hap_ramp;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
540 SDL_HapticCustom *hap_custom;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
541 DWORD *axes;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
542
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
543 /* Set global stuff. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
544 SDL_memset(dest, 0, sizeof(FFEFFECT));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
545 dest->dwSize = sizeof(FFEFFECT); /* Set the structure size. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
546 dest->dwSamplePeriod = 0; /* Not used by us. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
547 dest->dwGain = 10000; /* Gain is set globally, not locally. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
548
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
549 /* Envelope. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
550 envelope = SDL_malloc( sizeof(FFENVELOPE) );
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
551 if (envelope == NULL) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
552 SDL_OutOfMemory();
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
553 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
554 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
555 SDL_memset(envelope, 0, sizeof(FFENVELOPE));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
556 dest->lpEnvelope = envelope;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
557 envelope->dwSize = sizeof(FFENVELOPE); /* Always should be this. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
558
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
559 /* Axes. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
560 dest->cAxes = haptic->naxes;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
561 if (dest->cAxes > 0) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
562 axes = SDL_malloc(sizeof(DWORD) * dest->cAxes);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
563 if (axes == NULL) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
564 SDL_OutOfMemory();
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
565 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
566 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
567 axes[0] = FFJOFS_X; /* Always at least one axis. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
568 if (dest->cAxes > 1) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
569 axes[1] = FFJOFS_Y;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
570 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
571 if (dest->cAxes > 2) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
572 axes[2] = FFJOFS_Z;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
573 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
574 dest->rgdwAxes = axes;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
575 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
576
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
577
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
578 /* The big type handling switch, even bigger then linux's version. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
579 switch (src->type) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
580 case SDL_HAPTIC_CONSTANT:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
581 hap_constant = &src->constant;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
582 constant = SDL_malloc( sizeof(FFCONSTANTFORCE) );
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
583 if (constant == NULL) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
584 SDL_OutOfMemory();
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
585 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
586 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
587 SDL_memset(constant, 0, sizeof(FFCONSTANTFORCE));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
588
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
589 /* Specifics */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
590 constant->lMagnitude = CONVERT(hap_constant->level);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
591 dest->cbTypeSpecificParams = sizeof(FFCONSTANTFORCE);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
592 dest->lpvTypeSpecificParams = constant;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
593
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
594 /* Generics */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
595 dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
596 dest->dwTriggerButton = FFJOFS_BUTTON(hap_constant->button);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
597 dest->dwTriggerRepeatInterval = hap_constant->interval;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
598 dest->dwStartDelay = hap_constant->delay * 1000; /* In microseconds. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
599
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
600 /* Direction. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
601 if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
602 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
603 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
604
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
605 /* Envelope */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
606 envelope->dwAttackLevel = CONVERT(hap_constant->attack_level);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
607 envelope->dwAttackTime = hap_constant->attack_length * 1000;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
608 envelope->dwFadeLevel = CONVERT(hap_constant->fade_level);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
609 envelope->dwFadeTime = hap_constant->fade_length * 1000;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
610
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
611 break;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
612
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
613 case SDL_HAPTIC_SINE:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
614 case SDL_HAPTIC_SQUARE:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
615 case SDL_HAPTIC_TRIANGLE:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
616 case SDL_HAPTIC_SAWTOOTHUP:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
617 case SDL_HAPTIC_SAWTOOTHDOWN:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
618 hap_periodic = &src->periodic;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
619 periodic = SDL_malloc(sizeof(FFPERIODIC));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
620 if (periodic == NULL) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
621 SDL_OutOfMemory();
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
622 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
623 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
624 SDL_memset(periodic, 0, sizeof(FFPERIODIC));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
625
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
626 /* Specifics */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
627 periodic->dwMagnitude = CONVERT(hap_periodic->magnitude);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
628 periodic->lOffset = CONVERT(hap_periodic->offset);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
629 periodic->dwPhase = hap_periodic->phase;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
630 periodic->dwPeriod = hap_periodic->period * 1000;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
631 dest->cbTypeSpecificParams = sizeof(FFPERIODIC);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
632 dest->lpvTypeSpecificParams = periodic;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
633
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
634 /* Generics */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
635 dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
636 dest->dwTriggerButton = FFJOFS_BUTTON(hap_periodic->button);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
637 dest->dwTriggerRepeatInterval = hap_periodic->interval;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
638 dest->dwStartDelay = hap_periodic->delay * 1000; /* In microseconds. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
639
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
640 /* Direction. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
641 if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) < 0) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
642 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
643 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
644
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
645 /* Envelope */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
646 envelope->dwAttackLevel = CONVERT(hap_periodic->attack_level);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
647 envelope->dwAttackTime = hap_periodic->attack_length * 1000;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
648 envelope->dwFadeLevel = CONVERT(hap_periodic->fade_level);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
649 envelope->dwFadeTime = hap_periodic->fade_length * 1000;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
650
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
651 break;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
652
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
653 case SDL_HAPTIC_SPRING:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
654 case SDL_HAPTIC_DAMPER:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
655 case SDL_HAPTIC_INERTIA:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
656 case SDL_HAPTIC_FRICTION:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
657 hap_condition = &src->condition;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
658 condition = SDL_malloc(sizeof(FFCONDITION) * dest->cAxes);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
659 if (condition == NULL) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
660 SDL_OutOfMemory();
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
661 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
662 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
663 SDL_memset(condition, 0, sizeof(FFCONDITION));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
664
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
665 /* Specifics */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
666 for (i=0; i<dest->cAxes; i++) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
667 condition[i].lOffset = CONVERT(hap_condition->center[i]);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
668 condition[i].lPositiveCoefficient = CONVERT(hap_condition->right_coeff[i]);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
669 condition[i].lNegativeCoefficient = CONVERT(hap_condition->left_coeff[i]);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
670 condition[i].dwPositiveSaturation = CONVERT(hap_condition->right_sat[i]);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
671 condition[i].dwNegativeSaturation = CONVERT(hap_condition->left_sat[i]);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
672 condition[i].lDeadBand = CONVERT(hap_condition->deadband[i]);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
673 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
674 dest->cbTypeSpecificParams = sizeof(FFCONDITION) * dest->cAxes;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
675 dest->lpvTypeSpecificParams = condition;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
676
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
677 /* Generics */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
678 dest->dwDuration = hap_condition->length * 1000; /* In microseconds. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
679 dest->dwTriggerButton = FFJOFS_BUTTON(hap_condition->button);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
680 dest->dwTriggerRepeatInterval = hap_condition->interval;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
681 dest->dwStartDelay = hap_condition->delay * 1000; /* In microseconds. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
682
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
683 /* Direction. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
684 if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) < 0) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
685 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
686 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
687
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
688 /* Envelope */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
689 /* TODO Check is envelope actually used.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
690 envelope->dwAttackLevel = CONVERT(hap_condition->attack_level);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
691 envelope->dwAttackTime = hap_condition->attack_length * 1000;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
692 envelope->dwFadeLevel = CONVERT(hap_condition->fade_level);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
693 envelope->dwFadeTime = hap_condition->fade_length * 1000;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
694 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
695
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
696 break;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
697
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
698 case SDL_HAPTIC_RAMP:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
699 hap_ramp = &src->ramp;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
700 ramp = SDL_malloc(sizeof(FFRAMPFORCE));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
701 if (ramp == NULL) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
702 SDL_OutOfMemory();
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
703 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
704 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
705 SDL_memset(ramp, 0, sizeof(FFRAMPFORCE));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
706
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
707 /* Specifics */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
708 ramp->lStart = CONVERT(hap_ramp->start);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
709 ramp->lEnd = CONVERT(hap_ramp->end);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
710 dest->cbTypeSpecificParams = sizeof(FFRAMPFORCE);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
711 dest->lpvTypeSpecificParams = ramp;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
712
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
713 /* Generics */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
714 dest->dwDuration = hap_ramp->length * 1000; /* In microseconds. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
715 dest->dwTriggerButton = FFJOFS_BUTTON(hap_ramp->button);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
716 dest->dwTriggerRepeatInterval = hap_ramp->interval;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
717 dest->dwStartDelay = hap_ramp->delay * 1000; /* In microseconds. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
718
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
719 /* Direction. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
720 if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
721 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
722 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
723
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
724 /* Envelope */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
725 envelope->dwAttackLevel = CONVERT(hap_ramp->attack_level);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
726 envelope->dwAttackTime = hap_ramp->attack_length * 1000;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
727 envelope->dwFadeLevel = CONVERT(hap_ramp->fade_level);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
728 envelope->dwFadeTime = hap_ramp->fade_length * 1000;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
729
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
730 break;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
731
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
732 case SDL_HAPTIC_CUSTOM:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
733 hap_custom = &src->custom;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
734 custom = SDL_malloc(sizeof(FFCUSTOMFORCE));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
735 if (custom == NULL) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
736 SDL_OutOfMemory();
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
737 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
738 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
739 SDL_memset(custom, 0, sizeof(FFCUSTOMFORCE));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
740
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
741 /* Specifics */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
742 custom->cChannels = hap_custom->channels;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
743 custom->dwSamplePeriod = hap_custom->period * 1000;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
744 custom->cSamples = hap_custom->samples;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
745 custom->rglForceData = SDL_malloc(sizeof(LONG)*custom->cSamples*custom->cChannels);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
746 for (i=0; i<hap_custom->samples*hap_custom->channels; i++) { /* Copy data. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
747 custom->rglForceData[i] = CONVERT(hap_custom->data[i]);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
748 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
749 dest->cbTypeSpecificParams = sizeof(FFCUSTOMFORCE);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
750 dest->lpvTypeSpecificParams = custom;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
751
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
752 /* Generics */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
753 dest->dwDuration = hap_custom->length * 1000; /* In microseconds. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
754 dest->dwTriggerButton = FFJOFS_BUTTON(hap_custom->button);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
755 dest->dwTriggerRepeatInterval = hap_custom->interval;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
756 dest->dwStartDelay = hap_custom->delay * 1000; /* In microseconds. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
757
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
758 /* Direction. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
759 if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) < 0) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
760 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
761 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
762
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
763 /* Envelope */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
764 envelope->dwAttackLevel = CONVERT(hap_custom->attack_level);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
765 envelope->dwAttackTime = hap_custom->attack_length * 1000;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
766 envelope->dwFadeLevel = CONVERT(hap_custom->fade_level);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
767 envelope->dwFadeTime = hap_custom->fade_length * 1000;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
768
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
769 break;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
770
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
771
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
772 default:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
773 SDL_SetError("Haptic: Unknown effect type.");
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
774 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
775 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
776
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
777 return 0;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
778 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
779
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
780
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
781 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
782 * Frees an FFEFFECT allocated by SDL_SYS_ToFFEFFECT.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
783 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
784 static void
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
785 SDL_SYS_HapticFreeFFEFFECT( FFEFFECT * effect, int type )
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
786 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
787 FFCUSTOMFORCE *custom;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
788
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
789 if (effect->lpEnvelope != NULL) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
790 SDL_free(effect->lpEnvelope);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
791 effect->lpEnvelope = NULL;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
792 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
793 if (effect->rgdwAxes != NULL) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
794 SDL_free(effect->rgdwAxes);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
795 effect->rgdwAxes = NULL;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
796 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
797 if (effect->lpvTypeSpecificParams != NULL) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
798 if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
799 custom = (FFCUSTOMFORCE*) effect->lpvTypeSpecificParams;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
800 SDL_free(custom->rglForceData);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
801 custom->rglForceData = NULL;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
802 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
803 SDL_free(effect->lpvTypeSpecificParams);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
804 effect->lpvTypeSpecificParams = NULL;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
805 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
806 if (effect->rglDirection != NULL) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
807 SDL_free(effect->rglDirection);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
808 effect->rglDirection = NULL;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
809 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
810 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
811
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
812
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
813 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
814 * Gets the effect type from the generic SDL haptic effect wrapper.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
815 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
816 REFGUID
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
817 SDL_SYS_HapticEffectType(struct haptic_effect * effect)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
818 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
819 switch (effect->effect.type) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
820 case SDL_HAPTIC_CONSTANT:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
821 return GUID_ConstantForce;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
822
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
823 case SDL_HAPTIC_RAMP:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
824 return GUID_RampForce;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
825
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
826 case SDL_HAPTIC_SQUARE:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
827 return GUID_Square;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
828
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
829 case SDL_HAPTIC_SINE:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
830 return GUID_Sine;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
831
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
832 case SDL_HAPTIC_TRIANGLE:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
833 return GUID_Triangle;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
834
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
835 case SDL_HAPTIC_SAWTOOTHUP:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
836 return GUID_SawtoothUp;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
837
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
838 case SDL_HAPTIC_SAWTOOTHDOWN:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
839 return GUID_SawtoothDown;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
840
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
841 case SDL_HAPTIC_SPRING:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
842 return GUID_Spring;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
843
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
844 case SDL_HAPTIC_DAMPER:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
845 return GUID_Damper;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
846
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
847 case SDL_HAPTIC_INERTIA:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
848 return GUID_Inertia;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
849
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
850 case SDL_HAPTIC_FRICTION:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
851 return GUID_Friction;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
852
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
853 case SDL_HAPTIC_CUSTOM:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
854 return GUID_CustomForce;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
855
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
856 default:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
857 SDL_SetError("Haptic: Unknown effect type.");
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
858 return NULL;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
859 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
860 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
861
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
862
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
863 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
864 * Creates a new haptic effect.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
865 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
866 int
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
867 SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect * effect,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
868 SDL_HapticEffect * base)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
869 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
870 HRESULT ret;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
871 REFGUID type;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
872
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
873 /* Alloc the effect. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
874 effect->hweffect = (struct haptic_hweffect *)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
875 SDL_malloc(sizeof(struct haptic_hweffect));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
876 if (effect->hweffect == NULL) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
877 SDL_OutOfMemory();
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
878 goto err_hweffect;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
879 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
880
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
881 /* Get the type. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
882 type = SDL_SYS_HapticEffectType(effect);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
883 if (type == NULL) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
884 goto err_hweffect;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
885 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
886
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
887 /* Get the effect. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
888 if (SDL_SYS_ToFFEFFECT(haptic, &effect->hweffect->effect, base) < 0) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
889 goto err_effectdone;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
890 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
891
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
892 /* Create the actual effect. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
893 ret = FFDeviceCreateEffect(haptic->hwdata->device, type,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
894 &effect->hweffect->effect, &effect->hweffect->ref);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
895 if (ret != FF_OK) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
896 SDL_SetError("Haptic: Unable to create effect: %s.", FFStrError(ret));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
897 goto err_effectdone;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
898 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
899
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
900 return 0;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
901
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
902 err_effectdone:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
903 SDL_SYS_HapticFreeFFEFFECT(&effect->hweffect->effect, base->type);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
904 err_hweffect:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
905 if (effect->hweffect != NULL) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
906 SDL_free(effect->hweffect);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
907 effect->hweffect = NULL;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
908 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
909 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
910 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
911
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
912
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
913 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
914 * Updates an effect.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
915 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
916 int
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
917 SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
918 struct haptic_effect * effect, SDL_HapticEffect * data)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
919 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
920 HRESULT ret;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
921 FFEffectParameterFlag flags;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
922 FFEFFECT temp;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
923
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
924 /* Get the effect. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
925 SDL_memset(&temp, 0, sizeof(FFEFFECT));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
926 if (SDL_SYS_ToFFEFFECT(haptic, &temp, data) < 0) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
927 goto err_update;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
928 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
929
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
930 /* Set the flags. Might be worthwhile to diff temp with loaded effect and
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
931 * only change those parameters. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
932 flags = FFEP_ALLPARAMS;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
933
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
934 /* Create the actual effect. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
935 ret = FFEffectSetParameters(effect->hweffect->ref, &temp, flags);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
936 if (ret != FF_OK) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
937 SDL_SetError("Haptic: Unable to update effect: %s.", FFStrError(ret));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
938 goto err_update;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
939 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
940
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
941 /* Copy it over. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
942 SDL_SYS_HapticFreeFFEFFECT(&effect->hweffect->effect, data->type);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
943 SDL_memcpy(&effect->hweffect->effect, &temp, sizeof(FFEFFECT));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
944
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
945 return 0;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
946
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
947 err_update:
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
948 SDL_SYS_HapticFreeFFEFFECT(&temp, data->type);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
949 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
950 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
951
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
952
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
953 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
954 * Runs an effect.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
955 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
956 int
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
957 SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect * effect,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
958 Uint32 iterations)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
959 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
960 HRESULT ret;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
961 Uint32 iter;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
962
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
963 /* Check if it's infinite. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
964 if (iterations == SDL_HAPTIC_INFINITY) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
965 iter = FF_INFINITE;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
966 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
967 else
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
968 iter = iterations;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
969
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
970 /* Run the effect. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
971 ret = FFEffectStart(effect->hweffect->ref, iter, 0);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
972 if (ret != FF_OK) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
973 SDL_SetError("Haptic: Unable to run the effect: %s.", FFStrError(ret));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
974 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
975 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
976
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
977 return 0;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
978 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
979
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
980
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
981 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
982 * Stops an effect.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
983 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
984 int
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
985 SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect * effect)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
986 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
987 HRESULT ret;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
988
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
989 ret = FFEffectStop(effect->hweffect->ref);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
990 if (ret != FF_OK) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
991 SDL_SetError("Haptic: Unable to stop the effect: %s.", FFStrError(ret));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
992 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
993 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
994
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
995 return 0;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
996 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
997
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
998
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
999 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1000 * Frees the effect.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1001 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1002 void
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1003 SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect * effect)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1004 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1005 HRESULT ret;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1006
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1007 ret = FFDeviceReleaseEffect(haptic->hwdata->device, effect->hweffect->ref);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1008 if (ret != FF_OK) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1009 SDL_SetError("Haptic: Error removing the effect from the device: %s.",
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1010 FFStrError(ret));
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1011 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1012 SDL_free(effect->hweffect->effect.lpvTypeSpecificParams);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1013 effect->hweffect->effect.lpvTypeSpecificParams = NULL;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1014 SDL_free(effect->hweffect);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1015 effect->hweffect = NULL;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1016 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1017
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1018
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1019 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1020 * Gets the status of a haptic effect.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1021 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1022 int
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1023 SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect * effect)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1024 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1025 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1026
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1027
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1028 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1029 * Sets the gain.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1030 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1031 int
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1032 SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1033 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1034 HRESULT ret;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1035 DIPROPDWORD dipdw;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1036
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1037 /* Create the weird structure thingy. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1038 dipdw.diph.dwSize = sizeof(DIPROPDWORD);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1039 dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1040 dipdw.diph.dwObj = 0;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1041 dipdw.diph.dwHow = DIPH_DEVICE;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1042 dipdw.dwData = gain * 100; /* 0 to 10,000 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1043
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1044 /* Try to set the autocenter. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1045 ret = IDirectInputDevice2_SetProperty( haptic->hwdata->device,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1046 DIPROP_FFGAIN, &dipdw.diph );
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1047 if (FAILED(ret)) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1048 DI_SetError("Setting gain",ret);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1049 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1050 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1051
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1052 return 0;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1053 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1054
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1055
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1056 /*
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1057 * Sets the autocentering.
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1058 */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1059 int
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1060 SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1061 {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1062 HRESULT ret;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1063 DIPROPDWORD dipdw;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1064
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1065 /* Create the weird structure thingy. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1066 dipdw.diph.dwSize = sizeof(DIPROPDWORD);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1067 dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1068 dipdw.diph.dwObj = 0;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1069 dipdw.diph.dwHow = DIPH_DEVICE;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1070 dipdw.dwData = (autocenter == 0) ? DIPROPAUTOCENTER_OFF :
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1071 DIPROPAUTOCENTER_ON;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1072
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1073 /* Try to set the autocenter. */
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1074 ret = IDirectInputDevice2_SetProperty( haptic->hwdata->device,
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1075 DIPROP_AUTOCENTER, &dipdw.diph );
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1076 if (FAILED(ret)) {
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1077 DI_SetError("Setting autocenter",ret);
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1078 return -1;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1079 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1080
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1081 return 0;
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1082
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1083 }
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1084
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1085
f010e1d4e431 First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1086 #endif /* SDL_HAPTIC_DINPUT */