comparison src/haptic/win32/SDL_syshaptic.c @ 2568:5ad98a77bacb gsoc2008_force_feedback

First attempt to fix compilation on windows.
author Edgar Simo <bobbens@gmail.com>
date Thu, 31 Jul 2008 15:57:49 +0000
parents 94ff09afa478
children 806919b319d4
comparison
equal deleted inserted replaced
2567:d551e29f086b 2568:5ad98a77bacb
82 */ 82 */
83 static LPDIRECTINPUT dinput = NULL; 83 static LPDIRECTINPUT dinput = NULL;
84 84
85 85
86 /* 86 /*
87 * External stuff.
88 */
89 extern HINSTANCE SDL_Instance;
90 extern HWND SDL_Window;
91
92
93 /*
87 * Prototypes. 94 * Prototypes.
88 */ 95 */
89 static BOOL CALLBACK EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext); 96 static BOOL CALLBACK EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext);
90 97
91 98
139 return -1; 146 return -1;
140 } 147 }
141 148
142 /* Look for haptic devices. */ 149 /* Look for haptic devices. */
143 ret = IDirectInput_EnumDevices( dinput, 150 ret = IDirectInput_EnumDevices( dinput,
144 DIDEVTYPE_ALL, 151 DIDEVTYPE_DEVICE,
145 EnumJoysticksCallback, 152 EnumHapticsCallback,
146 NULL, DIEDFL_FORCEFEEDBACK | DIEDFL_ATTACHEDONLY); 153 NULL, DIEDFL_FORCEFEEDBACK | DIEDFL_ATTACHEDONLY);
147 if (FAILED(ret)) { 154 if (FAILED(ret)) {
148 DI_SetError("Enumerating DirectInput devices",ret); 155 DI_SetError("Enumerating DirectInput devices",ret);
149 return -1; 156 return -1;
150 } 157 }
181 188
182 /* 189 /*
183 * Callback to get all supported effects. 190 * Callback to get all supported effects.
184 */ 191 */
185 #define EFFECT_TEST(e,s) \ 192 #define EFFECT_TEST(e,s) \
186 if (pei->guid == (e)) \ 193 if (pei->guid == (e)) \
187 haptic->supported |= (s) 194 haptic->supported |= (s)
188 static BOOL CALLBACK 195 static BOOL CALLBACK
189 DI_EffectCallback(LPCDIEffectInfo pei, LPVOID pv) 196 DI_EffectCallback(LPCDIEffectInfo pei, LPVOID pv)
190 { 197 {
191 /* Prepare the haptic device. */ 198 /* Prepare the haptic device. */
238 } 245 }
239 SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata)); 246 SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
240 247
241 /* Open the device */ 248 /* Open the device */
242 ret = IDirectInput_CreateDevice( dinput, &instance, 249 ret = IDirectInput_CreateDevice( dinput, &instance,
243 guidInstance, &device, NULL); 250 guidInstance, &device );
244 if (FAILED(ret)) { 251 if (FAILED(ret)) {
245 DI_SetError("Creating DirectInput device",ret); 252 DI_SetError("Creating DirectInput device",ret);
246 goto creat_err; 253 goto creat_err;
247 } 254 }
248 255
249 /* Now get the IDirectInputDevice2 interface, instead. */ 256 /* Now get the IDirectInputDevice2 interface, instead. */
250 ret = IDirectInputDevice_QueryInterface( device, 257 ret = IDirectInputDevice_QueryInterface( device,
251 &IID_IDirectInputDevice2, 258 &IID_IDirectInputDevice2,
252 haptic->hwdata->device ); 259 (LPVOID *) &haptic->hwdata->device );
253 /* Done with the temporary one now. */ 260 /* Done with the temporary one now. */
254 IDirectInputDevice_Release(device); 261 IDirectInputDevice_Release(device);
255 if (FAILED(ret)) { 262 if (FAILED(ret)) {
256 DI_SetError("Querying DirectInput interface",ret); 263 DI_SetError("Querying DirectInput interface",ret);
257 goto creat_err; 264 goto creat_err;
299 goto acquire_err; 306 goto acquire_err;
300 } 307 }
301 308
302 309
303 /* Get supported effects. */ 310 /* Get supported effects. */
304 ret = IDirectInput_EnumEffects( DI_EffectCallback, haptic, DIEFT_ALL); 311 ret = IDirectInputDevice2_EnumEffects( haptic->hwdata->device,
312 DI_EffectCallback, haptic, DIEFT_ALL );
305 if (FAILED(ret)) { 313 if (FAILED(ret)) {
306 DI_SetError("Enumerating supported effects",ret); 314 DI_SetError("Enumerating supported effects",ret);
307 goto acquire_err; 315 goto acquire_err;
308 } 316 }
309 if (haptic->supported == 0) { /* Error since device supports nothing. */ 317 if (haptic->supported == 0) { /* Error since device supports nothing. */