diutil.h
上传用户:sycq158
上传日期:2008-10-22
资源大小:15361k
文件大小:2k
源码类别:

游戏

开发平台:

Visual C++

  1. //-----------------------------------------------------------------------------
  2. // File: DIUtil.h
  3. //
  4. // Desc: DirectInput support using action mapping
  5. //
  6. // Copyright (C) Microsoft Corporation. All Rights Reserved.
  7. //-----------------------------------------------------------------------------
  8. #ifndef DIUTIL_H
  9. #define DIUTIL_H
  10. #ifndef DIRECTINPUT_VERSION
  11. #define DIRECTINPUT_VERSION 0x0800
  12. #endif
  13. #include <dinput.h>
  14. //-----------------------------------------------------------------------------
  15. // Name: class CInputDeviceManager
  16. // Desc: Input device manager using DX8 action mapping
  17. //-----------------------------------------------------------------------------
  18. class CInputDeviceManager
  19. {
  20. public:
  21.     struct DeviceInfo
  22.     {
  23.         LPDIRECTINPUTDEVICE8 pdidDevice;
  24.         LPVOID               pParam;
  25.     };
  26.     typedef HRESULT (CALLBACK *LPDIMANAGERCALLBACK)(CInputDeviceManager::DeviceInfo* pDeviceInfo, const DIDEVICEINSTANCE* pdidi, LPVOID);
  27. private:
  28.     BOOL                    m_bCleanupCOM;
  29.     HWND                    m_hWnd;
  30.     TCHAR*                  m_strUserName;
  31.     LPDIRECTINPUT8          m_pDI;
  32.     DeviceInfo*             m_pDevices;
  33.     DWORD                   m_dwMaxDevices;
  34.     DWORD                   m_dwNumDevices;
  35.     DIACTIONFORMAT          m_diaf;
  36.     LPDIMANAGERCALLBACK  m_AddDeviceCallback;
  37.     LPVOID               m_AddDeviceCallbackParam;
  38. public:
  39.     // Device control
  40.     HRESULT AddDevice( const DIDEVICEINSTANCE* pdidi, LPDIRECTINPUTDEVICE8 pdidDevice );
  41.     HRESULT GetDevices( DeviceInfo** ppDeviceInfo, DWORD* pdwNumDevices );
  42.     HRESULT ConfigureDevices( HWND hWnd, IUnknown* pSurface, VOID* pCallback, DWORD dwFlags, LPVOID pvCBParam );
  43.     VOID UnacquireDevices();
  44.     VOID SetFocus( HWND hWnd );
  45.     // Construction
  46.     HRESULT SetActionFormat( DIACTIONFORMAT& diaf, BOOL bReenumerate );
  47.     HRESULT Create( HWND hWnd, TCHAR* strUserName, DIACTIONFORMAT& diaf, LPDIMANAGERCALLBACK AddDeviceCallback, LPVOID pCallbackParam );
  48.     CInputDeviceManager();
  49.     ~CInputDeviceManager();
  50. };
  51. #endif