0001: //-----------------------------------------------------------------------------
0002: // File: DIUtil.h
0003: //
0004: // Desc: DirectInput support using action mapping
0005: //-----------------------------------------------------------------------------
0006: #ifndef DIUTIL_H
0007: #define DIUTIL_H
0008: 
0009: #ifndef DIRECTINPUT_VERSION
0010: #define DIRECTINPUT_VERSION 0x0800
0011: #endif
0012: 
0013: #include <dinput.h>
0014: 
0015: 
0016: 
0017: 
0018: //-----------------------------------------------------------------------------
0019: // Name: class CInputDeviceManager
0020: // Desc: Input device manager using DX8 action mapping
0021: //-----------------------------------------------------------------------------
0022: class CInputDeviceManager
0023: {
0024: public:
0025:     struct DeviceInfo
0026:     {
0027:         LPDIRECTINPUTDEVICE8 pdidDevice;
0028:         LPVOID               pParam;
0029:     };
0030: 
0031:     typedef HRESULT (CALLBACK *LPDIMANAGERCALLBACK)(CInputDeviceManager::DeviceInfo* pDeviceInfo, const DIDEVICEINSTANCE* pdidi, LPVOID);
0032: 
0033: private:
0034:     BOOL                    m_bCleanupCOM;
0035:     HWND                    m_hWnd;
0036:     TCHAR*                  m_strUserName;
0037: 
0038:     LPDIRECTINPUT8          m_pDI;
0039:     DeviceInfo*             m_pDevices;
0040:     DWORD                   m_dwMaxDevices;
0041:     DWORD                   m_dwNumDevices;
0042:     DIACTIONFORMAT          m_diaf;
0043: 
0044:     LPDIMANAGERCALLBACK  m_AddDeviceCallback;
0045:     LPVOID               m_AddDeviceCallbackParam;
0046: 
0047: public:
0048:     // Device control
0049:     HRESULT AddDevice( const DIDEVICEINSTANCE* pdidi, LPDIRECTINPUTDEVICE8 pdidDevice );
0050:     HRESULT GetDevices( DeviceInfo** ppDeviceInfo, DWORD* pdwNumDevices );
0051:     HRESULT ConfigureDevices( HWND hWnd, IUnknown* pSurface, VOID* pCallback, DWORD dwFlags, LPVOID pvCBParam );
0052:     VOID UnacquireDevices();
0053:     VOID SetFocus( HWND hWnd );
0054: 
0055:     // Construction
0056:     HRESULT SetActionFormat( DIACTIONFORMAT& diaf, BOOL bReenumerate );
0057:     HRESULT Create( HWND hWnd, TCHAR* strUserName, DIACTIONFORMAT& diaf, LPDIMANAGERCALLBACK AddDeviceCallback, LPVOID pCallbackParam );
0058: 
0059:     CInputDeviceManager();
0060:     ~CInputDeviceManager();
0061: };
0062: 
0063: #endif
0064: 
0065: 
0066: