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
5c3f2f88
Commit
5c3f2f88
authored
Aug 16, 2021
by
Rémi Bernon
Committed by
Alexandre Julliard
Aug 17, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winebus.sys: Use bus_find_hid_device to find SDL devices from id.
Signed-off-by:
Rémi Bernon
<
rbernon@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
5703d5c0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
38 deletions
+26
-38
bus_sdl.c
dlls/winebus.sys/bus_sdl.c
+26
-38
No files found.
dlls/winebus.sys/bus_sdl.c
View file @
5c3f2f88
...
...
@@ -482,11 +482,9 @@ static void free_device(DEVICE_OBJECT *device)
pSDL_HapticClose
(
ext
->
sdl_haptic
);
}
static
int
compare_platform_device
(
DEVICE_OBJECT
*
device
,
void
*
platform_dev
)
static
int
compare_platform_device
(
DEVICE_OBJECT
*
device
,
void
*
context
)
{
SDL_JoystickID
id1
=
impl_from_DEVICE_OBJECT
(
device
)
->
id
;
SDL_JoystickID
id2
=
PtrToUlong
(
platform_dev
);
return
(
id1
!=
id2
);
return
impl_from_DEVICE_OBJECT
(
device
)
->
id
-
PtrToUlong
(
context
);
}
static
NTSTATUS
get_reportdescriptor
(
DEVICE_OBJECT
*
device
,
BYTE
*
buffer
,
DWORD
length
,
DWORD
*
out_length
)
...
...
@@ -606,23 +604,9 @@ static const platform_vtbl sdl_vtbl =
set_feature_report
,
};
static
int
compare_joystick_id
(
DEVICE_OBJECT
*
device
,
void
*
contex
t
)
static
BOOL
set_report_from_event
(
DEVICE_OBJECT
*
device
,
SDL_Event
*
even
t
)
{
return
impl_from_DEVICE_OBJECT
(
device
)
->
id
-
PtrToUlong
(
context
);
}
static
BOOL
set_report_from_event
(
SDL_Event
*
event
)
{
DEVICE_OBJECT
*
device
;
struct
platform_private
*
private
;
/* All the events coming in will have 'which' as a 3rd field */
SDL_JoystickID
id
=
((
SDL_JoyButtonEvent
*
)
event
)
->
which
;
device
=
bus_enumerate_hid_devices
(
sdl_busidW
,
compare_joystick_id
,
ULongToPtr
(
id
));
if
(
!
device
)
{
ERR
(
"Failed to find device at index %i
\n
"
,
id
);
return
FALSE
;
}
private
=
impl_from_DEVICE_OBJECT
(
device
);
if
(
private
->
sdl_controller
)
{
...
...
@@ -675,18 +659,9 @@ static BOOL set_report_from_event(SDL_Event *event)
return
FALSE
;
}
static
BOOL
set_mapped_report_from_event
(
SDL_Event
*
event
)
static
BOOL
set_mapped_report_from_event
(
DEVICE_OBJECT
*
device
,
SDL_Event
*
event
)
{
DEVICE_OBJECT
*
device
;
struct
platform_private
*
private
;
/* All the events coming in will have 'which' as a 3rd field */
SDL_JoystickID
id
=
((
SDL_ControllerButtonEvent
*
)
event
)
->
which
;
device
=
bus_enumerate_hid_devices
(
sdl_busidW
,
compare_joystick_id
,
ULongToPtr
(
id
));
if
(
!
device
)
{
ERR
(
"Failed to find device at index %i
\n
"
,
id
);
return
FALSE
;
}
private
=
impl_from_DEVICE_OBJECT
(
device
);
switch
(
event
->
type
)
...
...
@@ -744,13 +719,8 @@ static BOOL set_mapped_report_from_event(SDL_Event *event)
return
FALSE
;
}
static
void
try_remove_device
(
SDL_JoystickID
id
)
static
void
try_remove_device
(
DEVICE_OBJECT
*
device
)
{
DEVICE_OBJECT
*
device
=
NULL
;
device
=
bus_enumerate_hid_devices
(
sdl_busidW
,
compare_joystick_id
,
ULongToPtr
(
id
));
if
(
!
device
)
return
;
bus_unlink_hid_device
(
device
);
IoInvalidateDeviceRelations
(
bus_pdo
,
BusRelations
);
}
...
...
@@ -850,16 +820,34 @@ static void try_add_device(unsigned int index)
static
void
process_device_event
(
SDL_Event
*
event
)
{
DEVICE_OBJECT
*
device
;
SDL_JoystickID
id
;
TRACE_
(
hid_report
)(
"Received action %x
\n
"
,
event
->
type
);
if
(
event
->
type
==
SDL_JOYDEVICEADDED
)
try_add_device
(((
SDL_JoyDeviceEvent
*
)
event
)
->
which
);
else
if
(
event
->
type
==
SDL_JOYDEVICEREMOVED
)
try_remove_device
(((
SDL_JoyDeviceEvent
*
)
event
)
->
which
);
{
id
=
((
SDL_JoyDeviceEvent
*
)
event
)
->
which
;
device
=
bus_find_hid_device
(
sdl_busidW
,
ULongToPtr
(
id
));
if
(
device
)
try_remove_device
(
device
);
else
WARN
(
"failed to find device with id %d
\n
"
,
id
);
}
else
if
(
event
->
type
>=
SDL_JOYAXISMOTION
&&
event
->
type
<=
SDL_JOYBUTTONUP
)
set_report_from_event
(
event
);
{
id
=
((
SDL_JoyButtonEvent
*
)
event
)
->
which
;
device
=
bus_find_hid_device
(
sdl_busidW
,
ULongToPtr
(
id
));
if
(
device
)
set_report_from_event
(
device
,
event
);
else
WARN
(
"failed to find device with id %d
\n
"
,
id
);
}
else
if
(
event
->
type
>=
SDL_CONTROLLERAXISMOTION
&&
event
->
type
<=
SDL_CONTROLLERBUTTONUP
)
set_mapped_report_from_event
(
event
);
{
id
=
((
SDL_ControllerButtonEvent
*
)
event
)
->
which
;
device
=
bus_find_hid_device
(
sdl_busidW
,
ULongToPtr
(
id
));
if
(
device
)
set_mapped_report_from_event
(
device
,
event
);
else
WARN
(
"failed to find device with id %d
\n
"
,
id
);
}
}
static
void
sdl_load_mappings
(
void
)
...
...
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