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/dinput_main.c

    r8346 r9016  
    33 * Copyright 1998 Marcus Meissner
    44 * 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
    621 */
    722/* Status:
     
    1126 * - WingCommander Prophecy Demo:
    1227 *   Doesn't get Input Focus.
    13  * 
     28 *
    1429 * - Fallout : works great in X and DGA mode
    15  *
    16  * FIXME: The keyboard handling needs to (and will) be merged into keyboard.c
    17  *        (The current implementation is currently only a proof of concept and
    18  *         an utter mess.)
    1930 */
    2031
     
    2334#include <string.h>
    2435
    25 #include "debugtools.h"
     36#include "wine/debug.h"
    2637#include "winbase.h"
     38#include "winuser.h"
    2739#include "winerror.h"
    2840#include "windef.h"
    2941#include "dinput_private.h"
    3042
    31 DEFAULT_DEBUG_CHANNEL(dinput);
    32 
    33 static ICOM_VTABLE(IDirectInputA) ddiavt;
     43WINE_DEFAULT_DEBUG_CHANNEL(dinput);
     44
    3445static ICOM_VTABLE(IDirectInput7A) ddi7avt;
     46static ICOM_VTABLE(IDirectInput8A) ddi8avt;
    3547
    3648/* This array will be filled a dinput.so loading */
     
    3951static int nrof_dinput_devices = 0;
    4052
    41 /* register a direct draw driver. We better not use malloc for we are in
     53BOOL 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
    4269 * the ELF startup initialisation at this point.
    4370 */
     
    74101                (DWORD)hinst,dwVersion,debugstr_guid(riid),ppDI,punkOuter
    75102        );
    76         if (IsEqualGUID(&IID_IDirectInputA,riid)) {
     103        if (IsEqualGUID(&IID_IDirectInputA,riid) ||
     104            IsEqualGUID(&IID_IDirectInput2A,riid) ||
     105            IsEqualGUID(&IID_IDirectInput7A,riid)) {
    77106          This = (IDirectInputAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputAImpl));
     107          This->lpVtbl = &ddi7avt;
    78108          This->ref = 1;
    79           ICOM_VTBL(This) = &ddiavt;
    80109          *ppDI = This;
    81          
     110
    82111          return DI_OK;
    83112        }
    84        
    85         if (IsEqualGUID(&IID_IDirectInput7A,riid)) {
     113
     114
     115        if (IsEqualGUID(&IID_IDirectInput8A,riid)) {
    86116          This = (IDirectInputAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputAImpl));
     117          This->lpVtbl = &ddi8avt;
    87118          This->ref = 1;
    88           ICOM_VTBL(This) = (ICOM_VTABLE(IDirectInputA) *) &ddi7avt;
    89119          *ppDI = This;
    90          
     120
    91121          return DI_OK;
    92122        }
     
    105135        );
    106136        This = (IDirectInputAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputAImpl));
     137        This->lpVtbl = &ddi7avt;
    107138        This->ref = 1;
    108         ICOM_VTBL(This) = &ddiavt;
    109139        *ppDI=(IDirectInputA*)This;
    110140        return 0;
     141
    111142}
    112143/******************************************************************************
     
    126157        for (i = 0; i < nrof_dinput_devices; i++) {
    127158          if (dinput_devices[i]->enum_device(dwDevType, dwFlags, &devInstance)) {
     159            devInstance.dwSize = sizeof(devInstance);
    128160            if (lpCallback(&devInstance,pvRef) == DIENUM_STOP)
    129161              return 0;
    130162          }
    131163        }
    132        
     164
    133165        return 0;
     166}
     167
     168static 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;
    134184}
    135185
     
    157207        HRESULT ret_value = DIERR_DEVICENOTREG;
    158208        int i;
    159        
     209
    160210        TRACE("(this=%p,%s,%p,%p)\n",This,debugstr_guid(rguid),pdev,punk);
    161211
     
    173223}
    174224
    175 static HRESULT WINAPI IDirectInputAImpl_QueryInterface(
    176         LPDIRECTINPUT7A iface,REFIID riid,LPVOID *ppobj
    177 ) {
    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 
    195225static HRESULT WINAPI IDirectInputAImpl_Initialize(
    196226        LPDIRECTINPUT7A iface,HINSTANCE hinst,DWORD x
     
    202232                                                        REFGUID rguid) {
    203233  ICOM_THIS(IDirectInputAImpl,iface);
    204  
     234
    205235  FIXME("(%p)->(%s): stub\n",This,debugstr_guid(rguid));
    206  
     236
    207237  return DI_OK;
    208238}
     
    213243  ICOM_THIS(IDirectInputAImpl,iface);
    214244  FIXME("(%p)->(%08lx,%08lx): stub\n",This, (DWORD) hwndOwner, dwFlags);
    215  
     245
    216246  return DI_OK;
    217247}
    218248
    219 static HRESULT WINAPI IDirectInput2AImpl_FindDevice(LPDIRECTINPUT2A iface, REFGUID rguid,
     249static HRESULT WINAPI IDirectInput2AImpl_FindDevice(LPDIRECTINPUT7A iface, REFGUID rguid,
    220250                                                    LPCSTR pszName, LPGUID pguidInstance) {
    221251  ICOM_THIS(IDirectInputAImpl,iface);
    222252  FIXME("(%p)->(%s, %s, %p): stub\n", This, debugstr_guid(rguid), pszName, pguidInstance);
    223  
     253
    224254  return DI_OK;
    225255}
     
    231261  HRESULT ret_value = DIERR_DEVICENOTREG;
    232262  int i;
    233        
     263
    234264  TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
    235265
     
    239269    if ((ret = dinput_devices[i]->create_device(This, rguid, riid, (LPDIRECTINPUTDEVICEA*) pvOut)) == DI_OK)
    240270      return DI_OK;
    241    
     271
    242272    if (ret == DIERR_NOINTERFACE)
    243273      ret_value = DIERR_NOINTERFACE;
    244274  }
    245  
     275
    246276  return ret_value;
    247277}
    248278
     279static 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
     295static 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
     308static 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
    249320#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))
    271322#else
    272323# define XCAST(fun)     (void*)
     
    288339#undef XCAST
    289340
     341#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
     342# define XCAST(fun)     (typeof(ddi8avt.fun))
     343#else
     344# define XCAST(fun)     (void*)
     345#endif
     346
     347static 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
    290363/***********************************************************************
    291364 *              DllCanUnloadNow (DINPUT.@)
     
    304377                                        LPVOID *ppv)
    305378{
    306     FIXME("(%p, %p, %p): stub\n", debugstr_guid(rclsid), 
     379    FIXME("(%p, %p, %p): stub\n", debugstr_guid(rclsid),
    307380          debugstr_guid(riid), ppv);
    308381
Note: See TracChangeset for help on using the changeset viewer.