- Timestamp:
- Aug 16, 2002, 5:08:25 PM (23 years ago)
- Location:
- trunk/src/dinput
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/dinput/device.c
r8346 r9016 4 4 * Copyright 1998,1999 Lionel Ulmer 5 5 * 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 6 20 */ 7 21 … … 14 28 15 29 #include <string.h> 16 #include " debugtools.h"30 #include "wine/debug.h" 17 31 #include "winbase.h" 18 32 #include "winerror.h" … … 21 35 #include "device_private.h" 22 36 23 DEFAULT_DEBUG_CHANNEL(dinput);37 WINE_DEFAULT_DEBUG_CHANNEL(dinput); 24 38 25 39 /****************************************************************************** … … 112 126 *((char *) (out_c + df->dt[i].offset_out)) = *((char *) (in_c + df->dt[i].offset_in)); 113 127 break; 114 128 115 129 case 2: 116 130 TRACE("Copying (s) to %d from %d (value %d)\n", … … 118 132 *((short *) (out_c + df->dt[i].offset_out)) = *((short *) (in_c + df->dt[i].offset_in)); 119 133 break; 120 134 121 135 case 4: 122 136 TRACE("Copying (i) to %d from %d (value %d)\n", … … 124 138 *((int *) (out_c + df->dt[i].offset_out)) = *((int *) (in_c + df->dt[i].offset_in)); 125 139 break; 126 140 127 141 default: 128 142 memcpy((out_c + df->dt[i].offset_out), (in_c + df->dt[i].offset_in), df->dt[i].size); … … 135 149 *((char *) (out_c + df->dt[i].offset_out)) = (char) df->dt[i].value; 136 150 break; 137 151 138 152 case 2: 139 153 TRACE("Copying (s) to %d default value %d\n", … … 141 155 *((short *) (out_c + df->dt[i].offset_out)) = (short) df->dt[i].value; 142 156 break; 143 157 144 158 case 4: 145 159 TRACE("Copying (i) to %d default value %d\n", … … 147 161 *((int *) (out_c + df->dt[i].offset_out)) = (int) df->dt[i].value; 148 162 break; 149 163 150 164 default: 151 165 memset((out_c + df->dt[i].offset_out), df->dt[i].size, 0); … … 163 177 int *done; 164 178 int index = 0; 165 179 166 180 ret = (DataFormat *) HeapAlloc(GetProcessHeap(), 0, sizeof(DataFormat)); 167 181 168 182 done = (int *) HeapAlloc(GetProcessHeap(), 0, sizeof(int) * asked_format->dwNumObjs); 169 183 memset(done, 0, sizeof(int) * asked_format->dwNumObjs); … … 172 186 173 187 TRACE("Creating DataTransform : \n"); 174 188 175 189 for (i = 0; i < wine_format->dwNumObjs; i++) { 176 190 offset[i] = -1; 177 191 178 192 for (j = 0; j < asked_format->dwNumObjs; j++) { 179 193 if (done[j] == 1) 180 194 continue; 181 195 182 196 if (((asked_format->rgodf[j].pguid == NULL) || (IsEqualGUID(wine_format->rgodf[i].pguid, asked_format->rgodf[j].pguid))) 183 197 && … … 186 200 done[j] = 1; 187 201 188 TRACE("Matching : \n"); 202 TRACE("Matching : \n"); 189 203 TRACE(" - Asked (%d) : %s - Ofs = %3ld - (Type = 0x%02x | Instance = %04x)\n", 190 j, debugstr_guid(asked_format->rgodf[j].pguid), 204 j, debugstr_guid(asked_format->rgodf[j].pguid), 191 205 asked_format->rgodf[j].dwOfs, 192 206 DIDFT_GETTYPE(asked_format->rgodf[j].dwType), DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType)); 193 207 194 208 TRACE(" - Wine (%d) : %s - Ofs = %3ld - (Type = 0x%02x | Instance = %04x)\n", 195 j, debugstr_guid(wine_format->rgodf[i].pguid), 209 j, debugstr_guid(wine_format->rgodf[i].pguid), 196 210 wine_format->rgodf[i].dwOfs, 197 211 DIDFT_GETTYPE(wine_format->rgodf[i].dwType), DIDFT_GETINSTANCE(wine_format->rgodf[i].dwType)); 198 212 199 213 if (wine_format->rgodf[i].dwType & DIDFT_BUTTON) 200 214 dt[index].size = sizeof(BYTE); … … 205 219 dt[index].value = 0; 206 220 index++; 207 221 208 222 if (wine_format->rgodf[i].dwOfs != asked_format->rgodf[j].dwOfs) 209 223 same = 0; … … 222 236 if (done[j] == 0) { 223 237 TRACE(" - Asked (%d) : %s - Ofs = %3ld - (Type = 0x%02x | Instance = %04x)\n", 224 j, debugstr_guid(asked_format->rgodf[j].pguid), 238 j, debugstr_guid(asked_format->rgodf[j].pguid), 225 239 asked_format->rgodf[j].dwOfs, 226 240 DIDFT_GETTYPE(asked_format->rgodf[j].dwType), DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType)); 227 241 228 242 229 243 if (asked_format->rgodf[j].dwType & DIDFT_BUTTON) 230 244 dt[index].size = sizeof(BYTE); … … 248 262 ret->dt = dt; 249 263 } 250 264 251 265 HeapFree(GetProcessHeap(), 0, done); 252 266 … … 259 273 260 274 HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat( 261 LPDIRECTINPUTDEVICE 2A iface,LPCDIDATAFORMAT df275 LPDIRECTINPUTDEVICE8A iface,LPCDIDATAFORMAT df 262 276 ) { 263 277 int i; … … 265 279 266 280 TRACE("(this=%p,%p)\n",This,df); 267 281 268 282 TRACE("df.dwSize=%ld\n",df->dwSize); 269 283 TRACE("(df.dwObjsize=%ld)\n",df->dwObjSize); … … 271 285 TRACE("(df.dwDataSize=%ld)\n",df->dwDataSize); 272 286 TRACE("(df.dwNumObjs=%ld)\n",df->dwNumObjs); 273 287 274 288 for (i=0;i<df->dwNumObjs;i++) { 275 289 TRACE("df.rgodf[%d].guid %s\n",i,debugstr_guid(df->rgodf[i].pguid)); … … 282 296 283 297 HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel( 284 LPDIRECTINPUTDEVICE 2A iface,HWND hwnd,DWORD dwflags298 LPDIRECTINPUTDEVICE8A iface,HWND hwnd,DWORD dwflags 285 299 ) { 286 300 ICOM_THIS(IDirectInputDevice2AImpl,iface); … … 292 306 293 307 HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification( 294 LPDIRECTINPUTDEVICE 2A iface,HANDLE hnd308 LPDIRECTINPUTDEVICE8A iface,HANDLE hnd 295 309 ) { 296 310 ICOM_THIS(IDirectInputDevice2AImpl,iface); … … 299 313 } 300 314 301 ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE 2A iface)315 ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface) 302 316 { 303 317 ICOM_THIS(IDirectInputDevice2AImpl,iface); … … 310 324 311 325 HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface( 312 LPDIRECTINPUTDEVICE 2A iface,REFIID riid,LPVOID *ppobj326 LPDIRECTINPUTDEVICE8A iface,REFIID riid,LPVOID *ppobj 313 327 ) 314 328 { … … 336 350 337 351 ULONG WINAPI IDirectInputDevice2AImpl_AddRef( 338 LPDIRECTINPUTDEVICE 2A iface)352 LPDIRECTINPUTDEVICE8A iface) 339 353 { 340 354 ICOM_THIS(IDirectInputDevice2AImpl,iface); … … 343 357 344 358 HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects( 345 LPDIRECTINPUTDEVICE 2A iface,359 LPDIRECTINPUTDEVICE8A iface, 346 360 LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, 347 361 LPVOID lpvRef, … … 354 368 DPRINTF("\n"); 355 369 } 356 357 return DI_OK; 358 } 359 370 371 return DI_OK; 372 } 373 360 374 HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty( 361 LPDIRECTINPUTDEVICE 2A iface,375 LPDIRECTINPUTDEVICE8A iface, 362 376 REFGUID rguid, 363 377 LPDIPROPHEADER pdiph) … … 365 379 FIXME("(this=%p,%s,%p): stub!\n", 366 380 iface, debugstr_guid(rguid), pdiph); 367 381 368 382 if (TRACE_ON(dinput)) 369 383 _dump_DIPROPHEADER(pdiph); 370 384 371 385 return DI_OK; 372 386 } 373 387 374 388 HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo( 375 LPDIRECTINPUTDEVICE 2A iface,389 LPDIRECTINPUTDEVICE8A iface, 376 390 LPDIDEVICEOBJECTINSTANCEA pdidoi, 377 391 DWORD dwObj, … … 380 394 FIXME("(this=%p,%p,%ld,0x%08lx): stub!\n", 381 395 iface, pdidoi, dwObj, dwHow); 382 383 return DI_OK; 384 } 385 396 397 return DI_OK; 398 } 399 386 400 HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceInfo( 387 LPDIRECTINPUTDEVICE 2A iface,401 LPDIRECTINPUTDEVICE8A iface, 388 402 LPDIDEVICEINSTANCEA pdidi) 389 403 { 390 404 FIXME("(this=%p,%p): stub!\n", 391 405 iface, pdidi); 392 393 return DI_OK; 394 } 395 406 407 return DI_OK; 408 } 409 396 410 HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel( 397 LPDIRECTINPUTDEVICE 2A iface,411 LPDIRECTINPUTDEVICE8A iface, 398 412 HWND hwndOwner, 399 413 DWORD dwFlags) … … 401 415 FIXME("(this=%p,0x%08x,0x%08lx): stub!\n", 402 416 iface, hwndOwner, dwFlags); 403 404 return DI_OK; 405 } 406 417 418 return DI_OK; 419 } 420 407 421 HRESULT WINAPI IDirectInputDevice2AImpl_Initialize( 408 LPDIRECTINPUTDEVICE 2A iface,422 LPDIRECTINPUTDEVICE8A iface, 409 423 HINSTANCE hinst, 410 424 DWORD dwVersion, … … 415 429 return DI_OK; 416 430 } 417 431 418 432 /****************************************************************************** 419 433 * IDirectInputDevice2A … … 421 435 422 436 HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect( 423 LPDIRECTINPUTDEVICE 2A iface,437 LPDIRECTINPUTDEVICE8A iface, 424 438 REFGUID rguid, 425 439 LPCDIEFFECT lpeff, … … 433 447 434 448 HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects( 435 LPDIRECTINPUTDEVICE 2A iface,449 LPDIRECTINPUTDEVICE8A iface, 436 450 LPDIENUMEFFECTSCALLBACKA lpCallback, 437 451 LPVOID lpvRef, … … 440 454 FIXME("(this=%p,%p,%p,0x%08lx): stub!\n", 441 455 iface, lpCallback, lpvRef, dwFlags); 442 456 443 457 if (lpCallback) 444 458 lpCallback(NULL, lpvRef); … … 447 461 448 462 HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo( 449 LPDIRECTINPUTDEVICE 2A iface,463 LPDIRECTINPUTDEVICE8A iface, 450 464 LPDIEFFECTINFOA lpdei, 451 465 REFGUID rguid) … … 457 471 458 472 HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState( 459 LPDIRECTINPUTDEVICE 2A iface,473 LPDIRECTINPUTDEVICE8A iface, 460 474 LPDWORD pdwOut) 461 475 { … … 466 480 467 481 HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand( 468 LPDIRECTINPUTDEVICE 2A iface,482 LPDIRECTINPUTDEVICE8A iface, 469 483 DWORD dwFlags) 470 484 { … … 475 489 476 490 HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects( 477 LPDIRECTINPUTDEVICE 2A iface,491 LPDIRECTINPUTDEVICE8A iface, 478 492 LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, 479 493 LPVOID lpvRef, … … 488 502 489 503 HRESULT WINAPI IDirectInputDevice2AImpl_Escape( 490 LPDIRECTINPUTDEVICE 2A iface,504 LPDIRECTINPUTDEVICE8A iface, 491 505 LPDIEFFESCAPE lpDIEEsc) 492 506 { … … 497 511 498 512 HRESULT WINAPI IDirectInputDevice2AImpl_Poll( 499 LPDIRECTINPUTDEVICE 2A iface)513 LPDIRECTINPUTDEVICE8A iface) 500 514 { 501 515 /* Because wine devices do not need to be polled, just return DI_NOEFFECT */ … … 504 518 505 519 HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData( 506 LPDIRECTINPUTDEVICE 2A iface,520 LPDIRECTINPUTDEVICE8A iface, 507 521 DWORD cbObjectData, 508 LP DIDEVICEOBJECTDATA rgdod,522 LPCDIDEVICEOBJECTDATA rgdod, 509 523 LPDWORD pdwInOut, 510 524 DWORD dwFlags) … … 512 526 FIXME("(this=%p,0x%08lx,%p,%p,0x%08lx): stub!\n", 513 527 iface, cbObjectData, rgdod, pdwInOut, dwFlags); 514 515 return DI_OK; 516 } 517 518 HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE 7A iface,528 529 return DI_OK; 530 } 531 532 HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8A iface, 519 533 LPCSTR lpszFileName, 520 534 LPDIENUMEFFECTSINFILECALLBACK pec, … … 527 541 } 528 542 529 HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE 7A iface,543 HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8A iface, 530 544 LPCSTR lpszFileName, 531 545 DWORD dwEntries, … … 534 548 { 535 549 FIXME("(%p)->(%s,%08lx,%p,%08lx): stub !\n", iface, lpszFileName, dwEntries, rgDiFileEft, dwFlags); 536 550 537 551 return DI_OK; 538 552 } 553 554 HRESULT WINAPI IDirectInputDevice8AImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface, 555 LPDIACTIONFORMATA lpdiaf, 556 LPCSTR lpszUserName, 557 DWORD dwFlags) 558 { 559 FIXME("(%p)->(%p,%s,%08lx): stub !\n", iface, lpdiaf, lpszUserName, dwFlags); 560 561 return DI_OK; 562 } 563 564 HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface, 565 LPDIACTIONFORMATA lpdiaf, 566 LPCSTR lpszUserName, 567 DWORD dwFlags) 568 { 569 FIXME("(%p)->(%p,%s,%08lx): stub !\n", iface, lpdiaf, lpszUserName, dwFlags); 570 571 return DI_OK; 572 } 573 574 HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface, 575 LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader) 576 { 577 FIXME("(%p)->(%p): stub !\n", iface, lpdiDevImageInfoHeader); 578 579 return DI_OK; 580 } -
trunk/src/dinput/device_private.h
r8346 r9016 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 */ 19 1 20 #ifndef __WINE_DLLS_DINPUT_DINPUTDEVICE_PRIVATE_H 2 21 #define __WINE_DLLS_DINPUT_DINPUTDEVICE_PRIVATE_H … … 61 80 /* And the stubs */ 62 81 extern HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat( 63 LPDIRECTINPUTDEVICE 2A iface,LPCDIDATAFORMAT df ) ;82 LPDIRECTINPUTDEVICE8A iface,LPCDIDATAFORMAT df ) ; 64 83 extern HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel( 65 LPDIRECTINPUTDEVICE 2A iface,HWND hwnd,DWORD dwflags ) ;84 LPDIRECTINPUTDEVICE8A iface,HWND hwnd,DWORD dwflags ) ; 66 85 extern HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification( 67 LPDIRECTINPUTDEVICE 2A iface,HANDLE hnd ) ;68 extern ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE 2A iface) ;86 LPDIRECTINPUTDEVICE8A iface,HANDLE hnd ) ; 87 extern ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface) ; 69 88 extern HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface( 70 LPDIRECTINPUTDEVICE 2A iface,REFIID riid,LPVOID *ppobj ) ;89 LPDIRECTINPUTDEVICE8A iface,REFIID riid,LPVOID *ppobj ) ; 71 90 extern ULONG WINAPI IDirectInputDevice2AImpl_AddRef( 72 LPDIRECTINPUTDEVICE 2A iface) ;91 LPDIRECTINPUTDEVICE8A iface) ; 73 92 extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects( 74 LPDIRECTINPUTDEVICE 2A iface,93 LPDIRECTINPUTDEVICE8A iface, 75 94 LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, 76 95 LPVOID lpvRef, 77 96 DWORD dwFlags) ; 78 97 extern HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty( 79 LPDIRECTINPUTDEVICE 2A iface,98 LPDIRECTINPUTDEVICE8A iface, 80 99 REFGUID rguid, 81 100 LPDIPROPHEADER pdiph) ; 82 101 extern HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo( 83 LPDIRECTINPUTDEVICE 2A iface,102 LPDIRECTINPUTDEVICE8A iface, 84 103 LPDIDEVICEOBJECTINSTANCEA pdidoi, 85 104 DWORD dwObj, 86 105 DWORD dwHow) ; 87 106 extern HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceInfo( 88 LPDIRECTINPUTDEVICE 2A iface,107 LPDIRECTINPUTDEVICE8A iface, 89 108 LPDIDEVICEINSTANCEA pdidi) ; 90 109 extern HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel( 91 LPDIRECTINPUTDEVICE 2A iface,110 LPDIRECTINPUTDEVICE8A iface, 92 111 HWND hwndOwner, 93 112 DWORD dwFlags) ; 94 113 extern HRESULT WINAPI IDirectInputDevice2AImpl_Initialize( 95 LPDIRECTINPUTDEVICE 2A iface,114 LPDIRECTINPUTDEVICE8A iface, 96 115 HINSTANCE hinst, 97 116 DWORD dwVersion, 98 117 REFGUID rguid) ; 99 118 extern HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect( 100 LPDIRECTINPUTDEVICE 2A iface,119 LPDIRECTINPUTDEVICE8A iface, 101 120 REFGUID rguid, 102 121 LPCDIEFFECT lpeff, … … 104 123 LPUNKNOWN pUnkOuter) ; 105 124 extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects( 106 LPDIRECTINPUTDEVICE 2A iface,125 LPDIRECTINPUTDEVICE8A iface, 107 126 LPDIENUMEFFECTSCALLBACKA lpCallback, 108 127 LPVOID lpvRef, 109 128 DWORD dwFlags) ; 110 129 extern HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo( 111 LPDIRECTINPUTDEVICE 2A iface,130 LPDIRECTINPUTDEVICE8A iface, 112 131 LPDIEFFECTINFOA lpdei, 113 132 REFGUID rguid) ; 114 133 extern HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState( 115 LPDIRECTINPUTDEVICE 2A iface,134 LPDIRECTINPUTDEVICE8A iface, 116 135 LPDWORD pdwOut) ; 117 136 extern HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand( 118 LPDIRECTINPUTDEVICE 2A iface,137 LPDIRECTINPUTDEVICE8A iface, 119 138 DWORD dwFlags) ; 120 139 extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects( 121 LPDIRECTINPUTDEVICE 2A iface,140 LPDIRECTINPUTDEVICE8A iface, 122 141 LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, 123 142 LPVOID lpvRef, 124 143 DWORD dwFlags) ; 125 144 extern HRESULT WINAPI IDirectInputDevice2AImpl_Escape( 126 LPDIRECTINPUTDEVICE 2A iface,145 LPDIRECTINPUTDEVICE8A iface, 127 146 LPDIEFFESCAPE lpDIEEsc) ; 128 147 extern HRESULT WINAPI IDirectInputDevice2AImpl_Poll( 129 LPDIRECTINPUTDEVICE 2A iface) ;148 LPDIRECTINPUTDEVICE8A iface) ; 130 149 extern HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData( 131 LPDIRECTINPUTDEVICE 2A iface,150 LPDIRECTINPUTDEVICE8A iface, 132 151 DWORD cbObjectData, 133 LP DIDEVICEOBJECTDATA rgdod,152 LPCDIDEVICEOBJECTDATA rgdod, 134 153 LPDWORD pdwInOut, 135 154 DWORD dwFlags) ; 136 extern HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE 7A iface,155 extern HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8A iface, 137 156 LPCSTR lpszFileName, 138 157 LPDIENUMEFFECTSINFILECALLBACK pec, 139 158 LPVOID pvRef, 140 159 DWORD dwFlags) ; 141 extern HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE 7A iface,160 extern HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8A iface, 142 161 LPCSTR lpszFileName, 143 162 DWORD dwEntries, 144 163 LPDIFILEEFFECT rgDiFileEft, 145 164 DWORD dwFlags) ; 165 extern HRESULT WINAPI IDirectInputDevice8AImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface, 166 LPDIACTIONFORMATA lpdiaf, 167 LPCSTR lpszUserName, 168 DWORD dwFlags); 169 extern HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface, 170 LPDIACTIONFORMATA lpdiaf, 171 LPCSTR lpszUserName, 172 DWORD dwFlags); 173 extern HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface, 174 LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader); 146 175 147 176 #ifdef __WIN32OS2__ -
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 -
trunk/src/dinput/dinput_private.h
r8346 r9016 1 /* 2 * Copyright 2000 Lionel Ulmer 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 */ 18 1 19 #ifndef __WINE_DLLS_DINPUT_DINPUT_PRIVATE_H 2 20 #define __WINE_DLLS_DINPUT_DINPUT_PRIVATE_H … … 9 27 struct IDirectInputAImpl 10 28 { 11 ICOM_VFIELD(IDirectInputA);12 DWORDref;29 LPVOID lpVtbl; 30 DWORD ref; 13 31 14 15 32 /* Used to have an unique sequence number for all the events */ 33 DWORD evsequence; 16 34 }; 17 35 … … 19 37 typedef struct dinput_device { 20 38 INT pref; 21 BOOL (*enum_device)(DWORD dwDevType, DWORD dwFlags, LP CDIDEVICEINSTANCEA lpddi);39 BOOL (*enum_device)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi); 22 40 HRESULT (*create_device)(IDirectInputAImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev); 23 41 } dinput_device; … … 25 43 extern void dinput_register_device(dinput_device *device) ; 26 44 45 HHOOK keyboard_hook; 46 47 LRESULT CALLBACK KeyboardCallback( int code, WPARAM wparam, LPARAM lparam ); 48 27 49 #endif /* __WINE_DLLS_DINPUT_DINPUT_PRIVATE_H */ -
trunk/src/dinput/keyboard.c
r8346 r9016 3 3 * Copyright 1998 Marcus Meissner 4 4 * Copyright 1998,1999 Lionel Ulmer 5 * Copyright 2000-2001 TransGaming Technologies Inc. 5 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 6 20 */ 7 21 8 22 #include "config.h" 23 #include "wine/port.h" 24 9 25 #include <string.h> 10 26 #ifdef HAVE_SYS_ERRNO_H … … 19 35 #include "dinput_private.h" 20 36 #include "device_private.h" 21 #include "debugtools.h" 22 23 DEFAULT_DEBUG_CHANNEL(dinput); 24 25 static ICOM_VTABLE(IDirectInputDevice2A) SysKeyboardAvt; 26 static ICOM_VTABLE(IDirectInputDevice7A) SysKeyboard7Avt; 27 37 #include "wine/debug.h" 38 39 WINE_DEFAULT_DEBUG_CHANNEL(dinput); 40 41 static ICOM_VTABLE(IDirectInputDevice8A) SysKeyboardAvt; 42 28 43 typedef struct SysKeyboardAImpl SysKeyboardAImpl; 29 44 struct SysKeyboardAImpl 30 45 { 31 /* IDirectInputDevice2AImpl */ 32 ICOM_VFIELD(IDirectInputDevice2A); 46 LPVOID lpVtbl; 33 47 DWORD ref; 34 48 GUID guid; 35 49 36 50 IDirectInputAImpl *dinput; 37 51 52 HANDLE hEvent; 38 53 /* SysKeyboardAImpl */ 39 BYTE keystate[256];40 54 int acquired; 55 int buffersize; /* set in 'SetProperty' */ 56 LPDIDEVICEOBJECTDATA buffer; /* buffer for 'GetDeviceData'. 57 Alloc at 'Acquire', Free at 58 'Unacquire' */ 59 int count; /* number of objects in use in 60 'buffer' */ 61 int start; /* 'buffer' rotates. This is the 62 first in use (if count > 0) */ 63 BOOL overflow; /* return DI_BUFFEROVERFLOW in 64 'GetDeviceData' */ 65 CRITICAL_SECTION crit; 41 66 }; 67 68 SysKeyboardAImpl *current; /* Today's acquired device 69 FIXME: currently this can be only one. 70 Maybe this should be a linked list or st. 71 I don't know what the rules are for multiple acquired keyboards, 72 but 'DI_LOSTFOCUS' and 'DI_UNACQUIRED' exist for a reason. 73 */ 74 75 static BYTE DInputKeyState[256]; /* array for 'GetDeviceState' */ 76 77 HHOOK keyboard_hook; 78 79 LRESULT CALLBACK KeyboardCallback( int code, WPARAM wparam, LPARAM lparam ) 80 { 81 TRACE("(%d,%d,%ld)\n", code, wparam, lparam); 82 83 if (code == HC_ACTION) 84 { 85 BYTE dik_code; 86 BOOL down; 87 DWORD timestamp; 88 89 { 90 KBDLLHOOKSTRUCT *hook = (KBDLLHOOKSTRUCT *)lparam; 91 dik_code = hook->scanCode; 92 if (hook->flags & LLKHF_EXTENDED) dik_code |= 0x80; 93 down = !(hook->flags & LLKHF_UP); 94 timestamp = hook->time; 95 } 96 97 DInputKeyState[dik_code] = (down ? 0x80 : 0); 98 99 if (current != NULL) 100 { 101 if (current->hEvent) 102 SetEvent(current->hEvent); 103 104 if (current->buffer != NULL) 105 { 106 int n; 107 108 EnterCriticalSection(&(current->crit)); 109 110 n = (current->start + current->count) % current->buffersize; 111 112 current->buffer[n].dwOfs = dik_code; 113 current->buffer[n].dwData = down ? 0x80 : 0; 114 current->buffer[n].dwTimeStamp = timestamp; 115 current->buffer[n].dwSequence = current->dinput->evsequence++; 116 117 TRACE("Adding event at offset %d : %ld - %ld - %ld - %ld\n", n, 118 current->buffer[n].dwOfs, current->buffer[n].dwData, current->buffer[n].dwTimeStamp, current->buffer[n].dwSequence); 119 120 if (current->count == current->buffersize) 121 { 122 current->start++; 123 current->overflow = TRUE; 124 } 125 else 126 current->count++; 127 128 LeaveCriticalSection(&(current->crit)); 129 } 130 } 131 } 132 133 return CallNextHookEx(keyboard_hook, code, wparam, lparam); 134 } 42 135 43 136 static GUID DInput_Wine_Keyboard_GUID = { /* 0ab8648a-7735-11d2-8c73-71df54a96441 */ … … 48 141 }; 49 142 50 static BOOL keyboarddev_enum_device(DWORD dwDevType, DWORD dwFlags, LP CDIDEVICEINSTANCEA lpddi)143 static BOOL keyboarddev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi) 51 144 { 52 145 if ((dwDevType == 0) || (dwDevType == DIDEVTYPE_KEYBOARD)) { 53 146 TRACE("Enumerating the Keyboard device\n"); 54 147 55 148 lpddi->guidInstance = GUID_SysKeyboard;/* DInput's GUID */ 56 149 lpddi->guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */ … … 58 151 strcpy(lpddi->tszInstanceName, "Keyboard"); 59 152 strcpy(lpddi->tszProductName, "Wine Keyboard"); 60 153 61 154 return TRUE; 62 155 } … … 65 158 } 66 159 67 static SysKeyboardAImpl *alloc_device(REFGUID rguid, ICOM_VTABLE(IDirectInputDevice2A) *kvt, IDirectInputAImpl *dinput)160 static SysKeyboardAImpl *alloc_device(REFGUID rguid, LPVOID kvt, IDirectInputAImpl *dinput) 68 161 { 69 162 SysKeyboardAImpl* newDevice; 70 163 newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardAImpl)); 164 newDevice->lpVtbl = kvt; 71 165 newDevice->ref = 1; 72 ICOM_VTBL(newDevice) = kvt;73 166 memcpy(&(newDevice->guid),rguid,sizeof(*rguid)); 74 memset(newDevice->keystate,0,256);75 167 newDevice->dinput = dinput; 76 168 … … 83 175 if ((IsEqualGUID(&GUID_SysKeyboard,rguid)) || /* Generic Keyboard */ 84 176 (IsEqualGUID(&DInput_Wine_Keyboard_GUID,rguid))) { /* Wine Keyboard */ 85 if ((riid == NULL) || (IsEqualGUID(&IID_IDirectInputDevice2A,riid)) || (IsEqualGUID(&IID_IDirectInputDevice2A,riid))) { 177 if ((riid == NULL) || 178 IsEqualGUID(&IID_IDirectInputDeviceA,riid) || 179 IsEqualGUID(&IID_IDirectInputDevice2A,riid) || 180 IsEqualGUID(&IID_IDirectInputDevice7A,riid) || 181 IsEqualGUID(&IID_IDirectInputDevice8A,riid)) { 86 182 *pdev=(IDirectInputDeviceA*) alloc_device(rguid, &SysKeyboardAvt, dinput); 87 88 183 TRACE("Creating a Keyboard device (%p)\n", *pdev); 89 return DI_OK;90 } else if (IsEqualGUID(&IID_IDirectInputDevice7A,riid)) {91 *pdev=(IDirectInputDeviceA*) alloc_device(rguid, (ICOM_VTABLE(IDirectInputDevice2A) *) &SysKeyboard7Avt, dinput);92 93 TRACE("Creating a Keyboard DInput7A device (%p)\n", *pdev);94 184 return DI_OK; 95 185 } else … … 109 199 110 200 static HRESULT WINAPI SysKeyboardAImpl_SetProperty( 111 LPDIRECTINPUTDEVICE 2A iface,REFGUID rguid,LPCDIPROPHEADER ph201 LPDIRECTINPUTDEVICE8A iface,REFGUID rguid,LPCDIPROPHEADER ph 112 202 ) 113 203 { … … 123 213 124 214 TRACE("(buffersize=%ld)\n",pd->dwData); 215 216 if (This->acquired) 217 return DIERR_INVALIDPARAM; 218 219 This->buffersize = pd->dwData; 220 125 221 break; 126 222 } … … 134 230 135 231 static HRESULT WINAPI SysKeyboardAImpl_GetDeviceState( 136 LPDIRECTINPUTDEVICE 2A iface,DWORD len,LPVOID ptr232 LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr 137 233 ) 138 234 { 139 DWORD i; 140 141 memset( ptr, 0, len ); 235 /* Note: device does not need to be acquired */ 142 236 if (len != 256) 143 { 144 WARN("whoops, got len %ld?\n", len); 145 return DI_OK; 146 } 147 for (i = 0; i < 0x80; i++) 148 { 149 WORD vkey = MapVirtualKeyA( i, 1 ); 150 if (vkey && (GetAsyncKeyState( vkey ) & 0x8000)) 151 { 152 ((LPBYTE)ptr)[i] = 0x80; 153 ((LPBYTE)ptr)[i | 0x80] = 0x80; 154 } 155 } 237 return DIERR_INVALIDPARAM; 238 239 memcpy(ptr, DInputKeyState, 256); 156 240 return DI_OK; 157 241 } 158 242 159 243 static HRESULT WINAPI SysKeyboardAImpl_GetDeviceData( 160 LPDIRECTINPUTDEVICE 2A iface,DWORD dodsize,LPDIDEVICEOBJECTDATA dod,244 LPDIRECTINPUTDEVICE8A iface,DWORD dodsize,LPDIDEVICEOBJECTDATA dod, 161 245 LPDWORD entries,DWORD flags 162 246 ) 163 247 { 164 248 ICOM_THIS(SysKeyboardAImpl,iface); 165 int i, n;249 int ret = DI_OK, i = 0; 166 250 167 251 TRACE("(this=%p,%ld,%p,%p(%ld)),0x%08lx)\n", 168 252 This,dodsize,dod,entries,entries?*entries:0,flags); 169 253 170 171 for (i = n = 0; (i < 0x80) && (n < *entries); i++) 172 { 173 WORD state, vkey = MapVirtualKeyA( i, 1 ); 174 if (!vkey) continue; 175 state = (GetAsyncKeyState( vkey ) >> 8) & 0x80; 176 if (state != This->keystate[vkey]) 177 { 178 if (dod) 179 { 180 /* add an entry */ 181 dod[n].dwOfs = i; /* scancode */ 182 dod[n].dwData = state; 183 dod[n].dwTimeStamp = GetCurrentTime(); /* umm */ 184 dod[n].dwSequence = This->dinput->evsequence++; 185 n++; 186 } 187 if (!(flags & DIGDD_PEEK)) This->keystate[vkey] = state; 188 } 189 } 190 if (n) TRACE_(dinput)("%d entries\n",n); 191 *entries = n; 192 return DI_OK; 193 } 194 195 static HRESULT WINAPI SysKeyboardAImpl_Acquire(LPDIRECTINPUTDEVICE2A iface) 254 if (This->acquired == 0) 255 return DIERR_NOTACQUIRED; 256 257 if (This->buffer == NULL) 258 return DIERR_NOTBUFFERED; 259 260 if (dodsize < sizeof(*dod)) 261 return DIERR_INVALIDPARAM; 262 263 EnterCriticalSection(&(This->crit)); 264 265 /* Copy item at a time for the case dodsize > sizeof(buffer[n]) */ 266 while ((i < *entries || *entries == INFINITE) && i < This->count) 267 { 268 if (dod != NULL) 269 { 270 int n = (This->start + i) % This->buffersize; 271 LPDIDEVICEOBJECTDATA pd 272 = (LPDIDEVICEOBJECTDATA)((BYTE *)dod + dodsize * i); 273 pd->dwOfs = This->buffer[n].dwOfs; 274 pd->dwData = This->buffer[n].dwData; 275 pd->dwTimeStamp = This->buffer[n].dwTimeStamp; 276 pd->dwSequence = This->buffer[n].dwSequence; 277 } 278 i++; 279 } 280 281 *entries = i; 282 283 if (This->overflow) 284 ret = DI_BUFFEROVERFLOW; 285 286 if (!(flags & DIGDD_PEEK)) 287 { 288 /* Empty buffer */ 289 This->count -= i; 290 This->start = (This->start + i) % This->buffersize; 291 This->overflow = FALSE; 292 } 293 294 LeaveCriticalSection(&(This->crit)); 295 296 TRACE("Returning %ld events queued\n", *entries); 297 298 return ret; 299 } 300 301 static HRESULT WINAPI SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface); 302 303 static HRESULT WINAPI SysKeyboardAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface) 196 304 { 197 305 ICOM_THIS(SysKeyboardAImpl,iface); 198 306 199 307 TRACE("(this=%p)\n",This); 200 201 if (This->acquired == 0) { 202 This->acquired = 1; 203 } 204 308 309 if (This->acquired) 310 return S_FALSE; 311 312 This->acquired = 1; 313 314 if (current != NULL) 315 { 316 FIXME("Not more than one keyboard can be acquired at the same time.\n"); 317 SysKeyboardAImpl_Unacquire(iface); 318 } 319 320 current = This; 321 322 if (This->buffersize > 0) 323 { 324 This->buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 325 This->buffersize * sizeof(*(This->buffer))); 326 This->start = 0; 327 This->count = 0; 328 This->overflow = FALSE; 329 InitializeCriticalSection(&(This->crit)); 330 } 331 else 332 This->buffer = NULL; 333 205 334 return DI_OK; 206 335 } 207 336 208 static HRESULT WINAPI SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE 2A iface)337 static HRESULT WINAPI SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface) 209 338 { 210 339 ICOM_THIS(SysKeyboardAImpl,iface); 211 340 TRACE("(this=%p)\n",This); 212 341 213 if (This->acquired == 1) { 214 This->acquired = 0; 215 } else { 216 ERR("Unacquiring a not-acquired device !!!\n"); 217 } 342 if (This->acquired == 0) 343 return DI_NOEFFECT; 344 345 if (current == This) 346 current = NULL; 347 else 348 ERR("this != current\n"); 349 350 This->acquired = 0; 351 352 if (This->buffersize >= 0) 353 { 354 HeapFree(GetProcessHeap(), 0, This->buffer); 355 This->buffer = NULL; 356 DeleteCriticalSection(&(This->crit)); 357 } 218 358 219 359 return DI_OK; 360 } 361 362 static HRESULT WINAPI SysKeyboardAImpl_SetEventNotification(LPDIRECTINPUTDEVICE8A iface, 363 HANDLE hnd) { 364 ICOM_THIS(SysKeyboardAImpl,iface); 365 366 TRACE("(this=%p,0x%08lx)\n",This,(DWORD)hnd); 367 368 This->hEvent = hnd; 369 return DI_OK; 220 370 } 221 371 … … 224 374 */ 225 375 static HRESULT WINAPI SysKeyboardAImpl_GetCapabilities( 226 LPDIRECTINPUTDEVICE 2A iface,376 LPDIRECTINPUTDEVICE8A iface, 227 377 LPDIDEVCAPS lpDIDevCaps) 228 378 { … … 246 396 FIXME("DirectX 3.0 not supported....\n"); 247 397 } 248 398 249 399 return DI_OK; 250 400 } 251 401 252 static ICOM_VTABLE(IDirectInputDevice 2A) SysKeyboardAvt =402 static ICOM_VTABLE(IDirectInputDevice8A) SysKeyboardAvt = 253 403 { 254 404 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE … … 265 415 SysKeyboardAImpl_GetDeviceData, 266 416 IDirectInputDevice2AImpl_SetDataFormat, 267 IDirectInputDevice2AImpl_SetEventNotification,417 SysKeyboardAImpl_SetEventNotification, 268 418 IDirectInputDevice2AImpl_SetCooperativeLevel, 269 419 IDirectInputDevice2AImpl_GetObjectInfo, … … 279 429 IDirectInputDevice2AImpl_Escape, 280 430 IDirectInputDevice2AImpl_Poll, 281 IDirectInputDevice2AImpl_SendDeviceData 431 IDirectInputDevice2AImpl_SendDeviceData, 432 IDirectInputDevice7AImpl_EnumEffectsInFile, 433 IDirectInputDevice7AImpl_WriteEffectToFile, 434 IDirectInputDevice8AImpl_BuildActionMap, 435 IDirectInputDevice8AImpl_SetActionMap, 436 IDirectInputDevice8AImpl_GetImageInfo 282 437 }; 283 284 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)285 # define XCAST(fun) (typeof(SysKeyboard7Avt.fun))286 #else287 # define XCAST(fun) (void*)288 #endif289 290 static ICOM_VTABLE(IDirectInputDevice7A) SysKeyboard7Avt =291 {292 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE293 XCAST(QueryInterface)IDirectInputDevice2AImpl_QueryInterface,294 XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,295 XCAST(Release)IDirectInputDevice2AImpl_Release,296 XCAST(GetCapabilities)SysKeyboardAImpl_GetCapabilities,297 XCAST(EnumObjects)IDirectInputDevice2AImpl_EnumObjects,298 XCAST(GetProperty)IDirectInputDevice2AImpl_GetProperty,299 XCAST(SetProperty)SysKeyboardAImpl_SetProperty,300 XCAST(Acquire)SysKeyboardAImpl_Acquire,301 XCAST(Unacquire)SysKeyboardAImpl_Unacquire,302 XCAST(GetDeviceState)SysKeyboardAImpl_GetDeviceState,303 XCAST(GetDeviceData)SysKeyboardAImpl_GetDeviceData,304 XCAST(SetDataFormat)IDirectInputDevice2AImpl_SetDataFormat,305 XCAST(SetEventNotification)IDirectInputDevice2AImpl_SetEventNotification,306 XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,307 XCAST(GetObjectInfo)IDirectInputDevice2AImpl_GetObjectInfo,308 XCAST(GetDeviceInfo)IDirectInputDevice2AImpl_GetDeviceInfo,309 XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,310 XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,311 XCAST(CreateEffect)IDirectInputDevice2AImpl_CreateEffect,312 XCAST(EnumEffects)IDirectInputDevice2AImpl_EnumEffects,313 XCAST(GetEffectInfo)IDirectInputDevice2AImpl_GetEffectInfo,314 XCAST(GetForceFeedbackState)IDirectInputDevice2AImpl_GetForceFeedbackState,315 XCAST(SendForceFeedbackCommand)IDirectInputDevice2AImpl_SendForceFeedbackCommand,316 XCAST(EnumCreatedEffectObjects)IDirectInputDevice2AImpl_EnumCreatedEffectObjects,317 XCAST(Escape)IDirectInputDevice2AImpl_Escape,318 XCAST(Poll)IDirectInputDevice2AImpl_Poll,319 XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,320 IDirectInputDevice7AImpl_EnumEffectsInFile,321 IDirectInputDevice7AImpl_WriteEffectToFile322 };323 324 #undef XCAST -
trunk/src/dinput/mouse.c
r8532 r9016 3 3 * Copyright 1998 Marcus Meissner 4 4 * Copyright 1998,1999 Lionel Ulmer 5 * Copyright 2000-2001 TransGaming Technologies Inc. 5 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 6 20 */ 7 21 8 22 #include "config.h" 23 #include "wine/port.h" 24 9 25 #include <string.h> 10 26 #ifdef HAVE_SYS_ERRNO_H … … 20 36 #include "dinput_private.h" 21 37 #include "device_private.h" 22 #include " debugtools.h"38 #include "wine/debug.h" 23 39 24 40 #define MOUSE_HACK 25 41 26 DEFAULT_DEBUG_CHANNEL(dinput);42 WINE_DEFAULT_DEBUG_CHANNEL(dinput); 27 43 28 44 /* Wine mouse driver object instances */ 29 45 #define WINE_MOUSE_X_AXIS_INSTANCE 0x0001 30 46 #define WINE_MOUSE_Y_AXIS_INSTANCE 0x0002 31 #define WINE_MOUSE_L_BUTTON_INSTANCE 0x0004 32 #define WINE_MOUSE_R_BUTTON_INSTANCE 0x0008 33 #define WINE_MOUSE_M_BUTTON_INSTANCE 0x0010 47 #define WINE_MOUSE_Z_AXIS_INSTANCE 0x0004 48 #define WINE_MOUSE_L_BUTTON_INSTANCE 0x0008 49 #define WINE_MOUSE_R_BUTTON_INSTANCE 0x0010 50 #define WINE_MOUSE_M_BUTTON_INSTANCE 0x0020 34 51 35 52 /* ------------------------------- */ … … 40 57 #define WINE_MOUSE_X_POSITION 0 41 58 #define WINE_MOUSE_Y_POSITION 1 42 #define WINE_MOUSE_L_POSITION 2 43 #define WINE_MOUSE_R_POSITION 3 44 #define WINE_MOUSE_M_POSITION 4 59 #define WINE_MOUSE_Z_POSITION 2 60 #define WINE_MOUSE_L_POSITION 3 61 #define WINE_MOUSE_R_POSITION 4 62 #define WINE_MOUSE_M_POSITION 5 45 63 46 64 typedef struct { 47 65 LONG lX; 48 66 LONG lY; 67 LONG lZ; 49 68 BYTE rgbButtons[4]; 50 69 } Wine_InternalMouseData; 51 70 52 #define WINE_INTERNALMOUSE_NUM_OBJS 571 #define WINE_INTERNALMOUSE_NUM_OBJS 6 53 72 54 73 static DIOBJECTDATAFORMAT Wine_InternalMouseObjectFormat[WINE_INTERNALMOUSE_NUM_OBJS] = { … … 57 76 { &GUID_YAxis, FIELD_OFFSET(Wine_InternalMouseData, lY), 58 77 DIDFT_MAKEINSTANCE(WINE_MOUSE_Y_AXIS_INSTANCE) | DIDFT_RELAXIS, 0 }, 78 { &GUID_ZAxis, FIELD_OFFSET(Wine_InternalMouseData, lZ), 79 DIDFT_MAKEINSTANCE(WINE_MOUSE_Z_AXIS_INSTANCE) | DIDFT_RELAXIS, 0 }, 59 80 { &GUID_Button, (FIELD_OFFSET(Wine_InternalMouseData, rgbButtons)) + 0, 60 81 DIDFT_MAKEINSTANCE(WINE_MOUSE_L_BUTTON_INSTANCE) | DIDFT_PSHBUTTON, 0 }, … … 74 95 }; 75 96 76 static ICOM_VTABLE(IDirectInputDevice2A) SysMouseAvt; 77 static ICOM_VTABLE(IDirectInputDevice7A) SysMouse7Avt; 97 static ICOM_VTABLE(IDirectInputDevice8A) SysMouseAvt; 78 98 typedef struct SysMouseAImpl SysMouseAImpl; 79 99 … … 86 106 struct SysMouseAImpl 87 107 { 88 /* IDirectInputDevice2AImpl */ 89 ICOM_VFIELD(IDirectInputDevice2A); 108 LPVOID lpVtbl; 90 109 DWORD ref; 91 110 GUID guid; 92 111 93 112 IDirectInputAImpl *dinput; 94 113 95 114 /* The current data format and the conversion between internal 96 115 and external data formats */ 97 116 LPDIDATAFORMAT df; 98 117 DataFormat *wine_df; 99 int offset_array[5];100 118 int offset_array[WINE_INTERNALMOUSE_NUM_OBJS]; 119 101 120 /* SysMouseAImpl */ 102 121 BYTE absolute; … … 133 152 134 153 /* FIXME: This is ugly and not thread safe :/ */ 135 static IDirectInputDevice 2A* current_lock = NULL;136 137 138 static BOOL mousedev_enum_device(DWORD dwDevType, DWORD dwFlags, LP CDIDEVICEINSTANCEA lpddi)154 static IDirectInputDevice8A* current_lock = NULL; 155 156 157 static BOOL mousedev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi) 139 158 { 140 159 if ((dwDevType == 0) || (dwDevType == DIDEVTYPE_MOUSE)) { … … 154 173 } 155 174 156 static SysMouseAImpl *alloc_device(REFGUID rguid, ICOM_VTABLE(IDirectInputDevice2A) *mvt, IDirectInputAImpl *dinput)157 { 158 int offset_array[ 5] = {175 static SysMouseAImpl *alloc_device(REFGUID rguid, LPVOID mvt, IDirectInputAImpl *dinput) 176 { 177 int offset_array[WINE_INTERNALMOUSE_NUM_OBJS] = { 159 178 FIELD_OFFSET(Wine_InternalMouseData, lX), 160 179 FIELD_OFFSET(Wine_InternalMouseData, lY), 180 FIELD_OFFSET(Wine_InternalMouseData, lZ), 161 181 FIELD_OFFSET(Wine_InternalMouseData, rgbButtons) + 0, 162 182 FIELD_OFFSET(Wine_InternalMouseData, rgbButtons) + 1, … … 166 186 newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysMouseAImpl)); 167 187 newDevice->ref = 1; 168 ICOM_VTBL(newDevice)= mvt;188 newDevice->lpVtbl = mvt; 169 189 InitializeCriticalSection(&(newDevice->crit)); 170 190 memcpy(&(newDevice->guid),rguid,sizeof(*rguid)); 171 191 172 192 /* Per default, Wine uses its internal data format */ 173 193 newDevice->df = &Wine_InternalMouseFormat; 174 memcpy(newDevice->offset_array, offset_array, 5* sizeof(int));194 memcpy(newDevice->offset_array, offset_array, WINE_INTERNALMOUSE_NUM_OBJS * sizeof(int)); 175 195 newDevice->wine_df = (DataFormat *) HeapAlloc(GetProcessHeap(), 0, sizeof(DataFormat)); 176 196 newDevice->wine_df->size = 0; … … 186 206 if ((IsEqualGUID(&GUID_SysMouse,rguid)) || /* Generic Mouse */ 187 207 (IsEqualGUID(&DInput_Wine_Mouse_GUID,rguid))) { /* Wine Mouse */ 188 if ((riid == NULL) || (IsEqualGUID(&IID_IDirectInputDevice2A,riid)) || (IsEqualGUID(&IID_IDirectInputDevice2A,riid))) { 208 if ((riid == NULL) || 209 IsEqualGUID(&IID_IDirectInputDeviceA,riid) || 210 IsEqualGUID(&IID_IDirectInputDevice2A,riid) || 211 IsEqualGUID(&IID_IDirectInputDevice7A,riid) || 212 IsEqualGUID(&IID_IDirectInputDevice8A,riid)) { 189 213 *pdev=(IDirectInputDeviceA*) alloc_device(rguid, &SysMouseAvt, dinput); 190 191 214 TRACE("Creating a Mouse device (%p)\n", *pdev); 192 return DI_OK;193 }else if (IsEqualGUID(&IID_IDirectInputDevice7A,riid)) {194 *pdev=(IDirectInputDeviceA*) alloc_device(rguid, (ICOM_VTABLE(IDirectInputDevice2A) *) &SysMouse7Avt, dinput);195 196 TRACE("Creating a Mouse DInput7A device (%p)\n", *pdev);197 215 return DI_OK; 198 216 } else … … 218 236 * Release : release the mouse buffer. 219 237 */ 220 static ULONG WINAPI SysMouseAImpl_Release(LPDIRECTINPUTDEVICE 2A iface)238 static ULONG WINAPI SysMouseAImpl_Release(LPDIRECTINPUTDEVICE8A iface) 221 239 { 222 240 ICOM_THIS(SysMouseAImpl,iface); … … 234 252 HeapFree(GetProcessHeap(),0,This->data_queue); 235 253 236 if (This->hook) UnhookWindowsHookEx( This->hook ); 254 if (This->hook) { 255 UnhookWindowsHookEx( This->hook ); 256 if (This->dwCoopLevel & DISCL_EXCLUSIVE) 257 ShowCursor(TRUE); /* show cursor */ 258 } 237 259 DeleteCriticalSection(&(This->crit)); 238 260 … … 242 264 HeapFree(GetProcessHeap(), 0, This->df); 243 265 } 244 266 245 267 HeapFree(GetProcessHeap(),0,This); 246 268 return 0; … … 253 275 */ 254 276 static HRESULT WINAPI SysMouseAImpl_SetCooperativeLevel( 255 LPDIRECTINPUTDEVICE 2A iface,HWND hwnd,DWORD dwflags277 LPDIRECTINPUTDEVICE8A iface,HWND hwnd,DWORD dwflags 256 278 ) 257 279 { … … 268 290 This->win = hwnd; 269 291 This->dwCoopLevel = dwflags; 270 292 271 293 return 0; 272 294 } … … 281 303 */ 282 304 static HRESULT WINAPI SysMouseAImpl_SetDataFormat( 283 LPDIRECTINPUTDEVICE 2A iface,LPCDIDATAFORMAT df305 LPDIRECTINPUTDEVICE8A iface,LPCDIDATAFORMAT df 284 306 ) 285 307 { 286 308 ICOM_THIS(SysMouseAImpl,iface); 287 309 int i; 288 310 289 311 TRACE("(this=%p,%p)\n",This,df); 290 312 … … 319 341 /* Prepare all the data-conversion filters */ 320 342 This->wine_df = create_DataFormat(&(Wine_InternalMouseFormat), df, This->offset_array); 321 343 322 344 return 0; 323 345 } 324 346 325 347 /* low-level mouse hook */ 326 348 #ifdef __WIN32OS2__ … … 335 357 SysMouseAImpl* This = (SysMouseAImpl*) current_lock; 336 358 #endif 337 338 //testestest 359 DWORD dwCoop; 360 static long last_event = 0; 361 int wdata; 362 363 #ifdef __WIN32OS2__ 339 364 dprintf(("dinput_mouse_hook %d %x %x", code, wparam, lparam)); 365 #endif 340 366 341 367 if (code != HC_ACTION) return CallNextHookEx( This->hook, code, wparam, lparam ); 342 368 343 369 EnterCriticalSection(&(This->crit)); 370 dwCoop = This->dwCoopLevel; 371 372 #ifndef __WIN32OS2__ 373 /* Only allow mouse events every 10 ms. 374 * This is to allow the cursor to start acceleration before 375 * the warps happen. But if it involves a mouse button event we 376 * allow it since we dont want to loose the clicks. 377 */ 378 if (((GetCurrentTime() - last_event) < 10) 379 && wparam == WM_MOUSEMOVE) 380 goto end; 381 else last_event = GetCurrentTime(); 382 #endif 383 344 384 /* Mouse moved -> send event if asked */ 345 385 if (This->hEvent) … … 350 390 if(hook->flags != LLMHF_INJECTED) 351 391 #endif 352 if(hook->dwExtraInfo != 666)353 392 if (This->absolute) { 354 393 if (hook->pt.x != This->prevX) … … 364 403 goto end; 365 404 } 366 405 367 406 /* Relative mouse input with absolute mouse event : the real fun starts here... */ 368 407 if ((This->need_warp == WARP_NEEDED) || … … 379 418 This->need_warp = WARP_NEEDED; 380 419 } 381 420 382 421 if (hook->pt.y != This->mapped_center.y) { 383 422 GEN_EVENT(This->offset_array[WINE_MOUSE_Y_POSITION], hook->pt.y - This->mapped_center.y, hook->time, (This->dinput->evsequence)++); … … 389 428 This->prevX = hook->pt.x; 390 429 This->prevY = hook->pt.y; 391 430 392 431 if (This->absolute) { 393 432 This->m_state.lX = hook->pt.x; … … 434 473 This->m_state.rgbButtons[2] = 0x00; 435 474 break; 475 case WM_MOUSEWHEEL: 476 wdata = (short)HIWORD(hook->mouseData); 477 GEN_EVENT(This->offset_array[WINE_MOUSE_Z_POSITION], wdata, 478 hook->time, This->dinput->evsequence++); 479 This->m_state.lZ += wdata; 480 break; 436 481 } 437 482 … … 441 486 442 487 end: 443 if (This->dwCoopLevel & DISCL_NONEXCLUSIVE) 488 LeaveCriticalSection(&(This->crit)); 489 490 if (dwCoop & DISCL_NONEXCLUSIVE) 444 491 { /* pass the events down to previous handlers (e.g. win32 input) */ 445 492 ret = CallNextHookEx( This->hook, code, wparam, lparam ); 446 493 } 447 494 else ret = 1; /* ignore message */ 448 LeaveCriticalSection(&(This->crit));449 495 return ret; 450 496 } 451 497 452 498 499 static void dinput_window_check(SysMouseAImpl* This) 500 { 501 RECT rect; 502 DWORD centerX, centerY; 503 504 /* make sure the window hasn't moved */ 505 GetWindowRect(This->win, &rect); 506 centerX = (rect.right - rect.left) / 2; 507 centerY = (rect.bottom - rect.top ) / 2; 508 if (This->win_centerX != centerX || This->win_centerY != centerY) { 509 This->win_centerX = centerX; 510 This->win_centerY = centerY; 511 } 512 This->mapped_center.x = This->win_centerX; 513 This->mapped_center.y = This->win_centerY; 514 MapWindowPoints(This->win, HWND_DESKTOP, &This->mapped_center, 1); 515 } 516 517 453 518 /****************************************************************************** 454 519 * Acquire : gets exclusive control of the mouse 455 520 */ 456 static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE 2A iface)521 static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface) 457 522 { 458 523 ICOM_THIS(SysMouseAImpl,iface); … … 464 529 TRACE("(this=%p)\n",This); 465 530 #endif 531 466 532 if (This->acquired == 0) { 467 533 POINT point; 468 534 469 535 /* Store (in a global variable) the current lock */ 470 current_lock = (IDirectInputDevice 2A*)This;536 current_lock = (IDirectInputDevice8A*)This; 471 537 472 538 /* Init the mouse state */ … … 481 547 This->m_state.lY = 0; 482 548 } 549 This->m_state.lZ = 0; 483 550 This->m_state.rgbButtons[0] = (GetKeyState(VK_LBUTTON) ? 0xFF : 0x00); 484 551 This->m_state.rgbButtons[1] = (GetKeyState(VK_MBUTTON) ? 0xFF : 0x00); … … 486 553 487 554 /* Install our mouse hook */ 555 if (This->dwCoopLevel & DISCL_EXCLUSIVE) 556 ShowCursor(FALSE); /* hide cursor */ 557 488 558 #ifdef __WIN32OS2__ 489 559 /* push ebp */ … … 524 594 This->mapped_center.y = This->win_centerY; 525 595 MapWindowPoints(This->win, HWND_DESKTOP, &This->mapped_center, 1); 526 TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y); 596 TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y); 527 597 SetCursorPos( This->mapped_center.x, This->mapped_center.y ); 528 598 #ifdef MOUSE_HACK … … 533 603 } 534 604 #endif 605 535 606 This->acquired = 1; 536 } 537 return DI_OK; 607 return DI_OK; 608 } 609 return S_FALSE; 538 610 } 539 611 … … 541 613 * Unacquire : frees the mouse 542 614 */ 543 static HRESULT WINAPI SysMouseAImpl_Unacquire(LPDIRECTINPUTDEVICE 2A iface)615 static HRESULT WINAPI SysMouseAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface) 544 616 { 545 617 ICOM_THIS(SysMouseAImpl,iface); … … 550 622 TRACE("(this=%p)\n",This); 551 623 #endif 552 553 624 if (This->acquired) 554 625 { 555 626 /* Reinstall previous mouse event handler */ 556 if (This->hook) UnhookWindowsHookEx( This->hook ); 557 This->hook = 0; 627 if (This->hook) { 628 UnhookWindowsHookEx( This->hook ); 629 This->hook = 0; 630 if (This->dwCoopLevel & DISCL_EXCLUSIVE) 631 ShowCursor(TRUE); /* show cursor */ 632 } 558 633 559 634 /* No more locks */ … … 565 640 else 566 641 ERR("Unacquiring a not-acquired device !!!\n"); 567 642 568 643 return DI_OK; 569 644 } … … 576 651 */ 577 652 static HRESULT WINAPI SysMouseAImpl_GetDeviceState( 578 LPDIRECTINPUTDEVICE 2A iface,DWORD len,LPVOID ptr653 LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr 579 654 ) { 580 655 ICOM_THIS(SysMouseAImpl,iface); 581 656 657 #ifdef __WIN32OS2__ 658 /* mouse state may have changed since last hook call; update it first */ 659 POINT point; 660 GetCursorPos(&point); 661 662 if(point.x != This->prevX || point.y != This->prevY) { 663 MSLLHOOKSTRUCT hook; 664 665 //Note: this is not entirely correct (should use HOOK_CallHooksW) 666 hook.pt.x = point.x; 667 hook.pt.y = point.y; 668 hook.mouseData = 0; 669 hook.flags = 0; 670 hook.time = GetCurrentTime(); 671 hook.dwExtraInfo = 0; 672 673 dinput_mouse_hook(This, HC_ACTION, WM_MOUSEMOVE, (LPARAM)&hook ); 674 } 675 #endif 676 582 677 EnterCriticalSection(&(This->crit)); 583 678 TRACE("(this=%p,0x%08lx,%p): \n",This,len,ptr); 584 679 585 680 /* Copy the current mouse state */ 586 681 fill_DataFormat(ptr, &(This->m_state), This->wine_df); 587 682 588 683 /* Initialize the buffer when in relative mode */ 589 684 if (This->absolute == 0) { 590 685 This->m_state.lX = 0; 591 686 This->m_state.lY = 0; 687 This->m_state.lZ = 0; 592 688 } 593 689 … … 596 692 /* Check if we need to do a mouse warping */ 597 693 if (This->need_warp == WARP_NEEDED) { 598 This->mapped_center.x = This->win_centerX; 599 This->mapped_center.y = This->win_centerY; 600 MapWindowPoints(This->win, HWND_DESKTOP, &This->mapped_center, 1); 601 TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y); 694 dinput_window_check(This); 695 TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y); 602 696 SetCursorPos( This->mapped_center.x, This->mapped_center.y ); 603 697 … … 609 703 } 610 704 #endif 611 612 705 LeaveCriticalSection(&(This->crit)); 613 706 614 707 TRACE("(X: %ld - Y: %ld L: %02x M: %02x R: %02x)\n", 615 708 This->m_state.lX, This->m_state.lY, 616 709 This->m_state.rgbButtons[0], This->m_state.rgbButtons[2], This->m_state.rgbButtons[1]); 617 710 618 711 return 0; 619 712 } … … 622 715 * GetDeviceState : gets buffered input data. 623 716 */ 624 static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE 2A iface,717 static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface, 625 718 DWORD dodsize, 626 719 LPDIDEVICEOBJECTDATA dod, … … 630 723 ICOM_THIS(SysMouseAImpl,iface); 631 724 DWORD len, nqtail; 632 725 633 726 EnterCriticalSection(&(This->crit)); 634 727 TRACE("(%p)->(dods=%ld,entries=%ld,fl=0x%08lx)\n",This,dodsize,*entries,flags); … … 639 732 640 733 if (dod == NULL) { 734 if (len) 735 TRACE("Application discarding %ld event(s).\n", len); 736 641 737 *entries = len; 642 738 nqtail = This->queue_tail + len; 643 739 while (nqtail >= This->queue_len) nqtail -= This->queue_len; 644 740 } else { 645 if (dodsize !=sizeof(DIDEVICEOBJECTDATA)) {741 if (dodsize < sizeof(DIDEVICEOBJECTDATA)) { 646 742 ERR("Wrong structure size !\n"); 647 743 LeaveCriticalSection(&(This->crit)); … … 650 746 651 747 if (len) 652 TRACE("Application retrieving %ld event(s).\n", len); 748 TRACE("Application retrieving %ld event(s).\n", len); 653 749 654 750 *entries = 0; … … 676 772 /* Check if we need to do a mouse warping */ 677 773 if (This->need_warp == WARP_NEEDED) { 678 This->mapped_center.x = This->win_centerX; 679 This->mapped_center.y = This->win_centerY; 680 MapWindowPoints(This->win, HWND_DESKTOP, &This->mapped_center, 1); 681 TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y); 774 dinput_window_check(This); 775 TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y); 682 776 SetCursorPos( This->mapped_center.x, This->mapped_center.y ); 683 777 … … 695 789 * SetProperty : change input device properties 696 790 */ 697 static HRESULT WINAPI SysMouseAImpl_SetProperty(LPDIRECTINPUTDEVICE 2A iface,791 static HRESULT WINAPI SysMouseAImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface, 698 792 REFGUID rguid, 699 793 LPCDIPROPHEADER ph) … … 702 796 703 797 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(rguid),ph); 704 798 705 799 if (!HIWORD(rguid)) { 706 800 switch ((DWORD)rguid) { 707 801 case (DWORD) DIPROP_BUFFERSIZE: { 708 802 LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph; 709 803 710 804 TRACE("buffersize = %ld\n",pd->dwData); 711 805 … … 728 822 } 729 823 } 730 824 731 825 return 0; 732 826 } … … 735 829 * GetProperty : get input device properties 736 830 */ 737 static HRESULT WINAPI SysMouseAImpl_GetProperty(LPDIRECTINPUTDEVICE 2A iface,831 static HRESULT WINAPI SysMouseAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, 738 832 REFGUID rguid, 739 833 LPDIPROPHEADER pdiph) … … 746 840 if (TRACE_ON(dinput)) 747 841 _dump_DIPROPHEADER(pdiph); 748 842 749 843 if (!HIWORD(rguid)) { 750 844 switch ((DWORD)rguid) { 751 845 case (DWORD) DIPROP_BUFFERSIZE: { 752 846 LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph; 753 847 754 848 TRACE(" return buffersize = %d\n",This->queue_len); 755 849 pd->dwData = This->queue_len; 850 break; 851 } 852 853 case (DWORD) DIPROP_GRANULARITY: { 854 LPDIPROPDWORD pr = (LPDIPROPDWORD) pdiph; 855 856 /* We'll just assume that the app asks about the Z axis */ 857 pr->dwData = WHEEL_DELTA; 858 756 859 break; 757 860 } … … 769 872 pr->lMax = DIPROPRANGE_NOMAX; 770 873 } 771 874 772 875 break; 773 876 } 774 877 775 878 default: 776 879 FIXME("Unknown type %ld (%s)\n",(DWORD)rguid,debugstr_guid(rguid)); … … 778 881 } 779 882 } 780 781 883 884 782 885 return DI_OK; 783 886 } … … 788 891 * SetEventNotification : specifies event to be sent on state change 789 892 */ 790 static HRESULT WINAPI SysMouseAImpl_SetEventNotification(LPDIRECTINPUTDEVICE 2A iface,893 static HRESULT WINAPI SysMouseAImpl_SetEventNotification(LPDIRECTINPUTDEVICE8A iface, 791 894 HANDLE hnd) { 792 895 ICOM_THIS(SysMouseAImpl,iface); … … 803 906 */ 804 907 static HRESULT WINAPI SysMouseAImpl_GetCapabilities( 805 LPDIRECTINPUTDEVICE 2A iface,908 LPDIRECTINPUTDEVICE8A iface, 806 909 LPDIDEVCAPS lpDIDevCaps) 807 910 { … … 813 916 lpDIDevCaps->dwFlags = DIDC_ATTACHED; 814 917 lpDIDevCaps->dwDevType = DIDEVTYPE_MOUSE; 815 lpDIDevCaps->dwAxes = 2;918 lpDIDevCaps->dwAxes = 3; 816 919 lpDIDevCaps->dwButtons = 3; 817 920 lpDIDevCaps->dwPOVs = 0; … … 825 928 FIXME("DirectX 3.0 not supported....\n"); 826 929 } 827 930 828 931 return DI_OK; 829 932 } … … 834 937 */ 835 938 static HRESULT WINAPI SysMouseAImpl_EnumObjects( 836 LPDIRECTINPUTDEVICE 2A iface,939 LPDIRECTINPUTDEVICE8A iface, 837 940 LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, 838 941 LPVOID lpvRef, … … 841 944 ICOM_THIS(SysMouseAImpl,iface); 842 945 DIDEVICEOBJECTINSTANCEA ddoi; 843 946 844 947 TRACE("(this=%p,%p,%p,%08lx)\n", This, lpCallback, lpvRef, dwFlags); 845 948 if (TRACE_ON(dinput)) { … … 851 954 /* Only the fields till dwFFMaxForce are relevant */ 852 955 ddoi.dwSize = FIELD_OFFSET(DIDEVICEOBJECTINSTANCEA, dwFFMaxForce); 853 956 854 957 /* In a mouse, we have : two relative axis and three buttons */ 855 958 if ((dwFlags == DIDFT_ALL) || … … 862 965 _dump_OBJECTINSTANCEA(&ddoi); 863 966 if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) return DI_OK; 864 967 865 968 /* Y axis */ 866 969 ddoi.guidType = GUID_YAxis; … … 870 973 _dump_OBJECTINSTANCEA(&ddoi); 871 974 if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) return DI_OK; 975 976 /* Z axis */ 977 ddoi.guidType = GUID_ZAxis; 978 ddoi.dwOfs = This->offset_array[WINE_MOUSE_Z_POSITION]; 979 ddoi.dwType = DIDFT_MAKEINSTANCE(WINE_MOUSE_Z_AXIS_INSTANCE) | DIDFT_RELAXIS; 980 strcpy(ddoi.tszName, "Z-Axis"); 981 _dump_OBJECTINSTANCEA(&ddoi); 982 if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) return DI_OK; 872 983 } 873 984 … … 902 1013 903 1014 904 static ICOM_VTABLE(IDirectInputDevice 2A) SysMouseAvt =1015 static ICOM_VTABLE(IDirectInputDevice8A) SysMouseAvt = 905 1016 { 906 1017 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE … … 932 1043 IDirectInputDevice2AImpl_Poll, 933 1044 IDirectInputDevice2AImpl_SendDeviceData, 1045 IDirectInputDevice7AImpl_EnumEffectsInFile, 1046 IDirectInputDevice7AImpl_WriteEffectToFile, 1047 IDirectInputDevice8AImpl_BuildActionMap, 1048 IDirectInputDevice8AImpl_SetActionMap, 1049 IDirectInputDevice8AImpl_GetImageInfo 934 1050 }; 935 936 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)937 # define XCAST(fun) (typeof(SysMouse7Avt.fun))938 #else939 # define XCAST(fun) (void*)940 #endif941 942 static ICOM_VTABLE(IDirectInputDevice7A) SysMouse7Avt =943 {944 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE945 XCAST(QueryInterface)IDirectInputDevice2AImpl_QueryInterface,946 XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,947 XCAST(Release)SysMouseAImpl_Release,948 XCAST(GetCapabilities)SysMouseAImpl_GetCapabilities,949 XCAST(EnumObjects)SysMouseAImpl_EnumObjects,950 XCAST(GetProperty)SysMouseAImpl_GetProperty,951 XCAST(SetProperty)SysMouseAImpl_SetProperty,952 XCAST(Acquire)SysMouseAImpl_Acquire,953 XCAST(Unacquire)SysMouseAImpl_Unacquire,954 XCAST(GetDeviceState)SysMouseAImpl_GetDeviceState,955 XCAST(GetDeviceData)SysMouseAImpl_GetDeviceData,956 XCAST(SetDataFormat)SysMouseAImpl_SetDataFormat,957 XCAST(SetEventNotification)SysMouseAImpl_SetEventNotification,958 XCAST(SetCooperativeLevel)SysMouseAImpl_SetCooperativeLevel,959 XCAST(GetObjectInfo)IDirectInputDevice2AImpl_GetObjectInfo,960 XCAST(GetDeviceInfo)IDirectInputDevice2AImpl_GetDeviceInfo,961 XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,962 XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,963 XCAST(CreateEffect)IDirectInputDevice2AImpl_CreateEffect,964 XCAST(EnumEffects)IDirectInputDevice2AImpl_EnumEffects,965 XCAST(GetEffectInfo)IDirectInputDevice2AImpl_GetEffectInfo,966 XCAST(GetForceFeedbackState)IDirectInputDevice2AImpl_GetForceFeedbackState,967 XCAST(SendForceFeedbackCommand)IDirectInputDevice2AImpl_SendForceFeedbackCommand,968 XCAST(EnumCreatedEffectObjects)IDirectInputDevice2AImpl_EnumCreatedEffectObjects,969 XCAST(Escape)IDirectInputDevice2AImpl_Escape,970 XCAST(Poll)IDirectInputDevice2AImpl_Poll,971 XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,972 IDirectInputDevice7AImpl_EnumEffectsInFile,973 IDirectInputDevice7AImpl_WriteEffectToFile974 };975 976 #undef XCAST
Note:
See TracChangeset
for help on using the changeset viewer.