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.

177 lines
5.5 KiB

  1. /****************************************************************************
  2. MODULE: SW_OBJEC.CPP
  3. Tab Settings: 5 9
  4. Copyright 1995, 1996, Microsoft Corporation, All Rights Reserved.
  5. PURPOSE: IUnknown Method(s) for DirectInputEffectDriver Class objects
  6. FUNCTIONS:
  7. Author(s): Name:
  8. ---------- ----------------
  9. MEA Manolito E. Adan
  10. Revision History:
  11. -----------------
  12. Version Date Author Comments
  13. ------- ------ ----- -------------------------------------------
  14. 1.0 06-Feb-97 MEA original, Based on SWForce
  15. 23-Feb-97 MEA Modified for DirectInput FF Device Driver
  16. 16-Mar-99 waltw Moved CJoltMidi initialization from
  17. CDirectInputEffectDriver::Init to
  18. CImpIDirectInputEffectDriver::DeviceID
  19. ****************************************************************************/
  20. #include "SW_objec.hpp"
  21. //
  22. // External Data
  23. //
  24. #ifdef _DEBUG
  25. extern char g_cMsg[160];
  26. #endif
  27. extern HANDLE g_hSWFFDataMutex;
  28. // ****************************************************************************
  29. // *** --- Member functions for base class CDirectInputEffectDriver
  30. //
  31. // ****************************************************************************
  32. //
  33. // ----------------------------------------------------------------------------
  34. // Function: CDirectInputEffectDriver::CDirectInputEffectDriver
  35. // Purpose: Constructor(s)/Destructor for CDirectInputEffectDriver Object
  36. // Parameters: LPUNKNOWN pUnkOuter - Ptr to a controlling unknown.
  37. // PFNDESTROYED pfnDestroy - Call when object is destroyed.
  38. // Returns:
  39. // Algorithm:
  40. // ----------------------------------------------------------------------------
  41. CDirectInputEffectDriver::CDirectInputEffectDriver(LPUNKNOWN pUnkOuter, PFNDESTROYED pfnDestroy)
  42. {
  43. #ifdef _DEBUG
  44. OutputDebugString("CDirectInputEffectDriver::CDirectInputEffectDriver()\r\n");
  45. #endif
  46. m_cRef=0;
  47. m_pImpIDirectInputEffectDriver=NULL;
  48. m_pUnkOuter=pUnkOuter;
  49. m_pfnDestroy=pfnDestroy;
  50. return;
  51. }
  52. CDirectInputEffectDriver::~CDirectInputEffectDriver(void)
  53. {
  54. #ifdef _DEBUG
  55. OutputDebugString("CDirectInputEffectDriver::~CDirectInputEffectDriver()\r\n");
  56. #endif
  57. //Delete the interface implementations created in Init
  58. DeleteInterfaceImp(m_pImpIDirectInputEffectDriver);
  59. return;
  60. }
  61. // ----------------------------------------------------------------------------
  62. // Function: CDirectInputEffectDriver::Init
  63. // Purpose: Instantiates the interface implementations for this object.
  64. // Parameters: none
  65. //
  66. // Returns: BOOL - TRUE if initialization succeeds, FALSE otherwise.
  67. // Algorithm:
  68. //
  69. // Note:
  70. // Creating the interfaces means creating instances of
  71. // the interface implementation classes. The constructor
  72. // parameters is a pointer to CDirectInputEffectDriver that has the
  73. // IUnknown functions to which the interface implementations
  74. // delegate.
  75. //
  76. // ----------------------------------------------------------------------------
  77. BOOL CDirectInputEffectDriver::Init(void)
  78. {
  79. #ifdef _DEBUG
  80. OutputDebugString("CDirectInputEffectDriver::Init\n");
  81. #endif
  82. m_pImpIDirectInputEffectDriver=new CImpIDirectInputEffectDriver(this);
  83. if (NULL==m_pImpIDirectInputEffectDriver)
  84. return FALSE;
  85. return TRUE;
  86. }
  87. // ----------------------------------------------------------------------------
  88. // Function: CDirectInputEffectDriver::QueryInterface
  89. // Purpose: Manages the interfaces for this object which supports the
  90. // IUnknown, and IDirectInputEffectDriver interfaces.
  91. //
  92. // Parameters: REFIID riid - REFIID of the interface to return.
  93. // PPVOID ppv - PPVOID in which to store the pointer.
  94. //
  95. //
  96. // Returns: HRESULT NOERROR on success, E_NOINTERFACE if the
  97. // interface is not supported.
  98. //
  99. // Algorithm:
  100. //
  101. // Note:
  102. // IUnknown comes from CDirectInputEffectDriver. Note that here and in
  103. // the lines below we do not need to explicitly typecast
  104. // the object pointers into interface pointers because
  105. // the vtables are identical. If we had additional virtual
  106. // member functions in the object, we would have to cast
  107. // in order to set the right vtable. This is demonstrated
  108. // in the multiple-inheritance version, CObject3.
  109. //
  110. // ----------------------------------------------------------------------------
  111. STDMETHODIMP CDirectInputEffectDriver::QueryInterface(REFIID riid, PPVOID ppv)
  112. {
  113. //Always NULL the out-parameters
  114. *ppv=NULL;
  115. if (IID_IUnknown==riid)
  116. *ppv=this;
  117. //Other interfaces come from interface implementations
  118. if (IID_IDirectInputEffectDriver==riid)
  119. *ppv=m_pImpIDirectInputEffectDriver;
  120. if (NULL==*ppv)
  121. return ResultFromScode(E_NOINTERFACE);
  122. //AddRef any interface we'll return.
  123. ((LPUNKNOWN)*ppv)->AddRef();
  124. return NOERROR;
  125. }
  126. // ----------------------------------------------------------------------------
  127. // Function: CDirectInputEffectDriver::AddRef and CDirectInputEffectDriver::Release
  128. // Purpose: Reference counting members. When Release sees a zero count
  129. // the object destroys itself.
  130. //
  131. // Parameters: none
  132. //
  133. // Returns: DWORD m_cRef value
  134. //
  135. // Algorithm:
  136. //
  137. // Note:
  138. //
  139. // ----------------------------------------------------------------------------
  140. DWORD CDirectInputEffectDriver::AddRef(void)
  141. {
  142. return ++m_cRef;
  143. }
  144. DWORD CDirectInputEffectDriver::Release(void)
  145. {
  146. if (0!=--m_cRef) return m_cRef;
  147. delete this;
  148. return 0;
  149. }