diff --git a/reactos/dll/directx/wine/dinput/dinput.rc b/reactos/dll/directx/wine/dinput/dinput.rc index 3b598e00d29..e677561c5df 100644 --- a/reactos/dll/directx/wine/dinput/dinput.rc +++ b/reactos/dll/directx/wine/dinput/dinput.rc @@ -32,6 +32,8 @@ #include +#pragma makedep po + LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT STRINGTABLE diff --git a/reactos/dll/directx/wine/dinput/dinput_main.c b/reactos/dll/directx/wine/dinput/dinput_main.c index c725d63db9b..5127371cdd3 100644 --- a/reactos/dll/directx/wine/dinput/dinput_main.c +++ b/reactos/dll/directx/wine/dinput/dinput_main.c @@ -911,7 +911,9 @@ static HRESULT WINAPI IDirectInput8AImpl_EnumDevicesBySemantics( LPDIRECTINPUTDEVICE8A lpdid; DWORD callbackFlags; int i, j; - + int device_count = 0; + int remain; + DIDEVICEINSTANCEA *didevis = 0; FIXME("(this=%p,%s,%p,%p,%p,%04x): semi-stub\n", This, debugstr_a(ptszUserName), lpdiActionFormat, lpCallback, pvRef, dwFlags); @@ -939,19 +941,37 @@ static HRESULT WINAPI IDirectInput8AImpl_EnumDevicesBySemantics( { TRACE(" - checking device %u ('%s')\n", i, dinput_devices[i]->name); - callbackFlags = diactionformat_priorityA(lpdiActionFormat, lpdiActionFormat->dwGenre); /* Default behavior is to enumerate attached game controllers */ enumSuccess = dinput_devices[i]->enum_deviceA(DI8DEVCLASS_GAMECTRL, DIEDFL_ATTACHEDONLY | dwFlags, &didevi, This->dwVersion, j); if (enumSuccess == S_OK) { - IDirectInput_CreateDevice(iface, &didevi.guidInstance, &lpdid, NULL); - - if (lpCallback(&didevi, lpdid, callbackFlags, 0, pvRef) == DIENUM_STOP) - return DI_OK; + if (device_count++) + didevis = HeapReAlloc(GetProcessHeap(), 0, didevis, sizeof(DIDEVICEINSTANCEA)*device_count); + else + didevis = HeapAlloc(GetProcessHeap(), 0, sizeof(DIDEVICEINSTANCEA)*device_count); + didevis[device_count-1] = didevi; } } } + remain = device_count; + if (!(dwFlags & DIEDBSFL_FORCEFEEDBACK)) + remain += sizeof(guids)/sizeof(guids[0]); + + for (i = 0; i < device_count; i++) + { + callbackFlags = diactionformat_priorityA(lpdiActionFormat, lpdiActionFormat->dwGenre); + IDirectInput_CreateDevice(iface, &didevis[i].guidInstance, &lpdid, NULL); + + if (lpCallback(&didevis[i], lpdid, callbackFlags, --remain, pvRef) == DIENUM_STOP) + { + HeapFree(GetProcessHeap(), 0, didevis); + return DI_OK; + } + } + + HeapFree(GetProcessHeap(), 0, didevis); + if (dwFlags & DIEDBSFL_FORCEFEEDBACK) return DI_OK; /* Enumerate keyboard and mouse */ @@ -982,6 +1002,9 @@ static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics( LPDIRECTINPUTDEVICE8W lpdid; DWORD callbackFlags; int i, j; + int device_count = 0; + int remain; + DIDEVICEINSTANCEW *didevis = 0; FIXME("(this=%p,%s,%p,%p,%p,%04x): semi-stub\n", This, debugstr_w(ptszUserName), lpdiActionFormat, lpCallback, pvRef, dwFlags); @@ -999,19 +1022,37 @@ static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics( { TRACE(" - checking device %u ('%s')\n", i, dinput_devices[i]->name); - callbackFlags = diactionformat_priorityW(lpdiActionFormat, lpdiActionFormat->dwGenre); /* Default behavior is to enumerate attached game controllers */ enumSuccess = dinput_devices[i]->enum_deviceW(DI8DEVCLASS_GAMECTRL, DIEDFL_ATTACHEDONLY | dwFlags, &didevi, This->dwVersion, j); if (enumSuccess == S_OK) { - IDirectInput_CreateDevice(iface, &didevi.guidInstance, &lpdid, NULL); - - if (lpCallback(&didevi, lpdid, callbackFlags, 0, pvRef) == DIENUM_STOP) - return DI_OK; + if (device_count++) + didevis = HeapReAlloc(GetProcessHeap(), 0, didevis, sizeof(DIDEVICEINSTANCEW)*device_count); + else + didevis = HeapAlloc(GetProcessHeap(), 0, sizeof(DIDEVICEINSTANCEW)*device_count); + didevis[device_count-1] = didevi; } } } + remain = device_count; + if (!(dwFlags & DIEDBSFL_FORCEFEEDBACK)) + remain += sizeof(guids)/sizeof(guids[0]); + + for (i = 0; i < device_count; i++) + { + callbackFlags = diactionformat_priorityW(lpdiActionFormat, lpdiActionFormat->dwGenre); + IDirectInput_CreateDevice(iface, &didevis[i].guidInstance, &lpdid, NULL); + + if (lpCallback(&didevis[i], lpdid, callbackFlags, --remain, pvRef) == DIENUM_STOP) + { + HeapFree(GetProcessHeap(), 0, didevis); + return DI_OK; + } + } + + HeapFree(GetProcessHeap(), 0, didevis); + if (dwFlags & DIEDBSFL_FORCEFEEDBACK) return DI_OK; /* Enumerate keyboard and mouse */ diff --git a/reactos/dll/directx/wine/dinput/effect_linuxinput.c b/reactos/dll/directx/wine/dinput/effect_linuxinput.c index d3fede596bd..7477bc757da 100644 --- a/reactos/dll/directx/wine/dinput/effect_linuxinput.c +++ b/reactos/dll/directx/wine/dinput/effect_linuxinput.c @@ -234,11 +234,16 @@ static HRESULT WINAPI LinuxInputEffectImpl_GetEffectStatus( LPDIRECTINPUTEFFECT iface, LPDWORD pdwFlags) { - TRACE("(this=%p,%p)\n", iface, pdwFlags); + LinuxInputEffectImpl *This = impl_from_IDirectInputEffect(iface); + + TRACE("(this=%p,%p)\n", This, pdwFlags); if (!pdwFlags) return E_POINTER; + if (This->effect.id == -1) + return DIERR_NOTDOWNLOADED; + /* linux sends the effect status through an event. * that event is trapped by our parent joystick driver * and there is no clean way to pass it back to us. */ @@ -633,9 +638,9 @@ static HRESULT WINAPI LinuxInputEffectImpl_SetParameters( This->effect.u.periodic.magnitude = (tsp->dwMagnitude / 10) * 32; This->effect.u.periodic.offset = (tsp->lOffset / 10) * 32; - /* phase ranges from 0 - 35999 in dinput and 0 - 65535 on linux */ + /* phase ranges from 0 - 35999 in dinput and 0 - 65535 on Linux */ This->effect.u.periodic.phase = (tsp->dwPhase / 36) * 65; - /* dinput uses microseconds, linux uses miliseconds */ + /* dinput uses microseconds, Linux uses milliseconds */ if (tsp->dwPeriod <= 1000) This->effect.u.periodic.period = 1; else diff --git a/reactos/dll/directx/wine/dinput/joystick_linuxinput.c b/reactos/dll/directx/wine/dinput/joystick_linuxinput.c index a962b561d1d..2cd01e831a1 100644 --- a/reactos/dll/directx/wine/dinput/joystick_linuxinput.c +++ b/reactos/dll/directx/wine/dinput/joystick_linuxinput.c @@ -69,6 +69,8 @@ HRESULT linuxinput_create_effect(int* fd, REFGUID rguid, struct list *parent_lis HRESULT linuxinput_get_info_A(int fd, REFGUID rguid, LPDIEFFECTINFOA info); HRESULT linuxinput_get_info_W(int fd, REFGUID rguid, LPDIEFFECTINFOW info); +static HRESULT WINAPI JoystickWImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8W iface, DWORD dwFlags); + typedef struct JoystickImpl JoystickImpl; static const IDirectInputDevice8AVtbl JoystickAvt; static const IDirectInputDevice8WVtbl JoystickWvt; @@ -726,18 +728,10 @@ static HRESULT WINAPI JoystickWImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface) TRACE("(this=%p)\n",This); res = IDirectInputDevice2WImpl_Unacquire(iface); if (res==DI_OK && This->joyfd!=-1) { - effect_list_item *itr; struct input_event event; - /* For each known effect: - * - stop it - * - unload it - * But, unlike DISFFC_RESET, do not release the effect. - */ - LIST_FOR_EACH_ENTRY(itr, &This->ff_effects, effect_list_item, entry) { - IDirectInputEffect_Stop(itr->ref); - IDirectInputEffect_Unload(itr->ref); - } + /* Stop and unload all effects */ + JoystickWImpl_SendForceFeedbackCommand(iface, DISFFC_RESET); /* Enable autocenter. */ event.type = EV_FF; @@ -883,7 +877,7 @@ static void joy_polldev(LPDIRECTINPUTDEVICE8A iface) break; #endif default: - FIXME("joystick cannot handle type %d event (code %d)\n",ie.type,ie.code); + TRACE("skipping event\n"); break; } if (inst_id >= 0) @@ -1312,9 +1306,9 @@ static HRESULT WINAPI JoystickWImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE { case DISFFC_STOPALL: { - /* Stop all effects */ effect_list_item *itr; + /* Stop all effects */ LIST_FOR_EACH_ENTRY(itr, &This->ff_effects, effect_list_item, entry) IDirectInputEffect_Stop(itr->ref); break; @@ -1322,17 +1316,19 @@ static HRESULT WINAPI JoystickWImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE case DISFFC_RESET: { - effect_list_item *itr, *ptr; + effect_list_item *itr; - /* Stop, unload, release and free all effects */ - /* This returns the device to its "bare" state */ - LIST_FOR_EACH_ENTRY_SAFE(itr, ptr, &This->ff_effects, effect_list_item, entry) - IDirectInputEffect_Release(itr->ref); + /* Stop and unload all effects. It is not true that effects are released */ + LIST_FOR_EACH_ENTRY(itr, &This->ff_effects, effect_list_item, entry) + { + IDirectInputEffect_Stop(itr->ref); + IDirectInputEffect_Unload(itr->ref); + } break; } case DISFFC_PAUSE: case DISFFC_CONTINUE: - FIXME("No support for Pause or Continue in linux\n"); + FIXME("No support for Pause or Continue in linux\n"); break; case DISFFC_SETACTUATORSOFF: @@ -1341,8 +1337,8 @@ static HRESULT WINAPI JoystickWImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE break; default: - FIXME("Unknown Force Feedback Command!\n"); - return DIERR_INVALIDPARAM; + WARN("Unknown Force Feedback Command %u!\n", dwFlags); + return DIERR_INVALIDPARAM; } return DI_OK; #else diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index da0148702a6..62ec23669b1 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -30,7 +30,7 @@ reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to WineStaging-1.9.4 reactos/dll/directx/wine/d3dxof # Synced to WineStaging-1.9.23 reactos/dll/directx/wine/ddraw # Synced to WineStaging-1.9.4 reactos/dll/directx/wine/devenum # Synced to WineStaging-1.9.23 -reactos/dll/directx/wine/dinput # Synced to WineStaging-1.9.23 +reactos/dll/directx/wine/dinput # Synced to WineStaging-2.2 reactos/dll/directx/wine/dinput8 # Synced to WineStaging-1.9.23 reactos/dll/directx/wine/dmusic # Synced to WineStaging-1.9.23 reactos/dll/directx/wine/dplay # Synced to WineStaging-1.9.23