DIDevice.h
上传用户:wymy58
上传日期:2007-01-07
资源大小:2086k
文件大小:3k
源码类别:

DirextX编程

开发平台:

Visual C++

  1. // Copyright (C) 1998-1999 DXGuide.  All Rights Reserved.
  2. // File: DIDevice.h
  3. #ifndef _DIDEVICE__H
  4. #define _DIDEVICE__H
  5. #if _MSC_VER >= 1000
  6. #pragma once
  7. #endif // _MSC_VER >= 1000
  8. #include <dinput.h>
  9. class CDIDevice : public  CObject
  10. {
  11. friend class CDirectInput;
  12. DECLARE_SERIAL(CDIDevice);
  13. protected:
  14. CDIDevice(void);
  15. virtual ~CDIDevice();
  16. public:
  17. virtual bool Create(LPDIRECTINPUT7  lpDI, HWND  hWnd);
  18. virtual HRESULT Update(void);
  19. protected:
  20. void SetDeviceInfo(const DIDEVICEINSTANCE*  pDIDeviceInstance);
  21. public:
  22. DIDEVICEINSTANCE* GetDeviceInfo(void) const;
  23. LPGUID GetGuid(void) const;
  24. CString GetDeviceName(void) const;
  25. CString GetDescription(void) const;
  26. CString GetFullDescription(void) const;
  27. int GetDeviceType(void) const;
  28. int GetSubDeviceType(void) const;
  29. bool IsGeneric(void) const;
  30. bool IsKeyboard(void) const;
  31. bool IsMouse(void) const;
  32. bool IsJoyStick(void) const;
  33. int Unit(void); // get unit number
  34. public:
  35. HRESULT Acquire(void);
  36. HRESULT GetCapabilities(LPDIDEVCAPS  lpDIDevCaps);
  37. HRESULT GetDeviceData(LPDIDEVICEOBJECTDATA  rgdod,
  38. LPDWORD  pdwInOut, DWORD  dwFlags = 0);
  39. HRESULT GetDeviceInfo(LPDIDEVICEINSTANCE  pdidi);
  40. HRESULT GetDeviceState(DWORD  cbData, LPVOID  lpvData);
  41. HRESULT GetObjectInfo(LPDIDEVICEOBJECTINSTANCE  pdidoi,
  42. DWORD dwObj = 0, DWORD dwHow = DIPH_DEVICE);
  43. HRESULT GetProperty(REFGUID  rguidProp, LPDIPROPHEADER  pdiph);
  44. HRESULT Initialize(HINSTANCE  hinst, DWORD  dwVersion, REFGUID  rguid);
  45. HRESULT RunControlPanel(HWND  hwnd);
  46. protected:
  47. HRESULT SetCooperativeLevel(HWND  hwnd, DWORD  dwFlags);
  48. public:
  49. HRESULT SetDataFormat(LPCDIDATAFORMAT  lpdf);
  50. HRESULT SetEventNotification(HANDLE  hEvent);
  51. HRESULT SetProperty(REFGUID  rguidProp, LPCDIPROPHEADER  pdiph);
  52. HRESULT SetPropertyDword(REFGUID  rguidProp, DWORD  dwVal);
  53. HRESULT SetPropertyDword(REFGUID  rguidProp, DWORD  dwOffset, DWORD  dwVal);
  54. HRESULT SetPropertyRangeID(REFGUID  rguidProp, DWORD  dwObj, LONG  lMin, LONG  lMax);
  55. HRESULT SetPropertyRangeOffset(REFGUID rguidProp, DWORD  dwOffset, LONG  lMin, LONG  lMax);
  56. HRESULT Unacquire(void);
  57. HRESULT Poll(void);
  58. bool IsBuffered(void) const;
  59. HRESULT SetBuffered(DWORD  dwBufferSize = 16);
  60. HRESULT FlushBuffer(DWORD&  dwItems);
  61. HRESULT GetDeviceDataItems(DWORD&  dwItems);
  62. bool IsBufferOverflow(void);
  63. LPDIDEVICEOBJECTDATA GetBufferData(DWORD&  dwItems);
  64. protected:
  65. LPDIRECTINPUTDEVICE7 m_lpDirectInputDevice;
  66. protected:
  67. DIDEVICEINSTANCE* m_pDIDeviceInstance; // device information
  68. LPDIDEVICEOBJECTDATA m_pDIDeviceObjectData;
  69. DWORD m_dwBufferSize;
  70. };
  71. #include "DIDevice.inl"
  72. #endif // _DIDEVICE__H