int SDL_DINPUT_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) { HRESULT ret; ret = IDirectInputEffect_Stop(effect->hweffect->ref); if (FAILED(ret)) { return DI_SetError("Unable to stop effect", ret); } return 0; }
static void dinput_joypad_destroy(void) { unsigned i; for (i = 0; i < MAX_USERS; i++) { if (g_pads[i].joypad) { if (g_pads[i].rumble_iface[0]) { IDirectInputEffect_Stop(g_pads[i].rumble_iface[0]); IDirectInputEffect_Release(g_pads[i].rumble_iface[0]); } if (g_pads[i].rumble_iface[1]) { IDirectInputEffect_Stop(g_pads[i].rumble_iface[1]); IDirectInputEffect_Release(g_pads[i].rumble_iface[1]); } IDirectInputDevice8_Unacquire(g_pads[i].joypad); IDirectInputDevice8_Release(g_pads[i].joypad); } free(g_pads[i].joy_name); g_pads[i].joy_name = NULL; free(g_pads[i].joy_friendly_name); g_pads[i].joy_friendly_name = NULL; input_config_clear_device_name(i); } g_joypad_cnt = 0; memset(g_pads, 0, sizeof(g_pads)); /* Can be blocked by global Dinput context. */ dinput_destroy_context(); }
/* * Stops an effect. */ int SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) { HRESULT ret; if (haptic->hwdata->bXInputHaptic) { XINPUT_VIBRATION vibration = { 0, 0 }; SDL_LockMutex(haptic->hwdata->mutex); haptic->hwdata->stopTicks = 0; SDL_UnlockMutex(haptic->hwdata->mutex); return (XINPUTSETSTATE(haptic->hwdata->userid, &vibration) == ERROR_SUCCESS) ? 0 : -1; } ret = IDirectInputEffect_Stop(effect->hweffect->ref); if (FAILED(ret)) { return DI_SetError("Unable to stop effect", ret); } return 0; }
bool dinput_joypad_set_rumble(unsigned pad, enum retro_rumble_effect type, uint16_t strenght) { int i = type == RETRO_RUMBLE_STRONG ? 1 : 0; if (pad >= g_joypad_cnt || !g_pads[pad].rumble_iface[i]) return false; if (strenght) { g_pads[pad].rumble_props.dwGain = (DWORD)((double)strenght / 65535.0 * (double)DI_FFNOMINALMAX); IDirectInputEffect_SetParameters(g_pads[pad].rumble_iface[i], &g_pads[pad].rumble_props, DIEP_GAIN | DIEP_START); } else IDirectInputEffect_Stop(g_pads[pad].rumble_iface[i]); return true; }