Andrew Eikum : winebus.sys: Add missing padding between hatswitch and constant.

Alexandre Julliard julliard at winehq.org
Mon May 20 15:50:48 CDT 2019


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

Author: Andrew Eikum <aeikum at codeweavers.com>
Date:   Mon May 20 10:31:06 2019 -0500

winebus.sys: Add missing padding between hatswitch and constant.

Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winebus.sys/bus_sdl.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c
index d79c200..2b367e5 100644
--- a/dlls/winebus.sys/bus_sdl.c
+++ b/dlls/winebus.sys/bus_sdl.c
@@ -548,19 +548,23 @@ static BOOL build_mapped_report_descriptor(struct platform_private *ext)
     BYTE *report_ptr;
     INT i, descript_size;
 
+    static const int BUTTON_BIT_COUNT = CONTROLLER_NUM_BUTTONS + CONTROLLER_NUM_HATSWITCHES * 4;
+
     descript_size = sizeof(REPORT_HEADER) + sizeof(REPORT_TAIL);
     descript_size += sizeof(CONTROLLER_AXIS);
     descript_size += sizeof(CONTROLLER_TRIGGERS);
     descript_size += sizeof(CONTROLLER_BUTTONS);
     descript_size += sizeof(REPORT_HATSWITCH);
     descript_size += sizeof(REPORT_PADDING);
+    if (BUTTON_BIT_COUNT % 8 != 0)
+        descript_size += sizeof(REPORT_PADDING);
     descript_size += test_haptic(ext);
 
     ext->axis_start = 0;
     ext->button_start = CONTROLLER_NUM_AXES * sizeof(WORD);
     ext->hat_bit_offs = CONTROLLER_NUM_BUTTONS;
 
-    ext->buffer_length = (CONTROLLER_NUM_BUTTONS + CONTROLLER_NUM_HATSWITCHES * 4 + 7) / 8
+    ext->buffer_length = (BUTTON_BIT_COUNT + 7) / 8
         + CONTROLLER_NUM_AXES * sizeof(WORD)
         + 2/* unknown constant*/;
 
@@ -586,6 +590,8 @@ static BOOL build_mapped_report_descriptor(struct platform_private *ext)
     memcpy(report_ptr, CONTROLLER_BUTTONS, sizeof(CONTROLLER_BUTTONS));
     report_ptr += sizeof(CONTROLLER_BUTTONS);
     report_ptr = add_hatswitch(report_ptr, 1);
+    if (BUTTON_BIT_COUNT % 8 != 0)
+        report_ptr = add_padding_block(report_ptr, 8 - (BUTTON_BIT_COUNT % 8));/* unused bits between hatswitch and following constant */
     report_ptr = add_padding_block(report_ptr, 16);/* unknown constant */
     report_ptr += build_haptic(ext, report_ptr);
     memcpy(report_ptr, REPORT_TAIL, sizeof(REPORT_TAIL));
@@ -606,8 +612,8 @@ static BOOL build_mapped_report_descriptor(struct platform_private *ext)
     set_hat_value(ext, 0, compose_dpad_value(ext->sdl_controller));
 
     /* unknown constant */
-    ext->report_buffer[12] = 0x89;
-    ext->report_buffer[13] = 0xc5;
+    ext->report_buffer[14] = 0x89;
+    ext->report_buffer[15] = 0xc5;
 
     return TRUE;
 }




More information about the wine-cvs mailing list