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
d7c48672
Commit
d7c48672
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: Enforce all axis values to be 32bit.
Signed-off-by:
Rémi Bernon
<
rbernon@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
059764e8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
70 deletions
+30
-70
bus_sdl.c
dlls/winebus.sys/bus_sdl.c
+18
-22
bus_udev.c
dlls/winebus.sys/bus_udev.c
+6
-9
hid.c
dlls/winebus.sys/hid.c
+5
-38
unix_private.h
dlls/winebus.sys/unix_private.h
+1
-1
No files found.
dlls/winebus.sys/bus_sdl.c
View file @
d7c48672
...
@@ -51,9 +51,9 @@
...
@@ -51,9 +51,9 @@
#include "hidusage.h"
#include "hidusage.h"
#ifdef WORDS_BIGENDIAN
#ifdef WORDS_BIGENDIAN
# define LE_
WORD(x) RtlUshort
ByteSwap(x)
# define LE_
DWORD(x) RtlUlong
ByteSwap(x)
#else
#else
# define LE_WORD(x) (x)
# define LE_
D
WORD(x) (x)
#endif
#endif
#include "unix_private.h"
#include "unix_private.h"
...
@@ -175,24 +175,20 @@ static void set_button_value(struct platform_private *ext, int index, int value)
...
@@ -175,24 +175,20 @@ static void set_button_value(struct platform_private *ext, int index, int value)
static
void
set_axis_value
(
struct
platform_private
*
ext
,
int
index
,
short
value
,
BOOL
controller
)
static
void
set_axis_value
(
struct
platform_private
*
ext
,
int
index
,
short
value
,
BOOL
controller
)
{
{
WORD
*
report
=
(
WORD
*
)(
ext
->
report_buffer
+
ext
->
axis_start
);
DWORD
*
report
=
(
D
WORD
*
)(
ext
->
report_buffer
+
ext
->
axis_start
);
if
(
controller
&&
(
index
==
SDL_CONTROLLER_AXIS_TRIGGERLEFT
||
index
==
SDL_CONTROLLER_AXIS_TRIGGERRIGHT
))
if
(
controller
&&
(
index
==
SDL_CONTROLLER_AXIS_TRIGGERLEFT
||
index
==
SDL_CONTROLLER_AXIS_TRIGGERRIGHT
))
report
[
index
]
=
LE_WORD
(
value
);
report
[
index
]
=
LE_
D
WORD
(
value
);
else
else
report
[
index
]
=
LE_WORD
(
value
)
+
32768
;
report
[
index
]
=
LE_
D
WORD
(
value
)
+
32768
;
}
}
static
void
set_ball_value
(
struct
platform_private
*
ext
,
int
index
,
int
value1
,
int
value2
)
static
void
set_ball_value
(
struct
platform_private
*
ext
,
int
index
,
int
value1
,
int
value2
)
{
{
int
offset
;
int
offset
;
offset
=
ext
->
ball_start
+
(
index
*
sizeof
(
WORD
));
offset
=
ext
->
ball_start
+
(
index
*
sizeof
(
DWORD
));
if
(
value1
>
127
)
value1
=
127
;
*
(
DWORD
*
)
&
ext
->
report_buffer
[
offset
]
=
LE_DWORD
(
value1
);
if
(
value1
<
-
127
)
value1
=
-
127
;
*
(
DWORD
*
)
&
ext
->
report_buffer
[
offset
+
sizeof
(
DWORD
)]
=
LE_DWORD
(
value2
);
if
(
value2
>
127
)
value2
=
127
;
if
(
value2
<
-
127
)
value2
=
-
127
;
*
((
WORD
*
)
&
ext
->
report_buffer
[
offset
])
=
LE_WORD
(
value1
);
*
((
WORD
*
)
&
ext
->
report_buffer
[
offset
+
sizeof
(
WORD
)])
=
LE_WORD
(
value2
);
}
}
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
)
...
@@ -308,7 +304,7 @@ static NTSTATUS build_report_descriptor(struct platform_private *ext)
...
@@ -308,7 +304,7 @@ static NTSTATUS build_report_descriptor(struct platform_private *ext)
ext
->
axis_start
=
report_size
;
ext
->
axis_start
=
report_size
;
if
(
axis_count
)
if
(
axis_count
)
{
{
report_size
+=
(
sizeof
(
WORD
)
*
axis_count
);
report_size
+=
(
sizeof
(
D
WORD
)
*
axis_count
);
}
}
ball_count
=
pSDL_JoystickNumBalls
(
ext
->
sdl_joystick
);
ball_count
=
pSDL_JoystickNumBalls
(
ext
->
sdl_joystick
);
...
@@ -320,7 +316,7 @@ static NTSTATUS build_report_descriptor(struct platform_private *ext)
...
@@ -320,7 +316,7 @@ static NTSTATUS build_report_descriptor(struct platform_private *ext)
FIXME
(
"Capping ball + axis at 9
\n
"
);
FIXME
(
"Capping ball + axis at 9
\n
"
);
ball_count
=
(
9
-
axis_count
)
/
2
;
ball_count
=
(
9
-
axis_count
)
/
2
;
}
}
report_size
+=
(
sizeof
(
WORD
)
*
2
*
ball_count
);
report_size
+=
(
sizeof
(
D
WORD
)
*
2
*
ball_count
);
}
}
/* For now lump all buttons just into incremental usages, Ignore Keys */
/* For now lump all buttons just into incremental usages, Ignore Keys */
...
@@ -340,18 +336,18 @@ static NTSTATUS build_report_descriptor(struct platform_private *ext)
...
@@ -340,18 +336,18 @@ static NTSTATUS build_report_descriptor(struct platform_private *ext)
if
(
axis_count
==
6
&&
button_count
>=
14
)
if
(
axis_count
==
6
&&
button_count
>=
14
)
{
{
if
(
!
hid_descriptor_add_axes
(
&
ext
->
desc
,
axis_count
,
HID_USAGE_PAGE_GENERIC
,
if
(
!
hid_descriptor_add_axes
(
&
ext
->
desc
,
axis_count
,
HID_USAGE_PAGE_GENERIC
,
controller_usages
,
FALSE
,
16
,
0
,
0xffff
))
controller_usages
,
FALSE
,
0
,
0xffff
))
return
STATUS_NO_MEMORY
;
return
STATUS_NO_MEMORY
;
}
}
else
if
(
axis_count
)
else
if
(
axis_count
)
{
{
if
(
!
hid_descriptor_add_axes
(
&
ext
->
desc
,
axis_count
,
HID_USAGE_PAGE_GENERIC
,
if
(
!
hid_descriptor_add_axes
(
&
ext
->
desc
,
axis_count
,
HID_USAGE_PAGE_GENERIC
,
joystick_usages
,
FALSE
,
16
,
0
,
0xffff
))
joystick_usages
,
FALSE
,
0
,
0xffff
))
return
STATUS_NO_MEMORY
;
return
STATUS_NO_MEMORY
;
}
}
if
(
ball_count
&&
!
hid_descriptor_add_axes
(
&
ext
->
desc
,
ball_count
*
2
,
HID_USAGE_PAGE_GENERIC
,
if
(
ball_count
&&
!
hid_descriptor_add_axes
(
&
ext
->
desc
,
ball_count
*
2
,
HID_USAGE_PAGE_GENERIC
,
&
joystick_usages
[
axis_count
],
TRUE
,
8
,
0x81
,
0x7f
))
&
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
(
button_count
&&
!
hid_descriptor_add_buttons
(
&
ext
->
desc
,
HID_USAGE_PAGE_BUTTON
,
1
,
button_count
))
...
@@ -420,11 +416,11 @@ static NTSTATUS build_mapped_report_descriptor(struct platform_private *ext)
...
@@ -420,11 +416,11 @@ static NTSTATUS build_mapped_report_descriptor(struct platform_private *ext)
static
const
int
BUTTON_BIT_COUNT
=
CONTROLLER_NUM_BUTTONS
+
CONTROLLER_NUM_HATSWITCHES
*
4
;
static
const
int
BUTTON_BIT_COUNT
=
CONTROLLER_NUM_BUTTONS
+
CONTROLLER_NUM_HATSWITCHES
*
4
;
ext
->
axis_start
=
0
;
ext
->
axis_start
=
0
;
ext
->
button_start
=
CONTROLLER_NUM_AXES
*
sizeof
(
WORD
);
ext
->
button_start
=
CONTROLLER_NUM_AXES
*
sizeof
(
D
WORD
);
ext
->
hat_bit_offs
=
CONTROLLER_NUM_BUTTONS
;
ext
->
hat_bit_offs
=
CONTROLLER_NUM_BUTTONS
;
ext
->
buffer_length
=
(
BUTTON_BIT_COUNT
+
7
)
/
8
ext
->
buffer_length
=
(
BUTTON_BIT_COUNT
+
7
)
/
8
+
CONTROLLER_NUM_AXES
*
sizeof
(
WORD
);
+
CONTROLLER_NUM_AXES
*
sizeof
(
D
WORD
);
TRACE
(
"Report will be %i bytes
\n
"
,
ext
->
buffer_length
);
TRACE
(
"Report will be %i bytes
\n
"
,
ext
->
buffer_length
);
...
@@ -432,15 +428,15 @@ static NTSTATUS build_mapped_report_descriptor(struct platform_private *ext)
...
@@ -432,15 +428,15 @@ static NTSTATUS build_mapped_report_descriptor(struct platform_private *ext)
return
STATUS_NO_MEMORY
;
return
STATUS_NO_MEMORY
;
if
(
!
hid_descriptor_add_axes
(
&
ext
->
desc
,
2
,
HID_USAGE_PAGE_GENERIC
,
left_axis_usages
,
if
(
!
hid_descriptor_add_axes
(
&
ext
->
desc
,
2
,
HID_USAGE_PAGE_GENERIC
,
left_axis_usages
,
FALSE
,
16
,
0
,
0xffff
))
FALSE
,
0
,
0xffff
))
return
STATUS_NO_MEMORY
;
return
STATUS_NO_MEMORY
;
if
(
!
hid_descriptor_add_axes
(
&
ext
->
desc
,
2
,
HID_USAGE_PAGE_GENERIC
,
right_axis_usages
,
if
(
!
hid_descriptor_add_axes
(
&
ext
->
desc
,
2
,
HID_USAGE_PAGE_GENERIC
,
right_axis_usages
,
FALSE
,
16
,
0
,
0xffff
))
FALSE
,
0
,
0xffff
))
return
STATUS_NO_MEMORY
;
return
STATUS_NO_MEMORY
;
if
(
!
hid_descriptor_add_axes
(
&
ext
->
desc
,
2
,
HID_USAGE_PAGE_GENERIC
,
trigger_axis_usages
,
if
(
!
hid_descriptor_add_axes
(
&
ext
->
desc
,
2
,
HID_USAGE_PAGE_GENERIC
,
trigger_axis_usages
,
FALSE
,
16
,
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_BUTTONS
))
if
(
!
hid_descriptor_add_buttons
(
&
ext
->
desc
,
HID_USAGE_PAGE_BUTTON
,
1
,
CONTROLLER_NUM_BUTTONS
))
...
...
dlls/winebus.sys/bus_udev.c
View file @
d7c48672
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
#include <stdarg.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
#include <stdint.h>
#ifdef HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
# include <unistd.h>
# include <unistd.h>
#endif
#endif
...
@@ -78,10 +79,8 @@
...
@@ -78,10 +79,8 @@
#endif
#endif
#ifdef WORDS_BIGENDIAN
#ifdef WORDS_BIGENDIAN
#define LE_WORD(x) RtlUshortByteSwap(x)
#define LE_DWORD(x) RtlUlongByteSwap(x)
#define LE_DWORD(x) RtlUlongByteSwap(x)
#else
#else
#define LE_WORD(x) (x)
#define LE_DWORD(x) (x)
#define LE_DWORD(x) (x)
#endif
#endif
...
@@ -389,9 +388,7 @@ static void set_rel_axis_value(struct wine_input_private *ext, int code, int val
...
@@ -389,9 +388,7 @@ static void set_rel_axis_value(struct wine_input_private *ext, int code, int val
if
(
code
<
HID_REL_MAX
&&
REL_TO_HID_MAP
[
code
][
0
]
!=
0
)
if
(
code
<
HID_REL_MAX
&&
REL_TO_HID_MAP
[
code
][
0
]
!=
0
)
{
{
index
=
ext
->
rel_map
[
code
];
index
=
ext
->
rel_map
[
code
];
if
(
value
>
127
)
value
=
127
;
*
(
DWORD
*
)
&
ext
->
current_report_buffer
[
index
]
=
LE_DWORD
(
value
);
if
(
value
<
-
127
)
value
=
-
127
;
ext
->
current_report_buffer
[
index
]
=
value
;
}
}
}
}
...
@@ -474,7 +471,7 @@ static NTSTATUS build_report_descriptor(struct wine_input_private *ext, struct u
...
@@ -474,7 +471,7 @@ static NTSTATUS build_report_descriptor(struct wine_input_private *ext, struct u
if
(
!
(
usage
.
UsagePage
=
ABS_TO_HID_MAP
[
i
][
0
]))
continue
;
if
(
!
(
usage
.
UsagePage
=
ABS_TO_HID_MAP
[
i
][
0
]))
continue
;
if
(
!
(
usage
.
Usage
=
ABS_TO_HID_MAP
[
i
][
1
]))
continue
;
if
(
!
(
usage
.
Usage
=
ABS_TO_HID_MAP
[
i
][
1
]))
continue
;
if
(
!
hid_descriptor_add_axes
(
&
ext
->
desc
,
1
,
usage
.
UsagePage
,
&
usage
.
Usage
,
FALSE
,
32
,
if
(
!
hid_descriptor_add_axes
(
&
ext
->
desc
,
1
,
usage
.
UsagePage
,
&
usage
.
Usage
,
FALSE
,
LE_DWORD
(
abs_info
[
i
].
minimum
),
LE_DWORD
(
abs_info
[
i
].
maximum
)))
LE_DWORD
(
abs_info
[
i
].
minimum
),
LE_DWORD
(
abs_info
[
i
].
maximum
)))
return
STATUS_NO_MEMORY
;
return
STATUS_NO_MEMORY
;
...
@@ -490,12 +487,12 @@ static NTSTATUS build_report_descriptor(struct wine_input_private *ext, struct u
...
@@ -490,12 +487,12 @@ static NTSTATUS build_report_descriptor(struct wine_input_private *ext, struct u
if
(
!
(
usage
.
UsagePage
=
REL_TO_HID_MAP
[
i
][
0
]))
continue
;
if
(
!
(
usage
.
UsagePage
=
REL_TO_HID_MAP
[
i
][
0
]))
continue
;
if
(
!
(
usage
.
Usage
=
REL_TO_HID_MAP
[
i
][
1
]))
continue
;
if
(
!
(
usage
.
Usage
=
REL_TO_HID_MAP
[
i
][
1
]))
continue
;
if
(
!
hid_descriptor_add_axes
(
&
ext
->
desc
,
1
,
usage
.
UsagePage
,
&
usage
.
Usage
,
TRUE
,
8
,
if
(
!
hid_descriptor_add_axes
(
&
ext
->
desc
,
1
,
usage
.
UsagePage
,
&
usage
.
Usage
,
TRUE
,
0x81
,
0x7f
))
INT32_MIN
,
INT32_MAX
))
return
STATUS_NO_MEMORY
;
return
STATUS_NO_MEMORY
;
ext
->
rel_map
[
i
]
=
report_size
;
ext
->
rel_map
[
i
]
=
report_size
;
report_size
++
;
report_size
+=
4
;
rel_count
++
;
rel_count
++
;
}
}
...
...
dlls/winebus.sys/hid.c
View file @
d7c48672
...
@@ -148,7 +148,7 @@ BOOL hid_descriptor_add_hatswitch(struct hid_descriptor *desc, INT count)
...
@@ -148,7 +148,7 @@ BOOL hid_descriptor_add_hatswitch(struct hid_descriptor *desc, INT count)
}
}
BOOL
hid_descriptor_add_axes
(
struct
hid_descriptor
*
desc
,
BYTE
count
,
USAGE
usage_page
,
BOOL
hid_descriptor_add_axes
(
struct
hid_descriptor
*
desc
,
BYTE
count
,
USAGE
usage_page
,
const
USAGE
*
usages
,
BOOL
rel
,
INT
size
,
LONG
min
,
LONG
max
)
const
USAGE
*
usages
,
BOOL
rel
,
LONG
min
,
LONG
max
)
{
{
const
BYTE
template_begin
[]
=
const
BYTE
template_begin
[]
=
{
{
...
@@ -159,33 +159,13 @@ BOOL hid_descriptor_add_axes(struct hid_descriptor *desc, BYTE count, USAGE usag
...
@@ -159,33 +159,13 @@ BOOL hid_descriptor_add_axes(struct hid_descriptor *desc, BYTE count, USAGE usag
{
{
END_COLLECTION
,
END_COLLECTION
,
};
};
const
BYTE
template_1
[]
=
const
BYTE
template
[]
=
{
LOGICAL_MINIMUM
(
1
,
min
),
LOGICAL_MAXIMUM
(
1
,
max
),
PHYSICAL_MINIMUM
(
1
,
min
),
PHYSICAL_MAXIMUM
(
1
,
max
),
REPORT_SIZE
(
1
,
size
),
REPORT_COUNT
(
1
,
count
),
INPUT
(
1
,
Data
|
Var
|
(
rel
?
Rel
:
Abs
)),
};
const
BYTE
template_2
[]
=
{
LOGICAL_MINIMUM
(
2
,
min
),
LOGICAL_MAXIMUM
(
2
,
max
),
PHYSICAL_MINIMUM
(
2
,
min
),
PHYSICAL_MAXIMUM
(
2
,
max
),
REPORT_SIZE
(
1
,
size
),
REPORT_COUNT
(
1
,
count
),
INPUT
(
1
,
Data
|
Var
|
(
rel
?
Rel
:
Abs
)),
};
const
BYTE
template_4
[]
=
{
{
LOGICAL_MINIMUM
(
4
,
min
),
LOGICAL_MINIMUM
(
4
,
min
),
LOGICAL_MAXIMUM
(
4
,
max
),
LOGICAL_MAXIMUM
(
4
,
max
),
PHYSICAL_MINIMUM
(
4
,
min
),
PHYSICAL_MINIMUM
(
4
,
min
),
PHYSICAL_MAXIMUM
(
4
,
max
),
PHYSICAL_MAXIMUM
(
4
,
max
),
REPORT_SIZE
(
1
,
size
),
REPORT_SIZE
(
1
,
32
),
REPORT_COUNT
(
1
,
count
),
REPORT_COUNT
(
1
,
count
),
INPUT
(
1
,
Data
|
Var
|
(
rel
?
Rel
:
Abs
)),
INPUT
(
1
,
Data
|
Var
|
(
rel
?
Rel
:
Abs
)),
};
};
...
@@ -200,21 +180,8 @@ BOOL hid_descriptor_add_axes(struct hid_descriptor *desc, BYTE count, USAGE usag
...
@@ -200,21 +180,8 @@ BOOL hid_descriptor_add_axes(struct hid_descriptor *desc, BYTE count, USAGE usag
return
FALSE
;
return
FALSE
;
}
}
if
(
size
>=
16
)
if
(
!
hid_descriptor_append
(
desc
,
template
,
sizeof
(
template
)))
{
return
FALSE
;
if
(
!
hid_descriptor_append
(
desc
,
template_4
,
sizeof
(
template_4
)))
return
FALSE
;
}
else
if
(
size
>=
8
)
{
if
(
!
hid_descriptor_append
(
desc
,
template_2
,
sizeof
(
template_2
)))
return
FALSE
;
}
else
{
if
(
!
hid_descriptor_append
(
desc
,
template_1
,
sizeof
(
template_1
)))
return
FALSE
;
}
if
(
!
hid_descriptor_append
(
desc
,
template_end
,
sizeof
(
template_end
)))
if
(
!
hid_descriptor_append
(
desc
,
template_end
,
sizeof
(
template_end
)))
return
FALSE
;
return
FALSE
;
...
...
dlls/winebus.sys/unix_private.h
View file @
d7c48672
...
@@ -85,7 +85,7 @@ extern BOOL hid_descriptor_add_buttons(struct hid_descriptor *desc, USAGE usage_
...
@@ -85,7 +85,7 @@ extern BOOL hid_descriptor_add_buttons(struct hid_descriptor *desc, USAGE usage_
extern
BOOL
hid_descriptor_add_padding
(
struct
hid_descriptor
*
desc
,
BYTE
bitcount
)
DECLSPEC_HIDDEN
;
extern
BOOL
hid_descriptor_add_padding
(
struct
hid_descriptor
*
desc
,
BYTE
bitcount
)
DECLSPEC_HIDDEN
;
extern
BOOL
hid_descriptor_add_hatswitch
(
struct
hid_descriptor
*
desc
,
INT
count
)
DECLSPEC_HIDDEN
;
extern
BOOL
hid_descriptor_add_hatswitch
(
struct
hid_descriptor
*
desc
,
INT
count
)
DECLSPEC_HIDDEN
;
extern
BOOL
hid_descriptor_add_axes
(
struct
hid_descriptor
*
desc
,
BYTE
count
,
USAGE
usage_page
,
extern
BOOL
hid_descriptor_add_axes
(
struct
hid_descriptor
*
desc
,
BYTE
count
,
USAGE
usage_page
,
const
USAGE
*
usages
,
BOOL
rel
,
INT
size
,
LONG
min
,
LONG
max
)
DECLSPEC_HIDDEN
;
const
USAGE
*
usages
,
BOOL
rel
,
LONG
min
,
LONG
max
)
DECLSPEC_HIDDEN
;
extern
BOOL
hid_descriptor_add_haptics
(
struct
hid_descriptor
*
desc
)
DECLSPEC_HIDDEN
;
extern
BOOL
hid_descriptor_add_haptics
(
struct
hid_descriptor
*
desc
)
DECLSPEC_HIDDEN
;
...
...
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