Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
2bd3c970
Commit
2bd3c970
authored
Jun 07, 2021
by
Rémi Bernon
Committed by
Alexandre Julliard
Jun 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xinput1_3: Allocate output report buffer on the heap.
Signed-off-by:
Rémi Bernon
<
rbernon@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
cfb24768
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
16 deletions
+13
-16
hid.c
dlls/xinput1_3/hid.c
+13
-16
No files found.
dlls/xinput1_3/hid.c
View file @
2bd3c970
...
...
@@ -64,6 +64,7 @@ struct hid_platform_private {
BOOL
enabled
;
char
*
input_report_buf
[
2
];
char
*
output_report_buf
;
struct
axis_info
lx
,
ly
,
ltrigger
,
rx
,
ry
,
rtrigger
;
};
...
...
@@ -185,6 +186,7 @@ static BOOL init_controller(xinput_controller *controller, PHIDP_PREPARSED_DATA
private
->
device
=
device
;
if
(
!
(
private
->
input_report_buf
[
0
]
=
calloc
(
1
,
private
->
caps
.
InputReportByteLength
)))
goto
failed
;
if
(
!
(
private
->
input_report_buf
[
1
]
=
calloc
(
1
,
private
->
caps
.
InputReportByteLength
)))
goto
failed
;
if
(
!
(
private
->
output_report_buf
=
calloc
(
1
,
private
->
caps
.
OutputReportByteLength
)))
goto
failed
;
size
=
(
lstrlenW
(
device_path
)
+
1
)
*
sizeof
(
WCHAR
);
if
(
!
(
private
->
device_path
=
malloc
(
size
)))
goto
failed
;
memcpy
(
private
->
device_path
,
device_path
,
size
);
...
...
@@ -200,6 +202,7 @@ failed:
free
(
private
->
device_path
);
free
(
private
->
input_report_buf
[
0
]);
free
(
private
->
input_report_buf
[
1
]);
free
(
private
->
output_report_buf
);
free
(
private
);
return
FALSE
;
}
...
...
@@ -311,6 +314,7 @@ static void remove_gamepad(xinput_controller *device)
CloseHandle
(
private
->
device
);
free
(
private
->
input_report_buf
[
0
]);
free
(
private
->
input_report_buf
[
1
]);
free
(
private
->
output_report_buf
);
free
(
private
->
device_path
);
HidD_FreePreparsedData
(
private
->
ppd
);
free
(
private
);
...
...
@@ -460,14 +464,8 @@ void HID_update_state(xinput_controller *device, XINPUT_STATE *state)
DWORD
HID_set_state
(
xinput_controller
*
device
,
XINPUT_VIBRATION
*
state
)
{
struct
hid_platform_private
*
private
=
device
->
platform_private
;
struct
{
BYTE
report
;
BYTE
pad1
[
2
];
BYTE
left
;
BYTE
right
;
BYTE
pad2
[
3
];
}
report
;
char
*
output_report_buf
=
private
->
output_report_buf
;
ULONG
output_report_len
=
private
->
caps
.
OutputReportByteLength
;
if
(
device
->
caps
.
Flags
&
XINPUT_CAPS_FFB_SUPPORTED
)
{
...
...
@@ -476,14 +474,13 @@ DWORD HID_set_state(xinput_controller* device, XINPUT_VIBRATION* state)
if
(
private
->
enabled
)
{
report
.
report
=
0
;
report
.
pad1
[
0
]
=
0x8
;
report
.
pad1
[
1
]
=
0x0
;
report
.
left
=
(
BYTE
)(
state
->
wLeftMotorSpeed
/
256
);
report
.
right
=
(
BYTE
)(
state
->
wRightMotorSpeed
/
256
);
memset
(
&
report
.
pad2
,
0
,
sizeof
(
report
.
pad2
));
if
(
!
HidD_SetOutputReport
(
private
->
device
,
&
report
,
sizeof
(
report
)))
memset
(
output_report_buf
,
0
,
output_report_len
);
output_report_buf
[
0
]
=
/* report id */
0
;
output_report_buf
[
1
]
=
0x8
;
output_report_buf
[
3
]
=
(
BYTE
)(
state
->
wLeftMotorSpeed
/
256
);
output_report_buf
[
4
]
=
(
BYTE
)(
state
->
wRightMotorSpeed
/
256
);
if
(
!
HidD_SetOutputReport
(
private
->
device
,
output_report_buf
,
output_report_len
))
{
WARN
(
"unable to set output report, HidD_SetOutputReport failed with error %u
\n
"
,
GetLastError
());
return
GetLastError
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment