/***************************************************************************/
/*  Description: InitPrv.c, part of CPA INO library                        */                                
/*               Declaration of the global variables for MMG and ERM       */
/*               for joystick and  keyboard and mouse                      */
/*                                                                         */
/*  Author: F. Jentey                                                      */
/*  Creation date: 21/04/97                                                */
/*  Last Update:   30/07/97  Direct input initialisation                   */
/***************************************************************************/
 
 
 
#include <windows.h>
#include <dinput.h>
#include "INOMain.h"
 
 
#define DIRECTINPUT_VERSION_3    0x0300
 
 
typedef struct INO_stDIDevice
        {
            DIDEVICEINSTANCE     m_stDevInstance;
            LPDIRECTINPUTDEVICE  m_p_stDevInterface;
            LPDIRECTINPUTDEVICE2 m_p_stDevInterface2;
            short                m_wExtendedInterfaceAvailable;
            INO_tdhDevice        m_hDevice;
        }
        INO_tdstDIDevice;
 
 
 
extern LPDIRECTINPUT     INO_g_p_stDInputInterface;
extern INO_tdstDIDevice  INO_g_a_stDIDevice[];
extern unsigned long     m_ulDITargetVersion;
extern unsigned long     m_ulDIInstalledVersion;
extern INO_tdstDevice    g_a_tdhDevice[];
extern DIDEVCAPS         g_stDIDevCaps;
extern DIDEVCAPS_DX3     g_stDIDevCaps3;
 
extern short INO_fn_wFillDeviceCaps(INO_tdhDevice hDev);
extern short INO_fn_wIsAttached(short hDev);
 
 
#define  M_DIDev1(A)     INO_g_a_stDIDevice[A].m_p_stDevInterface
#define  M_DIDev2(A)     INO_g_a_stDIDevice[A].m_p_stDevInterface2
#define  M_DIDevEx(A)    INO_g_a_stDIDevice[A].m_wExtendedInterfaceAvailable
#define  M_DIAcquire(A) ( \
              M_DIDevEx(A) ?\
                  M_DIDev2(A)->lpVtbl->Acquire(M_DIDev2(A)) \
                  : \
                  M_DIDev1(A)->lpVtbl->Acquire(M_DIDev1(A)) )
#define  M_DIUnacquire(A) ( \
              M_DIDevEx(A) ?\
                  M_DIDev2(A)->lpVtbl->Unacquire(M_DIDev2(A)) \
                  : \
                  M_DIDev1(A)->lpVtbl->Unacquire(M_DIDev1(A)) )
#define  M_DIRelease(A) ( \
              M_DIDevEx(A) ?\
                  M_DIDev2(A)->lpVtbl->Release(M_DIDev2(A)) \
                  : \
                  M_DIDev1(A)->lpVtbl->Release(M_DIDev1(A)) )
#define  M_DIGetCaps(A,B) ( \
              M_DIDevEx(A) ?\
                  M_DIDev2(A)->lpVtbl->GetCapabilities(M_DIDev2(A),B) \
                  : \
                  M_DIDev1(A)->lpVtbl->GetCapabilities(M_DIDev1(A),B) )
#define  M_DIGetState(A,B,C) ( \
              M_DIDevEx(A) ?\
                  M_DIDev2(A)->lpVtbl->GetDeviceState(M_DIDev2(A),B,C) \
                  : \
                  M_DIDev1(A)->lpVtbl->GetDeviceState(M_DIDev1(A),B,C) )
#define  M_DIGetProp(A,B,C) ( \
              M_DIDevEx(A) ?\
                  M_DIDev2(A)->lpVtbl->GetProperty(M_DIDev2(A),B,C) \
                  : \
                  M_DIDev1(A)->lpVtbl->GetProperty(M_DIDev1(A),B,C) )
 
 
 
 
