device_private.h 10.5 KB
Newer Older
1 2
/*
 * Copyright 2000 Lionel Ulmer
3
 * Copyright 2000-2001 TransGaming Technologies Inc.
4 5 6 7 8 9 10 11 12 13 14 15 16
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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
 */

Lionel Ulmer's avatar
Lionel Ulmer committed
20 21 22
#ifndef __WINE_DLLS_DINPUT_DINPUTDEVICE_PRIVATE_H
#define __WINE_DLLS_DINPUT_DINPUTDEVICE_PRIVATE_H

23 24 25
#include <stdarg.h>

#include "windef.h"
Lionel Ulmer's avatar
Lionel Ulmer committed
26 27
#include "winbase.h"
#include "dinput.h"
28
#include "wine/list.h"
29
#include "dinput_private.h"
Lionel Ulmer's avatar
Lionel Ulmer committed
30

31 32 33 34 35 36 37 38 39 40 41 42 43 44
typedef struct
{
    int size;
    int offset_in;
    int offset_out;
    int value;
} DataTransform;

typedef struct
{
    int                         size;
    int                         internal_format_size;
    DataTransform              *dt;

45
    int                        *offsets;     /* object offsets */
46
    LPDIDATAFORMAT              wine_df;     /* wine internal data format */
47
    LPDIDATAFORMAT              user_df;     /* user defined data format */
48 49
} DataFormat;

Lionel Ulmer's avatar
Lionel Ulmer committed
50 51 52 53
/* Device implementation */
typedef struct IDirectInputDevice2AImpl IDirectInputDevice2AImpl;
struct IDirectInputDevice2AImpl
{
54 55 56
    const void                 *lpVtbl;
    LONG                        ref;
    GUID                        guid;
57
    CRITICAL_SECTION            crit;
58
    IDirectInputImpl           *dinput;
59
    struct list                 entry;       /* entry into IDirectInput devices list */
60
    HANDLE                      hEvent;
61 62
    DWORD                       dwCoopLevel;
    HWND                        win;
63
    int                         acquired;
64
    DI_EVENT_PROC               event_proc;  /* function to receive mouse & keyboard events */
65 66 67 68 69 70

    LPDIDEVICEOBJECTDATA        data_queue;  /* buffer for 'GetDeviceData'.                 */
    int                         queue_len;   /* size of the queue - set in 'SetProperty'    */
    int                         queue_head;  /* position to write new event into queue      */
    int                         queue_tail;  /* next event to read from queue               */
    BOOL                        overflow;    /* return DI_BUFFEROVERFLOW in 'GetDeviceData' */
71 72

    DataFormat                  data_format; /* user data format and wine to user format converter */
Lionel Ulmer's avatar
Lionel Ulmer committed
73 74
};

75
extern BOOL get_app_key(HKEY*, HKEY*);
76 77
extern DWORD get_config_key(HKEY, HKEY, const char*, char*, DWORD);

Lionel Ulmer's avatar
Lionel Ulmer committed
78
/* Routines to do DataFormat / WineFormat conversions */
79
extern void fill_DataFormat(void *out, const void *in, const DataFormat *df) ;
80
extern HRESULT create_DataFormat(LPCDIDATAFORMAT asked_format, DataFormat *format);
81
extern void release_DataFormat(DataFormat *df) ;
82
extern void queue_event(LPDIRECTINPUTDEVICE8A iface, int ofs, DWORD data, DWORD time, DWORD seq);
83
/* Helper functions to work with data format */
84
extern int id_to_object(LPCDIDATAFORMAT df, int id);
85 86
extern int id_to_offset(const DataFormat *df, int id);
extern int find_property(const DataFormat *df, LPCDIPROPHEADER ph);
Lionel Ulmer's avatar
Lionel Ulmer committed
87

88
/* Common joystick stuff */
89 90 91 92 93 94 95 96 97 98
typedef struct
{
    LONG lDevMin;
    LONG lDevMax;
    LONG lMin;
    LONG lMax;
    LONG lDeadZone;
    LONG lSaturation;
} ObjProps;

99
extern DWORD joystick_map_pov(POINTL *p);
100
extern LONG joystick_map_axis(ObjProps *props, int val);
101

102 103 104 105 106 107 108 109 110 111 112
/**
 * Callback Data used by specific callback 
 *  for EnumObject on 'W' interfaces
 */
typedef struct {
  LPDIENUMDEVICEOBJECTSCALLBACKW lpCallBack;
  LPVOID lpvRef;
} device_enumobjects_AtoWcb_data;

extern BOOL DIEnumDevicesCallbackAtoW(LPCDIDEVICEOBJECTINSTANCEA, LPVOID);

113 114
extern const GUID DInput_Wine_Keyboard_GUID;
extern const GUID DInput_Wine_Mouse_GUID;
Lionel Ulmer's avatar
Lionel Ulmer committed
115 116 117 118

