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
26932c84
Commit
26932c84
authored
Jul 05, 2011
by
Andrew Nguyen
Committed by
Alexandre Julliard
Jul 06, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dinput: Improve the behavior of IDirectInput::Initialize.
parent
c28512a5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
8 deletions
+95
-8
dinput_main.c
dlls/dinput/dinput_main.c
+29
-8
dinput.c
dlls/dinput/tests/dinput.c
+66
-0
No files found.
dlls/dinput/dinput_main.c
View file @
26932c84
...
...
@@ -472,14 +472,35 @@ static HRESULT WINAPI IDirectInputWImpl_QueryInterface(LPDIRECTINPUT7W iface, RE
return
IDirectInputAImpl_QueryInterface
(
&
This
->
IDirectInput7A_iface
,
riid
,
ppobj
);
}
static
HRESULT
WINAPI
IDirectInputAImpl_Initialize
(
LPDIRECTINPUT7A
iface
,
HINSTANCE
hinst
,
DWORD
x
)
{
TRACE
(
"(this=%p,%p,%x)
\n
"
,
iface
,
hinst
,
x
);
/* Initialize can return: DIERR_BETADIRECTINPUTVERSION, DIERR_OLDDIRECTINPUTVERSION and DI_OK.
* Since we already initialized the device, return DI_OK. In the past we returned DIERR_ALREADYINITIALIZED
* which broke applications like Tomb Raider Legend because it isn't a legal return value.
*/
return
DI_OK
;
enum
directinput_versions
{
DIRECTINPUT_VERSION_300
=
0x0300
,
DIRECTINPUT_VERSION_500
=
0x0500
,
DIRECTINPUT_VERSION_50A
=
0x050A
,
DIRECTINPUT_VERSION_5B2
=
0x05B2
,
DIRECTINPUT_VERSION_602
=
0x0602
,
DIRECTINPUT_VERSION_61A
=
0x061A
,
DIRECTINPUT_VERSION_700
=
0x0700
,
};
static
HRESULT
WINAPI
IDirectInputAImpl_Initialize
(
LPDIRECTINPUT7A
iface
,
HINSTANCE
hinst
,
DWORD
version
)
{
TRACE
(
"(%p)->(%p, 0x%04x)
\n
"
,
iface
,
hinst
,
version
);
if
(
!
hinst
)
return
DIERR_INVALIDPARAM
;
else
if
(
version
==
0
)
return
DIERR_NOTINITIALIZED
;
/* We need to accept version 8, even though native rejects it. */
else
if
(
version
>
DIRECTINPUT_VERSION_700
&&
version
!=
DIRECTINPUT_VERSION
)
return
DIERR_OLDDIRECTINPUTVERSION
;
else
if
(
version
!=
DIRECTINPUT_VERSION_300
&&
version
!=
DIRECTINPUT_VERSION_500
&&
version
!=
DIRECTINPUT_VERSION_50A
&&
version
!=
DIRECTINPUT_VERSION_5B2
&&
version
!=
DIRECTINPUT_VERSION_602
&&
version
!=
DIRECTINPUT_VERSION_61A
&&
version
!=
DIRECTINPUT_VERSION_700
&&
version
!=
DIRECTINPUT_VERSION
)
return
DIERR_BETADIRECTINPUTVERSION
;
return
DI_OK
;
}
static
HRESULT
WINAPI
IDirectInputWImpl_Initialize
(
LPDIRECTINPUT7W
iface
,
HINSTANCE
hinst
,
DWORD
x
)
...
...
dlls/dinput/tests/dinput.c
View file @
26932c84
...
...
@@ -27,6 +27,28 @@
HINSTANCE
hInstance
;
enum
directinput_versions
{
DIRECTINPUT_VERSION_300
=
0x0300
,
DIRECTINPUT_VERSION_500
=
0x0500
,
DIRECTINPUT_VERSION_50A
=
0x050A
,
DIRECTINPUT_VERSION_5B2
=
0x05B2
,
DIRECTINPUT_VERSION_602
=
0x0602
,
DIRECTINPUT_VERSION_61A
=
0x061A
,
DIRECTINPUT_VERSION_700
=
0x0700
,
};
static
const
DWORD
directinput_version_list
[]
=
{
DIRECTINPUT_VERSION_300
,
DIRECTINPUT_VERSION_500
,
DIRECTINPUT_VERSION_50A
,
DIRECTINPUT_VERSION_5B2
,
DIRECTINPUT_VERSION_602
,
DIRECTINPUT_VERSION_61A
,
DIRECTINPUT_VERSION_700
,
};
static
void
test_QueryInterface
(
void
)
{
static
const
REFIID
iid_list
[]
=
{
&
IID_IUnknown
,
&
IID_IDirectInputA
,
&
IID_IDirectInputW
,
...
...
@@ -107,6 +129,49 @@ static void test_QueryInterface(void)
IDirectInput_Release
(
pDI
);
}
static
void
test_Initialize
(
void
)
{
IDirectInputA
*
pDI
;
HRESULT
hr
;
int
i
;
hr
=
CoCreateInstance
(
&
CLSID_DirectInput
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IDirectInputA
,
(
void
**
)
&
pDI
);
if
(
FAILED
(
hr
))
{
win_skip
(
"Failed to instantiate a IDirectInputA instance: 0x%08x
\n
"
,
hr
);
return
;
}
hr
=
IDirectInput_Initialize
(
pDI
,
NULL
,
0
);
ok
(
hr
==
DIERR_INVALIDPARAM
,
"IDirectInput_Initialize returned 0x%08x
\n
"
,
hr
);
hr
=
IDirectInput_Initialize
(
pDI
,
NULL
,
DIRECTINPUT_VERSION
);
ok
(
hr
==
DIERR_INVALIDPARAM
,
"IDirectInput_Initialize returned 0x%08x
\n
"
,
hr
);
hr
=
IDirectInput_Initialize
(
pDI
,
hInstance
,
0
);
ok
(
hr
==
DIERR_NOTINITIALIZED
,
"IDirectInput_Initialize returned 0x%08x
\n
"
,
hr
);
/* Invalid DirectInput versions less than 0x0700 yield DIERR_BETADIRECTINPUTVERSION. */
hr
=
IDirectInput_Initialize
(
pDI
,
hInstance
,
0x0123
);
ok
(
hr
==
DIERR_BETADIRECTINPUTVERSION
,
"IDirectInput_Initialize returned 0x%08x
\n
"
,
hr
);
/* Invalid DirectInput versions greater than 0x0700 yield DIERR_BETADIRECTINPUTVERSION. */
hr
=
IDirectInput_Initialize
(
pDI
,
hInstance
,
0xcafe
);
ok
(
hr
==
DIERR_OLDDIRECTINPUTVERSION
,
"IDirectInput_Initialize returned 0x%08x
\n
"
,
hr
);
for
(
i
=
0
;
i
<
sizeof
(
directinput_version_list
)
/
sizeof
(
directinput_version_list
[
0
]);
i
++
)
{
hr
=
IDirectInput_Initialize
(
pDI
,
hInstance
,
directinput_version_list
[
i
]);
ok
(
hr
==
DI_OK
,
"IDirectInput_Initialize returned 0x%08x
\n
"
,
hr
);
}
/* Parameters are still validated after successful initialization. */
hr
=
IDirectInput_Initialize
(
pDI
,
hInstance
,
0
);
ok
(
hr
==
DIERR_NOTINITIALIZED
,
"IDirectInput_Initialize returned 0x%08x
\n
"
,
hr
);
IDirectInput_Release
(
pDI
);
}
static
void
test_RunControlPanel
(
void
)
{
IDirectInputA
*
pDI
;
...
...
@@ -146,6 +211,7 @@ START_TEST(dinput)
CoInitialize
(
NULL
);
test_QueryInterface
();
test_Initialize
();
test_RunControlPanel
();
CoUninitialize
();
}
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