Changeset 9016 for trunk/src/dinput/mouse.c
- Timestamp:
- Aug 16, 2002, 5:08:25 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.