/* Various debug tools */
extern void _dump_cooperativelevel_DI(DWORD dwFlags) ;
extern void _dump_EnumObjects_flags(DWORD dwFlags) ;
119
extern void _dump_DIPROPHEADER(LPCDIPROPHEADER diph) ;
120 121
extern void _dump_OBJECTINSTANCEA(const DIDEVICEOBJECTINSTANCEA *ddoi) ;
extern void _dump_OBJECTINSTANCEW(const DIDEVICEOBJECTINSTANCEW *ddoi) ;
122 123
extern void _dump_DIDATAFORMAT(const DIDATAFORMAT *df) ;
extern const char *_dump_dinput_GUID(const GUID *guid) ;
Lionel Ulmer's avatar
Lionel Ulmer committed
124 125

/* And the stubs */
126 127
extern HRESULT WINAPI IDirectInputDevice2AImpl_Acquire(LPDIRECTINPUTDEVICE8A iface);
extern HRESULT WINAPI IDirectInputDevice2AImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface);
Lionel Ulmer's avatar
Lionel Ulmer committed
128
extern HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat(
129
	LPDIRECTINPUTDEVICE8A iface,LPCDIDATAFORMAT df ) ;
Lionel Ulmer's avatar
Lionel Ulmer committed
130
extern HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel(
131
	LPDIRECTINPUTDEVICE8A iface,HWND hwnd,DWORD dwflags ) ;
Lionel Ulmer's avatar
Lionel Ulmer committed
132
extern HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification(
133 134
	LPDIRECTINPUTDEVICE8A iface,HANDLE hnd ) ;
extern ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface) ;
135 136
extern HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(LPDIRECTINPUTDEVICE8A iface,REFIID riid,LPVOID *ppobj);
extern HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(LPDIRECTINPUTDEVICE8W iface,REFIID riid,LPVOID *ppobj);
Lionel Ulmer's avatar
Lionel Ulmer committed
137
extern ULONG WINAPI IDirectInputDevice2AImpl_AddRef(
138
	LPDIRECTINPUTDEVICE8A iface) ;
Lionel Ulmer's avatar
Lionel Ulmer committed
139
extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(
140
	LPDIRECTINPUTDEVICE8A iface,
Lionel Ulmer's avatar
Lionel Ulmer committed
141 142 143
	LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback,
	LPVOID lpvRef,
	DWORD dwFlags) ;
144 145 146 147 148
extern HRESULT WINAPI IDirectInputDevice2WImpl_EnumObjects(
	LPDIRECTINPUTDEVICE8W iface,
	LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
	LPVOID lpvRef,
	DWORD dwFlags) ;
149 150
extern HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph);
extern HRESULT WINAPI IDirectInputDevice2AImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIPROPHEADER pdiph);
Lionel Ulmer's avatar
Lionel Ulmer committed
151
extern HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo(
152
	LPDIRECTINPUTDEVICE8A iface,
Lionel Ulmer's avatar
Lionel Ulmer committed
153 154 155
	LPDIDEVICEOBJECTINSTANCEA pdidoi,
	DWORD dwObj,
	DWORD dwHow) ;
156 157 158 159
extern HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface, 
							     LPDIDEVICEOBJECTINSTANCEW pdidoi,
							     DWORD dwObj,
							     DWORD dwHow);
160 161
extern HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
        DWORD dodsize, LPDIDEVICEOBJECTDATA dod, LPDWORD entries, DWORD flags);
Lionel Ulmer's avatar
Lionel Ulmer committed
162
extern HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceInfo(
163
	LPDIRECTINPUTDEVICE8A iface,
Lionel Ulmer's avatar
Lionel Ulmer committed
164
	LPDIDEVICEINSTANCEA pdidi) ;
165 166 167
extern HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceInfo(
	LPDIRECTINPUTDEVICE8W iface,
	LPDIDEVICEINSTANCEW pdidi) ;
Lionel Ulmer's avatar
Lionel Ulmer committed
168
extern HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel(
169
	LPDIRECTINPUTDEVICE8A iface,
Lionel Ulmer's avatar
Lionel Ulmer committed
170 171 172
	HWND hwndOwner,
	DWORD dwFlags) ;
extern HRESULT WINAPI IDirectInputDevice2AImpl_Initialize(
173
	LPDIRECTINPUTDEVICE8A iface,
Lionel Ulmer's avatar
Lionel Ulmer committed
174 175 176 177
	HINSTANCE hinst,
	DWORD dwVersion,
	REFGUID rguid) ;
extern HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect(
178
	LPDIRECTINPUTDEVICE8A iface,
Lionel Ulmer's avatar
Lionel Ulmer committed
179 180 181 182 183
	REFGUID rguid,
	LPCDIEFFECT lpeff,
	LPDIRECTINPUTEFFECT *ppdef,
	LPUNKNOWN pUnkOuter) ;
extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects(
184
	LPDIRECTINPUTDEVICE8A iface,
Lionel Ulmer's avatar
Lionel Ulmer committed
185 186 187
	LPDIENUMEFFECTSCALLBACKA lpCallback,
	LPVOID lpvRef,
	DWORD dwFlags) ;
188 189 190 191 192
extern HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects(
	LPDIRECTINPUTDEVICE8W iface,
	LPDIENUMEFFECTSCALLBACKW lpCallback,
	LPVOID lpvRef,
	DWORD dwFlags) ;
Lionel Ulmer's avatar
Lionel Ulmer committed
193
extern HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo(
194
	LPDIRECTINPUTDEVICE8A iface,
Lionel Ulmer's avatar
Lionel Ulmer committed
195 196
	LPDIEFFECTINFOA lpdei,
	REFGUID rguid) ;
197 198 199 200
extern HRESULT WINAPI IDirectInputDevice2WImpl_GetEffectInfo(
	LPDIRECTINPUTDEVICE8W iface,
	LPDIEFFECTINFOW lpdei,
	REFGUID rguid) ;
Lionel Ulmer's avatar
Lionel Ulmer committed
201
extern HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(
202
	LPDIRECTINPUTDEVICE8A iface,
Lionel Ulmer's avatar
Lionel Ulmer committed
203 204
	LPDWORD pdwOut) ;
extern HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand(
205
	LPDIRECTINPUTDEVICE8A iface,
Lionel Ulmer's avatar
Lionel Ulmer committed
206 207
	DWORD dwFlags) ;
extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects(
208
	LPDIRECTINPUTDEVICE8A iface,
Lionel Ulmer's avatar
Lionel Ulmer committed
209 210 211 212
	LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
	LPVOID lpvRef,
	DWORD dwFlags) ;
extern HRESULT WINAPI IDirectInputDevice2AImpl_Escape(
213
	LPDIRECTINPUTDEVICE8A iface,
Lionel Ulmer's avatar
Lionel Ulmer committed
214 215
	LPDIEFFESCAPE lpDIEEsc) ;
extern HRESULT WINAPI IDirectInputDevice2AImpl_Poll(
216
	LPDIRECTINPUTDEVICE8A iface) ;
Lionel Ulmer's avatar
Lionel Ulmer committed
217
extern HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData(
218
	LPDIRECTINPUTDEVICE8A iface,
Lionel Ulmer's avatar
Lionel Ulmer committed
219
	DWORD cbObjectData,
220
	LPCDIDEVICEOBJECTDATA rgdod,
Lionel Ulmer's avatar
Lionel Ulmer committed
221 222
	LPDWORD pdwInOut,
	DWORD dwFlags) ;
223
extern HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8A iface,
Lionel Ulmer's avatar
Lionel Ulmer committed
224 225 226 227
								 LPCSTR lpszFileName,
								 LPDIENUMEFFECTSINFILECALLBACK pec,
								 LPVOID pvRef,
								 DWORD dwFlags) ;
228 229 230 231 232
extern HRESULT WINAPI IDirectInputDevice7WImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8W iface,
								 LPCWSTR lpszFileName,
								 LPDIENUMEFFECTSINFILECALLBACK pec,
								 LPVOID pvRef,
								 DWORD dwFlags) ;
233
extern HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8A iface,
Lionel Ulmer's avatar
Lionel Ulmer committed
234 235 236 237
								 LPCSTR lpszFileName,
								 DWORD dwEntries,
								 LPDIFILEEFFECT rgDiFileEft,
								 DWORD dwFlags) ;
238 239 240 241 242
extern HRESULT WINAPI IDirectInputDevice7WImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8W iface,
								 LPCWSTR lpszFileName,
								 DWORD dwEntries,
								 LPDIFILEEFFECT rgDiFileEft,
								 DWORD dwFlags) ;
243 244 245 246
extern HRESULT WINAPI IDirectInputDevice8AImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface,
							      LPDIACTIONFORMATA lpdiaf,
							      LPCSTR lpszUserName,
							      DWORD dwFlags);
247 248 249 250
extern HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
							      LPDIACTIONFORMATW lpdiaf,
							      LPCWSTR lpszUserName,
							      DWORD dwFlags);
251 252 253 254
extern HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface,
							    LPDIACTIONFORMATA lpdiaf,
							    LPCSTR lpszUserName,
							    DWORD dwFlags);
255 256 257 258
extern HRESULT WINAPI IDirectInputDevice8WImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
							    LPDIACTIONFORMATW lpdiaf,
							    LPCWSTR lpszUserName,
							    DWORD dwFlags);
259 260
extern HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface,
							    LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader);
261 262
extern HRESULT WINAPI IDirectInputDevice8WImpl_GetImageInfo(LPDIRECTINPUTDEVICE8W iface,
							    LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader);
Lionel Ulmer's avatar
Lionel Ulmer committed
263 264

#endif /* __WINE_DLLS_DINPUT_DINPUTDEVICE_PRIVATE_H */