343 if (FAILED(ret)) { |
345 if (FAILED(ret)) { |
344 DI_SetError("Resetting device",ret); |
346 DI_SetError("Resetting device",ret); |
345 goto acquire_err; |
347 goto acquire_err; |
346 } |
348 } |
347 |
349 |
348 |
|
349 /* Enabling actuators. */ |
350 /* Enabling actuators. */ |
350 ret = IDirectInputDevice2_SendForceFeedbackCommand( haptic->hwdata->device, |
351 ret = IDirectInputDevice2_SendForceFeedbackCommand( haptic->hwdata->device, |
351 DISFFC_SETACTUATORSON ); |
352 DISFFC_SETACTUATORSON ); |
352 if (FAILED(ret)) { |
353 if (FAILED(ret)) { |
353 DI_SetError("Enabling actuators",ret); |
354 DI_SetError("Enabling actuators",ret); |
372 dipdw.diph.dwObj = 0; |
373 dipdw.diph.dwObj = 0; |
373 dipdw.diph.dwHow = DIPH_DEVICE; |
374 dipdw.diph.dwHow = DIPH_DEVICE; |
374 dipdw.dwData = 10000; |
375 dipdw.dwData = 10000; |
375 ret = IDirectInputDevice2_SetProperty( haptic->hwdata->device, |
376 ret = IDirectInputDevice2_SetProperty( haptic->hwdata->device, |
376 DIPROP_FFGAIN, &dipdw.diph ); |
377 DIPROP_FFGAIN, &dipdw.diph ); |
377 if (FAILED(ret)) { |
378 if (!FAILED(ret)) { /* Gain is supported. */ |
378 if (ret != DIERR_UNSUPPORTED) { |
|
379 DI_SetError("Checking gain",ret); |
|
380 goto acquire_err; |
|
381 } |
|
382 } |
|
383 else { /* Gain is supported. */ |
|
384 haptic->supported |= SDL_HAPTIC_GAIN; |
379 haptic->supported |= SDL_HAPTIC_GAIN; |
385 } |
380 } |
386 dipdw.diph.dwObj = 0; |
381 dipdw.diph.dwObj = 0; |
387 dipdw.diph.dwHow = DIPH_DEVICE; |
382 dipdw.diph.dwHow = DIPH_DEVICE; |
388 dipdw.dwData = DIPROPAUTOCENTER_OFF; |
383 dipdw.dwData = DIPROPAUTOCENTER_OFF; |
389 ret = IDirectInputDevice2_SetProperty( haptic->hwdata->device, |
384 ret = IDirectInputDevice2_SetProperty( haptic->hwdata->device, |
390 DIPROP_AUTOCENTER, &dipdw.diph ); |
385 DIPROP_AUTOCENTER, &dipdw.diph ); |
391 if (FAILED(ret)) { |
386 if (!FAILED(ret)) { /* Autocenter is supported. */ |
392 if (ret != DIERR_UNSUPPORTED) { |
|
393 DI_SetError("Checking autocenter",ret); |
|
394 goto acquire_err; |
|
395 } |
|
396 } |
|
397 else { /* Autocenter is supported. */ |
|
398 haptic->supported |= SDL_HAPTIC_AUTOCENTER; |
387 haptic->supported |= SDL_HAPTIC_AUTOCENTER; |
399 } |
388 } |
400 |
|
401 |
389 |
402 /* Check maximum effects. */ |
390 /* Check maximum effects. */ |
403 haptic->neffects = 128; /* TODO actually figure this out. */ |
391 haptic->neffects = 128; /* TODO actually figure this out. */ |
404 haptic->nplaying = 128; |
392 haptic->nplaying = 128; |
405 |
|
406 |
393 |
407 /* Prepare effects memory. */ |
394 /* Prepare effects memory. */ |
408 haptic->effects = (struct haptic_effect *) |
395 haptic->effects = (struct haptic_effect *) |
409 SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); |
396 SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); |
410 if (haptic->effects == NULL) { |
397 if (haptic->effects == NULL) { |
632 axes = SDL_malloc(sizeof(DWORD) * dest->cAxes); |
619 axes = SDL_malloc(sizeof(DWORD) * dest->cAxes); |
633 if (axes == NULL) { |
620 if (axes == NULL) { |
634 SDL_OutOfMemory(); |
621 SDL_OutOfMemory(); |
635 return -1; |
622 return -1; |
636 } |
623 } |
637 axes[0] = DIJOFS_X; /* Always at least one axis. */ |
624 axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */ |
638 if (dest->cAxes > 1) { |
625 if (dest->cAxes > 1) { |
639 axes[1] = DIJOFS_Y; |
626 axes[1] = haptic->hwdata->axes[1]; |
640 } |
627 } |
641 if (dest->cAxes > 2) { |
628 if (dest->cAxes > 2) { |
642 axes[2] = DIJOFS_Z; |
629 axes[2] = haptic->hwdata->axes[2]; |
643 } |
630 } |
644 dest->rgdwAxes = axes; |
631 dest->rgdwAxes = axes; |
645 } |
632 } |
646 |
633 |
647 |
634 |