Rémi Bernon : winebus.sys: Add a PID device gain output report.

Alexandre Julliard julliard at winehq.org
Wed Nov 17 16:27:57 CST 2021


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

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Wed Nov 17 11:51:50 2021 +0100

winebus.sys: Add a PID device gain output report.

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          | 38 ++++++++++++++++++++++++++++++++++++++
 dlls/winebus.sys/unix_private.h |  2 ++
 dlls/winebus.sys/unixlib.c      | 12 ++++++++++++
 5 files changed, 68 insertions(+)

diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c
index 49afcbaf67c..48d5ad85a2b 100644
--- a/dlls/winebus.sys/bus_sdl.c
+++ b/dlls/winebus.sys/bus_sdl.c
@@ -480,6 +480,13 @@ static NTSTATUS sdl_device_physical_device_control(struct unix_device *iface, US
     return STATUS_NOT_SUPPORTED;
 }
 
+static NTSTATUS sdl_device_physical_device_set_gain(struct unix_device *iface, BYTE value)
+{
+    FIXME("iface %p, value %#x stub!\n", iface, value);
+
+    return STATUS_NOT_IMPLEMENTED;
+}
+
 static NTSTATUS sdl_device_physical_effect_control(struct unix_device *iface, BYTE index,
                                                    USAGE control, BYTE iterations)
 {
@@ -664,6 +671,7 @@ static const struct hid_device_vtbl sdl_device_vtbl =
     sdl_device_stop,
     sdl_device_haptics_start,
     sdl_device_physical_device_control,
+    sdl_device_physical_device_set_gain,
     sdl_device_physical_effect_control,
     sdl_device_physical_effect_update,
 };
diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c
index 5ff1719848d..74cfe486a03 100644
--- a/dlls/winebus.sys/bus_udev.c
+++ b/dlls/winebus.sys/bus_udev.c
@@ -924,6 +924,13 @@ static NTSTATUS lnxev_device_physical_device_control(struct unix_device *iface,
     return STATUS_NOT_SUPPORTED;
 }
 
+static NTSTATUS lnxev_device_physical_device_set_gain(struct unix_device *iface, BYTE value)
+{
+    FIXME("iface %p, value %#x stub!\n", iface, value);
+
+    return STATUS_NOT_IMPLEMENTED;
+}
+
 static NTSTATUS lnxev_device_physical_effect_control(struct unix_device *iface, BYTE index,
                                                      USAGE control, BYTE iterations)
 {
@@ -1095,6 +1102,7 @@ static const struct hid_device_vtbl lnxev_device_vtbl =
     lnxev_device_start,
     lnxev_device_stop,
     lnxev_device_haptics_start,
+    lnxev_device_physical_device_set_gain,
     lnxev_device_physical_device_control,
     lnxev_device_physical_effect_control,
     lnxev_device_physical_effect_update,
diff --git a/dlls/winebus.sys/hid.c b/dlls/winebus.sys/hid.c
index 893bf1cd7f6..6f22e0e81d8 100644
--- a/dlls/winebus.sys/hid.c
+++ b/dlls/winebus.sys/hid.c
@@ -412,6 +412,11 @@ static const USAGE pid_device_control_usages[] =
     PID_USAGE_DC_DEVICE_CONTINUE,
 };
 
