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
cb585669
Commit
cb585669
authored
Jun 25, 2021
by
Rémi Bernon
Committed by
Alexandre Julliard
Jun 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hid: Rewrite HidP_SetUsageValue using enum_value_caps.
Signed-off-by:
Rémi Bernon
<
rbernon@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
0a192647
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
62 deletions
+12
-62
hidp.c
dlls/hid/hidp.c
+11
-57
ntoskrnl.c
dlls/ntoskrnl.exe/tests/ntoskrnl.c
+1
-5
No files found.
dlls/hid/hidp.c
View file @
cb585669
...
@@ -192,48 +192,6 @@ static NTSTATUS get_report_data(BYTE *report, INT reportLength, INT startBit, IN
...
@@ -192,48 +192,6 @@ static NTSTATUS get_report_data(BYTE *report, INT reportLength, INT startBit, IN
return
HIDP_STATUS_SUCCESS
;
return
HIDP_STATUS_SUCCESS
;
}
}
static
NTSTATUS
set_report_data
(
BYTE
*
report
,
INT
reportLength
,
INT
startBit
,
INT
valueSize
,
ULONG
value
)
{
if
((
startBit
+
valueSize
)
/
8
>
reportLength
)
return
HIDP_STATUS_INVALID_REPORT_LENGTH
;
if
(
valueSize
==
1
)
{
ULONG
byte_index
=
startBit
/
8
;
ULONG
bit_index
=
startBit
-
(
byte_index
*
8
);
if
(
value
)
report
[
byte_index
]
|=
(
1
<<
bit_index
);
else
report
[
byte_index
]
&=
~
(
1
<<
bit_index
);
}
else
{
ULONG
byte_index
=
(
startBit
+
valueSize
-
1
)
/
8
;
ULONG
data
=
value
;
ULONG
remainingBits
=
valueSize
;
while
(
remainingBits
)
{
BYTE
subvalue
=
data
&
0xff
;
data
>>=
8
;
if
(
remainingBits
>=
8
)
{
report
[
byte_index
]
=
subvalue
;
byte_index
--
;
remainingBits
-=
8
;
}
else
if
(
remainingBits
>
0
)
{
BYTE
mask
=
(
0xff
<<
(
8
-
remainingBits
))
&
subvalue
;
report
[
byte_index
]
|=
mask
;
remainingBits
=
0
;
}
}
}
return
HIDP_STATUS_SUCCESS
;
}
NTSTATUS
WINAPI
HidP_GetButtonCaps
(
HIDP_REPORT_TYPE
report_type
,
HIDP_BUTTON_CAPS
*
caps
,
USHORT
*
caps_count
,
NTSTATUS
WINAPI
HidP_GetButtonCaps
(
HIDP_REPORT_TYPE
report_type
,
HIDP_BUTTON_CAPS
*
caps
,
USHORT
*
caps_count
,
PHIDP_PREPARSED_DATA
preparsed_data
)
PHIDP_PREPARSED_DATA
preparsed_data
)
{
{
...
@@ -533,25 +491,21 @@ static NTSTATUS set_usage_value( const struct hid_value_caps *caps, void *user )
...
@@ -533,25 +491,21 @@ static NTSTATUS set_usage_value( const struct hid_value_caps *caps, void *user )
return
HIDP_STATUS_NULL
;
return
HIDP_STATUS_NULL
;
}
}
NTSTATUS
WINAPI
HidP_SetUsageValue
(
HIDP_REPORT_TYPE
ReportType
,
USAGE
UsagePage
,
USHORT
LinkCollection
,
NTSTATUS
WINAPI
HidP_SetUsageValue
(
HIDP_REPORT_TYPE
report_type
,
USAGE
usage_page
,
USHORT
collection
,
USAGE
usage
,
USAGE
Usage
,
ULONG
UsageValue
,
PHIDP_PREPARSED_DATA
PreparsedData
,
ULONG
value
,
PHIDP_PREPARSED_DATA
preparsed_data
,
char
*
report_buf
,
ULONG
report_len
)
CHAR
*
Report
,
ULONG
ReportLength
)
{
{
WINE_HID_ELEMENT
element
;
struct
usage_value_params
params
=
{.
value_buf
=
&
value
,
.
value_len
=
sizeof
(
value
),
.
report_buf
=
report_buf
};
NTSTATUS
rc
;
WINE_HIDP_PREPARSED_DATA
*
preparsed
=
(
WINE_HIDP_PREPARSED_DATA
*
)
preparsed_data
;
struct
caps_filter
filter
=
{.
values
=
TRUE
,
.
usage_page
=
usage_page
,
.
collection
=
collection
,
.
usage
=
usage
};
USHORT
count
=
1
;
TRACE
(
"(%i, %x, %i, %i, %i, %p, %p, %i)
\n
"
,
ReportType
,
UsagePage
,
LinkCollection
,
Usage
,
UsageValue
,
TRACE
(
"report_type %d, usage_page %x, collection %d, usage %x, value %u, preparsed_data %p, report_buf %p, report_len %u.
\n
"
,
PreparsedData
,
Report
,
ReportLength
);
report_type
,
usage_page
,
collection
,
usage
,
value
,
preparsed_data
,
report_buf
,
report_len
);
rc
=
find_usage
(
ReportType
,
UsagePage
,
LinkCollection
,
Usage
,
PreparsedData
,
Report
,
0
,
&
element
);
if
(
!
report_len
)
return
HIDP_STATUS_INVALID_REPORT_LENGTH
;
if
(
rc
==
HIDP_STATUS_SUCCESS
)
{
return
set_report_data
((
BYTE
*
)
Report
,
ReportLength
,
element
.
valueStartBit
,
element
.
bitCount
,
UsageValue
);
}
return
rc
;
filter
.
report_id
=
report_buf
[
0
];
return
enum_value_caps
(
preparsed
,
report_type
,
report_len
,
&
filter
,
set_usage_value
,
&
params
,
&
count
);
}
}
NTSTATUS
WINAPI
HidP_SetUsageValueArray
(
HIDP_REPORT_TYPE
report_type
,
USAGE
usage_page
,
USHORT
collection
,
NTSTATUS
WINAPI
HidP_SetUsageValueArray
(
HIDP_REPORT_TYPE
report_type
,
USAGE
usage_page
,
USHORT
collection
,
...
...
dlls/ntoskrnl.exe/tests/ntoskrnl.c
View file @
cb585669
...
@@ -2093,7 +2093,6 @@ static void test_hidp(HANDLE file, int report_id)
...
@@ -2093,7 +2093,6 @@ static void test_hidp(HANDLE file, int report_id)
status
=
HidP_GetUsageValue
(
HidP_Input
,
HID_USAGE_PAGE_GENERIC
,
0
,
HID_USAGE_GENERIC_Z
,
status
=
HidP_GetUsageValue
(
HidP_Input
,
HID_USAGE_PAGE_GENERIC
,
0
,
HID_USAGE_GENERIC_Z
,
&
value
,
preparsed_data
,
report
,
caps
.
InputReportByteLength
);
&
value
,
preparsed_data
,
report
,
caps
.
InputReportByteLength
);
ok
(
status
==
HIDP_STATUS_SUCCESS
,
"HidP_GetUsageValue returned %#x
\n
"
,
status
);
ok
(
status
==
HIDP_STATUS_SUCCESS
,
"HidP_GetUsageValue returned %#x
\n
"
,
status
);
todo_wine
ok
(
value
==
0x7fffffff
,
"got value %x, expected %#x
\n
"
,
value
,
0x7fffffff
);
ok
(
value
==
0x7fffffff
,
"got value %x, expected %#x
\n
"
,
value
,
0x7fffffff
);
value
=
0x3fffffff
;
value
=
0x3fffffff
;
...
@@ -2292,13 +2291,12 @@ static void test_hidp(HANDLE file, int report_id)
...
@@ -2292,13 +2291,12 @@ static void test_hidp(HANDLE file, int report_id)
status
=
HidP_SetUsageValue
(
HidP_Feature
,
HID_USAGE_PAGE_ORDINAL
,
waveform_list
,
3
,
status
=
HidP_SetUsageValue
(
HidP_Feature
,
HID_USAGE_PAGE_ORDINAL
,
waveform_list
,
3
,
HID_USAGE_HAPTICS_WAVEFORM_RUMBLE
,
preparsed_data
,
report
,
HID_USAGE_HAPTICS_WAVEFORM_RUMBLE
,
preparsed_data
,
report
,
caps
.
FeatureReportByteLength
+
1
);
caps
.
FeatureReportByteLength
+
1
);
todo_wine
ok
(
status
==
HIDP_STATUS_INVALID_REPORT_LENGTH
,
"HidP_SetUsageValue returned %#x
\n
"
,
status
);
ok
(
status
==
HIDP_STATUS_INVALID_REPORT_LENGTH
,
"HidP_SetUsageValue returned %#x
\n
"
,
status
);
report
[
0
]
=
1
-
report_id
;
report
[
0
]
=
1
-
report_id
;
status
=
HidP_SetUsageValue
(
HidP_Feature
,
HID_USAGE_PAGE_ORDINAL
,
waveform_list
,
3
,
status
=
HidP_SetUsageValue
(
HidP_Feature
,
HID_USAGE_PAGE_ORDINAL
,
waveform_list
,
3
,
HID_USAGE_HAPTICS_WAVEFORM_RUMBLE
,
preparsed_data
,
report
,
HID_USAGE_HAPTICS_WAVEFORM_RUMBLE
,
preparsed_data
,
report
,
caps
.
FeatureReportByteLength
);
caps
.
FeatureReportByteLength
);
todo_wine
todo_wine
_if
(
!
report_id
)
ok
(
status
==
(
report_id
?
HIDP_STATUS_SUCCESS
:
HIDP_STATUS_INCOMPATIBLE_REPORT_ID
),
ok
(
status
==
(
report_id
?
HIDP_STATUS_SUCCESS
:
HIDP_STATUS_INCOMPATIBLE_REPORT_ID
),
"HidP_SetUsageValue returned %#x
\n
"
,
status
);
"HidP_SetUsageValue returned %#x
\n
"
,
status
);
report
[
0
]
=
2
;
report
[
0
]
=
2
;
...
@@ -2310,7 +2308,6 @@ static void test_hidp(HANDLE file, int report_id)
...
@@ -2310,7 +2308,6 @@ static void test_hidp(HANDLE file, int report_id)
report
[
0
]
=
report_id
;
report
[
0
]
=
report_id
;
status
=
HidP_SetUsageValue
(
HidP_Feature
,
HID_USAGE_PAGE_ORDINAL
,
0xdead
,
3
,
HID_USAGE_HAPTICS_WAVEFORM_RUMBLE
,
status
=
HidP_SetUsageValue
(
HidP_Feature
,
HID_USAGE_PAGE_ORDINAL
,
0xdead
,
3
,
HID_USAGE_HAPTICS_WAVEFORM_RUMBLE
,
preparsed_data
,
report
,
caps
.
FeatureReportByteLength
);
preparsed_data
,
report
,
caps
.
FeatureReportByteLength
);
todo_wine
ok
(
status
==
HIDP_STATUS_USAGE_NOT_FOUND
,
"HidP_SetUsageValue returned %#x
\n
"
,
status
);
ok
(
status
==
HIDP_STATUS_USAGE_NOT_FOUND
,
"HidP_SetUsageValue returned %#x
\n
"
,
status
);
status
=
HidP_SetUsageValue
(
HidP_Feature
,
HID_USAGE_PAGE_ORDINAL
,
waveform_list
,
3
,
status
=
HidP_SetUsageValue
(
HidP_Feature
,
HID_USAGE_PAGE_ORDINAL
,
waveform_list
,
3
,
...
@@ -2323,7 +2320,6 @@ static void test_hidp(HANDLE file, int report_id)
...
@@ -2323,7 +2320,6 @@ static void test_hidp(HANDLE file, int report_id)
buffer
[
0
]
=
report_id
;
buffer
[
0
]
=
report_id
;
value
=
HID_USAGE_HAPTICS_WAVEFORM_RUMBLE
;
value
=
HID_USAGE_HAPTICS_WAVEFORM_RUMBLE
;
memcpy
(
buffer
+
1
,
&
value
,
2
);
memcpy
(
buffer
+
1
,
&
value
,
2
);
todo_wine
ok
(
!
memcmp
(
buffer
,
report
,
sizeof
(
buffer
)),
"unexpected report data
\n
"
);
ok
(
!
memcmp
(
buffer
,
report
,
sizeof
(
buffer
)),
"unexpected report data
\n
"
);
status
=
HidP_GetUsageValue
(
HidP_Feature
,
HID_USAGE_PAGE_ORDINAL
,
waveform_list
,
3
,
&
value
,
status
=
HidP_GetUsageValue
(
HidP_Feature
,
HID_USAGE_PAGE_ORDINAL
,
waveform_list
,
3
,
&
value
,
...
...
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