dsound: Don't use state.buffer_size before it has been initialized.
[wine] / dlls / 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 #include <stdarg.h>
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "dinput.h"
28
29 /* Device implementation */
30 typedef struct IDirectInputDevice2AImpl IDirectInputDevice2AImpl;
31 struct IDirectInputDevice2AImpl
32 {
33         const IDirectInputDevice2AVtbl *lpVtbl;
34         LONG                            ref;
35         GUID                            guid;
36 };
37
38 /* Routines to do DataFormat / WineFormat conversions */
39 typedef struct {
40   int size;
41   int offset_in;
42   int offset_out;
43   int value;
44 } DataTransform;
45
46 typedef struct {
47   int size;
48   int internal_format_size;
49   DataTransform *dt;
50 } DataFormat;
51 extern void fill_DataFormat(void *out, const void *in, DataFormat *df) ;
52 extern DataFormat *create_DataFormat(const DIDATAFORMAT *wine_format, LPCDIDATAFORMAT asked_format, int *offset) ;
53 extern void release_DataFormat(DataFormat *df) ;
54
55 /* Used to fill events in the queue */
56 #define GEN_EVENT(offset,data,xtime,seq)                                        \
57 {                                                                               \
58   /* If queue_len > 0, queuing is requested -> TRACE the event queued */        \
59   if (This->queue_len > 0) {                                                    \
60     int nq;                                                                     \
61     TRACE(" queueing %d at offset %d (queue head %d / size %d)\n",              \
62           (int) (data), (int) (offset),                                         \
63           (int) (This->queue_head), (int) (This->queue_len));                   \
64                                                                                 \
65     nq = (This->queue_head+1) % This->queue_len;                                \
66     if ((offset >= 0) && (nq != This->queue_tail)) {                            \
67       This->data_queue[This->queue_head].dwOfs = offset;                        \
68       This->data_queue[This->queue_head].dwData = data;                         \
69       This->data_queue[This->queue_head].dwTimeStamp = xtime;                   \
70       This->data_queue[This->queue_head].dwSequence = seq;                      \
71       This->queue_head = nq;                                                    \
72     } else                                                                      \
73       This->overflow = TRUE;                                                    \
74   }                                                                             \
75 }
76
77 /**
78  * Callback Data used by specific callback 
79  *  for EnumObject on 'W' interfaces
80  */
81 typedef struct {
82   LPDIENUMDEVICEOBJECTSCALLBACKW lpCallBack;
83   LPVOID lpvRef;
84 } device_enumobjects_AtoWcb_data;
85
86 extern BOOL DIEnumDevicesCallbackAtoW(LPCDIDEVICEOBJECTINSTANCEA, LPVOID);
87
88
89 /* Various debug tools */
90 extern void _dump_cooperativelevel_DI(DWORD dwFlags) ;
91 extern void _dump_EnumObjects_flags(DWORD dwFlags) ;
92 extern void _dump_DIPROPHEADER(LPCDIPROPHEADER diph) ;
93 extern void _dump_OBJECTINSTANCEA(DIDEVICEOBJECTINSTANCEA *ddoi) ;
94 extern void _dump_OBJECTINSTANCEW(DIDEVICEOBJECTINSTANCEW *ddoi) ;
95 extern void _dump_DIDATAFORMAT(const DIDATAFORMAT *df) ;
96 extern const char *_dump_dinput_GUID(const GUID *guid) ;
97
98 /* And the stubs */
99 extern HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat(
100         LPDIRECTINPUTDEVICE8A iface,LPCDIDATAFORMAT df ) ;
101 extern HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel(
102         LPDIRECTINPUTDEVICE8A iface,HWND hwnd,DWORD dwflags ) ;
103 extern HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification(
104         LPDIRECTINPUTDEVICE8A iface,HANDLE hnd ) ;
105 extern ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface) ;
106 extern HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(LPDIRECTINPUTDEVICE8A iface,REFIID riid,LPVOID *ppobj);
107 extern HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(LPDIRECTINPUTDEVICE8W iface,REFIID riid,LPVOID *ppobj);
108 extern ULONG WINAPI IDirectInputDevice2AImpl_AddRef(
109         LPDIRECTINPUTDEVICE8A iface) ;
110 extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(
111         LPDIRECTINPUTDEVICE8A iface,
112         LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback,
113         LPVOID lpvRef,
114         DWORD dwFlags) ;
115 extern HRESULT WINAPI IDirectInputDevice2WImpl_EnumObjects(
116         LPDIRECTINPUTDEVICE8W iface,
117         LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
118         LPVOID lpvRef,
119         DWORD dwFlags) ;
120 extern HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(
121         LPDIRECTINPUTDEVICE8A iface,
122         REFGUID rguid,
123         LPDIPROPHEADER pdiph) ;
124 extern HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo(
125         LPDIRECTINPUTDEVICE8A iface,
126         LPDIDEVICEOBJECTINSTANCEA pdidoi,
127         DWORD dwObj,
128         DWORD dwHow) ;
129 extern HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface, 
130                                                              LPDIDEVICEOBJECTINSTANCEW pdidoi,
131                                                              DWORD dwObj,
132                                                              DWORD dwHow);
133 extern HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceInfo(
134         LPDIRECTINPUTDEVICE8A iface,
135         LPDIDEVICEINSTANCEA pdidi) ;
136 extern HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceInfo(
137         LPDIRECTINPUTDEVICE8W iface,
138         LPDIDEVICEINSTANCEW pdidi) ;
139 extern HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel(
140         LPDIRECTINPUTDEVICE8A iface,
141         HWND hwndOwner,
142         DWORD dwFlags) ;
143 extern HRESULT WINAPI IDirectInputDevice2AImpl_Initialize(
144         LPDIRECTINPUTDEVICE8A iface,
145         HINSTANCE hinst,
146         DWORD dwVersion,
147         REFGUID rguid) ;
148 extern HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect(
149         LPDIRECTINPUTDEVICE8A iface,
150         REFGUID rguid,
151         LPCDIEFFECT lpeff,
152         LPDIRECTINPUTEFFECT *ppdef,
153         LPUNKNOWN pUnkOuter) ;
154 extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects(
155         LPDIRECTINPUTDEVICE8A iface,
156         LPDIENUMEFFECTSCALLBACKA lpCallback,
157         LPVOID lpvRef,
158         DWORD dwFlags) ;
159 extern HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects(
160         LPDIRECTINPUTDEVICE8W iface,
161         LPDIENUMEFFECTSCALLBACKW lpCallback,
162         LPVOID lpvRef,
163         DWORD dwFlags) ;
164 extern HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo(
165         LPDIRECTINPUTDEVICE8A iface,
166         LPDIEFFECTINFOA lpdei,
167         REFGUID rguid) ;
168 extern HRESULT WINAPI IDirectInputDevice2WImpl_GetEffectInfo(
169         LPDIRECTINPUTDEVICE8W iface,
170         LPDIEFFECTINFOW lpdei,
171         REFGUID rguid) ;
172 extern HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(
173         LPDIRECTINPUTDEVICE8A iface,
174         LPDWORD pdwOut) ;
175 extern HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand(
176         LPDIRECTINPUTDEVICE8A iface,
177         DWORD dwFlags) ;
178 extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects(
179         LPDIRECTINPUTDEVICE8A iface,
180         LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
181         LPVOID lpvRef,
182         DWORD dwFlags) ;
183 extern HRESULT WINAPI IDirectInputDevice2AImpl_Escape(
184         LPDIRECTINPUTDEVICE8A iface,
185         LPDIEFFESCAPE lpDIEEsc) ;
186 extern HRESULT WINAPI IDirectInputDevice2AImpl_Poll(
187         LPDIRECTINPUTDEVICE8A iface) ;
188 extern HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData(
189         LPDIRECTINPUTDEVICE8A iface,
190         DWORD cbObjectData,
191         LPCDIDEVICEOBJECTDATA rgdod,
192         LPDWORD pdwInOut,
193         DWORD dwFlags) ;
194 extern HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8A iface,
195                                                                  LPCSTR lpszFileName,
196                                                                  LPDIENUMEFFECTSINFILECALLBACK pec,
197                                                                  LPVOID pvRef,
198                                                                  DWORD dwFlags) ;
199 extern HRESULT WINAPI IDirectInputDevice7WImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8W iface,
200                                                                  LPCWSTR lpszFileName,
201                                                                  LPDIENUMEFFECTSINFILECALLBACK pec,
202                                                                  LPVOID pvRef,
203                                                                  DWORD dwFlags) ;
204 extern HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8A iface,
205                                                                  LPCSTR lpszFileName,
206                                                                  DWORD dwEntries,
207                                                                  LPDIFILEEFFECT rgDiFileEft,
208                                                                  DWORD dwFlags) ;
209 extern HRESULT WINAPI IDirectInputDevice7WImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8W iface,
210                                                                  LPCWSTR lpszFileName,
211                                                                  DWORD dwEntries,
212                                                                  LPDIFILEEFFECT rgDiFileEft,
213                                                                  DWORD dwFlags) ;
214 extern HRESULT WINAPI IDirectInputDevice8AImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface,
215                                                               LPDIACTIONFORMATA lpdiaf,
216                                                               LPCSTR lpszUserName,
217                                                               DWORD dwFlags);
218 extern HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
219                                                               LPDIACTIONFORMATW lpdiaf,
220                                                               LPCWSTR lpszUserName,
221                                                               DWORD dwFlags);
222 extern HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface,
223                                                             LPDIACTIONFORMATA lpdiaf,
224                                                             LPCSTR lpszUserName,
225                                                             DWORD dwFlags);
226 extern HRESULT WINAPI IDirectInputDevice8WImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
227                                                             LPDIACTIONFORMATW lpdiaf,
228                                                             LPCWSTR lpszUserName,
229                                                             DWORD dwFlags);
230 extern HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface,
231                                                             LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader);
232 extern HRESULT WINAPI IDirectInputDevice8WImpl_GetImageInfo(LPDIRECTINPUTDEVICE8W iface,
233                                                             LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader);
234
235 #endif /* __WINE_DLLS_DINPUT_DINPUTDEVICE_PRIVATE_H */