Rémi Bernon : winebus.sys: Add support for PID effect gain.

Alexandre Julliard julliard at winehq.org
Thu May 19 16:15:12 CDT 2022


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

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Fri Apr 29 17:56:02 2022 +0200

winebus.sys: Add support for PID effect gain.

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      | 8 ++++----
 dlls/winebus.sys/bus_udev.c     | 8 ++++----
 dlls/winebus.sys/hid.c          | 9 +++++++++
 dlls/winebus.sys/unix_private.h | 1 +
 4 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c
index a1e7942fe59..a5621972493 100644
--- a/dlls/winebus.sys/bus_sdl.c
+++ b/dlls/winebus.sys/bus_sdl.c
@@ -647,7 +647,7 @@ static NTSTATUS sdl_device_physical_effect_update(struct unix_device *iface, BYT
         effect.periodic.direction.dir[0] = direction;
         effect.periodic.direction.dir[1] = params->direction[1];
         effect.periodic.period = params->periodic.period;
-        effect.periodic.magnitude = params->periodic.magnitude;
+        effect.periodic.magnitude = (params->periodic.magnitude * params->gain_percent) / 100;
         effect.periodic.offset = params->periodic.offset;
         effect.periodic.phase = params->periodic.phase;
         effect.periodic.attack_length = params->envelope.attack_time;
@@ -695,7 +695,7 @@ static NTSTATUS sdl_device_physical_effect_update(struct unix_device *iface, BYT
         effect.constant.direction.type = SDL_HAPTIC_SPHERICAL;
         effect.constant.direction.dir[0] = direction;
         effect.constant.direction.dir[1] = params->direction[1];
-        effect.constant.level = params->constant_force.magnitude;
+        effect.constant.level = (params->constant_force.magnitude * params->gain_percent) / 100;
         effect.constant.attack_length = params->envelope.attack_time;
         effect.constant.attack_level = params->envelope.attack_level;
         effect.constant.fade_length = params->envelope.fade_time;
@@ -712,8 +712,8 @@ static NTSTATUS sdl_device_physical_effect_update(struct unix_device *iface, BYT
         effect.ramp.direction.type = SDL_HAPTIC_SPHERICAL;
         effect.ramp.direction.dir[0] = params->direction[0];
         effect.ramp.direction.dir[1] = params->direction[1];
-        effect.ramp.start = params->ramp_force.ramp_start;
-        effect.ramp.end = params->ramp_force.ramp_end;
+        effect.ramp.start = (params->ramp_force.ramp_start * params->gain_percent) / 100;
+        effect.ramp.end = (params->ramp_force.ramp_end * params->gain_percent) / 100;
         effect.ramp.attack_length = params->envelope.attack_time;
         effect.ramp.attack_level = params->envelope.attack_level;
         effect.ramp.fade_length = params->envelope.fade_time;
diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c
index 39573162afa..21a70d0829b 100644
--- a/dlls/winebus.sys/bus_udev.c
+++ b/dlls/winebus.sys/bus_udev.c
@@ -1138,7 +1138,7 @@ static NTSTATUS lnxev_device_physical_effect_update(struct unix_device *iface, B
     case PID_USAGE_ET_SAWTOOTH_UP:
     case PID_USAGE_ET_SAWTOOTH_DOWN:
         effect.u.periodic.period = params->periodic.period;
-        effect.u.periodic.magnitude = params->periodic.magnitude;
+        effect.u.periodic.magnitude = (params->periodic.magnitude * params->gain_percent) / 100;
         effect.u.periodic.offset = params->periodic.offset;
         effect.u.periodic.phase = params->periodic.phase * 0x800 / 1125;
         effect.u.periodic.envelope.attack_length = params->envelope.attack_time;
@@ -1172,7 +1172,7 @@ static NTSTATUS lnxev_device_physical_effect_update(struct unix_device *iface, B
         break;
 
     case PID_USAGE_ET_CONSTANT_FORCE:
-        effect.u.constant.level = params->constant_force.magnitude;
+        effect.u.constant.level = (params->constant_force.magnitude * params->gain_percent) / 100;
         effect.u.constant.envelope.attack_length = params->envelope.attack_time;
         effect.u.constant.envelope.attack_level = params->envelope.attack_level;
         effect.u.constant.envelope.fade_length = params->envelope.fade_time;
@@ -1180,8 +1180,8 @@ static NTSTATUS lnxev_device_physical_effect_update(struct unix_device *iface, B
         break;
 
     case PID_USAGE_ET_RAMP:
-        effect.u.ramp.start_level = params->ramp_force.ramp_start;
-        effect.u.ramp.end_level = params->ramp_force.ramp_end;
+        effect.u.ramp.start_level = (params->ramp_force.ramp_start * params->gain_percent) / 100;
+        effect.u.ramp.end_level = (params->ramp_force.ramp_end * params->gain_percent) / 100;
         effect.u.ramp.envelope.attack_length = params->envelope.attack_time;
         effect.u.ramp.envelope.attack_level = params->envelope.attack_level;
         effect.u.ramp.envelope.fade_length = params->envelope.fade_time;
diff --git a/dlls/winebus.sys/hid.c b/dlls/winebus.sys/hid.c
index de0c3bb0848..8ed8c752893 100644
--- a/dlls/winebus.sys/hid.c
+++ b/dlls/winebus.sys/hid.c
@@ -487,6 +487,7 @@ struct pid_effect_update
     UINT16 trigger_repeat_interval;
     UINT16 sample_period;
     UINT16 start_delay;
+    BYTE gain_percent;
     BYTE trigger_button;
     BYTE enable_bits;
     UINT16 direction[2];
@@ -909,6 +910,13 @@ BOOL hid_device_add_physical(struct unix_device *iface, USAGE *usages, USHORT co
             UNIT_EXPONENT(1, 0),
             UNIT(1, 0), /* None */
 
+            USAGE(1, PID_USAGE_GAIN),
+            LOGICAL_MINIMUM(1, 0),
+            LOGICAL_MAXIMUM(1, 100),
+            REPORT_SIZE(1, 8),
+            REPORT_COUNT(1, 1),
+            OUTPUT(1, Data|Var|Abs|Null),
+
             USAGE(1, PID_USAGE_TRIGGER_BUTTON),
             LOGICAL_MINIMUM(1, 0),
             LOGICAL_MAXIMUM(2, state->button_count),
@@ -1181,6 +1189,7 @@ static void hid_device_set_output_report(struct unix_device *iface, HID_XFER_PAC
             params->trigger_repeat_interval = report->trigger_repeat_interval;
             params->sample_period = report->sample_period;
             params->start_delay = report->start_delay;
+            params->gain_percent = report->gain_percent;
             params->trigger_button = report->trigger_button == 0xff ? 0 : report->trigger_button;
             params->axis_enabled[0] = (report->enable_bits & 1) != 0;
             params->axis_enabled[1] = (report->enable_bits & 2) != 0;
diff --git a/dlls/winebus.sys/unix_private.h b/dlls/winebus.sys/unix_private.h
index ab8060611a4..f94a243d887 100644
--- a/dlls/winebus.sys/unix_private.h
+++ b/dlls/winebus.sys/unix_private.h
@@ -78,6 +78,7 @@ struct effect_params
     BOOL axis_enabled[2];
     BOOL direction_enabled;
     UINT16 direction[2];
+    BYTE gain_percent;
     BYTE condition_count;
     /* only for periodic, constant or ramp forces */
     struct effect_envelope envelope;




More information about the wine-cvs mailing list