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.

168 lines
4.5 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999 - 1999
  6. //
  7. // File: dinputeffectobj.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "stdafx.h"
  11. #include "Direct.h"
  12. #include "dms.h"
  13. #include "dInputEffectObj.h"
  14. extern HRESULT FixUpCoverEffect(GUID g, DIEFFECT_CDESC *cover,DIEFFECT *realEffect);
  15. extern HRESULT FixUpRealEffect(GUID g,DIEFFECT *realEffect,DIEFFECT_CDESC *cover);
  16. extern BSTR DINPUTGUIDtoBSTR(LPGUID g);
  17. CONSTRUCTOR(_dxj_DirectInputEffect, {});
  18. DESTRUCTOR(_dxj_DirectInputEffect, {});
  19. GETSET_OBJECT(_dxj_DirectInputEffect);
  20. STDMETHODIMP C_dxj_DirectInputEffectObject::download()
  21. {
  22. HRESULT hr;
  23. hr=m__dxj_DirectInputEffect->Download();
  24. return hr;
  25. }
  26. STDMETHODIMP C_dxj_DirectInputEffectObject::getEffectGuid(BSTR *guid)
  27. {
  28. HRESULT hr;
  29. GUID g;
  30. if (!guid) return E_INVALIDARG;
  31. hr=m__dxj_DirectInputEffect->GetEffectGuid(&g);
  32. *guid=DINPUTGUIDtoBSTR(&g);
  33. return hr;
  34. }
  35. STDMETHODIMP C_dxj_DirectInputEffectObject::getEffectStatus(long *ret)
  36. {
  37. HRESULT hr;
  38. if (!ret) return E_INVALIDARG;
  39. hr=m__dxj_DirectInputEffect->GetEffectStatus((DWORD*)ret);
  40. return hr;
  41. }
  42. STDMETHODIMP C_dxj_DirectInputEffectObject::start(
  43. /* [in] */ long iterations,
  44. /* [in] */ long flags)
  45. {
  46. HRESULT hr;
  47. hr=m__dxj_DirectInputEffect->Start((DWORD)iterations,(DWORD)flags);
  48. return hr;
  49. }
  50. STDMETHODIMP C_dxj_DirectInputEffectObject::stop()
  51. {
  52. HRESULT hr;
  53. hr=m__dxj_DirectInputEffect->Stop();
  54. return hr;
  55. }
  56. STDMETHODIMP C_dxj_DirectInputEffectObject::unload()
  57. {
  58. HRESULT hr;
  59. hr=m__dxj_DirectInputEffect->Unload();
  60. return hr;
  61. }
  62. STDMETHODIMP C_dxj_DirectInputEffectObject::setParameters(
  63. /* [in] */ DIEFFECT_CDESC __RPC_FAR *effectInfo, long flags)
  64. {
  65. DIEFFECT realEffect;
  66. HRESULT hr;
  67. GUID g;
  68. m__dxj_DirectInputEffect->GetEffectGuid(&g);
  69. hr=FixUpRealEffect(g,&realEffect,effectInfo);
  70. if FAILED(hr) return hr;
  71. hr=m__dxj_DirectInputEffect->SetParameters(&realEffect,(DWORD) flags);
  72. return hr;
  73. }
  74. #define DICONDITION_USE_BOTH_AXIS 1
  75. #define DICONDITION_USE_DIRECTION 2
  76. STDMETHODIMP C_dxj_DirectInputEffectObject::getParameters(
  77. /* [in] */ DIEFFECT_CDESC __RPC_FAR *effectInfo)
  78. {
  79. HRESULT hr;
  80. GUID g;
  81. DIEFFECT *pRealEffect=(DIEFFECT*)effectInfo;
  82. DWORD dwFlags= DIEP_ALLPARAMS;
  83. if (!effectInfo) return E_INVALIDARG;
  84. ZeroMemory(pRealEffect,sizeof(DIEFFECT_CDESC));
  85. if (!pRealEffect->dwFlags) pRealEffect->dwFlags = DIEFF_OBJECTOFFSETS | DIEFF_POLAR;
  86. pRealEffect->dwSize =sizeof(DIEFFECT);
  87. pRealEffect->lpEnvelope =(DIENVELOPE*)&(effectInfo->envelope);
  88. pRealEffect->lpEnvelope->dwSize=sizeof(DIENVELOPE);
  89. pRealEffect->cAxes = 2;
  90. pRealEffect->rglDirection =(long*)&(effectInfo->x);
  91. hr=m__dxj_DirectInputEffect->GetEffectGuid(&g);
  92. if FAILED(hr) return hr;
  93. if (g==GUID_ConstantForce)
  94. {
  95. pRealEffect->lpvTypeSpecificParams =&(effectInfo->constantForce);
  96. pRealEffect->cbTypeSpecificParams =sizeof(DICONSTANTFORCE);
  97. }
  98. else if ((g==GUID_Square)||(g==GUID_Triangle)||(g==GUID_SawtoothUp)||(g==GUID_SawtoothDown)||(g==GUID_Sine))
  99. {
  100. pRealEffect->lpvTypeSpecificParams =&(effectInfo->periodicForce);
  101. pRealEffect->cbTypeSpecificParams =sizeof(DIPERIODIC);
  102. }
  103. else if ((g==GUID_Spring)|| (g==GUID_Damper)|| (g==GUID_Inertia)|| (g==GUID_Friction)){
  104. pRealEffect->cbTypeSpecificParams =sizeof(DICONDITION)*2;
  105. pRealEffect->lpvTypeSpecificParams =&(effectInfo->conditionX);
  106. }
  107. else if (g==GUID_RampForce){
  108. pRealEffect->lpvTypeSpecificParams =&(effectInfo->rampForce);
  109. pRealEffect->cbTypeSpecificParams =sizeof(DIRAMPFORCE);
  110. }
  111. else {
  112. pRealEffect->lpvTypeSpecificParams =NULL;
  113. pRealEffect->cbTypeSpecificParams =0;
  114. dwFlags= dwFlags -DIEP_TYPESPECIFICPARAMS;
  115. }
  116. effectInfo->axisOffsets.x=DIJOFS_X;
  117. effectInfo->axisOffsets.y=DIJOFS_Y;
  118. pRealEffect->rgdwAxes=(DWORD*)&(effectInfo->axisOffsets);
  119. hr=m__dxj_DirectInputEffect->GetParameters(pRealEffect, dwFlags);
  120. if FAILED(hr) return hr;
  121. if (pRealEffect->cbTypeSpecificParams == sizeof(DICONDITION)*2)
  122. effectInfo->conditionFlags=DICONDITION_USE_BOTH_AXIS;
  123. else
  124. effectInfo->conditionFlags=DICONDITION_USE_DIRECTION;
  125. if (pRealEffect->lpEnvelope){
  126. effectInfo->bUseEnvelope=VARIANT_TRUE;
  127. }
  128. return hr;
  129. }