Ivo Ivanov : winebus.sys: Support arbitrary effect parameter updates.

Alexandre Julliard julliard at winehq.org
Mon Nov 22 16:05:17 CST 2021


Module: wine
Branch: master
Commit: 31a668439b95b93424a3c6bc3c2c05f702ce49e5
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=31a668439b95b93424a3c6bc3c2c05f702ce49e5

Author: Ivo Ivanov <logos128 at gmail.com>
Date:   Mon Nov 22 11:05:47 2021 +0100

winebus.sys: Support arbitrary effect parameter updates.

DInput will only send the output reports that have been modified, we
need to support sparse effect updates.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52061
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winebus.sys/bus_sdl.c  |  1 +
 dlls/winebus.sys/bus_udev.c |  1 +
 dlls/winebus.sys/hid.c      | 21 ++++++++++++++++++---
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c
index e3932e31ff5..003f6652f05 100644
--- a/dlls/winebus.sys/bus_sdl.c
+++ b/dlls/winebus.sys/bus_sdl.c
@@ -569,6 +569,7 @@ static NTSTATUS sdl_device_physical_effect_update(struct unix_device *iface, BYT
 
     TRACE("iface %p, index %u, params %p.\n", iface, index, params);
 
+    if (params->effect_type == PID_USAGE_UNDEFINED) return STATUS_SUCCESS;
     if ((status = set_effect_type_from_usage(&effect, params->effect_type))) return status;
 
     switch (params->effect_type)
diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c
index 3a7a5db723d..521ae4192b5 100644
--- a/dlls/winebus.sys/bus_udev.c
+++ b/dlls/winebus.sys/bus_udev.c
@@ -1024,6 +1024,7 @@ static NTSTATUS lnxev_device_physical_effect_update(struct unix_device *iface, B
 
     TRACE("iface %p, index %u, params %p.\n", iface, index, params);
 
+    if (params->effect_type == PID_USAGE_UNDEFINED) return STATUS_SUCCESS;
     if ((status = set_effect_type_from_usage(&effect, params->effect_type))) return status;
 
     effect.replay.length = params->duration;
diff --git a/dlls/winebus.sys/hid.c b/dlls/winebus.sys/hid.c
index 56f30338481..beb2ebe8ad9 100644
--- a/dlls/winebus.sys/hid.c
+++ b/dlls/winebus.sys/hid.c
@@ -1033,7 +1033,11 @@ static void hid_device_set_output_report(struct unix_device *iface, HID_XFER_PAC
         else if (!(control = pid_device_control_usages[report->control_index]))
             io->Status = STATUS_INVALID_PARAMETER;
         else
+        {
             io->Status = iface->hid_vtbl->physical_device_control(iface, control);
+            if (control == PID_USAGE_DC_DEVICE_RESET && io->Status == STATUS_SUCCESS)
+                memset(physical->effect_params, 0, sizeof(physical->effect_params));
+        }
     }
     else if (packet->reportId == physical->device_gain_report)
     {
@@ -1088,8 +1092,6 @@ static void hid_device_set_output_report(struct unix_device *iface, HID_XFER_PAC
             params->direction[1] = report->direction[1];
 
             io->Status = iface->hid_vtbl->physical_effect_update(iface, report->index, params);
-
-            params->condition_count = 0;
         }
     }
     else if (packet->reportId == physical->set_periodic_report)
@@ -1106,6 +1108,8 @@ static void hid_device_set_output_report(struct unix_device *iface, HID_XFER_PAC
             params->periodic.offset = report->offset;
             params->periodic.phase = report->phase;
             params->periodic.period = report->period;
+
+            io->Status = iface->hid_vtbl->physical_effect_update(iface, report->index, params);
         }
     }
     else if (packet->reportId == physical->set_envelope_report)
@@ -1122,6 +1126,8 @@ static void hid_device_set_output_report(struct unix_device *iface, HID_XFER_PAC
             params->envelope.fade_level = report->fade_level;
             params->envelope.attack_time = report->attack_time;
             params->envelope.fade_time = report->fade_time;
+
+            io->Status = iface->hid_vtbl->physical_effect_update(iface, report->index, params);
         }
     }
     else if (packet->reportId == physical->set_condition_report)
@@ -1134,10 +1140,11 @@ static void hid_device_set_output_report(struct unix_device *iface, HID_XFER_PAC
         io->Information = sizeof(*report) + 1;
         if (packet->reportBufferLen < io->Information)
             io->Status = STATUS_BUFFER_TOO_SMALL;
-        else if ((index = params->condition_count++) >= ARRAY_SIZE(params->condition))
+        else if ((index = report->condition_index) >= ARRAY_SIZE(params->condition))
             io->Status = STATUS_INVALID_PARAMETER;
         else
         {
+            if (params->condition_count <= index) params->condition_count = index + 1;
             condition = params->condition + index;
             condition->center_point_offset = report->center_point_offset;
             condition->positive_coefficient = report->positive_coefficient;
@@ -1145,6 +1152,8 @@ static void hid_device_set_output_report(struct unix_device *iface, HID_XFER_PAC
             condition->positive_saturation = report->positive_saturation;
             condition->negative_saturation = report->negative_saturation;
             condition->dead_band = report->dead_band;
+
+            io->Status = iface->hid_vtbl->physical_effect_update(iface, report->index, params);
         }
     }
     else if (packet->reportId == physical->set_constant_force_report)
@@ -1156,7 +1165,11 @@ static void hid_device_set_output_report(struct unix_device *iface, HID_XFER_PAC
         if (packet->reportBufferLen < io->Information)
             io->Status = STATUS_BUFFER_TOO_SMALL;
         else
+        {
             params->constant_force.magnitude = report->magnitude;
+
+            io->Status = iface->hid_vtbl->physical_effect_update(iface, report->index, params);
+        }
     }
     else if (packet->reportId == physical->set_ramp_force_report)
     {
@@ -1170,6 +1183,8 @@ static void hid_device_set_output_report(struct unix_device *iface, HID_XFER_PAC
         {
             params->ramp_force.ramp_start = report->ramp_start;
             params->ramp_force.ramp_end = report->ramp_end;
+
+            io->Status = iface->hid_vtbl->physical_effect_update(iface, report->index, params);
         }
     }
     else




More information about the wine-cvs mailing list