diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index d79c2004c89..2b367e5794a 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; }