[DINPUT]
[reactos.git] / reactos / dll / directx / wine / dinput / device_private.h
1 /*
2 * Copyright 2000 Lionel Ulmer
3 * Copyright 2000-2001 TransGaming Technologies Inc.
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 #ifndef __WINE_DLLS_DINPUT_DINPUTDEVICE_PRIVATE_H
21 #define __WINE_DLLS_DINPUT_DINPUTDEVICE_PRIVATE_H
22
23 typedef struct
24 {
25 int size;
26 int offset_in;
27 int offset_out;
28 int value;
29 } DataTransform;
30
31 typedef struct
32 {
33 int size;
34 int internal_format_size;
35 DataTransform *dt;
36
37 int *offsets; /* object offsets */
38 LPDIDATAFORMAT wine_df; /* wine internal data format */
39 LPDIDATAFORMAT user_df; /* user defined data format */
40 } DataFormat;
41
42 typedef struct
43 {
44 unsigned int offset;
45 UINT_PTR uAppData;
46 } ActionMap;
47
48 /* Device implementation */
49 typedef struct IDirectInputDeviceImpl IDirectInputDeviceImpl;
50 struct IDirectInputDeviceImpl
51 {
52 IDirectInputDevice8A IDirectInputDevice8A_iface;
53 IDirectInputDevice8W IDirectInputDevice8W_iface;
54 LONG ref;
55 GUID guid;
56 CRITICAL_SECTION crit;
57 IDirectInputImpl *dinput;
58 struct list entry; /* entry into IDirectInput devices list */
59 HANDLE hEvent;
60 DWORD dwCoopLevel;
61 HWND win;
62 int acquired;
63 DI_EVENT_PROC event_proc; /* function to receive mouse & keyboard events */
64
65 LPDIDEVICEOBJECTDATA data_queue; /* buffer for 'GetDeviceData'. */
66 int queue_len; /* size of the queue - set in 'SetProperty' */
67 int queue_head; /* position to write new event into queue */
68 int queue_tail; /* next event to read from queue */
69 BOOL overflow; /* return DI_BUFFEROVERFLOW in 'GetDeviceData' */
70
71 DataFormat data_format; /* user data format and wine to user format converter */
72
73 /* Action mapping */
74 int num_actions; /* number of actions mapped */
75 ActionMap *action_map; /* array of mappings */
76 };
77
78 extern BOOL get_app_key(HKEY*, HKEY*) DECLSPEC_HIDDEN;
79 extern DWORD get_config_key(HKEY, HKEY, const char*, char*, DWORD) DECLSPEC_HIDDEN;
80
81 /* Routines to do DataFormat / WineFormat conversions */
82 extern void fill_DataFormat(void *out, DWORD size, const void *in, const DataFormat *df) DECLSPEC_HIDDEN;
83 extern void release_DataFormat(DataFormat *df) DECLSPEC_HIDDEN;
84 extern void queue_event(LPDIRECTINPUTDEVICE8A iface, int inst_id, DWORD data, DWORD time, DWORD seq) DECLSPEC_HIDDEN;
85 /* Helper functions to work with data format */
86 extern int id_to_object(LPCDIDATAFORMAT df, int id) DECLSPEC_HIDDEN;
87 extern int find_property(const DataFormat *df, LPCDIPROPHEADER ph) DECLSPEC_HIDDEN;
88
89 /* Common joystick stuff */
90 typedef struct
91 {
92 LONG lDevMin;
93 LONG lDevMax;
94 LONG lMin;
95 LONG lMax;
96 LONG lDeadZone;
97 LONG lSaturation;
98 } ObjProps;
99
100 extern DWORD joystick_map_pov(const POINTL *p) DECLSPEC_HIDDEN;
101 extern LONG joystick_map_axis(ObjProps *props, int val) DECLSPEC_HIDDEN;
102
103 typedef struct
104 {
105 struct list entry;
106 LPDIRECTINPUTEFFECT ref;
107 } effect_list_item;
108
109 extern const GUID DInput_Wine_Keyboard_GUID DECLSPEC_HIDDEN;
110 extern const GUID DInput_Wine_Mouse_GUID DECLSPEC_HIDDEN;
111
112 /* Various debug tools */
113 extern void _dump_DIPROPHEADER(LPCDIPROPHEADER diph) DECLSPEC_HIDDEN;
114 extern void _dump_OBJECTINSTANCEA(const DIDEVICEOBJECTINSTANCEA *ddoi) DECLSPEC_HIDDEN;
115 extern void _dump_OBJECTINSTANCEW(const DIDEVICEOBJECTINSTANCEW *ddoi) DECLSPEC_HIDDEN;
116 extern void _dump_DIDATAFORMAT(const DIDATAFORMAT *df) DECLSPEC_HIDDEN;
117 extern const char *_dump_dinput_GUID(const GUID *guid) DECLSPEC_HIDDEN;
118
119 extern LPDIOBJECTDATAFORMAT dataformat_to_odf_by_type(LPCDIDATAFORMAT df, int n, DWORD type) DECLSPEC_HIDDEN;
120
121 extern HRESULT _build_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags, DWORD devMask, LPCDIDATAFORMAT df) DECLSPEC_HIDDEN;
122 extern HRESULT _set_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags, LPCDIDATAFORMAT df) DECLSPEC_HIDDEN;
123
124 /* And the stubs */
125 extern HRESULT WINAPI IDirectInputDevice2AImpl_Acquire(LPDIRECTINPUTDEVICE8A iface) DECLSPEC_HIDDEN;
126 extern HRESULT WINAPI IDirectInputDevice2WImpl_Acquire(LPDIRECTINPUTDEVICE8W iface) DECLSPEC_HIDDEN;
127 extern HRESULT WINAPI IDirectInputDevice2AImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface) DECLSPEC_HIDDEN;
128 extern HRESULT WINAPI IDirectInputDevice2WImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface) DECLSPEC_HIDDEN;
129 extern HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat(LPDIRECTINPUTDEVICE8A iface, LPCDIDATAFORMAT df) DECLSPEC_HIDDEN;
130 extern HRESULT WINAPI IDirectInputDevice2WImpl_SetDataFormat(LPDIRECTINPUTDEVICE8W iface, LPCDIDATAFORMAT df) DECLSPEC_HIDDEN;
131 extern HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel(LPDIRECTINPUTDEVICE8A iface, HWND hwnd, DWORD dwflags) DECLSPEC_HIDDEN;
132 extern HRESULT WINAPI IDirectInputDevice2WImpl_SetCooperativeLevel(LPDIRECTINPUTDEVICE8W iface, HWND hwnd, DWORD dwflags) DECLSPEC_HIDDEN;
133 extern HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification(LPDIRECTINPUTDEVICE8A iface, HANDLE hnd) DECLSPEC_HIDDEN;
134 extern HRESULT WINAPI IDirectInputDevice2WImpl_SetEventNotification(LPDIRECTINPUTDEVICE8W iface, HANDLE hnd) DECLSPEC_HIDDEN;
135 extern ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface) DECLSPEC_HIDDEN;
136 extern ULONG WINAPI IDirectInputDevice2WImpl_Release(LPDIRECTINPUTDEVICE8W iface) DECLSPEC_HIDDEN;
137 extern HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(LPDIRECTINPUTDEVICE8A iface, REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN;
138 extern HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(LPDIRECTINPUTDEVICE8W iface, REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN;
139 extern ULONG WINAPI IDirectInputDevice2AImpl_AddRef(LPDIRECTINPUTDEVICE8A iface) DECLSPEC_HIDDEN;
140 extern ULONG WINAPI IDirectInputDevice2WImpl_AddRef(LPDIRECTINPUTDEVICE8W iface) DECLSPEC_HIDDEN;
141 extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(
142 LPDIRECTINPUTDEVICE8A iface,
143 LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback,
144 LPVOID lpvRef,
145 DWORD dwFlags) DECLSPEC_HIDDEN;
146 extern HRESULT WINAPI IDirectInputDevice2WImpl_EnumObjects(
147 LPDIRECTINPUTDEVICE8W iface,
148 LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
149 LPVOID lpvRef,
150 DWORD dwFlags) DECLSPEC_HIDDEN;
151 extern HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph) DECLSPEC_HIDDEN;
152 extern HRESULT WINAPI IDirectInputDevice2WImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph) DECLSPEC_HIDDEN;
153 extern HRESULT WINAPI IDirectInputDevice2AImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIPROPHEADER pdiph) DECLSPEC_HIDDEN;
154 extern HRESULT WINAPI IDirectInputDevice2WImpl_SetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPCDIPROPHEADER pdiph) DECLSPEC_HIDDEN;
155 extern HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo(
156 LPDIRECTINPUTDEVICE8A iface,
157 LPDIDEVICEOBJECTINSTANCEA pdidoi,
158 DWORD dwObj,
159 DWORD dwHow) DECLSPEC_HIDDEN;
160 extern HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
161 LPDIDEVICEOBJECTINSTANCEW pdidoi,
162 DWORD dwObj,
163 DWORD dwHow) DECLSPEC_HIDDEN;
164 extern HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface, DWORD dodsize, LPDIDEVICEOBJECTDATA dod,
165 LPDWORD entries, DWORD flags) DECLSPEC_HIDDEN;
166 extern HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceData(LPDIRECTINPUTDEVICE8W iface, DWORD dodsize, LPDIDEVICEOBJECTDATA dod,
167 LPDWORD entries, DWORD flags) DECLSPEC_HIDDEN;
168 extern HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel(LPDIRECTINPUTDEVICE8A iface, HWND hwndOwner, DWORD dwFlags) DECLSPEC_HIDDEN;
169 extern HRESULT WINAPI IDirectInputDevice2WImpl_RunControlPanel(LPDIRECTINPUTDEVICE8W iface, HWND hwndOwner, DWORD dwFlags) DECLSPEC_HIDDEN;
170 extern HRESULT WINAPI IDirectInputDevice2AImpl_Initialize(LPDIRECTINPUTDEVICE8A iface, HINSTANCE hinst, DWORD dwVersion,
171 REFGUID rguid) DECLSPEC_HIDDEN;
172 extern HRESULT WINAPI IDirectInputDevice2WImpl_Initialize(LPDIRECTINPUTDEVICE8W iface, HINSTANCE hinst, DWORD dwVersion,
173 REFGUID rguid) DECLSPEC_HIDDEN;
174 extern HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIEFFECT lpeff,
175 LPDIRECTINPUTEFFECT *ppdef, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
176 extern HRESULT WINAPI IDirectInputDevice2WImpl_CreateEffect(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPCDIEFFECT lpeff,
177 LPDIRECTINPUTEFFECT *ppdef, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
178 extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects(
179 LPDIRECTINPUTDEVICE8A iface,
180 LPDIENUMEFFECTSCALLBACKA lpCallback,
181 LPVOID lpvRef,
182 DWORD dwFlags) DECLSPEC_HIDDEN;
183 extern HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects(
184 LPDIRECTINPUTDEVICE8W iface,
185 LPDIENUMEFFECTSCALLBACKW lpCallback,
186 LPVOID lpvRef,
187 DWORD dwFlags) DECLSPEC_HIDDEN;
188 extern HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo(
189 LPDIRECTINPUTDEVICE8A iface,
190 LPDIEFFECTINFOA lpdei,
191 REFGUID rguid) DECLSPEC_HIDDEN;
192 extern HRESULT WINAPI IDirectInputDevice2WImpl_GetEffectInfo(
193 LPDIRECTINPUTDEVICE8W iface,
194 LPDIEFFECTINFOW lpdei,
195 REFGUID rguid) DECLSPEC_HIDDEN;
196 extern HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(LPDIRECTINPUTDEVICE8A iface, LPDWORD pdwOut) DECLSPEC_HIDDEN;
197 extern HRESULT WINAPI IDirectInputDevice2WImpl_GetForceFeedbackState(LPDIRECTINPUTDEVICE8W iface, LPDWORD pdwOut) DECLSPEC_HIDDEN;
198 extern HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8A iface, DWORD dwFlags) DECLSPEC_HIDDEN;
199 extern HRESULT WINAPI IDirectInputDevice2WImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8W iface, DWORD dwFlags) DECLSPEC_HIDDEN;
200 extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDEVICE8A iface,
201 LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
202 LPVOID lpvRef, DWORD dwFlags) DECLSPEC_HIDDEN;
203 extern HRESULT WINAPI IDirectInputDevice2WImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDEVICE8W iface,
204 LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
205 LPVOID lpvRef, DWORD dwFlags) DECLSPEC_HIDDEN;
206 extern HRESULT WINAPI IDirectInputDevice2AImpl_Escape(LPDIRECTINPUTDEVICE8A iface, LPDIEFFESCAPE lpDIEEsc) DECLSPEC_HIDDEN;
207 extern HRESULT WINAPI IDirectInputDevice2WImpl_Escape(LPDIRECTINPUTDEVICE8W iface, LPDIEFFESCAPE lpDIEEsc) DECLSPEC_HIDDEN;
208 extern HRESULT WINAPI IDirectInputDevice2AImpl_Poll(LPDIRECTINPUTDEVICE8A iface) DECLSPEC_HIDDEN;
209 extern HRESULT WINAPI IDirectInputDevice2WImpl_Poll(LPDIRECTINPUTDEVICE8W iface) DECLSPEC_HIDDEN;
210 extern HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData(LPDIRECTINPUTDEVICE8A iface, DWORD cbObjectData,
211 LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) DECLSPEC_HIDDEN;
212 extern HRESULT WINAPI IDirectInputDevice2WImpl_SendDeviceData(LPDIRECTINPUTDEVICE8W iface, DWORD cbObjectData,
213 LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) DECLSPEC_HIDDEN;
214 extern HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8A iface,
215 LPCSTR lpszFileName,
216 LPDIENUMEFFECTSINFILECALLBACK pec,
217 LPVOID pvRef,
218 DWORD dwFlags) DECLSPEC_HIDDEN;
219 extern HRESULT WINAPI IDirectInputDevice7WImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8W iface,
220 LPCWSTR lpszFileName,
221 LPDIENUMEFFECTSINFILECALLBACK pec,
222 LPVOID pvRef,
223 DWORD dwFlags) DECLSPEC_HIDDEN;
224 extern HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8A iface,
225 LPCSTR lpszFileName,
226 DWORD dwEntries,
227 LPDIFILEEFFECT rgDiFileEft,
228 DWORD dwFlags) DECLSPEC_HIDDEN;
229 extern HRESULT WINAPI IDirectInputDevice7WImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8W iface,
230 LPCWSTR lpszFileName,
231 DWORD dwEntries,
232 LPDIFILEEFFECT rgDiFileEft,
233 DWORD dwFlags) DECLSPEC_HIDDEN;
234 extern HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
235 LPDIACTIONFORMATW lpdiaf,
236 LPCWSTR lpszUserName,
237 DWORD dwFlags) DECLSPEC_HIDDEN;
238 extern HRESULT WINAPI IDirectInputDevice8WImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
239 LPDIACTIONFORMATW lpdiaf,
240 LPCWSTR lpszUserName,
241 DWORD dwFlags) DECLSPEC_HIDDEN;
242 extern HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface,
243 LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader) DECLSPEC_HIDDEN;
244 extern HRESULT WINAPI IDirectInputDevice8WImpl_GetImageInfo(LPDIRECTINPUTDEVICE8W iface,
245 LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader) DECLSPEC_HIDDEN;
246
247 #endif /* __WINE_DLLS_DINPUT_DINPUTDEVICE_PRIVATE_H */