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
07753da9
Commit
07753da9
authored
Mar 15, 2023
by
Rémi Bernon
Committed by
Alexandre Julliard
Mar 16, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dinput/tests: Remove BuildActionMap / SaveActionMap mouse and keyboard tests.
parent
ed3f06b1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
517 deletions
+0
-517
device8.c
dlls/dinput/tests/device8.c
+0
-517
No files found.
dlls/dinput/tests/device8.c
View file @
07753da9
...
...
@@ -42,43 +42,7 @@ struct enum_data
IDirectInput8A
*
dinput8
;
IDirectInputA
*
dinput
;
};
DIACTIONFORMATA
*
lpdiaf
;
IDirectInputDevice8A
*
keyboard
;
IDirectInputDevice8A
*
mouse
;
const
char
*
username
;
int
ndevices
;
HWND
hwnd
;
};
/* Dummy GUID */
static
const
GUID
ACTION_MAPPING_GUID
=
{
0x1
,
0x2
,
0x3
,
{
0x4
,
0x5
,
0x6
,
0x7
,
0x8
,
0x9
,
0xa
,
0xb
}
};
enum
{
DITEST_AXIS
,
DITEST_BUTTON
,
DITEST_KEYBOARDSPACE
,
DITEST_MOUSEBUTTON0
,
DITEST_YAXIS
};
static
DIACTIONA
actionMapping
[]
=
{
/* axis */
{
0
,
0x01008A01
/* DIAXIS_DRIVINGR_STEER */
,
0
,
{
"Steer.
\0
"
}
},
/* button */
{
1
,
0x01000C01
/* DIBUTTON_DRIVINGR_SHIFTUP */
,
0
,
{
"Upshift.
\0
"
}
},
/* keyboard key */
{
2
,
DIKEYBOARD_SPACE
,
0
,
{
"Missile.
\0
"
}
},
/* mouse button */
{
3
,
DIMOUSE_BUTTON0
,
0
,
{
"Select
\0
"
}
},
/* mouse axis */
{
4
,
DIMOUSE_YAXIS
,
0
,
{
"Y Axis
\0
"
}
}
};
/* By placing the memory pointed to by lptszActionName right before memory with PAGE_NOACCESS
* one can find out that the regular ansi string termination is not respected by EnumDevicesBySemantics.
* Adding a double termination, making it a valid wide string termination, made the test succeed.
* Therefore it looks like ansi version of EnumDevicesBySemantics forwards the string to
* the wide variant without conversation. */
static
void
flush_events
(
void
)
{
...
...
@@ -574,485 +538,6 @@ static void test_device_input( IDirectInputDevice8A *device, DWORD type, DWORD c
CloseHandle
(
event
);
}
static
void
test_build_action_map
(
IDirectInputDevice8A
*
lpdid
,
DIACTIONFORMATA
*
lpdiaf
,
int
action_index
,
DWORD
expected_type
,
DWORD
expected_inst
)
{
HRESULT
hr
;
DIACTIONA
*
actions
;
DWORD
instance
,
type
,
how
;
GUID
assigned_to
;
DIDEVICEINSTANCEA
ddi
;
ddi
.
dwSize
=
sizeof
(
ddi
);
IDirectInputDevice_GetDeviceInfo
(
lpdid
,
&
ddi
);
hr
=
IDirectInputDevice8_BuildActionMap
(
lpdid
,
lpdiaf
,
NULL
,
DIDBAM_HWDEFAULTS
);
ok
(
SUCCEEDED
(
hr
),
"BuildActionMap failed hr=%#lx
\n
"
,
hr
);
actions
=
lpdiaf
->
rgoAction
;
instance
=
DIDFT_GETINSTANCE
(
actions
[
action_index
].
dwObjID
);
type
=
DIDFT_GETTYPE
(
actions
[
action_index
].
dwObjID
);
how
=
actions
[
action_index
].
dwHow
;
assigned_to
=
actions
[
action_index
].
guidInstance
;
ok
(
how
==
DIAH_USERCONFIG
||
how
==
DIAH_DEFAULT
,
"Action was not set dwHow=%#lx
\n
"
,
how
);
ok
(
instance
==
expected_inst
,
"Action not mapped correctly instance=%#lx expected=%#lx
\n
"
,
instance
,
expected_inst
);
ok
(
type
==
expected_type
,
"Action type not mapped correctly type=%#lx expected=%#lx
\n
"
,
type
,
expected_type
);
ok
(
IsEqualGUID
(
&
assigned_to
,
&
ddi
.
guidInstance
),
"Action and device GUID do not match action=%d
\n
"
,
action_index
);
}
static
BOOL
CALLBACK
enumeration_callback
(
const
DIDEVICEINSTANCEA
*
lpddi
,
IDirectInputDevice8A
*
lpdid
,
DWORD
dwFlags
,
DWORD
dwRemaining
,
LPVOID
pvRef
)
{
HRESULT
hr
;
DIPROPDWORD
dp
;
DIPROPRANGE
dpr
;
DIPROPSTRING
dps
;
WCHAR
usernameW
[
MAX_PATH
];
DWORD
username_size
=
MAX_PATH
;
struct
enum_data
*
data
=
pvRef
;
DWORD
cnt
;
DIDEVICEOBJECTDATA
buffer
[
5
];
IDirectInputDevice8A
*
lpdid2
;
if
(
!
data
)
return
DIENUM_CONTINUE
;
data
->
ndevices
++
;
/* Convert username to WCHAR */
if
(
data
->
username
!=
NULL
)
{
username_size
=
MultiByteToWideChar
(
CP_ACP
,
0
,
data
->
username
,
-
1
,
usernameW
,
0
);
MultiByteToWideChar
(
CP_ACP
,
0
,
data
->
username
,
-
1
,
usernameW
,
username_size
);
}
else
GetUserNameW
(
usernameW
,
&
username_size
);
/* collect the mouse and keyboard */
if
(
IsEqualGUID
(
&
lpddi
->
guidInstance
,
&
GUID_SysKeyboard
))
{
IDirectInputDevice_AddRef
(
lpdid
);
data
->
keyboard
=
lpdid
;
ok
(
dwFlags
&
DIEDBS_MAPPEDPRI1
,
"Keyboard should be mapped as pri1 dwFlags=%#lx
\n
"
,
dwFlags
);
}
if
(
IsEqualGUID
(
&
lpddi
->
guidInstance
,
&
GUID_SysMouse
))
{
IDirectInputDevice_AddRef
(
lpdid
);
data
->
mouse
=
lpdid
;
ok
(
dwFlags
&
DIEDBS_MAPPEDPRI1
,
"Mouse should be mapped as pri1 dwFlags=%#lx
\n
"
,
dwFlags
);
}
/* Creating second device object to check if it has the same username */
hr
=
IDirectInput_CreateDevice
(
data
->
dinput8
,
&
lpddi
->
guidInstance
,
&
lpdid2
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"IDirectInput_CreateDevice() failed: %#lx
\n
"
,
hr
);
/* Building and setting an action map */
/* It should not use any pre-stored mappings so we use DIDBAM_HWDEFAULTS */
hr
=
IDirectInputDevice8_BuildActionMap
(
lpdid
,
data
->
lpdiaf
,
NULL
,
DIDBAM_HWDEFAULTS
);
ok
(
SUCCEEDED
(
hr
),
"BuildActionMap failed hr=%#lx
\n
"
,
hr
);
/* Device has no data format and thus can't be acquired */
hr
=
IDirectInputDevice8_Acquire
(
lpdid
);
ok
(
hr
==
DIERR_INVALIDPARAM
,
"Device was acquired before SetActionMap hr=%#lx
\n
"
,
hr
);
hr
=
IDirectInputDevice8_SetActionMap
(
lpdid
,
data
->
lpdiaf
,
data
->
username
,
0
);
ok
(
SUCCEEDED
(
hr
),
"SetActionMap failed hr=%#lx
\n
"
,
hr
);
/* Some joysticks may have no suitable actions and thus should not be tested */
if
(
hr
==
DI_NOEFFECT
)
return
DIENUM_CONTINUE
;
/* Test username after SetActionMap */
dps
.
diph
.
dwSize
=
sizeof
(
dps
);
dps
.
diph
.
dwHeaderSize
=
sizeof
(
DIPROPHEADER
);
dps
.
diph
.
dwObj
=
0
;
dps
.
diph
.
dwHow
=
DIPH_DEVICE
;
dps
.
wsz
[
0
]
=
'\0'
;
hr
=
IDirectInputDevice_GetProperty
(
lpdid
,
DIPROP_USERNAME
,
&
dps
.
diph
);
ok
(
SUCCEEDED
(
hr
),
"GetProperty failed hr=%#lx
\n
"
,
hr
);
ok
(
!
lstrcmpW
(
usernameW
,
dps
.
wsz
),
"Username not set correctly expected=%s, got=%s
\n
"
,
wine_dbgstr_w
(
usernameW
),
wine_dbgstr_w
(
dps
.
wsz
));
dps
.
wsz
[
0
]
=
'\0'
;
hr
=
IDirectInputDevice_GetProperty
(
lpdid2
,
DIPROP_USERNAME
,
&
dps
.
diph
);
ok
(
SUCCEEDED
(
hr
),
"GetProperty failed hr=%#lx
\n
"
,
hr
);
ok
(
!
lstrcmpW
(
usernameW
,
dps
.
wsz
),
"Username not set correctly expected=%s, got=%s
\n
"
,
wine_dbgstr_w
(
usernameW
),
wine_dbgstr_w
(
dps
.
wsz
));
/* Test buffer size */
memset
(
&
dp
,
0
,
sizeof
(
dp
));
dp
.
diph
.
dwSize
=
sizeof
(
dp
);
dp
.
diph
.
dwHeaderSize
=
sizeof
(
DIPROPHEADER
);
dp
.
diph
.
dwHow
=
DIPH_DEVICE
;
hr
=
IDirectInputDevice_GetProperty
(
lpdid
,
DIPROP_BUFFERSIZE
,
&
dp
.
diph
);
ok
(
SUCCEEDED
(
hr
),
"GetProperty failed hr=%#lx
\n
"
,
hr
);
ok
(
dp
.
dwData
==
data
->
lpdiaf
->
dwBufferSize
,
"SetActionMap must set the buffer, buffersize=%lu
\n
"
,
dp
.
dwData
);
cnt
=
1
;
hr
=
IDirectInputDevice_GetDeviceData
(
lpdid
,
sizeof
(
buffer
[
0
]),
buffer
,
&
cnt
,
0
);
ok
(
hr
==
DIERR_NOTACQUIRED
,
"GetDeviceData() failed hr=%#lx
\n
"
,
hr
);
/* Test axis range */
memset
(
&
dpr
,
0
,
sizeof
(
dpr
));
dpr
.
diph
.
dwSize
=
sizeof
(
dpr
);
dpr
.
diph
.
dwHeaderSize
=
sizeof
(
DIPROPHEADER
);
dpr
.
diph
.
dwHow
=
DIPH_DEVICE
;
hr
=
IDirectInputDevice_GetProperty
(
lpdid
,
DIPROP_RANGE
,
&
dpr
.
diph
);
/* Only test if device supports the range property */
if
(
SUCCEEDED
(
hr
))
{
ok
(
dpr
.
lMin
==
data
->
lpdiaf
->
lAxisMin
,
"SetActionMap must set the min axis range expected=%ld got=%ld
\n
"
,
data
->
lpdiaf
->
lAxisMin
,
dpr
.
lMin
);
ok
(
dpr
.
lMax
==
data
->
lpdiaf
->
lAxisMax
,
"SetActionMap must set the max axis range expected=%ld got=%ld
\n
"
,
data
->
lpdiaf
->
lAxisMax
,
dpr
.
lMax
);
}
/* SetActionMap has set the data format so now it should work */
hr
=
IDirectInputDevice8_Acquire
(
lpdid
);
ok
(
SUCCEEDED
(
hr
),
"Acquire failed hr=%#lx
\n
"
,
hr
);
cnt
=
1
;
hr
=
IDirectInputDevice_GetDeviceData
(
lpdid
,
sizeof
(
buffer
[
0
]),
buffer
,
&
cnt
,
0
);
ok
(
hr
==
DI_OK
,
"GetDeviceData() failed hr=%#lx
\n
"
,
hr
);
/* SetActionMap should not work on an acquired device */
hr
=
IDirectInputDevice8_SetActionMap
(
lpdid
,
data
->
lpdiaf
,
NULL
,
0
);
ok
(
hr
==
DIERR_ACQUIRED
,
"SetActionMap succeeded with an acquired device hr=%#lx
\n
"
,
hr
);
IDirectInputDevice_Release
(
lpdid2
);
return
DIENUM_CONTINUE
;
}
static
void
test_appdata_property_vs_map
(
struct
enum_data
*
data
)
{
HRESULT
hr
;
DIPROPPOINTER
dp
;
dp
.
diph
.
dwSize
=
sizeof
(
dp
);
dp
.
diph
.
dwHeaderSize
=
sizeof
(
DIPROPHEADER
);
dp
.
diph
.
dwHow
=
DIPH_BYID
;
dp
.
diph
.
dwObj
=
DIDFT_MAKEINSTANCE
(
DIK_SPACE
)
|
DIDFT_PSHBUTTON
;
dp
.
uData
=
10
;
hr
=
IDirectInputDevice8_SetProperty
(
data
->
keyboard
,
DIPROP_APPDATA
,
&
(
dp
.
diph
));
ok
(
SUCCEEDED
(
hr
),
"IDirectInputDevice8_SetProperty failed hr=%#lx
\n
"
,
hr
);
test_device_input
(
data
->
keyboard
,
INPUT_KEYBOARD
,
DIK_SPACE
,
10
);
dp
.
diph
.
dwHow
=
DIPH_BYID
;
dp
.
diph
.
dwObj
=
DIDFT_MAKEINSTANCE
(
DIK_V
)
|
DIDFT_PSHBUTTON
;
dp
.
uData
=
11
;
hr
=
IDirectInputDevice8_SetProperty
(
data
->
keyboard
,
DIPROP_APPDATA
,
&
(
dp
.
diph
));
ok
(
hr
==
DIERR_OBJECTNOTFOUND
,
"IDirectInputDevice8_SetProperty should not find key that's not in the action map hr=%#lx
\n
"
,
hr
);
/* setting format should reset action map */
hr
=
IDirectInputDevice8_SetDataFormat
(
data
->
keyboard
,
&
c_dfDIKeyboard
);
ok
(
SUCCEEDED
(
hr
),
"SetDataFormat failed: %#lx
\n
"
,
hr
);
test_device_input
(
data
->
keyboard
,
INPUT_KEYBOARD
,
DIK_SPACE
,
-
1
);
dp
.
diph
.
dwHow
=
DIPH_BYID
;
dp
.
diph
.
dwObj
=
DIDFT_MAKEINSTANCE
(
DIK_V
)
|
DIDFT_PSHBUTTON
;
dp
.
uData
=
11
;
hr
=
IDirectInputDevice8_SetProperty
(
data
->
keyboard
,
DIPROP_APPDATA
,
&
(
dp
.
diph
));
ok
(
SUCCEEDED
(
hr
),
"IDirectInputDevice8_SetProperty failed hr=%#lx
\n
"
,
hr
);
test_device_input
(
data
->
keyboard
,
INPUT_KEYBOARD
,
DIK_V
,
11
);
/* back to action map */
hr
=
IDirectInputDevice8_SetActionMap
(
data
->
keyboard
,
data
->
lpdiaf
,
NULL
,
0
);
ok
(
SUCCEEDED
(
hr
),
"SetActionMap failed hr=%#lx
\n
"
,
hr
);
test_device_input
(
data
->
keyboard
,
INPUT_KEYBOARD
,
DIK_SPACE
,
2
);
}
static
void
test_action_mapping
(
void
)
{
HRESULT
hr
;
IDirectInput8A
*
pDI
=
NULL
;
DIACTIONFORMATA
af
;
DIPROPSTRING
dps
;
struct
enum_data
data
=
{.
version
=
0x800
,
.
lpdiaf
=
&
af
};
HWND
hwnd
;
hr
=
CoCreateInstance
(
&
CLSID_DirectInput8
,
0
,
CLSCTX_INPROC_SERVER
,
&
IID_IDirectInput8A
,
(
LPVOID
*
)
&
pDI
);
if
(
hr
==
DIERR_OLDDIRECTINPUTVERSION
||
hr
==
DIERR_BETADIRECTINPUTVERSION
||
hr
==
REGDB_E_CLASSNOTREG
)
{
win_skip
(
"ActionMapping requires dinput8
\n
"
);
return
;
}
ok
(
SUCCEEDED
(
hr
),
"DirectInput8 Create failed: hr=%#lx
\n
"
,
hr
);
if
(
FAILED
(
hr
))
return
;
hr
=
IDirectInput8_Initialize
(
pDI
,
instance
,
DIRECTINPUT_VERSION
);
if
(
hr
==
DIERR_OLDDIRECTINPUTVERSION
||
hr
==
DIERR_BETADIRECTINPUTVERSION
)
{
win_skip
(
"ActionMapping requires dinput8
\n
"
);
return
;
}
ok
(
SUCCEEDED
(
hr
),
"DirectInput8 Initialize failed: hr=%#lx
\n
"
,
hr
);
if
(
FAILED
(
hr
))
return
;
memset
(
&
af
,
0
,
sizeof
(
af
));
af
.
dwSize
=
sizeof
(
af
);
af
.
dwActionSize
=
sizeof
(
DIACTIONA
);
af
.
dwDataSize
=
4
*
ARRAY_SIZE
(
actionMapping
);
af
.
dwNumActions
=
ARRAY_SIZE
(
actionMapping
);
af
.
rgoAction
=
actionMapping
;
af
.
guidActionMap
=
ACTION_MAPPING_GUID
;
af
.
dwGenre
=
0x01000000
;
/* DIVIRTUAL_DRIVING_RACE */
af
.
dwBufferSize
=
32
;
/* This enumeration builds and sets the action map for all devices */
data
.
dinput8
=
pDI
;
hr
=
IDirectInput8_EnumDevicesBySemantics
(
pDI
,
0
,
&
af
,
enumeration_callback
,
&
data
,
DIEDBSFL_ATTACHEDONLY
);
ok
(
SUCCEEDED
(
hr
),
"EnumDevicesBySemantics failed: hr=%#lx
\n
"
,
hr
);
if
(
data
.
keyboard
)
IDirectInputDevice_Release
(
data
.
keyboard
);
if
(
data
.
mouse
)
IDirectInputDevice_Release
(
data
.
mouse
);
/* Repeat tests with a non NULL user */
data
.
username
=
"Ninja Brian"
;
hr
=
IDirectInput8_EnumDevicesBySemantics
(
pDI
,
NULL
,
&
af
,
enumeration_callback
,
&
data
,
DIEDBSFL_ATTACHEDONLY
);
ok
(
SUCCEEDED
(
hr
),
"EnumDevicesBySemantics failed: hr=%#lx
\n
"
,
hr
);
hwnd
=
CreateWindowExA
(
WS_EX_TOPMOST
,
"static"
,
"dinput"
,
WS_POPUP
|
WS_VISIBLE
,
0
,
0
,
100
,
100
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
hwnd
!=
NULL
,
"failed to create window
\n
"
);
SetCursorPos
(
50
,
50
);
if
(
data
.
keyboard
!=
NULL
)
{
/* Test keyboard BuildActionMap */
test_build_action_map
(
data
.
keyboard
,
data
.
lpdiaf
,
DITEST_KEYBOARDSPACE
,
DIDFT_PSHBUTTON
,
DIK_SPACE
);
/* Test keyboard input */
test_device_input
(
data
.
keyboard
,
INPUT_KEYBOARD
,
DIK_SPACE
,
2
);
/* setting format should reset action map */
hr
=
IDirectInputDevice8_SetDataFormat
(
data
.
keyboard
,
&
c_dfDIKeyboard
);
ok
(
SUCCEEDED
(
hr
),
"IDirectInputDevice8_SetDataFormat failed: %#lx
\n
"
,
hr
);
test_device_input
(
data
.
keyboard
,
INPUT_KEYBOARD
,
DIK_SPACE
,
-
1
);
/* back to action map */
hr
=
IDirectInputDevice8_SetActionMap
(
data
.
keyboard
,
data
.
lpdiaf
,
NULL
,
0
);
ok
(
SUCCEEDED
(
hr
),
"SetActionMap should succeed hr=%#lx
\n
"
,
hr
);
test_device_input
(
data
.
keyboard
,
INPUT_KEYBOARD
,
DIK_SPACE
,
2
);
test_appdata_property_vs_map
(
&
data
);
/* Test BuildActionMap with no suitable actions for a device */
IDirectInputDevice_Unacquire
(
data
.
keyboard
);
af
.
dwDataSize
=
4
*
DITEST_KEYBOARDSPACE
;
af
.
dwNumActions
=
DITEST_KEYBOARDSPACE
;
hr
=
IDirectInputDevice8_BuildActionMap
(
data
.
keyboard
,
data
.
lpdiaf
,
NULL
,
DIDBAM_HWDEFAULTS
);
ok
(
hr
==
DI_NOEFFECT
,
"BuildActionMap should have no effect with no actions hr=%#lx
\n
"
,
hr
);
hr
=
IDirectInputDevice8_SetActionMap
(
data
.
keyboard
,
data
.
lpdiaf
,
NULL
,
0
);
ok
(
hr
==
DI_NOEFFECT
,
"SetActionMap should have no effect with no actions to map hr=%#lx
\n
"
,
hr
);
af
.
dwDataSize
=
4
*
ARRAY_SIZE
(
actionMapping
);
af
.
dwNumActions
=
ARRAY_SIZE
(
actionMapping
);
/* test DIDSAM_NOUSER */
dps
.
diph
.
dwSize
=
sizeof
(
dps
);
dps
.
diph
.
dwHeaderSize
=
sizeof
(
DIPROPHEADER
);
dps
.
diph
.
dwObj
=
0
;
dps
.
diph
.
dwHow
=
DIPH_DEVICE
;
dps
.
wsz
[
0
]
=
'\0'
;
hr
=
IDirectInputDevice_GetProperty
(
data
.
keyboard
,
DIPROP_USERNAME
,
&
dps
.
diph
);
ok
(
SUCCEEDED
(
hr
),
"GetProperty failed hr=%#lx
\n
"
,
hr
);
ok
(
dps
.
wsz
[
0
]
!=
0
,
"Expected any username, got=%s
\n
"
,
wine_dbgstr_w
(
dps
.
wsz
));
hr
=
IDirectInputDevice8_SetActionMap
(
data
.
keyboard
,
data
.
lpdiaf
,
NULL
,
DIDSAM_NOUSER
);
ok
(
SUCCEEDED
(
hr
),
"SetActionMap failed hr=%#lx
\n
"
,
hr
);
dps
.
diph
.
dwSize
=
sizeof
(
dps
);
dps
.
diph
.
dwHeaderSize
=
sizeof
(
DIPROPHEADER
);
dps
.
diph
.
dwObj
=
0
;
dps
.
diph
.
dwHow
=
DIPH_DEVICE
;
dps
.
wsz
[
0
]
=
'\0'
;
hr
=
IDirectInputDevice_GetProperty
(
data
.
keyboard
,
DIPROP_USERNAME
,
&
dps
.
diph
);
ok
(
SUCCEEDED
(
hr
),
"GetProperty failed hr=%#lx
\n
"
,
hr
);
ok
(
dps
.
wsz
[
0
]
==
0
,
"Expected empty username, got=%s
\n
"
,
wine_dbgstr_w
(
dps
.
wsz
));
IDirectInputDevice_Release
(
data
.
keyboard
);
}
if
(
data
.
mouse
!=
NULL
)
{
/* Test mouse BuildActionMap */
test_build_action_map
(
data
.
mouse
,
data
.
lpdiaf
,
DITEST_MOUSEBUTTON0
,
DIDFT_PSHBUTTON
,
0x03
);
test_build_action_map
(
data
.
mouse
,
data
.
lpdiaf
,
DITEST_YAXIS
,
DIDFT_RELAXIS
,
0x01
);
test_device_input
(
data
.
mouse
,
INPUT_MOUSE
,
MOUSEEVENTF_LEFTDOWN
,
3
);
IDirectInputDevice_Release
(
data
.
mouse
);
}
DestroyWindow
(
hwnd
);
IDirectInput_Release
(
pDI
);
}
static
void
test_save_settings
(
void
)
{
HRESULT
hr
;
IDirectInput8A
*
pDI
=
NULL
;
DIACTIONFORMATA
af
;
IDirectInputDevice8A
*
pKey
;
static
const
GUID
mapping_guid
=
{
0xcafecafe
,
0x2
,
0x3
,
{
0x4
,
0x5
,
0x6
,
0x7
,
0x8
,
0x9
,
0xa
,
0xb
}
};
static
const
GUID
other_guid
=
{
0xcafe
,
0xcafe
,
0x3
,
{
0x4
,
0x5
,
0x6
,
0x7
,
0x8
,
0x9
,
0xa
,
0xb
}
};
static
DIACTIONA
actions
[]
=
{
{
0
,
DIKEYBOARD_A
,
0
,
{
"Blam"
}
},
{
1
,
DIKEYBOARD_B
,
0
,
{
"Kapow"
}
}
};
static
const
DWORD
results
[]
=
{
DIDFT_MAKEINSTANCE
(
DIK_A
)
|
DIDFT_PSHBUTTON
,
DIDFT_MAKEINSTANCE
(
DIK_B
)
|
DIDFT_PSHBUTTON
};
static
const
DWORD
other_results
[]
=
{
DIDFT_MAKEINSTANCE
(
DIK_C
)
|
DIDFT_PSHBUTTON
,
DIDFT_MAKEINSTANCE
(
DIK_D
)
|
DIDFT_PSHBUTTON
};
hr
=
CoCreateInstance
(
&
CLSID_DirectInput8
,
0
,
CLSCTX_INPROC_SERVER
,
&
IID_IDirectInput8A
,
(
LPVOID
*
)
&
pDI
);
if
(
hr
==
DIERR_OLDDIRECTINPUTVERSION
||
hr
==
DIERR_BETADIRECTINPUTVERSION
||
hr
==
REGDB_E_CLASSNOTREG
)
{
win_skip
(
"ActionMapping requires dinput8
\n
"
);
return
;
}
ok
(
SUCCEEDED
(
hr
),
"DirectInput8 Create failed: hr=%#lx
\n
"
,
hr
);
if
(
FAILED
(
hr
))
return
;
hr
=
IDirectInput8_Initialize
(
pDI
,
instance
,
DIRECTINPUT_VERSION
);
if
(
hr
==
DIERR_OLDDIRECTINPUTVERSION
||
hr
==
DIERR_BETADIRECTINPUTVERSION
)
{
win_skip
(
"ActionMapping requires dinput8
\n
"
);
return
;
}
ok
(
SUCCEEDED
(
hr
),
"DirectInput8 Initialize failed: hr=%#lx
\n
"
,
hr
);
if
(
FAILED
(
hr
))
return
;
hr
=
IDirectInput_CreateDevice
(
pDI
,
&
GUID_SysKeyboard
,
&
pKey
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"IDirectInput_Create device failed hr: 0x%#lx
\n
"
,
hr
);
if
(
FAILED
(
hr
))
return
;
memset
(
&
af
,
0
,
sizeof
(
af
));
af
.
dwSize
=
sizeof
(
af
);
af
.
dwActionSize
=
sizeof
(
DIACTIONA
);
af
.
dwDataSize
=
4
*
ARRAY_SIZE
(
actions
);
af
.
dwNumActions
=
ARRAY_SIZE
(
actions
);
af
.
rgoAction
=
actions
;
af
.
guidActionMap
=
mapping_guid
;
af
.
dwGenre
=
0x01000000
;
/* DIVIRTUAL_DRIVING_RACE */
af
.
dwBufferSize
=
32
;
/* Easy case. Ask for default mapping, save, ask for previous map and read it back */
hr
=
IDirectInputDevice8_BuildActionMap
(
pKey
,
&
af
,
NULL
,
DIDBAM_HWDEFAULTS
);
ok
(
SUCCEEDED
(
hr
),
"BuildActionMap failed hr=%#lx
\n
"
,
hr
);
ok
(
results
[
0
]
==
af
.
rgoAction
[
0
].
dwObjID
,
"Mapped incorrectly expected: 0x%#lx got: 0x%#lx
\n
"
,
results
[
0
],
af
.
rgoAction
[
0
].
dwObjID
);
ok
(
results
[
1
]
==
af
.
rgoAction
[
1
].
dwObjID
,
"Mapped incorrectly expected: 0x%#lx got: 0x%#lx
\n
"
,
results
[
1
],
af
.
rgoAction
[
1
].
dwObjID
);
hr
=
IDirectInputDevice8_SetActionMap
(
pKey
,
&
af
,
NULL
,
DIDSAM_FORCESAVE
);
ok
(
SUCCEEDED
(
hr
),
"SetActionMap failed hr=%#lx
\n
"
,
hr
);
if
(
hr
==
DI_SETTINGSNOTSAVED
)
{
skip
(
"Can't test saving settings if SetActionMap returns DI_SETTINGSNOTSAVED
\n
"
);
return
;
}
af
.
rgoAction
[
0
].
dwObjID
=
0
;
af
.
rgoAction
[
1
].
dwObjID
=
0
;
memset
(
&
af
.
rgoAction
[
0
].
guidInstance
,
0
,
sizeof
(
GUID
));
memset
(
&
af
.
rgoAction
[
1
].
guidInstance
,
0
,
sizeof
(
GUID
));
hr
=
IDirectInputDevice8_BuildActionMap
(
pKey
,
&
af
,
NULL
,
0
);
ok
(
SUCCEEDED
(
hr
),
"BuildActionMap failed hr=%#lx
\n
"
,
hr
);
ok
(
results
[
0
]
==
af
.
rgoAction
[
0
].
dwObjID
,
"Mapped incorrectly expected: 0x%#lx got: 0x%#lx
\n
"
,
results
[
0
],
af
.
rgoAction
[
0
].
dwObjID
);
ok
(
IsEqualGUID
(
&
GUID_SysKeyboard
,
&
af
.
rgoAction
[
0
].
guidInstance
),
"Action should be mapped to keyboard
\n
"
);
ok
(
results
[
1
]
==
af
.
rgoAction
[
1
].
dwObjID
,
"Mapped incorrectly expected: 0x%#lx got: 0x%#lx
\n
"
,
results
[
1
],
af
.
rgoAction
[
1
].
dwObjID
);
ok
(
IsEqualGUID
(
&
GUID_SysKeyboard
,
&
af
.
rgoAction
[
1
].
guidInstance
),
"Action should be mapped to keyboard
\n
"
);
/* Test that a different action map with no pre-stored settings, in spite of the flags,
does not try to load mappings and instead applies the default mapping */
af
.
guidActionMap
=
other_guid
;
af
.
rgoAction
[
0
].
dwObjID
=
0
;
af
.
rgoAction
[
1
].
dwObjID
=
0
;
memset
(
&
af
.
rgoAction
[
0
].
guidInstance
,
0
,
sizeof
(
GUID
));
memset
(
&
af
.
rgoAction
[
1
].
guidInstance
,
0
,
sizeof
(
GUID
));
hr
=
IDirectInputDevice8_BuildActionMap
(
pKey
,
&
af
,
NULL
,
0
);
ok
(
SUCCEEDED
(
hr
),
"BuildActionMap failed hr=%#lx
\n
"
,
hr
);
ok
(
results
[
0
]
==
af
.
rgoAction
[
0
].
dwObjID
,
"Mapped incorrectly expected: 0x%#lx got: 0x%#lx
\n
"
,
results
[
0
],
af
.
rgoAction
[
0
].
dwObjID
);
ok
(
IsEqualGUID
(
&
GUID_SysKeyboard
,
&
af
.
rgoAction
[
0
].
guidInstance
),
"Action should be mapped to keyboard
\n
"
);
ok
(
results
[
1
]
==
af
.
rgoAction
[
1
].
dwObjID
,
"Mapped incorrectly expected: 0x%#lx got: 0x%#lx
\n
"
,
results
[
1
],
af
.
rgoAction
[
1
].
dwObjID
);
ok
(
IsEqualGUID
(
&
GUID_SysKeyboard
,
&
af
.
rgoAction
[
1
].
guidInstance
),
"Action should be mapped to keyboard
\n
"
);
af
.
guidActionMap
=
mapping_guid
;
/* Hard case. Customized mapping, save, ask for previous map and read it back */
af
.
rgoAction
[
0
].
dwObjID
=
other_results
[
0
];
af
.
rgoAction
[
0
].
dwHow
=
DIAH_USERCONFIG
;
af
.
rgoAction
[
0
].
guidInstance
=
GUID_SysKeyboard
;
af
.
rgoAction
[
1
].
dwObjID
=
other_results
[
1
];
af
.
rgoAction
[
1
].
dwHow
=
DIAH_USERCONFIG
;
af
.
rgoAction
[
1
].
guidInstance
=
GUID_SysKeyboard
;
hr
=
IDirectInputDevice8_SetActionMap
(
pKey
,
&
af
,
NULL
,
DIDSAM_FORCESAVE
);
ok
(
SUCCEEDED
(
hr
),
"SetActionMap failed hr=%#lx
\n
"
,
hr
);
if
(
hr
==
DI_SETTINGSNOTSAVED
)
{
skip
(
"Can't test saving settings if SetActionMap returns DI_SETTINGSNOTSAVED
\n
"
);
return
;
}
af
.
rgoAction
[
0
].
dwObjID
=
0
;
af
.
rgoAction
[
1
].
dwObjID
=
0
;
memset
(
&
af
.
rgoAction
[
0
].
guidInstance
,
0
,
sizeof
(
GUID
));
memset
(
&
af
.
rgoAction
[
1
].
guidInstance
,
0
,
sizeof
(
GUID
));
hr
=
IDirectInputDevice8_BuildActionMap
(
pKey
,
&
af
,
NULL
,
0
);
ok
(
SUCCEEDED
(
hr
),
"BuildActionMap failed hr=%#lx
\n
"
,
hr
);
ok
(
other_results
[
0
]
==
af
.
rgoAction
[
0
].
dwObjID
,
"Mapped incorrectly expected: 0x%#lx got: 0x%#lx
\n
"
,
other_results
[
0
],
af
.
rgoAction
[
0
].
dwObjID
);
ok
(
IsEqualGUID
(
&
GUID_SysKeyboard
,
&
af
.
rgoAction
[
0
].
guidInstance
),
"Action should be mapped to keyboard
\n
"
);
ok
(
other_results
[
1
]
==
af
.
rgoAction
[
1
].
dwObjID
,
"Mapped incorrectly expected: 0x%#lx got: 0x%#lx
\n
"
,
other_results
[
1
],
af
.
rgoAction
[
1
].
dwObjID
);
ok
(
IsEqualGUID
(
&
GUID_SysKeyboard
,
&
af
.
rgoAction
[
1
].
guidInstance
),
"Action should be mapped to keyboard
\n
"
);
IDirectInputDevice_Release
(
pKey
);
IDirectInput_Release
(
pDI
);
}
static
void
test_mouse_keyboard
(
void
)
{
HRESULT
hr
;
...
...
@@ -2724,8 +2209,6 @@ START_TEST(device8)
test_sys_keyboard
(
0x700
);
test_sys_keyboard
(
0x800
);
test_action_mapping
();
test_save_settings
();
test_mouse_keyboard
();
test_keyboard_events
();
test_appdata_property
();
...
...
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