2 * Copyright (c) 2011 Lucas Fialho Zawacki
3 * Copyright (c) 2006 Vitaliy Margolen
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #define DIRECTINPUT_VERSION 0x0800
25 #include "wine/test.h"
30 static BOOL CALLBACK
enum_by_semantics(
31 LPCDIDEVICEINSTANCE lpddi
,
32 LPDIRECTINPUTDEVICE8 lpdid
,
37 return DIENUM_CONTINUE
;
41 static void test_action_mapping(void)
44 HINSTANCE hinst
= GetModuleHandle(NULL
);
45 LPDIRECTINPUT8 pDI
= NULL
;
48 const GUID ACTION_MAPPING_GUID
= { 0x1, 0x2, 0x3, { 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb } };
50 DIACTION actionMapping
[]=
53 { 0, 0x01008A01 /* DIAXIS_DRIVINGR_STEER */ , 0, { "Steer" } },
56 { 1, 0x01000C01 /* DIBUTTON_DRIVINGR_SHIFTUP */ , 0, { "Upshift" } }
59 hr
= CoCreateInstance(&CLSID_DirectInput8
, 0, 1, &IID_IDirectInput8A
, (LPVOID
*)&pDI
);
60 if (hr
== DIERR_OLDDIRECTINPUTVERSION
||
61 hr
== DIERR_BETADIRECTINPUTVERSION
||
62 hr
== REGDB_E_CLASSNOTREG
)
64 win_skip("ActionMapping requires dinput8\n");
67 ok(SUCCEEDED(hr
), "DirectInput8 Create failed: hr=%08x\n", hr
);
68 if (FAILED(hr
)) return;
70 hr
= IDirectInput8_Initialize(pDI
,hinst
, DIRECTINPUT_VERSION
);
71 if (hr
== DIERR_OLDDIRECTINPUTVERSION
|| hr
== DIERR_BETADIRECTINPUTVERSION
)
73 win_skip("ActionMapping requires dinput8\n");
76 ok(SUCCEEDED(hr
), "DirectInput8 Initialize failed: hr=%08x\n", hr
);
77 if (FAILED(hr
)) return;
79 memset (&af
, 0, sizeof(af
));
80 af
.dwSize
= sizeof(af
);
81 af
.dwActionSize
= sizeof(DIACTION
);
82 af
.dwDataSize
= 4 * sizeof(actionMapping
) / sizeof(actionMapping
[0]);
83 af
.dwNumActions
= sizeof(actionMapping
) / sizeof(actionMapping
[0]);
84 af
.rgoAction
= actionMapping
;
85 af
.guidActionMap
= ACTION_MAPPING_GUID
;
86 af
.dwGenre
= 0x01000000; /* DIVIRTUAL_DRIVING_RACE */
88 hr
= IDirectInput8_EnumDevicesBySemantics(pDI
,0, &af
,
89 enum_by_semantics
, 0, 0);
91 ok(SUCCEEDED(hr
), "EnumDevicesBySemantics failed: hr=%08x\n",hr
);
93 /* The call fails with a zeroed GUID */
94 memset(&af
.guidActionMap
, 0, sizeof(GUID
));
95 hr
= IDirectInput8_EnumDevicesBySemantics(pDI
,0, &af
,
96 enum_by_semantics
, 0, 0);
98 todo_wine
ok(FAILED(hr
), "EnumDevicesBySemantics succeeded with invalid GUID hr=%08x\n", hr
);
106 test_action_mapping();