+struct pid_device_gain
+{
+    BYTE value;
+};
+
 struct pid_effect_control
 {
     BYTE index;
@@ -741,6 +746,25 @@ BOOL hid_device_add_physical(struct unix_device *iface, USAGE *usages, USHORT co
         END_COLLECTION,
     };
 
+    const BYTE device_gain_report = ++desc->next_report_id[HidP_Output];
+    const BYTE device_gain[] =
+    {
+        USAGE_PAGE(1, HID_USAGE_PAGE_PID),
+        USAGE(1, PID_USAGE_DEVICE_GAIN_REPORT),
+        COLLECTION(1, Logical),
+            REPORT_ID(1, device_gain_report),
+
+            USAGE(1, PID_USAGE_DEVICE_GAIN),
+            LOGICAL_MINIMUM(1, 0),
+            LOGICAL_MAXIMUM(2, 0x00ff),
+            PHYSICAL_MINIMUM(1, 0),
+            PHYSICAL_MAXIMUM(2, 0x2710),
+            REPORT_SIZE(1, 8),
+            REPORT_COUNT(1, 1),
+            OUTPUT(1, Data|Var|Abs),
+        END_COLLECTION,
+    };
+
     const BYTE effect_control_report = ++desc->next_report_id[HidP_Output];
     const BYTE effect_control_header[] =
     {
@@ -882,6 +906,9 @@ BOOL hid_device_add_physical(struct unix_device *iface, USAGE *usages, USHORT co
     if (!hid_report_descriptor_append(desc, device_control_footer, sizeof(device_control_footer)))
         return FALSE;
 
+    if (!hid_report_descriptor_append(desc, device_gain, sizeof(device_gain)))
+        return FALSE;
+
     if (!hid_report_descriptor_append(desc, effect_control_header, sizeof(effect_control_header)))
         return FALSE;
     for (i = 1; i < ARRAY_SIZE(pid_effect_control_usages); ++i)
@@ -936,6 +963,7 @@ BOOL hid_device_add_physical(struct unix_device *iface, USAGE *usages, USHORT co
     memcpy(iface->hid_physical.effect_types + 1, usages, count * sizeof(*usages));
 
     iface->hid_physical.device_control_report = device_control_report;
+    iface->hid_physical.device_gain_report = device_gain_report;
     iface->hid_physical.effect_control_report = effect_control_report;
     iface->hid_physical.effect_update_report = effect_update_report;
     return TRUE;
@@ -1013,6 +1041,16 @@ static void hid_device_set_output_report(struct unix_device *iface, HID_XFER_PAC
         else
             io->Status = iface->hid_vtbl->physical_device_control(iface, control);
     }
+    else if (packet->reportId == physical->device_gain_report)
+    {
+        struct pid_device_gain *report = (struct pid_device_gain *)(packet->reportBuffer + 1);
+
+        io->Information = sizeof(*report) + 1;
+        if (packet->reportBufferLen < io->Information)
+            io->Status = STATUS_BUFFER_TOO_SMALL;
+        else
+            io->Status = iface->hid_vtbl->physical_device_set_gain(iface, report->value);
+    }
     else if (packet->reportId == physical->effect_control_report)
     {
         struct pid_effect_control *report = (struct pid_effect_control *)(packet->reportBuffer + 1);
diff --git a/dlls/winebus.sys/unix_private.h b/dlls/winebus.sys/unix_private.h
index 89a0c9abad9..ef574e48cee 100644
--- a/dlls/winebus.sys/unix_private.h
+++ b/dlls/winebus.sys/unix_private.h
@@ -109,6 +109,7 @@ struct hid_device_vtbl
     NTSTATUS (*haptics_start)(struct unix_device *iface, DWORD duration_ms,
                               USHORT rumble_intensity, USHORT buzz_intensity);
     NTSTATUS (*physical_device_control)(struct unix_device *iface, USAGE control);
+    NTSTATUS (*physical_device_set_gain)(struct unix_device *iface, BYTE value);
     NTSTATUS (*physical_effect_control)(struct unix_device *iface, BYTE index, USAGE control, BYTE iterations);
     NTSTATUS (*physical_effect_update)(struct unix_device *iface, BYTE index, struct effect_params *params);
 };
@@ -157,6 +158,7 @@ struct hid_physical
     struct effect_params effect_params[256];
 
     BYTE device_control_report;
+    BYTE device_gain_report;
     BYTE effect_control_report;
     BYTE effect_update_report;
     BYTE set_periodic_report;
diff --git a/dlls/winebus.sys/unixlib.c b/dlls/winebus.sys/unixlib.c
index 6cf58570c76..9d819bab7e3 100644
--- a/dlls/winebus.sys/unixlib.c
+++ b/dlls/winebus.sys/unixlib.c
@@ -106,6 +106,11 @@ static NTSTATUS mouse_physical_device_control(struct unix_device *iface, USAGE c
     return STATUS_NOT_SUPPORTED;
 }
 
+static NTSTATUS mouse_physical_device_set_gain(struct unix_device *iface, BYTE value)
+{
+    return STATUS_NOT_SUPPORTED;
+}
+
 static NTSTATUS mouse_physical_effect_control(struct unix_device *iface, BYTE index,
                                               USAGE control, BYTE iterations)
 {
@@ -125,6 +130,7 @@ static const struct hid_device_vtbl mouse_vtbl =
     mouse_stop,
     mouse_haptics_start,
     mouse_physical_device_control,
+    mouse_physical_device_set_gain,
     mouse_physical_effect_control,
     mouse_physical_effect_update,
 };
@@ -183,6 +189,11 @@ static NTSTATUS keyboard_physical_device_control(struct unix_device *iface, USAG
     return STATUS_NOT_SUPPORTED;
 }
 
+static NTSTATUS keyboard_physical_device_set_gain(struct unix_device *iface, BYTE value)
+{
+    return STATUS_NOT_SUPPORTED;
+}
+
 static NTSTATUS keyboard_physical_effect_control(struct unix_device *iface, BYTE index,
                                                  USAGE control, BYTE iterations)
 {
@@ -202,6 +213,7 @@ static const struct hid_device_vtbl keyboard_vtbl =
     keyboard_stop,
     keyboard_haptics_start,
     keyboard_physical_device_control,
+    keyboard_physical_device_set_gain,
     keyboard_physical_effect_control,
     keyboard_physical_effect_update,
 };




More information about the wine-cvs mailing list