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
17958bc8
Commit
17958bc8
authored
May 31, 2021
by
Rémi Bernon
Committed by
Alexandre Julliard
May 31, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dinput: Factor out device creation interface queries.
Signed-off-by:
Rémi Bernon
<
rbernon@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
96ab7b44
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
36 additions
and
168 deletions
+36
-168
dinput_main.c
dlls/dinput/dinput_main.c
+15
-17
dinput_private.h
dlls/dinput/dinput_private.h
+1
-1
joystick_linux.c
dlls/dinput/joystick_linux.c
+4
-30
joystick_linuxinput.c
dlls/dinput/joystick_linuxinput.c
+4
-30
joystick_osx.c
dlls/dinput/joystick_osx.c
+4
-29
keyboard.c
dlls/dinput/keyboard.c
+4
-31
mouse.c
dlls/dinput/mouse.c
+4
-30
No files found.
dlls/dinput/dinput_main.c
View file @
17958bc8
...
...
@@ -644,9 +644,15 @@ static HRESULT WINAPI IDirectInput2WImpl_FindDevice(LPDIRECTINPUT7W iface, REFGU
return
DI_OK
;
}
static
HRESULT
create_device
(
IDirectInputImpl
*
This
,
REFGUID
rguid
,
REFIID
riid
,
LPVOID
*
pvOut
,
BOOL
unicode
)
static
HRESULT
WINAPI
IDirectInput7WImpl_CreateDeviceEx
(
IDirectInput7W
*
iface
,
REFGUID
rguid
,
REFIID
riid
,
LPVOID
*
pvOut
,
LPUNKNOWN
lpUnknownOuter
)
{
IDirectInputDevice8W
*
device
;
IDirectInputImpl
*
This
=
impl_from_IDirectInput7W
(
iface
);
unsigned
int
i
;
HRESULT
hr
;
TRACE
(
"(%p)->(%s, %s, %p, %p)
\n
"
,
This
,
debugstr_guid
(
rguid
),
debugstr_guid
(
riid
),
pvOut
,
lpUnknownOuter
);
if
(
pvOut
)
*
pvOut
=
NULL
;
...
...
@@ -660,31 +666,23 @@ static HRESULT create_device(IDirectInputImpl *This, REFGUID rguid, REFIID riid,
/* Loop on all the devices to see if anyone matches the given GUID */
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
dinput_devices
);
i
++
)
{
HRESULT
ret
;
if
(
!
dinput_devices
[
i
]
->
create_device
)
continue
;
if
((
ret
=
dinput_devices
[
i
]
->
create_device
(
This
,
rguid
,
riid
,
pvOut
,
unicode
))
==
DI_OK
)
return
DI_OK
;
if
(
SUCCEEDED
(
hr
=
dinput_devices
[
i
]
->
create_device
(
This
,
rguid
,
&
device
)))
{
hr
=
IDirectInputDevice8_QueryInterface
(
device
,
riid
,
pvOut
);
IDirectInputDevice8_Release
(
device
);
return
hr
;
}
}
WARN
(
"invalid device GUID %s
\n
"
,
debugstr_guid
(
rguid
));
return
DIERR_DEVICENOTREG
;
}
static
HRESULT
WINAPI
IDirectInput7WImpl_CreateDeviceEx
(
LPDIRECTINPUT7W
iface
,
REFGUID
rguid
,
REFIID
riid
,
LPVOID
*
pvOut
,
LPUNKNOWN
lpUnknownOuter
)
{
IDirectInputImpl
*
This
=
impl_from_IDirectInput7W
(
iface
);
TRACE
(
"(%p)->(%s, %s, %p, %p)
\n
"
,
This
,
debugstr_guid
(
rguid
),
debugstr_guid
(
riid
),
pvOut
,
lpUnknownOuter
);
return
create_device
(
This
,
rguid
,
riid
,
pvOut
,
TRUE
);
}
static
HRESULT
WINAPI
IDirectInputWImpl_CreateDevice
(
LPDIRECTINPUT7W
iface
,
REFGUID
rguid
,
LPDIRECTINPUTDEVICEW
*
pdev
,
LPUNKNOWN
punk
)
{
return
IDirectInput7_CreateDeviceEx
(
iface
,
rguid
,
NULL
,
(
LPVOID
*
)
pdev
,
punk
);
return
IDirectInput7_CreateDeviceEx
(
iface
,
rguid
,
&
IID_IDirectInputDeviceW
,
(
LPVOID
*
)
pdev
,
punk
);
}
/*******************************************************************************
...
...
@@ -713,7 +711,7 @@ static HRESULT WINAPI IDirectInput8WImpl_CreateDevice(LPDIRECTINPUT8W iface, REF
LPDIRECTINPUTDEVICE8W
*
pdev
,
LPUNKNOWN
punk
)
{
IDirectInputImpl
*
This
=
impl_from_IDirectInput8W
(
iface
);
return
IDirectInput7_CreateDeviceEx
(
&
This
->
IDirectInput7W_iface
,
rguid
,
NULL
,
(
LPVOID
*
)
pdev
,
punk
);
return
IDirectInput7_CreateDeviceEx
(
&
This
->
IDirectInput7W_iface
,
rguid
,
&
IID_IDirectInputDevice8W
,
(
LPVOID
*
)
pdev
,
punk
);
}
static
HRESULT
WINAPI
IDirectInput8WImpl_EnumDevices
(
LPDIRECTINPUT8W
iface
,
DWORD
dwDevType
,
LPDIENUMDEVICESCALLBACKW
lpCallback
,
...
...
dlls/dinput/dinput_private.h
View file @
17958bc8
...
...
@@ -57,7 +57,7 @@ struct dinput_device {
const
char
*
name
;
HRESULT
(
*
enum_deviceA
)(
DWORD
dwDevType
,
DWORD
dwFlags
,
LPDIDEVICEINSTANCEA
lpddi
,
DWORD
version
,
int
id
);
HRESULT
(
*
enum_deviceW
)(
DWORD
dwDevType
,
DWORD
dwFlags
,
LPDIDEVICEINSTANCEW
lpddi
,
DWORD
version
,
int
id
);
HRESULT
(
*
create_device
)(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPVOID
*
pdev
,
int
unicode
);
HRESULT
(
*
create_device
)(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
IDirectInputDevice8W
**
out
);
};
struct
DevicePlayer
{
...
...
dlls/dinput/joystick_linux.c
View file @
17958bc8
...
...
@@ -587,13 +587,13 @@ static unsigned short get_joystick_index(REFGUID guid)
return
MAX_JOYSTICKS
;
}
static
HRESULT
joydev_create_device
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPVOID
*
pdev
,
int
unicode
)
static
HRESULT
joydev_create_device
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
IDirectInputDevice8W
**
out
)
{
unsigned
short
index
;
TRACE
(
"%p %s %s %p %i
\n
"
,
dinput
,
debugstr_guid
(
rguid
),
debugstr_guid
(
riid
),
pdev
,
unicode
);
TRACE
(
"%p %s %p
\n
"
,
dinput
,
debugstr_guid
(
rguid
),
out
);
find_joystick_devices
();
*
pdev
=
NULL
;
*
out
=
NULL
;
if
((
index
=
get_joystick_index
(
rguid
))
<
MAX_JOYSTICKS
&&
joystick_devices_count
&&
index
<
joystick_devices_count
)
...
...
@@ -601,37 +601,11 @@ static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REF
JoystickImpl
*
This
;
HRESULT
hr
;
if
(
riid
==
NULL
)
;
/* nothing */
else
if
(
IsEqualGUID
(
&
IID_IDirectInputDeviceA
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8A
,
riid
))
{
unicode
=
0
;
}
else
if
(
IsEqualGUID
(
&
IID_IDirectInputDeviceW
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8W
,
riid
))
{
unicode
=
1
;
}
else
{
WARN
(
"no interface
\n
"
);
return
DIERR_NOINTERFACE
;
}
if
(
FAILED
(
hr
=
alloc_device
(
rguid
,
dinput
,
&
This
,
index
)))
return
hr
;
TRACE
(
"Created a Joystick device (%p)
\n
"
,
This
);
if
(
unicode
)
*
pdev
=
&
This
->
generic
.
base
.
IDirectInputDevice8W_iface
;
else
*
pdev
=
&
This
->
generic
.
base
.
IDirectInputDevice8A_iface
;
*
out
=
&
This
->
generic
.
base
.
IDirectInputDevice8W_iface
;
return
hr
;
}
...
...
dlls/dinput/joystick_linuxinput.c
View file @
17958bc8
...
...
@@ -612,13 +612,13 @@ static unsigned short get_joystick_index(REFGUID guid)
return
MAX_JOYDEV
;
}
static
HRESULT
joydev_create_device
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPVOID
*
pdev
,
int
unicode
)
static
HRESULT
joydev_create_device
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
IDirectInputDevice8W
**
out
)
{
unsigned
short
index
;
TRACE
(
"%p %s %s %p %i
\n
"
,
dinput
,
debugstr_guid
(
rguid
),
debugstr_guid
(
riid
),
pdev
,
unicode
);
TRACE
(
"%p %s %p
\n
"
,
dinput
,
debugstr_guid
(
rguid
),
out
);
find_joydevs
();
*
pdev
=
NULL
;
*
out
=
NULL
;
if
((
index
=
get_joystick_index
(
rguid
))
<
MAX_JOYDEV
&&
have_joydevs
&&
index
<
have_joydevs
)
...
...
@@ -626,37 +626,11 @@ static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REF
JoystickImpl
*
This
;
HRESULT
hr
;
if
(
riid
==
NULL
)
;
/* nothing */
else
if
(
IsEqualGUID
(
&
IID_IDirectInputDeviceA
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8A
,
riid
))
{
unicode
=
0
;
}
else
if
(
IsEqualGUID
(
&
IID_IDirectInputDeviceW
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8W
,
riid
))
{
unicode
=
1
;
}
else
{
WARN
(
"no interface
\n
"
);
return
DIERR_NOINTERFACE
;
}
if
(
FAILED
(
hr
=
alloc_device
(
rguid
,
dinput
,
&
This
,
index
)))
return
hr
;
TRACE
(
"Created a Joystick device (%p)
\n
"
,
This
);
if
(
unicode
)
*
pdev
=
&
This
->
generic
.
base
.
IDirectInputDevice8W_iface
;
else
*
pdev
=
&
This
->
generic
.
base
.
IDirectInputDevice8A_iface
;
*
out
=
&
This
->
generic
.
base
.
IDirectInputDevice8W_iface
;
return
DI_OK
;
}
...
...
dlls/dinput/joystick_osx.c
View file @
17958bc8
...
...
@@ -1323,13 +1323,13 @@ static unsigned short get_joystick_index(REFGUID guid)
return
0xffff
;
}
static
HRESULT
joydev_create_device
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPVOID
*
pdev
,
int
unicode
)
static
HRESULT
joydev_create_device
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
IDirectInputDevice8W
**
out
)
{
unsigned
short
index
;
int
joystick_devices_count
;
TRACE
(
"%p %s %s %p %i
\n
"
,
dinput
,
debugstr_guid
(
rguid
),
debugstr_guid
(
riid
),
pdev
,
unicode
);
*
pdev
=
NULL
;
TRACE
(
"%p %s %p
\n
"
,
dinput
,
debugstr_guid
(
rguid
),
out
);
*
out
=
NULL
;
if
((
joystick_devices_count
=
find_joystick_devices
())
==
0
)
return
DIERR_DEVICENOTREG
;
...
...
@@ -1340,36 +1340,11 @@ static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REF
JoystickImpl
*
This
;
HRESULT
hr
;
if
(
riid
==
NULL
)
;
/* nothing */
else
if
(
IsEqualGUID
(
&
IID_IDirectInputDeviceA
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8A
,
riid
))
{
unicode
=
0
;
}
else
if
(
IsEqualGUID
(
&
IID_IDirectInputDeviceW
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8W
,
riid
))
{
unicode
=
1
;
}
else
{
WARN
(
"no interface
\n
"
);
return
DIERR_NOINTERFACE
;
}
if
(
FAILED
(
hr
=
alloc_device
(
rguid
,
dinput
,
&
This
,
index
)))
return
hr
;
TRACE
(
"Created a Joystick device (%p)
\n
"
,
This
);
if
(
unicode
)
*
pdev
=
&
This
->
generic
.
base
.
IDirectInputDevice8W_iface
;
else
*
pdev
=
&
This
->
generic
.
base
.
IDirectInputDevice8A_iface
;
*
out
=
&
This
->
generic
.
base
.
IDirectInputDevice8W_iface
;
return
hr
;
}
...
...
dlls/dinput/keyboard.c
View file @
17958bc8
...
...
@@ -283,48 +283,21 @@ failed:
return
DIERR_OUTOFMEMORY
;
}
static
HRESULT
keyboarddev_create_device
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPVOID
*
pdev
,
int
unicode
)
static
HRESULT
keyboarddev_create_device
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
IDirectInputDevice8W
**
out
)
{
TRACE
(
"%p %s %s %p %i
\n
"
,
dinput
,
debugstr_guid
(
rguid
),
debugstr_guid
(
riid
),
pdev
,
unicode
);
*
pdev
=
NULL
;
TRACE
(
"%p %s %p
\n
"
,
dinput
,
debugstr_guid
(
rguid
),
out
);
*
out
=
NULL
;
if
(
IsEqualGUID
(
&
GUID_SysKeyboard
,
rguid
))
/* Wine Keyboard */
{
SysKeyboardImpl
*
This
;
HRESULT
hr
;
if
(
riid
==
NULL
)
;
/* nothing */
else
if
(
IsEqualGUID
(
&
IID_IDirectInputDeviceA
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8A
,
riid
))
{
unicode
=
0
;
}
else
if
(
IsEqualGUID
(
&
IID_IDirectInputDeviceW
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8W
,
riid
))
{
unicode
=
1
;
}
else
{
WARN
(
"no interface
\n
"
);
return
DIERR_NOINTERFACE
;
}
if
(
FAILED
(
hr
=
alloc_device
(
rguid
,
dinput
,
&
This
)))
return
hr
;
TRACE
(
"Created a Keyboard device (%p)
\n
"
,
This
);
if
(
unicode
)
*
pdev
=
&
This
->
base
.
IDirectInputDevice8W_iface
;
else
*
pdev
=
&
This
->
base
.
IDirectInputDevice8A_iface
;
*
out
=
&
This
->
base
.
IDirectInputDevice8W_iface
;
return
DI_OK
;
}
...
...
dlls/dinput/mouse.c
View file @
17958bc8
...
...
@@ -240,47 +240,21 @@ failed:
return
DIERR_OUTOFMEMORY
;
}
static
HRESULT
mousedev_create_device
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPVOID
*
pdev
,
int
unicode
)
static
HRESULT
mousedev_create_device
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
IDirectInputDevice8W
**
out
)
{
TRACE
(
"%p %s %s %p %i
\n
"
,
dinput
,
debugstr_guid
(
rguid
),
debugstr_guid
(
riid
),
pdev
,
unicode
);
*
pdev
=
NULL
;
TRACE
(
"%p %s %p
\n
"
,
dinput
,
debugstr_guid
(
rguid
),
out
);
*
out
=
NULL
;
if
(
IsEqualGUID
(
&
GUID_SysMouse
,
rguid
))
/* Wine Mouse */
{
SysMouseImpl
*
This
;
HRESULT
hr
;
if
(
riid
==
NULL
)
;
/* nothing */
else
if
(
IsEqualGUID
(
&
IID_IDirectInputDeviceA
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8A
,
riid
))
{
unicode
=
0
;
}
else
if
(
IsEqualGUID
(
&
IID_IDirectInputDeviceW
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8W
,
riid
))
{
unicode
=
1
;
}
else
{
WARN
(
"no interface
\n
"
);
return
DIERR_NOINTERFACE
;
}
if
(
FAILED
(
hr
=
alloc_device
(
rguid
,
dinput
,
&
This
)))
return
hr
;
TRACE
(
"Created a Mouse device (%p)
\n
"
,
This
);
if
(
unicode
)
*
pdev
=
&
This
->
base
.
IDirectInputDevice8W_iface
;
else
*
pdev
=
&
This
->
base
.
IDirectInputDevice8A_iface
;
*
out
=
&
This
->
base
.
IDirectInputDevice8W_iface
;
return
DI_OK
;
}
...
...
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