Ignore:
Timestamp:
Aug 16, 2002, 5:08:25 PM (23 years ago)
Author:
sandervl
Message:

Wine resync; added missing bugfix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/dinput/mouse.c

    r8532 r9016  
    33 * Copyright 1998 Marcus Meissner
    44 * Copyright 1998,1999 Lionel Ulmer
     5 * Copyright 2000-2001 TransGaming Technologies Inc.
    56 *
     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
    620 */
    721
    822#include "config.h"
     23#include "wine/port.h"
     24
    925#include <string.h>
    1026#ifdef HAVE_SYS_ERRNO_H
     
    2036#include "dinput_private.h"
    2137#include "device_private.h"
    22 #include "debugtools.h"
     38#include "wine/debug.h"
    2339
    2440#define MOUSE_HACK
    2541
    26 DEFAULT_DEBUG_CHANNEL(dinput);
     42WINE_DEFAULT_DEBUG_CHANNEL(dinput);
    2743
    2844/* Wine mouse driver object instances */
    2945#define WINE_MOUSE_X_AXIS_INSTANCE 0x0001
    3046#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
    3451
    3552/* ------------------------------- */
     
    4057#define WINE_MOUSE_X_POSITION 0
    4158#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
    4563
    4664typedef struct {
    4765  LONG lX;
    4866  LONG lY;
     67  LONG lZ;
    4968  BYTE rgbButtons[4];
    5069} Wine_InternalMouseData;
    5170
    52 #define WINE_INTERNALMOUSE_NUM_OBJS 5
     71#define WINE_INTERNALMOUSE_NUM_OBJS 6
    5372
    5473static DIOBJECTDATAFORMAT Wine_InternalMouseObjectFormat[WINE_INTERNALMOUSE_NUM_OBJS] = {
     
    5776  { &GUID_YAxis,   FIELD_OFFSET(Wine_InternalMouseData, lY),
    5877      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 },
    5980  { &GUID_Button, (FIELD_OFFSET(Wine_InternalMouseData, rgbButtons)) + 0,
    6081      DIDFT_MAKEINSTANCE(WINE_MOUSE_L_BUTTON_INSTANCE) | DIDFT_PSHBUTTON, 0 },
     
    7495};
    7596
    76 static ICOM_VTABLE(IDirectInputDevice2A) SysMouseAvt;
    77 static ICOM_VTABLE(IDirectInputDevice7A) SysMouse7Avt;
     97static ICOM_VTABLE(IDirectInputDevice8A) SysMouseAvt;
    7898typedef struct SysMouseAImpl SysMouseAImpl;
    7999
     
    86106struct SysMouseAImpl
    87107{
    88         /* IDirectInputDevice2AImpl */
    89         ICOM_VFIELD(IDirectInputDevice2A);
     108        LPVOID                          lpVtbl;
    90109        DWORD                           ref;
    91110        GUID                            guid;
    92111
    93112        IDirectInputAImpl *dinput;
    94        
     113
    95114        /* The current data format and the conversion between internal
    96115           and external data formats */
    97116        LPDIDATAFORMAT                  df;
    98117        DataFormat                     *wine_df;
    99         int                             offset_array[5];
    100        
     118        int                             offset_array[WINE_INTERNALMOUSE_NUM_OBJS];
     119
    101120        /* SysMouseAImpl */
    102121        BYTE                            absolute;
     
    133152
    134153/* FIXME: This is ugly and not thread safe :/ */
    135 static IDirectInputDevice2A* current_lock = NULL;
    136 
    137 
    138 static BOOL mousedev_enum_device(DWORD dwDevType, DWORD dwFlags, LPCDIDEVICEINSTANCEA lpddi)
     154static IDirectInputDevice8A* current_lock = NULL;
     155
     156
     157static BOOL mousedev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi)
    139158{
    140159  if ((dwDevType == 0) || (dwDevType == DIDEVTYPE_MOUSE)) {
     
    154173}
    155174
    156 static SysMouseAImpl *alloc_device(REFGUID rguid, ICOM_VTABLE(IDirectInputDevice2A) *mvt, IDirectInputAImpl *dinput)
    157 {
    158     int offset_array[5] = {
     175static SysMouseAImpl *alloc_device(REFGUID rguid, LPVOID mvt, IDirectInputAImpl *dinput)
     176{
     177    int offset_array[WINE_INTERNALMOUSE_NUM_OBJS] = {
    159178      FIELD_OFFSET(Wine_InternalMouseData, lX),
    160179      FIELD_OFFSET(Wine_InternalMouseData, lY),
     180      FIELD_OFFSET(Wine_InternalMouseData, lZ),
    161181      FIELD_OFFSET(Wine_InternalMouseData, rgbButtons) + 0,
    162182      FIELD_OFFSET(Wine_InternalMouseData, rgbButtons) + 1,
     
    166186    newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysMouseAImpl));
    167187    newDevice->ref = 1;
    168     ICOM_VTBL(newDevice) = mvt;
     188    newDevice->lpVtbl = mvt;
    169189    InitializeCriticalSection(&(newDevice->crit));
    170190    memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
    171    
     191
    172192    /* Per default, Wine uses its internal data format */
    173193    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));
    175195    newDevice->wine_df = (DataFormat *) HeapAlloc(GetProcessHeap(), 0, sizeof(DataFormat));
    176196    newDevice->wine_df->size = 0;
     
    186206  if ((IsEqualGUID(&GUID_SysMouse,rguid)) ||             /* Generic Mouse */
    187207      (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)) {
    189213      *pdev=(IDirectInputDeviceA*) alloc_device(rguid, &SysMouseAvt, dinput);
    190    
    191214      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);
    197215      return DI_OK;
    198216    } else
     
    218236  *     Release : release the mouse buffer.
    219237  */
    220 static ULONG WINAPI SysMouseAImpl_Release(LPDIRECTINPUTDEVICE2A iface)
     238static ULONG WINAPI SysMouseAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
    221239{
    222240        ICOM_THIS(SysMouseAImpl,iface);
     
    234252          HeapFree(GetProcessHeap(),0,This->data_queue);
    235253
    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        }
    237259        DeleteCriticalSection(&(This->crit));
    238260
     
    242264          HeapFree(GetProcessHeap(), 0, This->df);
    243265        }
    244        
     266
    245267        HeapFree(GetProcessHeap(),0,This);
    246268        return 0;
     
    253275  */
    254276static HRESULT WINAPI SysMouseAImpl_SetCooperativeLevel(
    255         LPDIRECTINPUTDEVICE2A iface,HWND hwnd,DWORD dwflags
     277        LPDIRECTINPUTDEVICE8A iface,HWND hwnd,DWORD dwflags
    256278)
    257279{
     
    268290  This->win = hwnd;
    269291  This->dwCoopLevel = dwflags;
    270  
     292
    271293  return 0;
    272294}
     
    281303  */
    282304static HRESULT WINAPI SysMouseAImpl_SetDataFormat(
    283         LPDIRECTINPUTDEVICE2A iface,LPCDIDATAFORMAT df
     305        LPDIRECTINPUTDEVICE8A iface,LPCDIDATAFORMAT df
    284306)
    285307{
    286308  ICOM_THIS(SysMouseAImpl,iface);
    287309  int i;
    288  
     310
    289311  TRACE("(this=%p,%p)\n",This,df);
    290312
     
    319341  /* Prepare all the data-conversion filters */
    320342  This->wine_df = create_DataFormat(&(Wine_InternalMouseFormat), df, This->offset_array);
    321  
     343
    322344  return 0;
    323345}
    324  
     346
    325347/* low-level mouse hook */
    326348#ifdef __WIN32OS2__
     
    335357    SysMouseAImpl* This = (SysMouseAImpl*) current_lock;
    336358#endif
    337 
    338 //testestest
     359    DWORD dwCoop;
     360    static long last_event = 0;
     361    int wdata;
     362
     363#ifdef __WIN32OS2__
    339364    dprintf(("dinput_mouse_hook %d %x %x", code, wparam, lparam));
     365#endif
    340366
    341367    if (code != HC_ACTION) return CallNextHookEx( This->hook, code, wparam, lparam );
    342368
    343369    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
    344384    /* Mouse moved -> send event if asked */
    345385    if (This->hEvent)
     
    350390      if(hook->flags != LLMHF_INJECTED)
    351391#endif
    352       if(hook->dwExtraInfo != 666)
    353392        if (This->absolute) {
    354393          if (hook->pt.x != This->prevX)
     
    364403            goto end;
    365404          }
    366                  
     405
    367406          /* Relative mouse input with absolute mouse event : the real fun starts here... */
    368407          if ((This->need_warp == WARP_NEEDED) ||
     
    379418              This->need_warp = WARP_NEEDED;
    380419            }
    381            
     420
    382421            if (hook->pt.y != This->mapped_center.y) {
    383422              GEN_EVENT(This->offset_array[WINE_MOUSE_Y_POSITION], hook->pt.y - This->mapped_center.y, hook->time, (This->dinput->evsequence)++);
     
    389428        This->prevX = hook->pt.x;
    390429        This->prevY = hook->pt.y;
    391        
     430
    392431        if (This->absolute) {
    393432          This->m_state.lX = hook->pt.x;
     
    434473        This->m_state.rgbButtons[2] = 0x00;
    435474        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;
    436481    }
    437482
     
    441486
    442487end:
    443   if (This->dwCoopLevel & DISCL_NONEXCLUSIVE)
     488  LeaveCriticalSection(&(This->crit));
     489
     490  if (dwCoop & DISCL_NONEXCLUSIVE)
    444491  { /* pass the events down to previous handlers (e.g. win32 input) */
    445492      ret = CallNextHookEx( This->hook, code, wparam, lparam );
    446493  }
    447494  else ret = 1;  /* ignore message */
    448   LeaveCriticalSection(&(This->crit));
    449495  return ret;
    450496}
    451497
    452498
     499static 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
    453518/******************************************************************************
    454519  *     Acquire : gets exclusive control of the mouse
    455520  */
    456 static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE2A iface)
     521static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
    457522{
    458523  ICOM_THIS(SysMouseAImpl,iface);
     
    464529  TRACE("(this=%p)\n",This);
    465530#endif
     531
    466532  if (This->acquired == 0) {
    467533    POINT point;
    468534
    469535    /* Store (in a global variable) the current lock */
    470     current_lock = (IDirectInputDevice2A*)This;
     536    current_lock = (IDirectInputDevice8A*)This;
    471537
    472538    /* Init the mouse state */
     
    481547      This->m_state.lY = 0;
    482548    }
     549    This->m_state.lZ = 0;
    483550    This->m_state.rgbButtons[0] = (GetKeyState(VK_LBUTTON) ? 0xFF : 0x00);
    484551    This->m_state.rgbButtons[1] = (GetKeyState(VK_MBUTTON) ? 0xFF : 0x00);
     
    486553
    487554    /* Install our mouse hook */
     555    if (This->dwCoopLevel & DISCL_EXCLUSIVE)
     556      ShowCursor(FALSE); /* hide cursor */
     557
    488558#ifdef __WIN32OS2__
    489559    /* push ebp */
     
    524594      This->mapped_center.y = This->win_centerY;
    525595      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);
    527597      SetCursorPos( This->mapped_center.x, This->mapped_center.y );
    528598#ifdef MOUSE_HACK
     
    533603    }
    534604#endif
     605
    535606    This->acquired = 1;
    536   }
    537   return DI_OK;
     607    return DI_OK;
     608  }
     609  return S_FALSE;
    538610}
    539611
     
    541613  *     Unacquire : frees the mouse
    542614  */
    543 static HRESULT WINAPI SysMouseAImpl_Unacquire(LPDIRECTINPUTDEVICE2A iface)
     615static HRESULT WINAPI SysMouseAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
    544616{
    545617    ICOM_THIS(SysMouseAImpl,iface);
     
    550622    TRACE("(this=%p)\n",This);
    551623#endif
    552 
    553624    if (This->acquired)
    554625    {
    555626        /* 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        }
    558633
    559634        /* No more locks */
     
    565640    else
    566641        ERR("Unacquiring a not-acquired device !!!\n");
    567  
     642
    568643    return DI_OK;
    569644}
     
    576651  */
    577652static HRESULT WINAPI SysMouseAImpl_GetDeviceState(
    578         LPDIRECTINPUTDEVICE2A iface,DWORD len,LPVOID ptr
     653        LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
    579654) {
    580655  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
    582677  EnterCriticalSection(&(This->crit));
    583678  TRACE("(this=%p,0x%08lx,%p): \n",This,len,ptr);
    584  
     679
    585680  /* Copy the current mouse state */
    586681  fill_DataFormat(ptr, &(This->m_state), This->wine_df);
    587  
     682
    588683  /* Initialize the buffer when in relative mode */
    589684  if (This->absolute == 0) {
    590685    This->m_state.lX = 0;
    591686    This->m_state.lY = 0;
     687    This->m_state.lZ = 0;
    592688  }
    593689
     
    596692  /* Check if we need to do a mouse warping */
    597693  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);
    602696    SetCursorPos( This->mapped_center.x, This->mapped_center.y );
    603697
     
    609703  }
    610704#endif
    611 
    612705  LeaveCriticalSection(&(This->crit));
    613  
     706
    614707  TRACE("(X: %ld - Y: %ld   L: %02x M: %02x R: %02x)\n",
    615708        This->m_state.lX, This->m_state.lY,
    616709        This->m_state.rgbButtons[0], This->m_state.rgbButtons[2], This->m_state.rgbButtons[1]);
    617  
     710
    618711  return 0;
    619712}
     
    622715  *     GetDeviceState : gets buffered input data.
    623716  */
    624 static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE2A iface,
     717static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
    625718                                              DWORD dodsize,
    626719                                              LPDIDEVICEOBJECTDATA dod,
     
    630723  ICOM_THIS(SysMouseAImpl,iface);
    631724  DWORD len, nqtail;
    632  
     725
    633726  EnterCriticalSection(&(This->crit));
    634727  TRACE("(%p)->(dods=%ld,entries=%ld,fl=0x%08lx)\n",This,dodsize,*entries,flags);
     
    639732
    640733  if (dod == NULL) {
     734    if (len)
     735        TRACE("Application discarding %ld event(s).\n", len);
     736
    641737    *entries = len;
    642738    nqtail = This->queue_tail + len;
    643739    while (nqtail >= This->queue_len) nqtail -= This->queue_len;
    644740  } else {
    645     if (dodsize != sizeof(DIDEVICEOBJECTDATA)) {
     741    if (dodsize < sizeof(DIDEVICEOBJECTDATA)) {
    646742      ERR("Wrong structure size !\n");
    647743      LeaveCriticalSection(&(This->crit));
     
    650746
    651747    if (len)
    652         TRACE("Application retrieving %ld event(s).\n", len); 
     748        TRACE("Application retrieving %ld event(s).\n", len);
    653749
    654750    *entries = 0;
     
    676772  /* Check if we need to do a mouse warping */
    677773  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);
    682776    SetCursorPos( This->mapped_center.x, This->mapped_center.y );
    683777
     
    695789  *     SetProperty : change input device properties
    696790  */
    697 static HRESULT WINAPI SysMouseAImpl_SetProperty(LPDIRECTINPUTDEVICE2A iface,
     791static HRESULT WINAPI SysMouseAImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface,
    698792                                            REFGUID rguid,
    699793                                            LPCDIPROPHEADER ph)
     
    702796
    703797  TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
    704  
     798
    705799  if (!HIWORD(rguid)) {
    706800    switch ((DWORD)rguid) {
    707801    case (DWORD) DIPROP_BUFFERSIZE: {
    708802      LPCDIPROPDWORD    pd = (LPCDIPROPDWORD)ph;
    709      
     803
    710804      TRACE("buffersize = %ld\n",pd->dwData);
    711805
     
    728822    }
    729823  }
    730  
     824
    731825  return 0;
    732826}
     
    735829  *     GetProperty : get input device properties
    736830  */
    737 static HRESULT WINAPI SysMouseAImpl_GetProperty(LPDIRECTINPUTDEVICE2A iface,
     831static HRESULT WINAPI SysMouseAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
    738832                                                REFGUID rguid,
    739833                                                LPDIPROPHEADER pdiph)
     
    746840  if (TRACE_ON(dinput))
    747841    _dump_DIPROPHEADER(pdiph);
    748  
     842
    749843  if (!HIWORD(rguid)) {
    750844    switch ((DWORD)rguid) {
    751845    case (DWORD) DIPROP_BUFFERSIZE: {
    752846      LPDIPROPDWORD     pd = (LPDIPROPDWORD)pdiph;
    753      
     847
    754848      TRACE(" return buffersize = %d\n",This->queue_len);
    755849      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
    756859      break;
    757860    }
     
    769872        pr->lMax = DIPROPRANGE_NOMAX;
    770873      }
    771      
     874
    772875      break;
    773876    }
    774      
     877
    775878    default:
    776879      FIXME("Unknown type %ld (%s)\n",(DWORD)rguid,debugstr_guid(rguid));
     
    778881    }
    779882  }
    780  
    781  
     883
     884
    782885  return DI_OK;
    783886}
     
    788891  *     SetEventNotification : specifies event to be sent on state change
    789892  */
    790 static HRESULT WINAPI SysMouseAImpl_SetEventNotification(LPDIRECTINPUTDEVICE2A iface,
     893static HRESULT WINAPI SysMouseAImpl_SetEventNotification(LPDIRECTINPUTDEVICE8A iface,
    791894                                                         HANDLE hnd) {
    792895  ICOM_THIS(SysMouseAImpl,iface);
     
    803906  */
    804907static HRESULT WINAPI SysMouseAImpl_GetCapabilities(
    805         LPDIRECTINPUTDEVICE2A iface,
     908        LPDIRECTINPUTDEVICE8A iface,
    806909        LPDIDEVCAPS lpDIDevCaps)
    807910{
     
    813916    lpDIDevCaps->dwFlags = DIDC_ATTACHED;
    814917    lpDIDevCaps->dwDevType = DIDEVTYPE_MOUSE;
    815     lpDIDevCaps->dwAxes = 2;
     918    lpDIDevCaps->dwAxes = 3;
    816919    lpDIDevCaps->dwButtons = 3;
    817920    lpDIDevCaps->dwPOVs = 0;
     
    825928    FIXME("DirectX 3.0 not supported....\n");
    826929  }
    827  
     930
    828931  return DI_OK;
    829932}
     
    834937  */
    835938static HRESULT WINAPI SysMouseAImpl_EnumObjects(
    836         LPDIRECTINPUTDEVICE2A iface,
     939        LPDIRECTINPUTDEVICE8A iface,
    837940        LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback,
    838941        LPVOID lpvRef,
     
    841944  ICOM_THIS(SysMouseAImpl,iface);
    842945  DIDEVICEOBJECTINSTANCEA ddoi;
    843  
     946
    844947  TRACE("(this=%p,%p,%p,%08lx)\n", This, lpCallback, lpvRef, dwFlags);
    845948  if (TRACE_ON(dinput)) {
     
    851954  /* Only the fields till dwFFMaxForce are relevant */
    852955  ddoi.dwSize = FIELD_OFFSET(DIDEVICEOBJECTINSTANCEA, dwFFMaxForce);
    853    
     956
    854957  /* In a mouse, we have : two relative axis and three buttons */
    855958  if ((dwFlags == DIDFT_ALL) ||
     
    862965    _dump_OBJECTINSTANCEA(&ddoi);
    863966    if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) return DI_OK;
    864    
     967
    865968    /* Y axis */
    866969    ddoi.guidType = GUID_YAxis;
     
    870973    _dump_OBJECTINSTANCEA(&ddoi);
    871974    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;
    872983  }
    873984
     
    9021013
    9031014
    904 static ICOM_VTABLE(IDirectInputDevice2A) SysMouseAvt =
     1015static ICOM_VTABLE(IDirectInputDevice8A) SysMouseAvt =
    9051016{
    9061017        ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     
    9321043        IDirectInputDevice2AImpl_Poll,
    9331044        IDirectInputDevice2AImpl_SendDeviceData,
     1045        IDirectInputDevice7AImpl_EnumEffectsInFile,
     1046        IDirectInputDevice7AImpl_WriteEffectToFile,
     1047        IDirectInputDevice8AImpl_BuildActionMap,
     1048        IDirectInputDevice8AImpl_SetActionMap,
     1049        IDirectInputDevice8AImpl_GetImageInfo
    9341050};
    935 
    936 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
    937 # define XCAST(fun)     (typeof(SysMouse7Avt.fun))
    938 #else
    939 # define XCAST(fun)     (void*)
    940 #endif
    941 
    942 static ICOM_VTABLE(IDirectInputDevice7A) SysMouse7Avt =
    943 {
    944         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
    945         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_WriteEffectToFile
    974 };
    975 
    976 #undef XCAST
Note: See TracChangeset for help on using the changeset viewer.