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
d0c5a5e8
Commit
d0c5a5e8
authored
May 07, 2019
by
Andrew Eikum
Committed by
Alexandre Julliard
May 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winebus.sys: Order axes before buttons.
Signed-off-by:
Andrew Eikum
<
aeikum@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
fb4a77d5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
61 deletions
+84
-61
bus_sdl.c
dlls/winebus.sys/bus_sdl.c
+46
-25
bus_udev.c
dlls/winebus.sys/bus_udev.c
+38
-20
controller.h
dlls/winebus.sys/controller.h
+0
-16
No files found.
dlls/winebus.sys/bus_sdl.c
View file @
d0c5a5e8
...
...
@@ -119,6 +119,7 @@ struct platform_private
SDL_GameController
*
sdl_controller
;
SDL_JoystickID
id
;
int
button_start
;
int
axis_start
;
int
ball_start
;
int
hat_start
;
...
...
@@ -247,6 +248,23 @@ static BYTE *add_axis_block(BYTE *report_ptr, BYTE count, BYTE page, const BYTE
return
report_ptr
;
}
static
void
set_button_value
(
struct
platform_private
*
ext
,
int
index
,
int
value
)
{
int
byte_index
=
ext
->
button_start
+
index
/
8
;
int
bit_index
=
index
%
8
;
BYTE
mask
=
1
<<
bit_index
;
if
(
value
)
{
ext
->
report_buffer
[
byte_index
]
=
ext
->
report_buffer
[
byte_index
]
|
mask
;
}
else
{
mask
=
~
mask
;
ext
->
report_buffer
[
byte_index
]
=
ext
->
report_buffer
[
byte_index
]
&
mask
;
}
}
static
void
set_axis_value
(
struct
platform_private
*
ext
,
int
index
,
short
value
)
{
int
offset
;
...
...
@@ -362,16 +380,6 @@ static BOOL build_report_descriptor(struct platform_private *ext)
descript_size
=
sizeof
(
REPORT_HEADER
)
+
sizeof
(
REPORT_TAIL
);
report_size
=
0
;
/* For now lump all buttons just into incremental usages, Ignore Keys */
button_count
=
pSDL_JoystickNumButtons
(
ext
->
sdl_joystick
);
if
(
button_count
)
{
descript_size
+=
sizeof
(
REPORT_BUTTONS
);
if
(
button_count
%
8
)
descript_size
+=
sizeof
(
REPORT_PADDING
);
report_size
=
(
button_count
+
7
)
/
8
;
}
axis_count
=
pSDL_JoystickNumAxes
(
ext
->
sdl_joystick
);
if
(
axis_count
>
6
)
{
...
...
@@ -403,6 +411,17 @@ static BOOL build_report_descriptor(struct platform_private *ext)
report_size
+=
(
sizeof
(
WORD
)
*
2
*
ball_count
);
}
/* For now lump all buttons just into incremental usages, Ignore Keys */
button_count
=
pSDL_JoystickNumButtons
(
ext
->
sdl_joystick
);
ext
->
button_start
=
report_size
;
if
(
button_count
)
{
descript_size
+=
sizeof
(
REPORT_BUTTONS
);
if
(
button_count
%
8
)
descript_size
+=
sizeof
(
REPORT_PADDING
);
report_size
+=
(
button_count
+
7
)
/
8
;
}
hat_count
=
pSDL_JoystickNumHats
(
ext
->
sdl_joystick
);
ext
->
hat_start
=
report_size
;
if
(
hat_count
)
...
...
@@ -428,15 +447,6 @@ static BOOL build_report_descriptor(struct platform_private *ext)
report_ptr
[
IDX_HEADER_PAGE
]
=
device_usage
[
0
];
report_ptr
[
IDX_HEADER_USAGE
]
=
device_usage
[
1
];
report_ptr
+=
sizeof
(
REPORT_HEADER
);
if
(
button_count
)
{
report_ptr
=
add_button_block
(
report_ptr
,
1
,
button_count
);
if
(
button_count
%
8
)
{
BYTE
padding
=
8
-
(
button_count
%
8
);
report_ptr
=
add_padding_block
(
report_ptr
,
padding
);
}
}
if
(
axis_count
)
{
if
(
axis_count
==
6
&&
button_count
>=
14
)
...
...
@@ -449,6 +459,15 @@ static BOOL build_report_descriptor(struct platform_private *ext)
{
report_ptr
=
add_axis_block
(
report_ptr
,
ball_count
*
2
,
HID_USAGE_PAGE_GENERIC
,
&
joystick_usages
[
axis_count
],
FALSE
);
}
if
(
button_count
)
{
report_ptr
=
add_button_block
(
report_ptr
,
1
,
button_count
);
if
(
button_count
%
8
)
{
BYTE
padding
=
8
-
(
button_count
%
8
);
report_ptr
=
add_padding_block
(
report_ptr
,
padding
);
}
}
if
(
hat_count
)
report_ptr
=
add_hatswitch
(
report_ptr
,
hat_count
);
...
...
@@ -480,12 +499,14 @@ static BOOL build_mapped_report_descriptor(struct platform_private *ext)
INT
i
,
descript_size
;
descript_size
=
sizeof
(
REPORT_HEADER
)
+
sizeof
(
REPORT_TAIL
);
descript_size
+=
sizeof
(
CONTROLLER_BUTTONS
);
descript_size
+=
sizeof
(
CONTROLLER_AXIS
);
descript_size
+=
sizeof
(
CONTROLLER_TRIGGERS
);
descript_size
+=
sizeof
(
CONTROLLER_BUTTONS
);
descript_size
+=
test_haptic
(
ext
);
ext
->
axis_start
=
(
CONTROLLER_NUM_BUTTONS
+
7
)
/
8
;
ext
->
axis_start
=
0
;
ext
->
button_start
=
CONTROLLER_NUM_AXES
*
sizeof
(
WORD
);
ext
->
buffer_length
=
(
CONTROLLER_NUM_BUTTONS
+
7
)
/
8
+
CONTROLLER_NUM_AXES
*
sizeof
(
WORD
);
TRACE
(
"Report Descriptor will be %i bytes
\n
"
,
descript_size
);
...
...
@@ -503,12 +524,12 @@ static BOOL build_mapped_report_descriptor(struct platform_private *ext)
report_ptr
[
IDX_HEADER_PAGE
]
=
HID_USAGE_PAGE_GENERIC
;
report_ptr
[
IDX_HEADER_USAGE
]
=
HID_USAGE_GENERIC_GAMEPAD
;
report_ptr
+=
sizeof
(
REPORT_HEADER
);
memcpy
(
report_ptr
,
CONTROLLER_BUTTONS
,
sizeof
(
CONTROLLER_BUTTONS
));
report_ptr
+=
sizeof
(
CONTROLLER_BUTTONS
);
memcpy
(
report_ptr
,
CONTROLLER_AXIS
,
sizeof
(
CONTROLLER_AXIS
));
report_ptr
+=
sizeof
(
CONTROLLER_AXIS
);
memcpy
(
report_ptr
,
CONTROLLER_TRIGGERS
,
sizeof
(
CONTROLLER_TRIGGERS
));
report_ptr
+=
sizeof
(
CONTROLLER_TRIGGERS
);
memcpy
(
report_ptr
,
CONTROLLER_BUTTONS
,
sizeof
(
CONTROLLER_BUTTONS
));
report_ptr
+=
sizeof
(
CONTROLLER_BUTTONS
);
report_ptr
+=
build_haptic
(
ext
,
report_ptr
);
memcpy
(
report_ptr
,
REPORT_TAIL
,
sizeof
(
REPORT_TAIL
));
...
...
@@ -681,7 +702,7 @@ static BOOL set_report_from_event(SDL_Event *event)
{
SDL_JoyButtonEvent
*
ie
=
&
event
->
jbutton
;
set_button_value
(
ie
->
button
,
ie
->
state
,
private
->
report_buffer
);
set_button_value
(
private
,
ie
->
button
,
ie
->
state
);
process_hid_report
(
device
,
private
->
report_buffer
,
private
->
buffer_length
);
break
;
...
...
@@ -764,7 +785,7 @@ static BOOL set_mapped_report_from_event(SDL_Event *event)
if
(
usage
>=
0
)
{
set_button_value
(
usage
,
ie
->
state
,
private
->
report_buffer
);
set_button_value
(
private
,
usage
,
ie
->
state
);
process_hid_report
(
device
,
private
->
report_buffer
,
private
->
buffer_length
);
}
break
;
...
...
dlls/winebus.sys/bus_udev.c
View file @
d0c5a5e8
...
...
@@ -197,6 +197,7 @@ struct wine_input_private {
int
report_descriptor_size
;
BYTE
*
report_descriptor
;
int
button_start
;
BYTE
button_map
[
KEY_MAX
];
BYTE
rel_map
[
HID_REL_MAX
];
BYTE
hat_map
[
8
];
...
...
@@ -276,6 +277,22 @@ static const BYTE* what_am_I(struct udev_device *dev)
return
Unknown
;
}
static
void
set_button_value
(
int
index
,
int
value
,
BYTE
*
buffer
)
{
int
bindex
=
index
/
8
;
int
b
=
index
%
8
;
BYTE
mask
;
mask
=
1
<<
b
;
if
(
value
)
buffer
[
bindex
]
=
buffer
[
bindex
]
|
mask
;
else
{
mask
=
~
mask
;
buffer
[
bindex
]
=
buffer
[
bindex
]
&
mask
;
}
}
static
void
set_abs_axis_value
(
struct
wine_input_private
*
ext
,
int
code
,
int
value
)
{
int
index
;
...
...
@@ -403,16 +420,6 @@ static BOOL build_report_descriptor(struct wine_input_private *ext, struct udev_
descript_size
=
sizeof
(
REPORT_HEADER
)
+
sizeof
(
REPORT_TAIL
);
report_size
=
0
;
/* For now lump all buttons just into incremental usages, Ignore Keys */
button_count
=
count_buttons
(
ext
->
base
.
device_fd
,
ext
->
button_map
);
if
(
button_count
)
{
descript_size
+=
sizeof
(
REPORT_BUTTONS
);
if
(
button_count
%
8
)
descript_size
+=
sizeof
(
REPORT_PADDING
);
report_size
=
(
button_count
+
7
)
/
8
;
}
abs_count
=
0
;
memset
(
abs_pages
,
0
,
sizeof
(
abs_pages
));
for
(
i
=
0
;
i
<
HID_ABS_MAX
;
i
++
)
...
...
@@ -463,6 +470,17 @@ static BOOL build_report_descriptor(struct wine_input_private *ext, struct udev_
descript_size
+=
sizeof
(
REPORT_AXIS_HEADER
)
*
rel_count
;
descript_size
+=
sizeof
(
REPORT_REL_AXIS_TAIL
)
*
rel_count
;
/* For now lump all buttons just into incremental usages, Ignore Keys */
ext
->
button_start
=
report_size
;
button_count
=
count_buttons
(
ext
->
base
.
device_fd
,
ext
->
button_map
);
if
(
button_count
)
{
descript_size
+=
sizeof
(
REPORT_BUTTONS
);
if
(
button_count
%
8
)
descript_size
+=
sizeof
(
REPORT_PADDING
);
report_size
+=
(
button_count
+
7
)
/
8
;
}
hat_count
=
0
;
for
(
i
=
ABS_HAT0X
;
i
<=
ABS_HAT3X
;
i
+=
2
)
if
(
test_bit
(
absbits
,
i
))
...
...
@@ -491,15 +509,6 @@ static BOOL build_report_descriptor(struct wine_input_private *ext, struct udev_
report_ptr
[
IDX_HEADER_PAGE
]
=
device_usage
[
0
];
report_ptr
[
IDX_HEADER_USAGE
]
=
device_usage
[
1
];
report_ptr
+=
sizeof
(
REPORT_HEADER
);
if
(
button_count
)
{
report_ptr
=
add_button_block
(
report_ptr
,
1
,
button_count
);
if
(
button_count
%
8
)
{
BYTE
padding
=
8
-
(
button_count
%
8
);
report_ptr
=
add_padding_block
(
report_ptr
,
padding
);
}
}
if
(
abs_count
)
{
for
(
i
=
1
;
i
<
TOP_ABS_PAGE
;
i
++
)
...
...
@@ -528,6 +537,15 @@ static BOOL build_report_descriptor(struct wine_input_private *ext, struct udev_
}
}
}
if
(
button_count
)
{
report_ptr
=
add_button_block
(
report_ptr
,
1
,
button_count
);
if
(
button_count
%
8
)
{
BYTE
padding
=
8
-
(
button_count
%
8
);
report_ptr
=
add_padding_block
(
report_ptr
,
padding
);
}
}
if
(
hat_count
)
report_ptr
=
add_hatswitch
(
report_ptr
,
hat_count
);
...
...
@@ -592,7 +610,7 @@ static BOOL set_report_from_event(struct wine_input_private *ext, struct input_e
return
FALSE
;
#endif
case
EV_KEY
:
set_button_value
(
ext
->
button_map
[
ie
->
code
],
ie
->
value
,
ext
->
current_report_buffer
);
set_button_value
(
ext
->
button_
start
+
ext
->
button_
map
[
ie
->
code
],
ie
->
value
,
ext
->
current_report_buffer
);
return
FALSE
;
case
EV_ABS
:
set_abs_axis_value
(
ext
,
ie
->
code
,
ie
->
value
);
...
...
dlls/winebus.sys/controller.h
View file @
d0c5a5e8
...
...
@@ -113,19 +113,3 @@ static inline BYTE *add_hatswitch(BYTE *report_ptr, INT count)
report_ptr
[
IDX_HATSWITCH_COUNT
]
=
count
;
return
report_ptr
+
sizeof
(
REPORT_HATSWITCH
);
}
static
inline
void
set_button_value
(
int
index
,
int
value
,
BYTE
*
buffer
)
{
int
bindex
=
index
/
8
;
int
b
=
index
%
8
;
BYTE
mask
;
mask
=
1
<<
b
;
if
(
value
)
buffer
[
bindex
]
=
buffer
[
bindex
]
|
mask
;
else
{
mask
=
~
mask
;
buffer
[
bindex
]
=
buffer
[
bindex
]
&
mask
;
}
}
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