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
1528d168
Commit
1528d168
authored
Mar 20, 2019
by
Aric Stewart
Committed by
Alexandre Julliard
Apr 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winebus.sys: Allow mapping of SDL controllers.
Signed-off-by:
Aric Stewart
<
aric@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
dc16a6cd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
4 deletions
+66
-4
Makefile.in
dlls/winebus.sys/Makefile.in
+1
-1
bus_sdl.c
dlls/winebus.sys/bus_sdl.c
+65
-3
No files found.
dlls/winebus.sys/Makefile.in
View file @
1528d168
MODULE
=
winebus.sys
IMPORTS
=
ntoskrnl setupapi
IMPORTS
=
ntoskrnl setupapi
advapi32
EXTRALIBS
=
$(IOKIT_LIBS)
$(UDEV_LIBS)
EXTRAINCL
=
$(UDEV_CFLAGS)
$(SDL2_CFLAGS)
EXTRADLLFLAGS
=
-Wl
,--subsystem,native
...
...
dlls/winebus.sys/bus_sdl.c
View file @
1528d168
...
...
@@ -38,6 +38,7 @@
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winreg.h"
#include "winternl.h"
#include "ddk/wdm.h"
#include "ddk/hidtypes.h"
...
...
@@ -106,6 +107,7 @@ MAKE_FUNCPTR(SDL_HapticRunEffect);
MAKE_FUNCPTR
(
SDL_HapticStopAll
);
MAKE_FUNCPTR
(
SDL_JoystickIsHaptic
);
MAKE_FUNCPTR
(
SDL_memset
);
MAKE_FUNCPTR
(
SDL_GameControllerAddMapping
);
#endif
static
Uint16
(
*
pSDL_JoystickGetProduct
)(
SDL_Joystick
*
joystick
);
static
Uint16
(
*
pSDL_JoystickGetProductVersion
)(
SDL_Joystick
*
joystick
);
...
...
@@ -890,9 +892,14 @@ static void process_device_event(SDL_Event *event)
set_mapped_report_from_event
(
event
);
}
typedef
struct
_thread_args
{
HANDLE
event
;
UNICODE_STRING
*
registry_path
;
}
thread_arguments
;
static
DWORD
CALLBACK
deviceloop_thread
(
void
*
args
)
{
HANDLE
init_done
=
args
;
thread_arguments
*
thread_args
=
args
;
SDL_Event
event
;
if
(
pSDL_Init
(
SDL_INIT_GAMECONTROLLER
|
SDL_INIT_HAPTIC
)
<
0
)
...
...
@@ -904,7 +911,58 @@ static DWORD CALLBACK deviceloop_thread(void *args)
pSDL_JoystickEventState
(
SDL_ENABLE
);
pSDL_GameControllerEventState
(
SDL_ENABLE
);
SetEvent
(
init_done
);
/* Process mappings */
if
(
pSDL_GameControllerAddMapping
!=
NULL
)
{
HANDLE
key
;
OBJECT_ATTRIBUTES
attr
;
WCHAR
buffer
[
MAX_PATH
];
UNICODE_STRING
regpath
=
{
0
,
sizeof
(
buffer
),
buffer
};
static
const
WCHAR
szPath
[]
=
{
'\\'
,
'm'
,
'a'
,
'p'
,
0
};
RtlCopyUnicodeString
(
&
regpath
,
thread_args
->
registry_path
);
RtlAppendUnicodeToString
(
&
regpath
,
szPath
);
InitializeObjectAttributes
(
&
attr
,
&
regpath
,
OBJ_CASE_INSENSITIVE
|
OBJ_KERNEL_HANDLE
,
NULL
,
NULL
);
if
(
NtOpenKey
(
&
key
,
KEY_ALL_ACCESS
,
&
attr
)
==
STATUS_SUCCESS
)
{
DWORD
index
=
0
;
CHAR
*
buffer
=
NULL
;
DWORD
buffer_len
=
0
;
LSTATUS
rc
;
do
{
CHAR
name
[
255
];
DWORD
name_len
;
DWORD
type
;
DWORD
data_len
=
buffer_len
;
name_len
=
sizeof
(
name
);
rc
=
RegEnumValueA
(
key
,
index
,
name
,
&
name_len
,
NULL
,
&
type
,
(
LPBYTE
)
buffer
,
&
data_len
);
if
(
rc
==
ERROR_MORE_DATA
||
buffer
==
NULL
)
{
if
(
buffer
)
buffer
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
buffer
,
data_len
);
else
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
data_len
);
buffer_len
=
data_len
;
name_len
=
sizeof
(
name
);
rc
=
RegEnumValueA
(
key
,
index
,
name
,
&
name_len
,
NULL
,
&
type
,
(
LPBYTE
)
buffer
,
&
data_len
);
}
if
(
rc
==
STATUS_SUCCESS
)
{
TRACE
(
"Setting mapping %s...
\n
"
,
debugstr_an
(
buffer
,
29
));
pSDL_GameControllerAddMapping
(
buffer
);
index
++
;
}
}
while
(
rc
==
STATUS_SUCCESS
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
NtClose
(
key
);
}
}
SetEvent
(
thread_args
->
event
);
while
(
1
)
while
(
pSDL_WaitEvent
(
&
event
)
!=
0
)
...
...
@@ -926,6 +984,7 @@ NTSTATUS WINAPI sdl_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_
HANDLE
events
[
2
];
DWORD
result
;
thread_arguments
args
;
TRACE
(
"(%p, %s)
\n
"
,
driver
,
debugstr_w
(
registry_path
->
Buffer
));
if
(
sdl_handle
==
NULL
)
...
...
@@ -969,6 +1028,7 @@ NTSTATUS WINAPI sdl_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_
LOAD_FUNCPTR
(
SDL_HapticStopAll
);
LOAD_FUNCPTR
(
SDL_JoystickIsHaptic
);
LOAD_FUNCPTR
(
SDL_memset
);
LOAD_FUNCPTR
(
SDL_GameControllerAddMapping
);
#undef LOAD_FUNCPTR
pSDL_JoystickGetProduct
=
wine_dlsym
(
sdl_handle
,
"SDL_JoystickGetProduct"
,
NULL
,
0
);
pSDL_JoystickGetProductVersion
=
wine_dlsym
(
sdl_handle
,
"SDL_JoystickGetProductVersion"
,
NULL
,
0
);
...
...
@@ -983,7 +1043,9 @@ NTSTATUS WINAPI sdl_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_
if
(
!
(
events
[
0
]
=
CreateEventW
(
NULL
,
TRUE
,
FALSE
,
NULL
)))
goto
error
;
if
(
!
(
events
[
1
]
=
CreateThread
(
NULL
,
0
,
deviceloop_thread
,
events
[
0
],
0
,
NULL
)))
args
.
event
=
events
[
0
];
args
.
registry_path
=
registry_path
;
if
(
!
(
events
[
1
]
=
CreateThread
(
NULL
,
0
,
deviceloop_thread
,
&
args
,
0
,
NULL
)))
{
CloseHandle
(
events
[
0
]);
goto
error
;
...
...
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