Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

171 lines
5.4 KiB

  1. /****************************************************************************
  2. MODULE: SW_Objec.hpp
  3. Tab settings: 5 9
  4. Copyright 1995, 1996, 1999, Microsoft Corporation, All Rights Reserved.
  5. PURPOSE: Definition of the CDirectInputEffectDriver class that uses interface
  6. implementations to provide IDirectInputEffectDriver
  7. FUNCTIONS:
  8. Author(s): Name:
  9. ---------- ----------------
  10. MEA Manolito E. Adan
  11. Revision History:
  12. -----------------
  13. Version Date Author Comments
  14. ------- ------ ----- -------------------------------------------
  15. 1.0 06-Feb-97 MEA original, Based on SWForce
  16. 23-Feb-97 MEA Modified for DirectInput FF Device Driver
  17. 26-Feb-97 MEA Added SetGain
  18. 21-Mar-99 waltw Removed unreferenced CreateDirectInputEffectDriver
  19. ****************************************************************************/
  20. #ifndef _SW_OBJEC_SEEN
  21. #define _SW_OBJEC_SEEN
  22. #include <windows.h>
  23. #include <mmsystem.h>
  24. #include <memory.h>
  25. #include "dinput.h"
  26. #include "dinputd.h"
  27. #include "midi_obj.hpp"
  28. #include "dx_map.hpp"
  29. //Type for an object-destroyed callback
  30. typedef void (*PFNDESTROYED)(void);
  31. //DeleteInterfaceImp calls 'delete' and NULLs the pointer
  32. #define DeleteInterfaceImp(p)\
  33. {\
  34. if (NULL!=p)\
  35. {\
  36. delete p;\
  37. p=NULL;\
  38. }\
  39. }
  40. //ReleaseInterface calls 'Release' and NULLs the pointer
  41. #define ReleaseInterface(p)\
  42. {\
  43. if (NULL!=p)\
  44. {\
  45. p->Release();\
  46. p=NULL;\
  47. }\
  48. }
  49. #ifndef PPVOID
  50. typedef LPVOID * PPVOID;
  51. #endif //PPVOID
  52. /*
  53. * The object we want to provide in OLE supports the IUnknown,
  54. * IDirectInputEffectDriver interfaces.
  55. *
  56. * The C++ class, CDirectInputEffectDriver, implements these interfaces with
  57. * "interface implementations" where the C++ class itself inherits
  58. * from and implements IUnknown members and then contains
  59. * other C++ classes that each separately inherit from the other
  60. * interfaces. The other classes are the "interface implementations."
  61. */
  62. /*
  63. * In this technique you'll generally need forward references
  64. * like this for use in declaring the object class.
  65. */
  66. class CImpIDirectInputEffectDriver;
  67. typedef CImpIDirectInputEffectDriver *PCImpIDirectInputEffectDriver;
  68. //The C++ class that manages the actual object.
  69. class CDirectInputEffectDriver : public IUnknown
  70. {
  71. /*
  72. * Usually interface implementations will need back pointers
  73. * to the object itself since this object usually manages
  74. * the important data members. In that case, make the
  75. * interface implementation classes friends of the object.
  76. */
  77. friend CImpIDirectInputEffectDriver;
  78. protected:
  79. ULONG m_cRef; //Object reference count
  80. LPUNKNOWN m_pUnkOuter; //Controlling unknown
  81. PFNDESTROYED m_pfnDestroy; //To call on closure
  82. /*
  83. * I use "m_pImpI" as a prefix to differentiate interface
  84. * implementations for this object from other interface
  85. * pointer variables I might hold to other objects, which
  86. * would be prefixed with "m_pI".
  87. */
  88. PCImpIDirectInputEffectDriver m_pImpIDirectInputEffectDriver;
  89. public:
  90. CDirectInputEffectDriver(LPUNKNOWN, PFNDESTROYED);
  91. ~CDirectInputEffectDriver(void);
  92. BOOL Init(void);
  93. //IUnknown members
  94. STDMETHODIMP QueryInterface(REFIID, PPVOID);
  95. STDMETHODIMP_(DWORD) AddRef(void);
  96. STDMETHODIMP_(DWORD) Release(void);
  97. };
  98. typedef CDirectInputEffectDriver *PCDirectInputEffectDriver;
  99. /*
  100. * Interface implementation classes are C++ classes that
  101. * each singly inherit from an interface. Their IUnknown
  102. * members delegate calls to CDirectInputEffectDriver's IUnknown members--
  103. * since IUnknown members affect the entire *object*, and
  104. * since these interfaces are not the object itself, we must
  105. * delegate to implement the correct behavior.
  106. */
  107. class CImpIDirectInputEffectDriver : public IDirectInputEffectDriver
  108. {
  109. private:
  110. DWORD m_cRef; //For debugging
  111. PCDirectInputEffectDriver m_pObj; //Back pointer for delegation
  112. // SideWinder Force Feedback Device
  113. CJoltMidi *m_pJoltMidi;
  114. public:
  115. CImpIDirectInputEffectDriver(PCDirectInputEffectDriver);
  116. ~CImpIDirectInputEffectDriver(void);
  117. // CEffect access methods
  118. CJoltMidi *CJoltMidiPtrOf() { return m_pJoltMidi; }
  119. void SetJoltMidiPtr(CJoltMidi* pJoltMidi) { m_pJoltMidi = pJoltMidi; }
  120. //IUnknown members
  121. STDMETHODIMP QueryInterface(REFIID, PPVOID);
  122. STDMETHODIMP_(DWORD) AddRef(void);
  123. STDMETHODIMP_(DWORD) Release(void);
  124. /*** IDirectInputEffectDriver methods ***/
  125. STDMETHOD(DeviceID)(THIS_ DWORD,DWORD,DWORD,DWORD,LPVOID);
  126. STDMETHOD(GetVersions)(THIS_ LPDIDRIVERVERSIONS);
  127. STDMETHOD(Escape)(THIS_ DWORD,DWORD,LPDIEFFESCAPE);
  128. STDMETHOD(SetGain)(THIS_ DWORD,DWORD);
  129. STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD,DWORD);
  130. STDMETHOD(GetForceFeedbackState)(THIS_ DWORD,LPDIDEVICESTATE);
  131. STDMETHOD(DownloadEffect)(THIS_ DWORD,DWORD,LPDWORD,LPCDIEFFECT,DWORD);
  132. STDMETHOD(DestroyEffect)(THIS_ DWORD,DWORD);
  133. STDMETHOD(StartEffect)(THIS_ DWORD,DWORD,DWORD,DWORD);
  134. STDMETHOD(StopEffect)(THIS_ DWORD,DWORD);
  135. STDMETHOD(GetEffectStatus)(THIS_ DWORD,DWORD,LPDWORD);
  136. };
  137. #endif _SW_OBJEC_SEEN