Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 68db935c44a..4987a9f9872 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -1226,24 +1226,23 @@ static HRESULT hid_joystick_read( IDirectInputDevice8W *iface ) BOOL ret;
ret = GetOverlappedResult( impl->device, &impl->read_ovl, &count, FALSE ); - if (ret && TRACE_ON(dinput)) - { - TRACE( "read size %lu report:\n", count ); - for (i = 0; i < count;) - { - char buffer[256], *buf = buffer; - buf += sprintf(buf, "%08lx ", i); - do - { - buf += sprintf(buf, " %02x", (BYTE)report_buf[i] ); - } while (++i % 16 && i < count); - TRACE("%s\n", buffer); - } - }
EnterCriticalSection( &impl->base.crit ); while (ret) { + if (TRACE_ON(dinput)) + { + TRACE( "iface %p, size %lu, report:\n", iface, count ); + for (i = 0; i < count;) + { + char buffer[256], *buf = buffer; + buf += sprintf(buf, "%08lx ", i); + do { buf += sprintf(buf, " %02x", (BYTE)report_buf[i] ); } + while (++i % 16 && i < count); + TRACE("%s\n", buffer); + } + } + count = impl->usages_count; memset( impl->usages_buf, 0, count * sizeof(*impl->usages_buf) ); status = HidP_GetUsagesEx( HidP_Input, 0, impl->usages_buf, &count,
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 4987a9f9872..13c168bca89 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -1273,7 +1273,7 @@ static HRESULT hid_joystick_read( IDirectInputDevice8W *iface ) if (impl->base.hEvent && memcmp( ¶ms.old_state, impl->base.device_state, format->dwDataSize )) SetEvent( impl->base.hEvent ); } - else if (report_buf[0] == impl->pid_effect_state.id) + else if (report_buf[0] == impl->pid_effect_state.id && is_exclusively_acquired( impl )) { status = HidP_GetUsageValue( HidP_Input, HID_USAGE_PAGE_PID, 0, PID_USAGE_EFFECT_BLOCK_INDEX, &index, impl->preparsed, report_buf, report_len );
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 13c168bca89..ee67c904fa5 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -1279,7 +1279,6 @@ static HRESULT hid_joystick_read( IDirectInputDevice8W *iface ) &index, impl->preparsed, report_buf, report_len ); if (status != HIDP_STATUS_SUCCESS) WARN( "HidP_GetUsageValue EFFECT_BLOCK_INDEX returned %#lx\n", status );
- EnterCriticalSection( &impl->base.crit ); effect_state = 0; device_state = impl->base.force_feedback_state & DIGFFS_EMPTY; while (count--) @@ -1308,7 +1307,6 @@ static HRESULT hid_joystick_read( IDirectInputDevice8W *iface ) LIST_FOR_EACH_ENTRY( effect, &impl->effect_list, struct hid_joystick_effect, entry ) if (effect->index == index) effect->status = effect_state; impl->base.force_feedback_state = device_state; - LeaveCriticalSection( &impl->base.crit ); }
memset( &impl->read_ovl, 0, sizeof(impl->read_ovl) );
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index ee67c904fa5..00fd01b483a 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -163,6 +163,9 @@ struct pid_effect_state { BYTE id; UINT collection; + struct hid_value_caps *safety_switch_caps; + struct hid_value_caps *actuator_power_caps; + struct hid_value_caps *actuator_override_switch_caps; };
struct hid_joystick @@ -1298,9 +1301,12 @@ static HRESULT hid_joystick_read( IDirectInputDevice8W *iface ) } } if (!(device_state & DIGFFS_ACTUATORSON)) device_state |= DIGFFS_ACTUATORSOFF; - if (!(device_state & DIGFFS_SAFETYSWITCHON)) device_state |= DIGFFS_SAFETYSWITCHOFF; - if (!(device_state & DIGFFS_USERFFSWITCHON)) device_state |= DIGFFS_USERFFSWITCHOFF; - if (!(device_state & DIGFFS_POWERON)) device_state |= DIGFFS_POWEROFF; + if (!(device_state & DIGFFS_SAFETYSWITCHON) && impl->pid_effect_state.safety_switch_caps) + device_state |= DIGFFS_SAFETYSWITCHOFF; + if (!(device_state & DIGFFS_USERFFSWITCHON) && impl->pid_effect_state.actuator_override_switch_caps) + device_state |= DIGFFS_USERFFSWITCHOFF; + if (!(device_state & DIGFFS_POWERON) && impl->pid_effect_state.actuator_power_caps) + device_state |= DIGFFS_POWEROFF;
TRACE( "effect %lu state %#x, device state %#x\n", index, effect_state, device_state );
@@ -1772,7 +1778,15 @@ static BOOL init_pid_caps( struct hid_joystick *impl, struct hid_value_caps *cap return DIENUM_CONTINUE;
if (instance->wCollectionNumber == effect_state->collection) + { SET_REPORT_ID( effect_state ); + if (instance->wUsage == PID_USAGE_SAFETY_SWITCH) + effect_state->safety_switch_caps = caps; + if (instance->wUsage == PID_USAGE_ACTUATOR_POWER) + effect_state->actuator_power_caps = caps; + if (instance->wUsage == PID_USAGE_ACTUATOR_OVERRIDE_SWITCH) + effect_state->actuator_override_switch_caps = caps; + }
if (!(instance->dwType & DIDFT_OUTPUT)) return DIENUM_CONTINUE;