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
593c4d51
Commit
593c4d51
authored
Sep 21, 2021
by
Rémi Bernon
Committed by
Alexandre Julliard
Sep 21, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winebus.sys: Move hats before buttons and use one byte each.
Signed-off-by:
Rémi Bernon
<
rbernon@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
d7c48672
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
58 deletions
+35
-58
bus_sdl.c
dlls/winebus.sys/bus_sdl.c
+17
-40
bus_udev.c
dlls/winebus.sys/bus_udev.c
+17
-17
hid.c
dlls/winebus.sys/hid.c
+1
-1
No files found.
dlls/winebus.sys/bus_sdl.c
View file @
593c4d51
...
@@ -126,7 +126,7 @@ struct platform_private
...
@@ -126,7 +126,7 @@ struct platform_private
int
button_start
;
int
button_start
;
int
axis_start
;
int
axis_start
;
int
ball_start
;
int
ball_start
;
int
hat_
bit_offs
;
/* hatswitches are reported in the same bytes as buttons */
int
hat_
start
;
struct
hid_descriptor
desc
;
struct
hid_descriptor
desc
;
...
@@ -193,26 +193,8 @@ static void set_ball_value(struct platform_private *ext, int index, int value1,
...
@@ -193,26 +193,8 @@ static void set_ball_value(struct platform_private *ext, int index, int value1,
static
void
set_hat_value
(
struct
platform_private
*
ext
,
int
index
,
int
value
)
static
void
set_hat_value
(
struct
platform_private
*
ext
,
int
index
,
int
value
)
{
{
int
byte
=
ext
->
button_start
+
(
ext
->
hat_bit_offs
+
4
*
index
)
/
8
;
int
byte
=
ext
->
hat_start
+
index
;
int
bit_offs
=
(
ext
->
hat_bit_offs
+
4
*
index
)
%
8
;
unsigned
char
val
;
int
num_low_bits
,
num_high_bits
;
unsigned
char
val
,
low_mask
,
high_mask
;
/* 4-bit hatswitch value is packed into button bytes */
if
(
bit_offs
<=
4
)
{
num_low_bits
=
4
;
num_high_bits
=
0
;
low_mask
=
0xf
;
high_mask
=
0
;
}
else
{
num_low_bits
=
8
-
bit_offs
;
num_high_bits
=
4
-
num_low_bits
;
low_mask
=
(
1
<<
num_low_bits
)
-
1
;
high_mask
=
(
1
<<
num_high_bits
)
-
1
;
}
switch
(
value
)
switch
(
value
)
{
{
...
@@ -231,13 +213,7 @@ static void set_hat_value(struct platform_private *ext, int index, int value)
...
@@ -231,13 +213,7 @@ static void set_hat_value(struct platform_private *ext, int index, int value)
default:
return
;
default:
return
;
}
}
ext
->
report_buffer
[
byte
]
&=
~
(
low_mask
<<
bit_offs
);
ext
->
report_buffer
[
byte
]
=
val
;
ext
->
report_buffer
[
byte
]
|=
(
val
&
low_mask
)
<<
bit_offs
;
if
(
high_mask
)
{
ext
->
report_buffer
[
byte
+
1
]
&=
~
high_mask
;
ext
->
report_buffer
[
byte
+
1
]
|=
val
&
high_mask
;
}
}
}
static
BOOL
descriptor_add_haptic
(
struct
platform_private
*
ext
)
static
BOOL
descriptor_add_haptic
(
struct
platform_private
*
ext
)
...
@@ -319,14 +295,14 @@ static NTSTATUS build_report_descriptor(struct platform_private *ext)
...
@@ -319,14 +295,14 @@ static NTSTATUS build_report_descriptor(struct platform_private *ext)
report_size
+=
(
sizeof
(
DWORD
)
*
2
*
ball_count
);
report_size
+=
(
sizeof
(
DWORD
)
*
2
*
ball_count
);
}
}
hat_count
=
pSDL_JoystickNumHats
(
ext
->
sdl_joystick
);
ext
->
hat_start
=
report_size
;
report_size
+=
hat_count
;
/* For now lump all buttons just into incremental usages, Ignore Keys */
/* For now lump all buttons just into incremental usages, Ignore Keys */
button_count
=
pSDL_JoystickNumButtons
(
ext
->
sdl_joystick
);
button_count
=
pSDL_JoystickNumButtons
(
ext
->
sdl_joystick
);
ext
->
button_start
=
report_size
;
ext
->
button_start
=
report_size
;
report_size
+=
(
button_count
+
7
)
/
8
;
hat_count
=
pSDL_JoystickNumHats
(
ext
->
sdl_joystick
);
ext
->
hat_bit_offs
=
button_count
;
report_size
+=
(
button_count
+
hat_count
*
4
+
7
)
/
8
;
TRACE
(
"Report will be %i bytes
\n
"
,
report_size
);
TRACE
(
"Report will be %i bytes
\n
"
,
report_size
);
...
@@ -350,10 +326,10 @@ static NTSTATUS build_report_descriptor(struct platform_private *ext)
...
@@ -350,10 +326,10 @@ static NTSTATUS build_report_descriptor(struct platform_private *ext)
&
joystick_usages
[
axis_count
],
TRUE
,
INT32_MIN
,
INT32_MAX
))
&
joystick_usages
[
axis_count
],
TRUE
,
INT32_MIN
,
INT32_MAX
))
return
STATUS_NO_MEMORY
;
return
STATUS_NO_MEMORY
;
if
(
button_count
&&
!
hid_descriptor_add_buttons
(
&
ext
->
desc
,
HID_USAGE_PAGE_BUTTON
,
1
,
button
_count
))
if
(
hat_count
&&
!
hid_descriptor_add_hatswitch
(
&
ext
->
desc
,
hat
_count
))
return
STATUS_NO_MEMORY
;
return
STATUS_NO_MEMORY
;
if
(
hat_count
&&
!
hid_descriptor_add_hatswitch
(
&
ext
->
desc
,
hat
_count
))
if
(
button_count
&&
!
hid_descriptor_add_buttons
(
&
ext
->
desc
,
HID_USAGE_PAGE_BUTTON
,
1
,
button
_count
))
return
STATUS_NO_MEMORY
;
return
STATUS_NO_MEMORY
;
if
(
!
descriptor_add_haptic
(
ext
))
if
(
!
descriptor_add_haptic
(
ext
))
...
@@ -413,13 +389,14 @@ static NTSTATUS build_mapped_report_descriptor(struct platform_private *ext)
...
@@ -413,13 +389,14 @@ static NTSTATUS build_mapped_report_descriptor(struct platform_private *ext)
static
const
USAGE
trigger_axis_usages
[]
=
{
HID_USAGE_GENERIC_Z
,
HID_USAGE_GENERIC_RZ
};
static
const
USAGE
trigger_axis_usages
[]
=
{
HID_USAGE_GENERIC_Z
,
HID_USAGE_GENERIC_RZ
};
INT
i
;
INT
i
;
static
const
int
BUTTON_BIT_COUNT
=
CONTROLLER_NUM_BUTTONS
+
CONTROLLER_NUM_HATSWITCHES
*
4
;
static
const
int
BUTTON_BIT_COUNT
=
CONTROLLER_NUM_BUTTONS
;
ext
->
axis_start
=
0
;
ext
->
axis_start
=
0
;
ext
->
button
_start
=
CONTROLLER_NUM_AXES
*
sizeof
(
DWORD
);
ext
->
hat
_start
=
CONTROLLER_NUM_AXES
*
sizeof
(
DWORD
);
ext
->
hat_bit_offs
=
CONTROLLER_NUM_BUTTON
S
;
ext
->
button_start
=
ext
->
hat_start
+
CONTROLLER_NUM_HATSWITCHE
S
;
ext
->
buffer_length
=
(
BUTTON_BIT_COUNT
+
7
)
/
8
ext
->
buffer_length
=
(
BUTTON_BIT_COUNT
+
7
)
/
8
+
CONTROLLER_NUM_HATSWITCHES
+
CONTROLLER_NUM_AXES
*
sizeof
(
DWORD
);
+
CONTROLLER_NUM_AXES
*
sizeof
(
DWORD
);
TRACE
(
"Report will be %i bytes
\n
"
,
ext
->
buffer_length
);
TRACE
(
"Report will be %i bytes
\n
"
,
ext
->
buffer_length
);
...
@@ -439,10 +416,10 @@ static NTSTATUS build_mapped_report_descriptor(struct platform_private *ext)
...
@@ -439,10 +416,10 @@ static NTSTATUS build_mapped_report_descriptor(struct platform_private *ext)
FALSE
,
0
,
0x7fff
))
FALSE
,
0
,
0x7fff
))
return
STATUS_NO_MEMORY
;
return
STATUS_NO_MEMORY
;
if
(
!
hid_descriptor_add_
buttons
(
&
ext
->
desc
,
HID_USAGE_PAGE_BUTTON
,
1
,
CONTROLLER_NUM_BUTTON
S
))
if
(
!
hid_descriptor_add_
hatswitch
(
&
ext
->
desc
,
CONTROLLER_NUM_HATSWITCHE
S
))
return
STATUS_NO_MEMORY
;
return
STATUS_NO_MEMORY
;
if
(
!
hid_descriptor_add_
hatswitch
(
&
ext
->
desc
,
1
))
if
(
!
hid_descriptor_add_
buttons
(
&
ext
->
desc
,
HID_USAGE_PAGE_BUTTON
,
1
,
CONTROLLER_NUM_BUTTONS
))
return
STATUS_NO_MEMORY
;
return
STATUS_NO_MEMORY
;
if
(
BUTTON_BIT_COUNT
%
8
!=
0
)
if
(
BUTTON_BIT_COUNT
%
8
!=
0
)
...
...
dlls/winebus.sys/bus_udev.c
View file @
593c4d51
...
@@ -496,6 +496,23 @@ static NTSTATUS build_report_descriptor(struct wine_input_private *ext, struct u
...
@@ -496,6 +496,23 @@ static NTSTATUS build_report_descriptor(struct wine_input_private *ext, struct u
rel_count
++
;
rel_count
++
;
}
}
hat_count
=
0
;
for
(
i
=
ABS_HAT0X
;
i
<=
ABS_HAT3X
;
i
+=
2
)
{
if
(
!
test_bit
(
absbits
,
i
))
continue
;
ext
->
hat_map
[
i
-
ABS_HAT0X
]
=
report_size
;
ext
->
hat_values
[
i
-
ABS_HAT0X
]
=
0
;
ext
->
hat_values
[
i
-
ABS_HAT0X
+
1
]
=
0
;
report_size
++
;
hat_count
++
;
}
if
(
hat_count
)
{
if
(
!
hid_descriptor_add_hatswitch
(
&
ext
->
desc
,
hat_count
))
return
STATUS_NO_MEMORY
;
}
/* For now lump all buttons just into incremental usages, Ignore Keys */
/* For now lump all buttons just into incremental usages, Ignore Keys */
ext
->
button_start
=
report_size
;
ext
->
button_start
=
report_size
;
button_count
=
count_buttons
(
ext
->
base
.
device_fd
,
ext
->
button_map
);
button_count
=
count_buttons
(
ext
->
base
.
device_fd
,
ext
->
button_map
);
...
@@ -514,23 +531,6 @@ static NTSTATUS build_report_descriptor(struct wine_input_private *ext, struct u
...
@@ -514,23 +531,6 @@ static NTSTATUS build_report_descriptor(struct wine_input_private *ext, struct u
report_size
+=
(
button_count
+
7
)
/
8
;
report_size
+=
(
button_count
+
7
)
/
8
;
}
}
hat_count
=
0
;
for
(
i
=
ABS_HAT0X
;
i
<=
ABS_HAT3X
;
i
+=
2
)
{
if
(
!
test_bit
(
absbits
,
i
))
continue
;
ext
->
hat_map
[
i
-
ABS_HAT0X
]
=
report_size
;
ext
->
hat_values
[
i
-
ABS_HAT0X
]
=
0
;
ext
->
hat_values
[
i
-
ABS_HAT0X
+
1
]
=
0
;
report_size
++
;
hat_count
++
;
}
if
(
hat_count
)
{
if
(
!
hid_descriptor_add_hatswitch
(
&
ext
->
desc
,
hat_count
))
return
STATUS_NO_MEMORY
;
}
if
(
!
hid_descriptor_end
(
&
ext
->
desc
))
if
(
!
hid_descriptor_end
(
&
ext
->
desc
))
return
STATUS_NO_MEMORY
;
return
STATUS_NO_MEMORY
;
...
...
dlls/winebus.sys/hid.c
View file @
593c4d51
...
@@ -138,7 +138,7 @@ BOOL hid_descriptor_add_hatswitch(struct hid_descriptor *desc, INT count)
...
@@ -138,7 +138,7 @@ BOOL hid_descriptor_add_hatswitch(struct hid_descriptor *desc, INT count)
LOGICAL_MAXIMUM
(
1
,
8
),
LOGICAL_MAXIMUM
(
1
,
8
),
PHYSICAL_MINIMUM
(
1
,
0
),
PHYSICAL_MINIMUM
(
1
,
0
),
PHYSICAL_MAXIMUM
(
2
,
8
),
PHYSICAL_MAXIMUM
(
2
,
8
),
REPORT_SIZE
(
1
,
4
),
REPORT_SIZE
(
1
,
8
),
REPORT_COUNT
(
4
,
count
),
REPORT_COUNT
(
4
,
count
),
UNIT
(
1
,
0x0e
/* none */
),
UNIT
(
1
,
0x0e
/* none */
),
INPUT
(
1
,
Data
|
Var
|
Abs
|
Null
),
INPUT
(
1
,
Data
|
Var
|
Abs
|
Null
),
...
...
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