Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
cda4abac
Commit
cda4abac
authored
May 04, 2021
by
Rémi Bernon
Committed by
Alexandre Julliard
May 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32: Refactor and simplify GetRawInputDeviceInfoW cases.
Signed-off-by:
Rémi Bernon
<
rbernon@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
82211cd4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
35 deletions
+13
-35
rawinput.c
dlls/user32/rawinput.c
+13
-35
No files found.
dlls/user32/rawinput.c
View file @
cda4abac
...
...
@@ -686,8 +686,7 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE handle, UINT command, void *data, UINT
{
RID_DEVICE_INFO
info
;
struct
device
*
device
;
const
void
*
to_copy
;
UINT
to_copy_bytes
,
avail_bytes
;
DWORD
len
,
data_len
;
TRACE
(
"handle %p, command %#x, data %p, data_size %p.
\n
"
,
handle
,
command
,
data
,
data_size
);
...
...
@@ -703,45 +702,26 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE handle, UINT command, void *data, UINT
return
~
0U
;
}
/* each case below must set:
* *data_size: length (meaning defined by command) of data we want to copy
* avail_bytes: number of bytes available in user buffer
* to_copy_bytes: number of bytes we want to copy into user buffer
* to_copy: pointer to data we want to copy into user buffer
*/
data_len
=
*
data_size
;
switch
(
command
)
{
case
RIDI_DEVICENAME
:
/* for RIDI_DEVICENAME, data_size is in characters, not bytes */
avail_bytes
=
*
data_size
*
sizeof
(
WCHAR
);
*
data_size
=
wcslen
(
device
->
detail
->
DevicePath
)
+
1
;
to_copy
=
device
->
detail
->
DevicePath
;
to_copy_bytes
=
*
data_size
*
sizeof
(
WCHAR
);
if
((
len
=
wcslen
(
device
->
detail
->
DevicePath
)
+
1
)
<=
data_len
&&
data
)
memcpy
(
data
,
device
->
detail
->
DevicePath
,
len
*
sizeof
(
WCHAR
));
*
data_size
=
len
;
break
;
case
RIDI_DEVICEINFO
:
avail_bytes
=
*
data_size
;
info
.
cbSize
=
sizeof
(
info
);
info
=
device
->
info
;
to_copy_bytes
=
sizeof
(
info
);
*
data_size
=
to_copy_bytes
;
to_copy
=
&
info
;
if
((
len
=
sizeof
(
info
))
<=
data_len
&&
data
)
memcpy
(
data
,
&
device
->
info
,
len
);
*
data_size
=
len
;
break
;
case
RIDI_PREPARSEDDATA
:
avail_bytes
=
*
data_size
;
if
(
device
->
info
.
dwType
!=
RIM_TYPEHID
)
{
to_copy_bytes
=
0
;
*
data_size
=
0
;
to_copy
=
NULL
;
}
else
{
to_copy_bytes
=
((
WINE_HIDP_PREPARSED_DATA
*
)
device
->
data
)
->
dwSize
;
*
data_size
=
to_copy_bytes
;
to_copy
=
device
->
data
;
}
len
=
device
->
data
?
((
WINE_HIDP_PREPARSED_DATA
*
)
device
->
data
)
->
dwSize
:
0
;
if
(
device
->
data
&&
len
<=
data_len
&&
data
)
memcpy
(
data
,
device
->
data
,
len
);
*
data_size
=
len
;
break
;
default:
...
...
@@ -753,14 +733,12 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE handle, UINT command, void *data, UINT
if
(
!
data
)
return
0
;
if
(
avail_bytes
<
to_copy_bytes
)
if
(
data_len
<
len
)
{
SetLastError
(
ERROR_INSUFFICIENT_BUFFER
);
return
~
0U
;
}
memcpy
(
data
,
to_copy
,
to_copy_bytes
);
return
*
data_size
;
}
...
...
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