Changeset 9016 for trunk/src/dinput/dinput_main.c
- Timestamp:
- Aug 16, 2002, 5:08:25 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/dinput/dinput_main.c
r8346 r9016 3 3 * Copyright 1998 Marcus Meissner 4 4 * Copyright 1998,1999 Lionel Ulmer 5 * 5 * Copyright 2000-2002 TransGaming Technologies Inc. 6 * 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 6 21 */ 7 22 /* Status: … … 11 26 * - WingCommander Prophecy Demo: 12 27 * Doesn't get Input Focus. 13 * 28 * 14 29 * - Fallout : works great in X and DGA mode 15 *16 * FIXME: The keyboard handling needs to (and will) be merged into keyboard.c17 * (The current implementation is currently only a proof of concept and18 * an utter mess.)19 30 */ 20 31 … … 23 34 #include <string.h> 24 35 25 #include " debugtools.h"36 #include "wine/debug.h" 26 37 #include "winbase.h" 38 #include "winuser.h" 27 39 #include "winerror.h" 28 40 #include "windef.h" 29 41 #include "dinput_private.h" 30 42 31 DEFAULT_DEBUG_CHANNEL(dinput); 32 33 static ICOM_VTABLE(IDirectInputA) ddiavt; 43 WINE_DEFAULT_DEBUG_CHANNEL(dinput); 44 34 45 static ICOM_VTABLE(IDirectInput7A) ddi7avt; 46 static ICOM_VTABLE(IDirectInput8A) ddi8avt; 35 47 36 48 /* This array will be filled a dinput.so loading */ … … 39 51 static int nrof_dinput_devices = 0; 40 52 41 /* register a direct draw driver. We better not use malloc for we are in 53 BOOL WINAPI Init( HINSTANCE inst, DWORD reason, LPVOID reserv) 54 { 55 switch(reason) 56 { 57 case DLL_PROCESS_ATTACH: 58 keyboard_hook = SetWindowsHookExW( WH_KEYBOARD_LL, KeyboardCallback, 0, 0 ); 59 break; 60 case DLL_PROCESS_DETACH: 61 UnhookWindowsHookEx(keyboard_hook); 62 break; 63 } 64 return TRUE; 65 } 66 67 68 /* register a direct draw driver. We better not use malloc for we are in 42 69 * the ELF startup initialisation at this point. 43 70 */ … … 74 101 (DWORD)hinst,dwVersion,debugstr_guid(riid),ppDI,punkOuter 75 102 ); 76 if (IsEqualGUID(&IID_IDirectInputA,riid)) { 103 if (IsEqualGUID(&IID_IDirectInputA,riid) || 104 IsEqualGUID(&IID_IDirectInput2A,riid) || 105 IsEqualGUID(&IID_IDirectInput7A,riid)) { 77 106 This = (IDirectInputAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputAImpl)); 107 This->lpVtbl = &ddi7avt; 78 108 This->ref = 1; 79 ICOM_VTBL(This) = &ddiavt;80 109 *ppDI = This; 81 110 82 111 return DI_OK; 83 112 } 84 85 if (IsEqualGUID(&IID_IDirectInput7A,riid)) { 113 114 115 if (IsEqualGUID(&IID_IDirectInput8A,riid)) { 86 116 This = (IDirectInputAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputAImpl)); 117 This->lpVtbl = &ddi8avt; 87 118 This->ref = 1; 88 ICOM_VTBL(This) = (ICOM_VTABLE(IDirectInputA) *) &ddi7avt;89 119 *ppDI = This; 90 120 91 121 return DI_OK; 92 122 } … … 105 135 ); 106 136 This = (IDirectInputAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputAImpl)); 137 This->lpVtbl = &ddi7avt; 107 138 This->ref = 1; 108 ICOM_VTBL(This) = &ddiavt;109 139 *ppDI=(IDirectInputA*)This; 110 140 return 0; 141 111 142 } 112 143 /****************************************************************************** … … 126 157 for (i = 0; i < nrof_dinput_devices; i++) { 127 158 if (dinput_devices[i]->enum_device(dwDevType, dwFlags, &devInstance)) { 159 devInstance.dwSize = sizeof(devInstance); 128 160 if (lpCallback(&devInstance,pvRef) == DIENUM_STOP) 129 161 return 0; 130 162 } 131 163 } 132 164 133 165 return 0; 166 } 167 168 static HRESULT WINAPI IDirectInputAImpl_QueryInterface( 169 LPDIRECTINPUT7A iface,REFIID riid,LPVOID *ppobj 170 ) { 171 ICOM_THIS(IDirectInputAImpl,iface); 172 173 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj); 174 if (IsEqualGUID(&IID_IUnknown,riid) || 175 IsEqualGUID(&IID_IDirectInputA,riid) || 176 IsEqualGUID(&IID_IDirectInput2A,riid) || 177 IsEqualGUID(&IID_IDirectInput7A,riid)) { 178 IDirectInputA_AddRef(iface); 179 *ppobj = This; 180 return 0; 181 } 182 TRACE("Unsupported interface !\n"); 183 return E_FAIL; 134 184 } 135 185 … … 157 207 HRESULT ret_value = DIERR_DEVICENOTREG; 158 208 int i; 159 209 160 210 TRACE("(this=%p,%s,%p,%p)\n",This,debugstr_guid(rguid),pdev,punk); 161 211 … … 173 223 } 174 224 175 static HRESULT WINAPI IDirectInputAImpl_QueryInterface(176 LPDIRECTINPUT7A iface,REFIID riid,LPVOID *ppobj177 ) {178 ICOM_THIS(IDirectInputAImpl,iface);179 180 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);181 if (IsEqualGUID(&IID_IUnknown,riid)) {182 IDirectInputA_AddRef(iface);183 *ppobj = This;184 return 0;185 }186 if (IsEqualGUID(&IID_IDirectInputA,riid)) {187 IDirectInputA_AddRef(iface);188 *ppobj = This;189 return 0;190 }191 TRACE("Unsupported interface !\n");192 return E_FAIL;193 }194 195 225 static HRESULT WINAPI IDirectInputAImpl_Initialize( 196 226 LPDIRECTINPUT7A iface,HINSTANCE hinst,DWORD x … … 202 232 REFGUID rguid) { 203 233 ICOM_THIS(IDirectInputAImpl,iface); 204 234 205 235 FIXME("(%p)->(%s): stub\n",This,debugstr_guid(rguid)); 206 236 207 237 return DI_OK; 208 238 } … … 213 243 ICOM_THIS(IDirectInputAImpl,iface); 214 244 FIXME("(%p)->(%08lx,%08lx): stub\n",This, (DWORD) hwndOwner, dwFlags); 215 245 216 246 return DI_OK; 217 247 } 218 248 219 static HRESULT WINAPI IDirectInput2AImpl_FindDevice(LPDIRECTINPUT 2A iface, REFGUID rguid,249 static HRESULT WINAPI IDirectInput2AImpl_FindDevice(LPDIRECTINPUT7A iface, REFGUID rguid, 220 250 LPCSTR pszName, LPGUID pguidInstance) { 221 251 ICOM_THIS(IDirectInputAImpl,iface); 222 252 FIXME("(%p)->(%s, %s, %p): stub\n", This, debugstr_guid(rguid), pszName, pguidInstance); 223 253 224 254 return DI_OK; 225 255 } … … 231 261 HRESULT ret_value = DIERR_DEVICENOTREG; 232 262 int i; 233 263 234 264 TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter); 235 265 … … 239 269 if ((ret = dinput_devices[i]->create_device(This, rguid, riid, (LPDIRECTINPUTDEVICEA*) pvOut)) == DI_OK) 240 270 return DI_OK; 241 271 242 272 if (ret == DIERR_NOINTERFACE) 243 273 ret_value = DIERR_NOINTERFACE; 244 274 } 245 275 246 276 return ret_value; 247 277 } 248 278 279 static HRESULT WINAPI IDirectInput8AImpl_QueryInterface( 280 LPDIRECTINPUT8A iface,REFIID riid,LPVOID *ppobj 281 ) { 282 ICOM_THIS(IDirectInputAImpl,iface); 283 284 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj); 285 if (IsEqualGUID(&IID_IUnknown,riid) || 286 IsEqualGUID(&IID_IDirectInput8A,riid)) { 287 IDirectInputA_AddRef(iface); 288 *ppobj = This; 289 return 0; 290 } 291 TRACE("Unsupported interface !\n"); 292 return E_FAIL; 293 } 294 295 static HRESULT WINAPI IDirectInput8AImpl_EnumDevicesBySemantics( 296 LPDIRECTINPUT8A iface, LPCSTR ptszUserName, LPDIACTIONFORMATA lpdiActionFormat, 297 LPDIENUMDEVICESBYSEMANTICSCBA lpCallback, 298 LPVOID pvRef, DWORD dwFlags 299 ) 300 { 301 ICOM_THIS(IDirectInputAImpl,iface); 302 303 FIXME("(this=%p,%s,%p,%p,%p,%04lx): stub\n", This, ptszUserName, lpdiActionFormat, 304 lpCallback, pvRef, dwFlags); 305 return 0; 306 } 307 308 static HRESULT WINAPI IDirectInput8AImpl_ConfigureDevices( 309 LPDIRECTINPUT8A iface, LPDICONFIGUREDEVICESCALLBACK lpdiCallback, 310 LPDICONFIGUREDEVICESPARAMSA lpdiCDParams, DWORD dwFlags, LPVOID pvRefData 311 ) 312 { 313 ICOM_THIS(IDirectInputAImpl,iface); 314 315 FIXME("(this=%p,%p,%p,%04lx,%p): stub\n", This, lpdiCallback, lpdiCDParams, 316 dwFlags, pvRefData); 317 return 0; 318 } 319 249 320 #if !defined(__STRICT_ANSI__) && defined(__GNUC__) 250 # define XCAST(fun) (typeof(ddiavt.fun)) 251 #else 252 # define XCAST(fun) (void*) 253 #endif 254 255 static ICOM_VTABLE(IDirectInputA) ddiavt = 256 { 257 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE 258 XCAST(QueryInterface)IDirectInputAImpl_QueryInterface, 259 XCAST(AddRef)IDirectInputAImpl_AddRef, 260 XCAST(Release)IDirectInputAImpl_Release, 261 XCAST(CreateDevice)IDirectInputAImpl_CreateDevice, 262 XCAST(EnumDevices)IDirectInputAImpl_EnumDevices, 263 XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus, 264 XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel, 265 XCAST(Initialize)IDirectInputAImpl_Initialize 266 }; 267 #undef XCAST 268 269 #if !defined(__STRICT_ANSI__) && defined(__GNUC__) 270 # define XCAST(fun) (typeof(ddi7avt.fun)) 321 # define XCAST(fun) (typeof(ddi7avt.fun)) 271 322 #else 272 323 # define XCAST(fun) (void*) … … 288 339 #undef XCAST 289 340 341 #if !defined(__STRICT_ANSI__) && defined(__GNUC__) 342 # define XCAST(fun) (typeof(ddi8avt.fun)) 343 #else 344 # define XCAST(fun) (void*) 345 #endif 346 347 static ICOM_VTABLE(IDirectInput8A) ddi8avt = { 348 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE 349 XCAST(QueryInterface)IDirectInput8AImpl_QueryInterface, 350 XCAST(AddRef)IDirectInputAImpl_AddRef, 351 XCAST(Release)IDirectInputAImpl_Release, 352 XCAST(CreateDevice)IDirectInputAImpl_CreateDevice, 353 XCAST(EnumDevices)IDirectInputAImpl_EnumDevices, 354 XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus, 355 XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel, 356 XCAST(Initialize)IDirectInputAImpl_Initialize, 357 XCAST(FindDevice)IDirectInput2AImpl_FindDevice, 358 IDirectInput8AImpl_EnumDevicesBySemantics, 359 IDirectInput8AImpl_ConfigureDevices 360 }; 361 #undef XCAST 362 290 363 /*********************************************************************** 291 364 * DllCanUnloadNow (DINPUT.@) … … 304 377 LPVOID *ppv) 305 378 { 306 FIXME("(%p, %p, %p): stub\n", debugstr_guid(rclsid), 379 FIXME("(%p, %p, %p): stub\n", debugstr_guid(rclsid), 307 380 debugstr_guid(riid), ppv); 308 381
Note:
See TracChangeset
for help on using the changeset viewer.