d3d9: Implement IDirect3DVertexBuffer9 private data handling on top of wined3d_resource.
[wine] / dlls / dinput8 / tests / device.c
1 /*
2  * Copyright (c) 2011 Lucas Fialho Zawacki
3  * Copyright (c) 2006 Vitaliy Margolen
4  *
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.
9  *
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.
14  *
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
18  */
19
20 #define DIRECTINPUT_VERSION 0x0800
21
22 #define COBJMACROS
23 #include <windows.h>
24
25 #include "wine/test.h"
26 #include "windef.h"
27 #include "initguid.h"
28 #include "dinput.h"
29
30 static BOOL CALLBACK enum_by_semantics(
31     LPCDIDEVICEINSTANCE lpddi,
32     LPDIRECTINPUTDEVICE8 lpdid,
33     DWORD dwFlags,
34     DWORD dwRemaining,
35     LPVOID pvRef)
36 {
37     return DIENUM_CONTINUE;
38 }
39
40
41 static void test_action_mapping(void)
42 {
43     HRESULT hr;
44     HINSTANCE hinst = GetModuleHandle(NULL);
45     LPDIRECTINPUT8 pDI = NULL;
46     DIACTIONFORMAT af;
47     /* Dummy GUID */
48     const GUID ACTION_MAPPING_GUID = { 0x1, 0x2, 0x3, { 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb } };
49
50     DIACTION actionMapping[]=
51     {
52       /* axis */
53       { 0, 0x01008A01 /* DIAXIS_DRIVINGR_STEER */ , 0, { "Steer" } },
54
55       /* button */
56       { 1, 0x01000C01 /* DIBUTTON_DRIVINGR_SHIFTUP */ , 0, { "Upshift" } }
57     };
58
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)
63     {
64         win_skip("ActionMapping requires dinput8\n");
65         return;
66     }
67     ok(SUCCEEDED(hr), "DirectInput8 Create failed: hr=%08x\n", hr);
68     if (FAILED(hr)) return;
69
70     hr = IDirectInput8_Initialize(pDI,hinst, DIRECTINPUT_VERSION);
71     if (hr == DIERR_OLDDIRECTINPUTVERSION || hr == DIERR_BETADIRECTINPUTVERSION)
72     {
73         win_skip("ActionMapping requires dinput8\n");
74         return;
75     }
76     ok(SUCCEEDED(hr), "DirectInput8 Initialize failed: hr=%08x\n", hr);
77     if (FAILED(hr)) return;
78
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 */
87
88     hr = IDirectInput8_EnumDevicesBySemantics(pDI,0, &af,
89         enum_by_semantics, 0, 0);
90
91     ok(SUCCEEDED(hr), "EnumDevicesBySemantics failed: hr=%08x\n",hr);
92
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);
97
98     todo_wine ok(FAILED(hr), "EnumDevicesBySemantics succeeded with invalid GUID hr=%08x\n", hr);
99
100 }
101
102 START_TEST(device)
103 {
104     CoInitialize(NULL);
105
106     test_action_mapping();
107
108     CoUninitialize();
109 }