Source code of Windows XP (NT5)
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.

187 lines
3.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999 - 1999
  6. //
  7. // File: dienumeffectsobj.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "stdafx.h"
  11. #include "Direct.h"
  12. #include "dms.h"
  13. #include "dIEnumEffectsObj.h"
  14. extern BSTR DINPUTGUIDtoBSTR(LPGUID pGuid);
  15. extern HRESULT DINPUTBSTRtoGUID(LPGUID pGuid,BSTR bstr);
  16. ////////////////////////////////////////////////////////////////////////////
  17. /*extern "C"*/ BOOL CALLBACK objEnumInputEffectsCallback(
  18. LPCDIEFFECTINFOW pdei,
  19. LPVOID lpArg
  20. )
  21. {
  22. DPF(1,"Entered objEnumInputEffectsCallback\r\n");
  23. if (!pdei) return FALSE;
  24. C_dxj_DirectInputEnumEffectsObject *pObj=(C_dxj_DirectInputEnumEffectsObject*)lpArg;
  25. if (pObj==NULL) return FALSE;
  26. if (pObj->m_nCount >= pObj->m_nMax)
  27. {
  28. pObj->m_nMax += 10;
  29. if (pObj->m_pList){
  30. pObj->m_pList=(DIEFFECTINFOW*)realloc(pObj->m_pList,sizeof(DIEFFECTINFOW)* pObj->m_nMax);
  31. }
  32. else {
  33. pObj->m_pList=(DIEFFECTINFOW*)malloc( sizeof(DIEFFECTINFOW)* pObj->m_nMax);
  34. }
  35. if (pObj->m_pList==NULL)
  36. {
  37. pObj->m_bProblem=TRUE;
  38. return FALSE;
  39. }
  40. }
  41. memcpy(&(pObj->m_pList[pObj->m_nCount]),pdei,sizeof(DIEFFECTINFOW));
  42. DPF1(1,"objEnumInputEffects '%s'\n",pdei->tszName);
  43. pObj->m_nCount++;
  44. return TRUE;
  45. }
  46. C_dxj_DirectInputEnumEffectsObject::C_dxj_DirectInputEnumEffectsObject()
  47. {
  48. m_nMax=0;
  49. m_pList=NULL;
  50. m_nCount=0;
  51. m_bProblem=FALSE;
  52. }
  53. C_dxj_DirectInputEnumEffectsObject::~C_dxj_DirectInputEnumEffectsObject()
  54. {
  55. //empty list
  56. if (m_pList) free(m_pList);
  57. }
  58. HRESULT C_dxj_DirectInputEnumEffectsObject::create(LPDIRECTINPUTDEVICE8W pDI,long effectType,I_dxj_DirectInputEnumEffects **ppRet)
  59. {
  60. HRESULT hr;
  61. C_dxj_DirectInputEnumEffectsObject *pNew=NULL;
  62. *ppRet=NULL;
  63. pNew= new CComObject<C_dxj_DirectInputEnumEffectsObject>;
  64. if (!pNew) return E_OUTOFMEMORY;
  65. pNew->m_bProblem=FALSE;
  66. hr = pDI->EnumEffects(
  67. objEnumInputEffectsCallback,
  68. (void*)pNew,
  69. (DWORD) effectType);
  70. if (pNew->m_bProblem) hr=E_OUTOFMEMORY;
  71. if FAILED(hr)
  72. {
  73. if (pNew->m_pList) free(pNew->m_pList);
  74. pNew->m_pList=NULL;
  75. delete pNew;
  76. return hr;
  77. }
  78. hr=pNew->QueryInterface(IID_I_dxj_DirectInputEnumEffects,(void**)ppRet);
  79. return hr;
  80. }
  81. HRESULT C_dxj_DirectInputEnumEffectsObject::getEffectGuid( long index, BSTR *ret)
  82. {
  83. if (m_pList==NULL) return E_FAIL;
  84. if (index < 1) return E_INVALIDARG;
  85. if (index > m_nCount) return E_INVALIDARG;
  86. *ret=DINPUTGUIDtoBSTR(&(m_pList[index-1].guid));
  87. return S_OK;
  88. }
  89. HRESULT C_dxj_DirectInputEnumEffectsObject::getName( long index, BSTR *ret)
  90. {
  91. if (m_pList==NULL) return E_FAIL;
  92. if (index < 1) return E_INVALIDARG;
  93. if (index > m_nCount) return E_INVALIDARG;
  94. USES_CONVERSION;
  95. *ret=SysAllocString(m_pList[index-1].tszName); //T2BSTR(m_pList[index-1].tszName);
  96. return S_OK;
  97. }
  98. HRESULT C_dxj_DirectInputEnumEffectsObject::getType( long index, long *ret)
  99. {
  100. if (m_pList==NULL) return E_FAIL;
  101. if (index < 1) return E_INVALIDARG;
  102. if (index > m_nCount) return E_INVALIDARG;
  103. *ret=(long)m_pList[index-1].dwEffType;
  104. return S_OK;
  105. }
  106. HRESULT C_dxj_DirectInputEnumEffectsObject::getStaticParams( long index, long *ret)
  107. {
  108. if (m_pList==NULL) return E_FAIL;
  109. if (index < 1) return E_INVALIDARG;
  110. if (index > m_nCount) return E_INVALIDARG;
  111. *ret=(long)m_pList[index-1].dwStaticParams;
  112. return S_OK;
  113. }
  114. HRESULT C_dxj_DirectInputEnumEffectsObject::getDynamicParams( long index, long *ret)
  115. {
  116. if (m_pList==NULL) return E_FAIL;
  117. if (index < 1) return E_INVALIDARG;
  118. if (index > m_nCount) return E_INVALIDARG;
  119. *ret=(long)m_pList[index-1].dwDynamicParams;
  120. return S_OK;
  121. }
  122. HRESULT C_dxj_DirectInputEnumEffectsObject::getCount(long *retVal)
  123. {
  124. *retVal=m_nCount;
  125. return S_OK;
  126. }