home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / CDX.ZIP / Inc / CDI.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-09-14  |  3.0 KB  |  116 lines

  1. //////////////////////////////////////////////////////////////////////////////////
  2. // Project Name: [ CDI Class Library - CDI.lib ]
  3. // Author:       [ Dan Farley - 97308096@brookes.ac.uk ]
  4. // Source File:  [ Main Header File ]
  5. // Revision:     [ 1.6 ]
  6. //////////////////////////////////////////////////////////////////////////////////
  7. #ifndef CDI_H
  8. #define CDI_H
  9.  
  10. #include <dinput.h>
  11. #define RELEASE(x) if(x != NULL) { x->Release(); x = NULL; }
  12.  
  13. //////////////////////////////////////////////////////////////////////////////////
  14. // CDI_Input Class
  15. //////////////////////////////////////////////////////////////////////////////////
  16. class CDI_Input
  17. {
  18. public:
  19.     CDI_Input(void);
  20.     ~CDI_Input(void);
  21.  
  22.     HRESULT Create(void *hinst);
  23.     LPDIRECTINPUT GetDI(void) { return m_DirectInput; }
  24.  
  25. public:
  26.     LPDIRECTINPUT m_DirectInput;
  27. };
  28.  
  29. //////////////////////////////////////////////////////////////////////////////////
  30. // CDI_Device Class
  31. //////////////////////////////////////////////////////////////////////////////////
  32. class CDI_Device
  33. {
  34. public:
  35.     CDI_Device(void);
  36.     ~CDI_Device(void);
  37.  
  38.     HRESULT Create(CDI_Input*, REFGUID);
  39.     HRESULT SetDataFormat(LPCDIDATAFORMAT);
  40.     HRESULT SetCooperativeLevel(void*, DWORD);
  41.     HRESULT RunControlPanel(void*);
  42.     HRESULT Acquire(void);
  43.     HRESULT Unacquire(void);
  44.     HRESULT SetRelative(void);
  45.     HRESULT SetAbsolute(void);
  46.  
  47. public:
  48.     LPDIRECTINPUTDEVICE2 m_Device;
  49.     BOOL m_bActive;
  50. };
  51.  
  52. //////////////////////////////////////////////////////////////////////////////////
  53. // CDI_Keyboard Class
  54. //////////////////////////////////////////////////////////////////////////////////
  55. class CDI_Keyboard : public CDI_Device
  56. {
  57. public:
  58.     CDI_Keyboard(void);
  59.     ~CDI_Keyboard(void);
  60.  
  61.     HRESULT Create(CDI_Input*, void*);
  62.     void Update(void);
  63.  
  64. public:
  65.     BYTE m_Keys[256];
  66. };
  67.  
  68. //////////////////////////////////////////////////////////////////////////////////
  69. // CDI_Mouse Class
  70. //////////////////////////////////////////////////////////////////////////////////
  71. class CDI_Mouse : public CDI_Device
  72. {
  73. public:
  74.     CDI_Mouse(void);
  75.     ~CDI_Mouse(void);
  76.  
  77.     HRESULT Create(CDI_Input*, void*);
  78.     void Update(void);
  79.  
  80.     LONG GetX(void) { return m_X; }
  81.     LONG GetY(void) { return m_Y; }
  82.     LONG GetZ(void) { return m_Z; }
  83.     BYTE GetLB(void) { return m_Buttons[0]; }
  84.     BYTE GetRB(void) { return m_Buttons[1]; }
  85.     BYTE GetMB(void) { return m_Buttons[2]; }
  86.  
  87. public:
  88.     LONG m_X, m_Y, m_Z;
  89.     BYTE m_Buttons[4];
  90. };
  91.  
  92. //////////////////////////////////////////////////////////////////////////////////
  93. // CDI_Joystick Class
  94. //////////////////////////////////////////////////////////////////////////////////
  95. class CDI_Joystick : public CDI_Device
  96. {
  97. public:
  98.     CDI_Joystick(void);
  99.     ~CDI_Joystick(void);
  100.  
  101.     HRESULT Create(CDI_Input*, void*);
  102.     void Update(void);
  103.  
  104.     LONG GetX(void) { return m_X; }
  105.     LONG GetY(void) { return m_Y; }
  106.     LONG GetZ(void) { return m_Z; }
  107.     BYTE GetB1(void) { return m_Buttons[0]; }
  108.     BYTE GetB2(void) { return m_Buttons[1]; }
  109.  
  110. public:
  111.     LONG m_X, m_Y, m_Z;
  112.     BYTE m_Buttons[32];
  113. };
  114.  
  115. #endif
  116.