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
db116067
Commit
db116067
authored
Aug 05, 2021
by
Rémi Bernon
Committed by
Alexandre Julliard
Aug 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xinput1_3: Access controller list in HID code directly.
Signed-off-by:
Rémi Bernon
<
rbernon@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
1371bcf3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
14 deletions
+14
-14
hid.c
dlls/xinput1_3/hid.c
+7
-7
xinput_main.c
dlls/xinput1_3/xinput_main.c
+5
-5
xinput_private.h
dlls/xinput1_3/xinput_private.h
+2
-2
No files found.
dlls/xinput1_3/hid.c
View file @
db116067
...
@@ -71,7 +71,7 @@ struct hid_platform_private {
...
@@ -71,7 +71,7 @@ struct hid_platform_private {
static
DWORD
last_check
=
0
;
static
DWORD
last_check
=
0
;
static
BOOL
find_opened_device
(
xinput_controller
*
devices
,
SP_DEVICE_INTERFACE_DETAIL_DATA_W
*
detail
,
int
*
free_slot
)
static
BOOL
find_opened_device
(
SP_DEVICE_INTERFACE_DETAIL_DATA_W
*
detail
,
int
*
free_slot
)
{
{
struct
hid_platform_private
*
private
;
struct
hid_platform_private
*
private
;
int
i
;
int
i
;
...
@@ -79,7 +79,7 @@ static BOOL find_opened_device(xinput_controller *devices, SP_DEVICE_INTERFACE_D
...
@@ -79,7 +79,7 @@ static BOOL find_opened_device(xinput_controller *devices, SP_DEVICE_INTERFACE_D
*
free_slot
=
XUSER_MAX_COUNT
;
*
free_slot
=
XUSER_MAX_COUNT
;
for
(
i
=
XUSER_MAX_COUNT
;
i
>
0
;
i
--
)
for
(
i
=
XUSER_MAX_COUNT
;
i
>
0
;
i
--
)
{
{
if
(
!
(
private
=
device
s
[
i
-
1
].
platform_private
))
*
free_slot
=
i
-
1
;
if
(
!
(
private
=
controller
s
[
i
-
1
].
platform_private
))
*
free_slot
=
i
-
1
;
else
if
(
!
wcscmp
(
detail
->
DevicePath
,
private
->
device_path
))
return
TRUE
;
else
if
(
!
wcscmp
(
detail
->
DevicePath
,
private
->
device_path
))
return
TRUE
;
}
}
return
FALSE
;
return
FALSE
;
...
@@ -221,7 +221,7 @@ failed:
...
@@ -221,7 +221,7 @@ failed:
return
FALSE
;
return
FALSE
;
}
}
void
HID_find_gamepads
(
xinput_controller
*
devices
)
void
HID_find_gamepads
(
void
)
{
{
char
buffer
[
sizeof
(
SP_DEVICE_INTERFACE_DETAIL_DATA_W
)
+
MAX_PATH
*
sizeof
(
WCHAR
)];
char
buffer
[
sizeof
(
SP_DEVICE_INTERFACE_DETAIL_DATA_W
)
+
MAX_PATH
*
sizeof
(
WCHAR
)];
SP_DEVICE_INTERFACE_DETAIL_DATA_W
*
detail
=
(
SP_DEVICE_INTERFACE_DETAIL_DATA_W
*
)
buffer
;
SP_DEVICE_INTERFACE_DETAIL_DATA_W
*
detail
=
(
SP_DEVICE_INTERFACE_DETAIL_DATA_W
*
)
buffer
;
...
@@ -266,7 +266,7 @@ void HID_find_gamepads(xinput_controller *devices)
...
@@ -266,7 +266,7 @@ void HID_find_gamepads(xinput_controller *devices)
if
(
!
wcsstr
(
detail
->
DevicePath
,
L"IG_"
))
if
(
!
wcsstr
(
detail
->
DevicePath
,
L"IG_"
))
continue
;
continue
;
if
(
find_opened_device
(
de
vices
,
de
tail
,
&
i
))
continue
;
/* already opened */
if
(
find_opened_device
(
detail
,
&
i
))
continue
;
/* already opened */
if
(
i
==
XUSER_MAX_COUNT
)
break
;
/* no more slots */
if
(
i
==
XUSER_MAX_COUNT
)
break
;
/* no more slots */
device
=
CreateFileW
(
detail
->
DevicePath
,
GENERIC_READ
|
GENERIC_WRITE
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
device
=
CreateFileW
(
detail
->
DevicePath
,
GENERIC_READ
|
GENERIC_WRITE
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
...
@@ -282,7 +282,7 @@ void HID_find_gamepads(xinput_controller *devices)
...
@@ -282,7 +282,7 @@ void HID_find_gamepads(xinput_controller *devices)
WARN
(
"ignoring HID device, unsupported usage page %04x
\n
"
,
caps
.
UsagePage
);
WARN
(
"ignoring HID device, unsupported usage page %04x
\n
"
,
caps
.
UsagePage
);
else
if
(
caps
.
Usage
!=
HID_USAGE_GENERIC_GAMEPAD
&&
caps
.
Usage
!=
HID_USAGE_GENERIC_JOYSTICK
&&
caps
.
Usage
!=
HID_USAGE_GENERIC_MULTI_AXIS_CONTROLLER
)
else
if
(
caps
.
Usage
!=
HID_USAGE_GENERIC_GAMEPAD
&&
caps
.
Usage
!=
HID_USAGE_GENERIC_JOYSTICK
&&
caps
.
Usage
!=
HID_USAGE_GENERIC_MULTI_AXIS_CONTROLLER
)
WARN
(
"ignoring HID device, unsupported usage %04x:%04x
\n
"
,
caps
.
UsagePage
,
caps
.
Usage
);
WARN
(
"ignoring HID device, unsupported usage %04x:%04x
\n
"
,
caps
.
UsagePage
,
caps
.
Usage
);
else
if
(
!
init_controller
(
&
device
s
[
i
],
ppd
,
&
caps
,
device
,
detail
->
DevicePath
))
else
if
(
!
init_controller
(
&
controller
s
[
i
],
ppd
,
&
caps
,
device
,
detail
->
DevicePath
))
WARN
(
"ignoring HID device, failed to initialize
\n
"
);
WARN
(
"ignoring HID device, failed to initialize
\n
"
);
else
else
continue
;
continue
;
...
@@ -317,11 +317,11 @@ static void remove_gamepad(xinput_controller *device)
...
@@ -317,11 +317,11 @@ static void remove_gamepad(xinput_controller *device)
LeaveCriticalSection
(
&
device
->
crit
);
LeaveCriticalSection
(
&
device
->
crit
);
}
}
void
HID_destroy_gamepads
(
xinput_controller
*
devices
)
void
HID_destroy_gamepads
(
void
)
{
{
int
i
;
int
i
;
for
(
i
=
0
;
i
<
XUSER_MAX_COUNT
;
i
++
)
for
(
i
=
0
;
i
<
XUSER_MAX_COUNT
;
i
++
)
remove_gamepad
(
&
device
s
[
i
]);
remove_gamepad
(
&
controller
s
[
i
]);
}
}
static
SHORT
scale_short
(
LONG
value
,
const
struct
axis_info
*
axis
)
static
SHORT
scale_short
(
LONG
value
,
const
struct
axis_info
*
axis
)
...
...
dlls/xinput1_3/xinput_main.c
View file @
db116067
...
@@ -104,7 +104,7 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved)
...
@@ -104,7 +104,7 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved)
break
;
break
;
case
DLL_PROCESS_DETACH
:
case
DLL_PROCESS_DETACH
:
if
(
reserved
)
break
;
if
(
reserved
)
break
;
HID_destroy_gamepads
(
controllers
);
HID_destroy_gamepads
();
break
;
break
;
}
}
return
TRUE
;
return
TRUE
;
...
@@ -120,7 +120,7 @@ void WINAPI DECLSPEC_HOTPATCH XInputEnable(BOOL enable)
...
@@ -120,7 +120,7 @@ void WINAPI DECLSPEC_HOTPATCH XInputEnable(BOOL enable)
to the controllers. Setting to true will send the last vibration
to the controllers. Setting to true will send the last vibration
value (sent to XInputSetState) to the controller and allow messages to
value (sent to XInputSetState) to the controller and allow messages to
be sent */
be sent */
HID_find_gamepads
(
controllers
);
HID_find_gamepads
();
for
(
index
=
0
;
index
<
XUSER_MAX_COUNT
;
index
++
)
for
(
index
=
0
;
index
<
XUSER_MAX_COUNT
;
index
++
)
{
{
...
@@ -136,7 +136,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH XInputSetState(DWORD index, XINPUT_VIBRATION* vib
...
@@ -136,7 +136,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH XInputSetState(DWORD index, XINPUT_VIBRATION* vib
TRACE
(
"(index %u, vibration %p)
\n
"
,
index
,
vibration
);
TRACE
(
"(index %u, vibration %p)
\n
"
,
index
,
vibration
);
HID_find_gamepads
(
controllers
);
HID_find_gamepads
();
if
(
index
>=
XUSER_MAX_COUNT
)
if
(
index
>=
XUSER_MAX_COUNT
)
return
ERROR_BAD_ARGUMENTS
;
return
ERROR_BAD_ARGUMENTS
;
...
@@ -157,7 +157,7 @@ static DWORD xinput_get_state(DWORD index, XINPUT_STATE *state)
...
@@ -157,7 +157,7 @@ static DWORD xinput_get_state(DWORD index, XINPUT_STATE *state)
if
(
!
state
)
if
(
!
state
)
return
ERROR_BAD_ARGUMENTS
;
return
ERROR_BAD_ARGUMENTS
;
HID_find_gamepads
(
controllers
);
HID_find_gamepads
();
if
(
index
>=
XUSER_MAX_COUNT
)
if
(
index
>=
XUSER_MAX_COUNT
)
return
ERROR_BAD_ARGUMENTS
;
return
ERROR_BAD_ARGUMENTS
;
...
@@ -421,7 +421,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH XInputGetCapabilities(DWORD index, DWORD flags, X
...
@@ -421,7 +421,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH XInputGetCapabilities(DWORD index, DWORD flags, X
{
{
TRACE
(
"(index %u, flags 0x%x, capabilities %p)
\n
"
,
index
,
flags
,
capabilities
);
TRACE
(
"(index %u, flags 0x%x, capabilities %p)
\n
"
,
index
,
flags
,
capabilities
);
HID_find_gamepads
(
controllers
);
HID_find_gamepads
();
if
(
index
>=
XUSER_MAX_COUNT
)
if
(
index
>=
XUSER_MAX_COUNT
)
return
ERROR_BAD_ARGUMENTS
;
return
ERROR_BAD_ARGUMENTS
;
...
...
dlls/xinput1_3/xinput_private.h
View file @
db116067
...
@@ -30,8 +30,8 @@ typedef struct _xinput_controller
...
@@ -30,8 +30,8 @@ typedef struct _xinput_controller
extern
CRITICAL_SECTION
xinput_crit
;
extern
CRITICAL_SECTION
xinput_crit
;
extern
xinput_controller
controllers
[
XUSER_MAX_COUNT
];
extern
xinput_controller
controllers
[
XUSER_MAX_COUNT
];
void
HID_find_gamepads
(
xinput_controller
*
devices
)
DECLSPEC_HIDDEN
;
void
HID_find_gamepads
(
void
)
DECLSPEC_HIDDEN
;
void
HID_destroy_gamepads
(
xinput_controller
*
devices
)
DECLSPEC_HIDDEN
;
void
HID_destroy_gamepads
(
void
)
DECLSPEC_HIDDEN
;
void
HID_update_state
(
xinput_controller
*
device
,
XINPUT_STATE
*
state
)
DECLSPEC_HIDDEN
;
void
HID_update_state
(
xinput_controller
*
device
,
XINPUT_STATE
*
state
)
DECLSPEC_HIDDEN
;
DWORD
HID_set_state
(
xinput_controller
*
device
,
XINPUT_VIBRATION
*
state
)
DECLSPEC_HIDDEN
;
DWORD
HID_set_state
(
xinput_controller
*
device
,
XINPUT_VIBRATION
*
state
)
DECLSPEC_HIDDEN
;
void
HID_enable
(
xinput_controller
*
device
,
BOOL
enable
)
DECLSPEC_HIDDEN
;
void
HID_enable
(
xinput_controller
*
device
,
BOOL
enable
)
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