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
0ac5c603
Commit
0ac5c603
authored
Jan 23, 2011
by
Vitaliy Margolen
Committed by
Alexandre Julliard
Jan 24, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dinput: Combine ASCII and Unicode device create callbacks. Add tests.
parent
27d31c76
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
218 additions
and
256 deletions
+218
-256
dinput_main.c
dlls/dinput/dinput_main.c
+4
-4
dinput_private.h
dlls/dinput/dinput_private.h
+1
-2
joystick_linux.c
dlls/dinput/joystick_linux.c
+32
-46
joystick_linuxinput.c
dlls/dinput/joystick_linuxinput.c
+34
-54
joystick_osx.c
dlls/dinput/joystick_osx.c
+32
-50
keyboard.c
dlls/dinput/keyboard.c
+45
-46
mouse.c
dlls/dinput/mouse.c
+43
-48
device.c
dlls/dinput/tests/device.c
+27
-6
No files found.
dlls/dinput/dinput_main.c
View file @
0ac5c603
...
...
@@ -504,8 +504,8 @@ static HRESULT WINAPI IDirectInput7AImpl_CreateDeviceEx(LPDIRECTINPUT7A iface, R
for
(
i
=
0
;
i
<
NB_DINPUT_DEVICES
;
i
++
)
{
HRESULT
ret
;
if
(
!
dinput_devices
[
i
]
->
create_device
A
)
continue
;
if
((
ret
=
dinput_devices
[
i
]
->
create_device
A
(
This
,
rguid
,
riid
,
(
LPDIRECTINPUTDEVICEA
*
)
pvOut
))
==
DI_OK
)
if
(
!
dinput_devices
[
i
]
->
create_device
)
continue
;
if
((
ret
=
dinput_devices
[
i
]
->
create_device
(
This
,
rguid
,
riid
,
pvOut
,
0
))
==
DI_OK
)
return
DI_OK
;
if
(
ret
==
DIERR_NOINTERFACE
)
...
...
@@ -535,8 +535,8 @@ static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx(LPDIRECTINPUT7W iface, R
for
(
i
=
0
;
i
<
NB_DINPUT_DEVICES
;
i
++
)
{
HRESULT
ret
;
if
(
!
dinput_devices
[
i
]
->
create_device
W
)
continue
;
if
((
ret
=
dinput_devices
[
i
]
->
create_device
W
(
This
,
rguid
,
riid
,
(
LPDIRECTINPUTDEVICEW
*
)
pvOut
))
==
DI_OK
)
if
(
!
dinput_devices
[
i
]
->
create_device
)
continue
;
if
((
ret
=
dinput_devices
[
i
]
->
create_device
(
This
,
rguid
,
riid
,
pvOut
,
1
))
==
DI_OK
)
return
DI_OK
;
if
(
ret
==
DIERR_NOINTERFACE
)
...
...
dlls/dinput/dinput_private.h
View file @
0ac5c603
...
...
@@ -50,8 +50,7 @@ struct dinput_device {
const
char
*
name
;
BOOL
(
*
enum_deviceA
)(
DWORD
dwDevType
,
DWORD
dwFlags
,
LPDIDEVICEINSTANCEA
lpddi
,
DWORD
version
,
int
id
);
BOOL
(
*
enum_deviceW
)(
DWORD
dwDevType
,
DWORD
dwFlags
,
LPDIDEVICEINSTANCEW
lpddi
,
DWORD
version
,
int
id
);
HRESULT
(
*
create_deviceA
)(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPDIRECTINPUTDEVICEA
*
pdev
);
HRESULT
(
*
create_deviceW
)(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPDIRECTINPUTDEVICEW
*
pdev
);
HRESULT
(
*
create_device
)(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPVOID
*
pdev
,
int
unicode
);
};
extern
const
struct
dinput_device
mouse_device
;
...
...
dlls/dinput/joystick_linux.c
View file @
0ac5c603
...
...
@@ -450,65 +450,53 @@ static unsigned short get_joystick_index(REFGUID guid)
return
MAX_JOYSTICKS
;
}
static
HRESULT
joydev_create_device
A
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPDIRECTINPUTDEVICEA
*
pdev
)
static
HRESULT
joydev_create_device
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPVOID
*
pdev
,
int
unicode
)
{
unsigned
short
index
;
TRACE
(
"%p %s %
p %p
\n
"
,
dinput
,
debugstr_guid
(
rguid
),
riid
,
pdev
);
TRACE
(
"%p %s %
s %p %i
\n
"
,
dinput
,
debugstr_guid
(
rguid
),
debugstr_guid
(
riid
),
pdev
,
unicode
);
find_joystick_devices
();
*
pdev
=
NULL
;
if
((
index
=
get_joystick_index
(
rguid
))
<
MAX_JOYSTICKS
&&
joystick_devices_count
&&
index
<
joystick_devices_count
)
{
if
((
riid
==
NULL
)
||
IsEqualGUID
(
&
IID_IDirectInputDeviceA
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8A
,
riid
))
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
))
{
JoystickImpl
*
This
;
HRESULT
hr
=
alloc_device
(
rguid
,
dinput
,
&
This
,
index
);
*
pdev
=
(
LPDIRECTINPUTDEVICEA
)(
This
?
&
This
->
generic
.
base
.
IDirectInputDevice8A_iface
:
NULL
);
return
hr
;
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
;
}
WARN
(
"no interface
\n
"
);
return
DIERR_NOINTERFACE
;
}
return
DIERR_DEVICENOTREG
;
}
static
HRESULT
joydev_create_deviceW
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPDIRECTINPUTDEVICEW
*
pdev
)
{
unsigned
short
index
;
TRACE
(
"%p %s %p %p
\n
"
,
dinput
,
debugstr_guid
(
rguid
),
riid
,
pdev
);
find_joystick_devices
();
*
pdev
=
NULL
;
hr
=
alloc_device
(
rguid
,
dinput
,
&
This
,
index
);
if
(
!
This
)
return
hr
;
if
((
index
=
get_joystick_index
(
rguid
))
<
MAX_JOYSTICKS
&&
joystick_devices_count
&&
index
<
joystick_devices_count
)
{
if
((
riid
==
NULL
)
||
IsEqualGUID
(
&
IID_IDirectInputDeviceW
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8W
,
riid
))
{
JoystickImpl
*
This
;
HRESULT
hr
=
alloc_device
(
rguid
,
dinput
,
&
This
,
index
);
if
(
unicode
)
*
pdev
=
&
This
->
generic
.
base
.
IDirectInputDevice8W_iface
;
else
*
pdev
=
&
This
->
generic
.
base
.
IDirectInputDevice8A_iface
;
*
pdev
=
(
LPDIRECTINPUTDEVICEW
)(
This
?
&
This
->
generic
.
base
.
IDirectInputDevice8W_iface
:
NULL
);
return
hr
;
}
WARN
(
"no interface
\n
"
);
return
DIERR_NOINTERFACE
;
return
hr
;
}
WARN
(
"invalid device GUID %s
\n
"
,
debugstr_guid
(
rguid
));
return
DIERR_DEVICENOTREG
;
}
...
...
@@ -518,8 +506,7 @@ const struct dinput_device joystick_linux_device = {
"Wine Linux joystick driver"
,
joydev_enum_deviceA
,
joydev_enum_deviceW
,
joydev_create_deviceA
,
joydev_create_deviceW
joydev_create_device
};
/******************************************************************************
...
...
@@ -742,7 +729,6 @@ const struct dinput_device joystick_linux_device = {
"Wine Linux joystick driver"
,
NULL
,
NULL
,
NULL
,
NULL
};
...
...
dlls/dinput/joystick_linuxinput.c
View file @
0ac5c603
...
...
@@ -560,82 +560,63 @@ static unsigned short get_joystick_index(REFGUID guid)
return
MAX_JOYDEV
;
}
static
HRESULT
joydev_create_device
A
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPDIRECTINPUTDEVICEA
*
pdev
)
static
HRESULT
joydev_create_device
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPVOID
*
pdev
,
int
unicode
)
{
unsigned
short
index
;
TRACE
(
"%p %s %s %p %i
\n
"
,
dinput
,
debugstr_guid
(
rguid
),
debugstr_guid
(
riid
),
pdev
,
unicode
);
find_joydevs
();
*
pdev
=
NULL
;
if
((
index
=
get_joystick_index
(
rguid
))
<
MAX_JOYDEV
&&
have_joydevs
&&
index
<
have_joydevs
)
{
if
((
riid
==
NULL
)
||
IsEqualGUID
(
&
IID_IDirectInputDeviceA
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8A
,
riid
))
JoystickImpl
*
This
;
if
(
riid
==
NULL
)
;
/* nothing */
else
if
(
IsEqualGUID
(
&
IID_IDirectInputDeviceA
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8A
,
riid
))
{
JoystickImpl
*
This
=
alloc_device
(
rguid
,
dinput
,
index
);
TRACE
(
"Created a Joystick device (%p)
\n
"
,
This
);
if
(
!
This
)
{
ERR
(
"out of memory
\n
"
);
*
pdev
=
NULL
;
return
DIERR_OUTOFMEMORY
;
}
*
pdev
=
(
IDirectInputDeviceA
*
)
&
This
->
generic
.
base
.
IDirectInputDevice8A_iface
;
return
DI_OK
;
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
;
}
WARN
(
"no interface
\n
"
);
return
DIERR_NOINTERFACE
;
}
return
DIERR_DEVICENOTREG
;
}
This
=
alloc_device
(
rguid
,
dinput
,
index
);
TRACE
(
"Created a Joystick device (%p)
\n
"
,
This
);
if
(
!
This
)
return
DIERR_OUTOFMEMORY
;
static
HRESULT
joydev_create_deviceW
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPDIRECTINPUTDEVICEW
*
pdev
)
{
unsigned
short
index
;
find_joydevs
();
if
((
index
=
get_joystick_index
(
rguid
))
<
MAX_JOYDEV
&&
have_joydevs
&&
index
<
have_joydevs
)
{
if
((
riid
==
NULL
)
||
IsEqualGUID
(
&
IID_IDirectInputDeviceW
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8W
,
riid
))
{
JoystickImpl
*
This
=
alloc_device
(
rguid
,
dinput
,
index
);
TRACE
(
"Created a Joystick device (%p)
\n
"
,
This
);
if
(
unicode
)
*
pdev
=
&
This
->
generic
.
base
.
IDirectInputDevice8W_iface
;
else
*
pdev
=
&
This
->
generic
.
base
.
IDirectInputDevice8A_iface
;
if
(
!
This
)
{
ERR
(
"out of memory
\n
"
);
return
DIERR_OUTOFMEMORY
;
}
*
pdev
=
(
IDirectInputDeviceW
*
)
&
This
->
generic
.
base
.
IDirectInputDevice8W_iface
;
return
DI_OK
;
}
WARN
(
"no interface
\n
"
);
return
DIERR_NOINTERFACE
;
return
DI_OK
;
}
WARN
(
"invalid device GUID
\n
"
);
return
DIERR_DEVICENOTREG
;
}
const
struct
dinput_device
joystick_linuxinput_device
=
{
"Wine Linux-input joystick driver"
,
joydev_enum_deviceA
,
joydev_enum_deviceW
,
joydev_create_deviceA
,
joydev_create_deviceW
joydev_create_device
};
/******************************************************************************
...
...
@@ -1456,7 +1437,6 @@ const struct dinput_device joystick_linuxinput_device = {
"Wine Linux-input joystick driver"
,
NULL
,
NULL
,
NULL
,
NULL
};
...
...
dlls/dinput/joystick_osx.c
View file @
0ac5c603
...
...
@@ -878,12 +878,12 @@ static unsigned short get_joystick_index(REFGUID guid)
return
0xffff
;
}
static
HRESULT
joydev_create_device
A
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPDIRECTINPUTDEVICEA
*
pdev
)
static
HRESULT
joydev_create_device
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPVOID
*
pdev
,
int
unicode
)
{
unsigned
short
index
;
int
joystick_devices_count
;
TRACE
(
"%p %s %
p %p
\n
"
,
dinput
,
debugstr_guid
(
rguid
),
riid
,
pdev
);
TRACE
(
"%p %s %
s %p %i
\n
"
,
dinput
,
debugstr_guid
(
rguid
),
debugstr_guid
(
riid
),
pdev
,
unicode
);
*
pdev
=
NULL
;
if
((
joystick_devices_count
=
find_joystick_devices
())
==
0
)
...
...
@@ -892,57 +892,41 @@ static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, RE
if
((
index
=
get_joystick_index
(
rguid
))
<
0xffff
&&
joystick_devices_count
&&
index
<
joystick_devices_count
)
{
if
((
riid
==
NULL
)
||
IsEqualGUID
(
&
IID_IDirectInputDeviceA
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8A
,
riid
))
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
))
{
JoystickImpl
*
This
;
HRESULT
hr
=
alloc_device
(
rguid
,
dinput
,
&
This
,
index
);
*
pdev
=
(
LPDIRECTINPUTDEVICEA
)(
This
?
&
This
->
generic
.
base
.
IDirectInputDevice8A_iface
:
NULL
);
return
hr
;
unicode
=
0
;
}
WARN
(
"no interface
\n
"
);
return
DIERR_NOINTERFACE
;
}
return
DIERR_DEVICENOTREG
;
}
static
HRESULT
joydev_create_deviceW
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPDIRECTINPUTDEVICEW
*
pdev
)
{
unsigned
short
index
;
int
joystick_devices_count
;
TRACE
(
"%p %s %p %p
\n
"
,
dinput
,
debugstr_guid
(
rguid
),
riid
,
pdev
);
*
pdev
=
NULL
;
if
((
joystick_devices_count
=
find_joystick_devices
())
==
0
)
return
DIERR_DEVICENOTREG
;
if
((
index
=
get_joystick_index
(
rguid
))
<
0xffff
&&
joystick_devices_count
&&
index
<
joystick_devices_count
)
{
if
((
riid
==
NULL
)
||
IsEqualGUID
(
&
IID_IDirectInputDeviceW
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8W
,
riid
))
else
if
(
IsEqualGUID
(
&
IID_IDirectInputDeviceW
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8W
,
riid
))
{
JoystickImpl
*
This
;
HRESULT
hr
=
alloc_device
(
rguid
,
dinput
,
&
This
,
index
);
*
pdev
=
(
LPDIRECTINPUTDEVICEW
)(
This
?
&
This
->
generic
.
base
.
IDirectInputDevice8W_iface
:
NULL
);
return
hr
;
unicode
=
1
;
}
WARN
(
"no interface
\n
"
);
return
DIERR_NOINTERFACE
;
else
{
WARN
(
"no interface
\n
"
);
return
DIERR_NOINTERFACE
;
}
hr
=
alloc_device
(
rguid
,
dinput
,
&
This
,
index
);
if
(
!
This
)
return
hr
;
if
(
unicode
)
*
pdev
=
&
This
->
generic
.
base
.
IDirectInputDevice8W_iface
;
else
*
pdev
=
&
This
->
generic
.
base
.
IDirectInputDevice8A_iface
;
return
hr
;
}
WARN
(
"invalid device GUID %s
\n
"
,
debugstr_guid
(
rguid
));
return
DIERR_DEVICENOTREG
;
}
...
...
@@ -950,8 +934,7 @@ const struct dinput_device joystick_osx_device = {
"Wine OS X joystick driver"
,
joydev_enum_deviceA
,
joydev_enum_deviceW
,
joydev_create_deviceA
,
joydev_create_deviceW
joydev_create_device
};
static
const
IDirectInputDevice8AVtbl
JoystickAvt
=
...
...
@@ -1032,7 +1015,6 @@ const struct dinput_device joystick_osx_device = {
"Wine OS X joystick driver"
,
NULL
,
NULL
,
NULL
,
NULL
};
...
...
dlls/dinput/keyboard.c
View file @
0ac5c603
...
...
@@ -270,60 +270,59 @@ failed:
}
static
HRESULT
keyboarddev_create_device
A
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPDIRECTINPUTDEVICEA
*
pdev
)
static
HRESULT
keyboarddev_create_device
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPVOID
*
pdev
,
int
unicode
)
{
if
((
IsEqualGUID
(
&
GUID_SysKeyboard
,
rguid
))
||
/* Generic Keyboard */
(
IsEqualGUID
(
&
DInput_Wine_Keyboard_GUID
,
rguid
)))
{
/* Wine Keyboard */
if
((
riid
==
NULL
)
||
IsEqualGUID
(
&
IID_IDirectInputDeviceA
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8A
,
riid
))
{
SysKeyboardImpl
*
This
=
alloc_device
(
rguid
,
dinput
);
if
(
!
This
)
{
*
pdev
=
NULL
;
return
DIERR_OUTOFMEMORY
;
}
*
pdev
=
(
IDirectInputDeviceA
*
)
&
This
->
base
.
IDirectInputDevice8A_iface
;
TRACE
(
"Creating a Keyboard device (%p)
\n
"
,
*
pdev
);
return
DI_OK
;
}
else
return
DIERR_NOINTERFACE
;
}
return
DIERR_DEVICENOTREG
;
}
TRACE
(
"%p %s %s %p %i
\n
"
,
dinput
,
debugstr_guid
(
rguid
),
debugstr_guid
(
riid
),
pdev
,
unicode
);
*
pdev
=
NULL
;
static
HRESULT
keyboarddev_create_deviceW
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPDIRECTINPUTDEVICEW
*
pdev
)
{
if
((
IsEqualGUID
(
&
GUID_SysKeyboard
,
rguid
))
||
/* Generic Keyboard */
(
IsEqualGUID
(
&
DInput_Wine_Keyboard_GUID
,
rguid
)))
{
/* Wine Keyboard */
if
((
riid
==
NULL
)
||
IsEqualGUID
(
&
IID_IDirectInputDeviceW
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8W
,
riid
))
{
SysKeyboardImpl
*
This
=
alloc_device
(
rguid
,
dinput
);
if
(
!
This
)
{
*
pdev
=
NULL
;
return
DIERR_OUTOFMEMORY
;
}
*
pdev
=
(
IDirectInputDeviceW
*
)
&
This
->
base
.
IDirectInputDevice8W_iface
;
TRACE
(
"Creating a Keyboard device (%p)
\n
"
,
*
pdev
);
return
DI_OK
;
}
else
return
DIERR_NOINTERFACE
;
}
return
DIERR_DEVICENOTREG
;
if
(
IsEqualGUID
(
&
GUID_SysKeyboard
,
rguid
)
||
/* Generic Keyboard */
IsEqualGUID
(
&
DInput_Wine_Keyboard_GUID
,
rguid
))
/* Wine Keyboard */
{
SysKeyboardImpl
*
This
;
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
;
}
This
=
alloc_device
(
rguid
,
dinput
);
TRACE
(
"Created a Keyboard device (%p)
\n
"
,
This
);
if
(
!
This
)
return
DIERR_OUTOFMEMORY
;
if
(
unicode
)
*
pdev
=
&
This
->
base
.
IDirectInputDevice8W_iface
;
else
*
pdev
=
&
This
->
base
.
IDirectInputDevice8A_iface
;
return
DI_OK
;
}
return
DIERR_DEVICENOTREG
;
}
const
struct
dinput_device
keyboard_device
=
{
"Wine keyboard driver"
,
keyboarddev_enum_deviceA
,
keyboarddev_enum_deviceW
,
keyboarddev_create_deviceA
,
keyboarddev_create_deviceW
keyboarddev_create_device
};
static
HRESULT
WINAPI
SysKeyboardWImpl_GetDeviceState
(
LPDIRECTINPUTDEVICE8W
iface
,
DWORD
len
,
LPVOID
ptr
)
...
...
dlls/dinput/mouse.c
View file @
0ac5c603
...
...
@@ -256,55 +256,51 @@ failed:
return
NULL
;
}
static
HRESULT
mousedev_create_device
A
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPDIRECTINPUTDEVICEA
*
pdev
)
static
HRESULT
mousedev_create_device
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPVOID
*
pdev
,
int
unicode
)
{
if
((
IsEqualGUID
(
&
GUID_SysMouse
,
rguid
))
||
/* Generic Mouse */
(
IsEqualGUID
(
&
DInput_Wine_Mouse_GUID
,
rguid
)))
{
/* Wine Mouse */
if
((
riid
==
NULL
)
||
IsEqualGUID
(
&
IID_IDirectInputDeviceA
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8A
,
riid
))
{
SysMouseImpl
*
This
=
alloc_device
(
rguid
,
dinput
);
TRACE
(
"Created a Mouse device (%p)
\n
"
,
This
);
if
(
!
This
)
{
*
pdev
=
NULL
;
return
DIERR_OUTOFMEMORY
;
}
*
pdev
=
(
IDirectInputDeviceA
*
)
&
This
->
base
.
IDirectInputDevice8A_iface
;
return
DI_OK
;
}
else
return
DIERR_NOINTERFACE
;
}
return
DIERR_DEVICENOTREG
;
}
TRACE
(
"%p %s %s %p %i
\n
"
,
dinput
,
debugstr_guid
(
rguid
),
debugstr_guid
(
riid
),
pdev
,
unicode
);
*
pdev
=
NULL
;
static
HRESULT
mousedev_create_deviceW
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPDIRECTINPUTDEVICEW
*
pdev
)
{
if
((
IsEqualGUID
(
&
GUID_SysMouse
,
rguid
))
||
/* Generic Mouse */
(
IsEqualGUID
(
&
DInput_Wine_Mouse_GUID
,
rguid
)))
{
/* Wine Mouse */
if
((
riid
==
NULL
)
||
IsEqualGUID
(
&
IID_IDirectInputDeviceW
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8W
,
riid
))
{
SysMouseImpl
*
This
=
alloc_device
(
rguid
,
dinput
);
TRACE
(
"Created a Mouse device (%p)
\n
"
,
This
);
if
(
!
This
)
{
*
pdev
=
NULL
;
return
DIERR_OUTOFMEMORY
;
}
*
pdev
=
(
IDirectInputDeviceW
*
)
&
This
->
base
.
IDirectInputDevice8W_iface
;
return
DI_OK
;
}
else
return
DIERR_NOINTERFACE
;
if
(
IsEqualGUID
(
&
GUID_SysMouse
,
rguid
)
||
/* Generic Mouse */
IsEqualGUID
(
&
DInput_Wine_Mouse_GUID
,
rguid
))
/* Wine Mouse */
{
SysMouseImpl
*
This
;
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
;
}
This
=
alloc_device
(
rguid
,
dinput
);
TRACE
(
"Created a Mouse device (%p)
\n
"
,
This
);
if
(
!
This
)
return
DIERR_OUTOFMEMORY
;
if
(
unicode
)
*
pdev
=
&
This
->
base
.
IDirectInputDevice8W_iface
;
else
*
pdev
=
&
This
->
base
.
IDirectInputDevice8A_iface
;
return
DI_OK
;
}
return
DIERR_DEVICENOTREG
;
}
...
...
@@ -312,8 +308,7 @@ const struct dinput_device mouse_device = {
"Wine mouse driver"
,
mousedev_enum_deviceA
,
mousedev_enum_deviceW
,
mousedev_create_deviceA
,
mousedev_create_deviceW
mousedev_create_device
};
/******************************************************************************
...
...
dlls/dinput/tests/device.c
View file @
0ac5c603
...
...
@@ -109,6 +109,8 @@ static void test_object_info(LPDIRECTINPUTDEVICE device, HWND hwnd)
ok
(
hr
==
DI_OK
,
"Acquire() failed: %08x
\n
"
,
hr
);
hr
=
IDirectInputDevice_SetProperty
(
device
,
DIPROP_AXISMODE
,
&
dp
.
diph
);
ok
(
hr
==
DIERR_ACQUIRED
,
"SetProperty() returned: %08x
\n
"
,
hr
);
hr
=
IDirectInputDevice_Unacquire
(
device
);
ok
(
hr
==
DI_OK
,
"Unacquire() failed: %08x
\n
"
,
hr
);
}
}
...
...
@@ -121,7 +123,7 @@ struct enum_data
static
BOOL
CALLBACK
enum_devices
(
LPCDIDEVICEINSTANCE
lpddi
,
LPVOID
pvRef
)
{
struct
enum_data
*
data
=
pvRef
;
LPDIRECTINPUTDEVICE
device
;
LPDIRECTINPUTDEVICE
device
,
obj
=
NULL
;
HRESULT
hr
;
hr
=
IDirectInput_GetDeviceStatus
(
data
->
pDI
,
&
lpddi
->
guidInstance
);
...
...
@@ -131,8 +133,19 @@ static BOOL CALLBACK enum_devices(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef)
{
hr
=
IDirectInput_CreateDevice
(
data
->
pDI
,
&
lpddi
->
guidInstance
,
&
device
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"IDirectInput_CreateDevice() failed: %08x
\n
"
,
hr
);
trace
(
"Testing device
\"
%s
\"\n
"
,
lpddi
->
tszInstanceName
);
test_object_info
(
device
,
data
->
hwnd
);
trace
(
"Testing device %p
\"
%s
\"\n
"
,
device
,
lpddi
->
tszInstanceName
);
hr
=
IUnknown_QueryInterface
(
device
,
&
IID_IDirectInputDevice2A
,
(
LPVOID
*
)
&
obj
);
ok
(
SUCCEEDED
(
hr
),
"IUnknown_QueryInterface(IID_IDirectInputDevice7A) failed: %08x
\n
"
,
hr
);
test_object_info
(
obj
,
data
->
hwnd
);
if
(
obj
)
IUnknown_Release
(
obj
);
obj
=
NULL
;
hr
=
IUnknown_QueryInterface
(
device
,
&
IID_IDirectInputDevice2W
,
(
LPVOID
*
)
&
obj
);
ok
(
SUCCEEDED
(
hr
),
"IUnknown_QueryInterface(IID_IDirectInputDevice7W) failed: %08x
\n
"
,
hr
);
test_object_info
(
obj
,
data
->
hwnd
);
if
(
obj
)
IUnknown_Release
(
obj
);
IUnknown_Release
(
device
);
}
return
DIENUM_CONTINUE
;
...
...
@@ -141,13 +154,13 @@ static BOOL CALLBACK enum_devices(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef)
static
void
device_tests
(
void
)
{
HRESULT
hr
;
LPDIRECTINPUT
pDI
=
NULL
;
LPDIRECTINPUT
pDI
=
NULL
,
obj
=
NULL
;
HINSTANCE
hInstance
=
GetModuleHandle
(
NULL
);
HWND
hwnd
;
struct
enum_data
data
;
hr
=
DirectInputCreate
(
hInstance
,
DIRECTINPUT_VERSION
,
&
pDI
,
NULL
);
if
(
hr
==
DIERR_OLDDIRECTINPUTVERSION
)
hr
=
CoCreateInstance
(
&
CLSID_DirectInput
,
0
,
1
,
&
IID_IDirectInput2A
,
(
LPVOID
*
)
&
pDI
);
if
(
hr
==
DIERR_OLDDIRECTINPUTVERSION
||
hr
==
DIERR_DEVICENOTREG
)
{
skip
(
"Tests require a newer dinput version
\n
"
);
return
;
...
...
@@ -155,6 +168,13 @@ static void device_tests(void)
ok
(
SUCCEEDED
(
hr
),
"DirectInputCreate() failed: %08x
\n
"
,
hr
);
if
(
FAILED
(
hr
))
return
;
hr
=
IDirectInput_Initialize
(
pDI
,
hInstance
,
DIRECTINPUT_VERSION
);
ok
(
SUCCEEDED
(
hr
),
"Initialize() failed: %08x
\n
"
,
hr
);
if
(
FAILED
(
hr
))
return
;
hr
=
IUnknown_QueryInterface
(
pDI
,
&
IID_IDirectInput2W
,
(
LPVOID
*
)
&
obj
);
ok
(
SUCCEEDED
(
hr
),
"QueryInterface(IDirectInput7W) failed: %08x
\n
"
,
hr
);
hwnd
=
CreateWindow
(
"static"
,
"Title"
,
WS_OVERLAPPEDWINDOW
,
10
,
10
,
200
,
200
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
hwnd
!=
NULL
,
"err: %d
\n
"
,
GetLastError
());
...
...
@@ -181,6 +201,7 @@ static void device_tests(void)
DestroyWindow
(
hwnd
);
}
if
(
obj
)
IUnknown_Release
(
obj
);
if
(
pDI
)
IUnknown_Release
(
pDI
);
}
...
...
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