comparison src/haptic/win32/SDL_syshaptic.c @ 2601:4915cd01d0e7 gsoc2008_force_feedback

Get number of axes. Should fix the autocenter issue.
author Edgar Simo <bobbens@gmail.com>
date Tue, 05 Aug 2008 11:39:51 +0000
parents d1140f0ebedf
children f578389c9ead
comparison
equal deleted inserted replaced
2600:d1140f0ebedf 2601:4915cd01d0e7
222 return DIENUM_CONTINUE; 222 return DIENUM_CONTINUE;
223 } 223 }
224 224
225 225
226 /* 226 /*
227 * Callback to get supported axes.
228 */
229 static BOOL CALLBACK
230 DI_DeviceObjectCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef)
231 {
232 SDL_Haptic *haptic = (SDL_Hapti *) pvRef;
233
234 if (dev->dwType & DIDFT_AXIS) {
235
236 haptic->naxes++;
237
238 /* Currently using the artificial limit of 3 axes. */
239 if (haptic->naxes >= 3) {
240 return DIENUM_STOP;
241 }
242 }
243
244 return DIENUM_CONTINUE;
245 }
246
247
248 /*
227 * Opens the haptic device from the file descriptor. 249 * Opens the haptic device from the file descriptor.
228 * 250 *
229 * Steps: 251 * Steps:
230 * - Open temporary DirectInputDevice interface. 252 * - Open temporary DirectInputDevice interface.
231 * - Create DirectInputDevice2 interface. 253 * - Create DirectInputDevice2 interface.
297 DI_SetError("Getting device capabilities",ret); 319 DI_SetError("Getting device capabilities",ret);
298 goto acquire_err; 320 goto acquire_err;
299 } 321 }
300 #endif 322 #endif
301 323
324 /* Get number of axes. */
325 ret = IDirectInputDevice2_EnumObjects( haptic->hwdata->device,
326 DI_DeviceObjectCallback,
327 haptic, DIDFT_AXIS );
328 if (FAILED(ret)) {
329 DI_SetError("Getting device axes",ret);
330 goto query_err;
331 }
332
302 /* Acquire the device. */ 333 /* Acquire the device. */
303 ret = IDirectInputDevice2_Acquire(haptic->hwdata->device); 334 ret = IDirectInputDevice2_Acquire(haptic->hwdata->device);
304 if (FAILED(ret)) { 335 if (FAILED(ret)) {
305 DI_SetError("Acquiring DirectInput device",ret); 336 DI_SetError("Acquiring DirectInput device",ret);
306 goto query_err; 337 goto query_err;
350 } 381 }
351 } 382 }
352 else { /* Gain is supported. */ 383 else { /* Gain is supported. */
353 haptic->supported |= SDL_HAPTIC_GAIN; 384 haptic->supported |= SDL_HAPTIC_GAIN;
354 } 385 }
386 dipdw.diph.dwObj = 0;
387 dipdw.diph.dwHow = DIPH_DEVICE;
355 dipdw.dwData = DIPROPAUTOCENTER_OFF; 388 dipdw.dwData = DIPROPAUTOCENTER_OFF;
356 ret = IDirectInputDevice2_SetProperty( haptic->hwdata->device, 389 ret = IDirectInputDevice2_SetProperty( haptic->hwdata->device,
357 DIPROP_AUTOCENTER, &dipdw.diph ); 390 DIPROP_AUTOCENTER, &dipdw.diph );
358 if (FAILED(ret)) { 391 if (FAILED(ret)) {
359 if (ret != DIERR_UNSUPPORTED) { 392 if (ret != DIERR_UNSUPPORTED) {