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.

152 lines
4.6 KiB

  1. //@doc
  2. /******************************************************
  3. **
  4. ** @module DPACK.H | Definition file for DataPackager and DataPacket
  5. **
  6. ** Description:
  7. ** The Data Packager allows virtualization of the
  8. ** commands into the different firmware versions packet format
  9. ** DataPackager - Base class that defines the functionality of all DataPackagers
  10. ** DataPackager100 - DataPackager for Firmware 1.**
  11. ** DataPackager200 - DataPackager for Firmware 2.**
  12. **
  13. ** Classes:
  14. ** DataPackager
  15. ** DataPackager100 - DataPackager for Firmware 1.**
  16. ** DataPackager200 - DataPackager for Firmware 2.**
  17. ** DataPacket - Array of bytes for download. If there are 32 or less items
  18. ** it is fixed on the stack if more are requested it is heap based.
  19. ** (most things use less than 32)
  20. **
  21. ** History:
  22. ** Created 1/05/98 Matthew L. Coill (mlc)
  23. **
  24. ** (c) 1986-1998 Microsoft Corporation. All Rights Reserved.
  25. ******************************************************/
  26. #ifndef __DPACK_H__
  27. #define __DPACK_H__
  28. #include "DX_Map.hpp"
  29. #ifndef override
  30. #define override
  31. #endif
  32. #define MODIFY_CMD_200 0xF1
  33. #define EFFECT_CMD_200 0xF2
  34. class InternalEffect;
  35. //
  36. // @class DataPacket class
  37. //
  38. class DataPacket
  39. {
  40. //@access Constructor
  41. public:
  42. //@cmember constructor
  43. DataPacket();
  44. ~DataPacket();
  45. BOOL AllocateBytes(DWORD numBytes);
  46. BYTE* m_pData;
  47. BYTE m_pFixedData[32];
  48. DWORD m_BytesOfData;
  49. UINT m_AckNackMethod;
  50. DWORD m_AckNackDelay;
  51. DWORD m_AckNackTimeout;
  52. DWORD m_NumberOfRetries;
  53. };
  54. typedef DataPacket* DataPacketPtr;
  55. //
  56. // @class DataPackager class
  57. //
  58. class DataPackager
  59. {
  60. //@access Constructor
  61. public:
  62. //@cmember constructor
  63. DataPackager();
  64. virtual ~DataPackager();
  65. void SetDirectInputVersion(DWORD diVersion) { m_DirectInputVersion = diVersion; }
  66. // Commands to be packaged
  67. virtual HRESULT Escape(DWORD effectID, LPDIEFFESCAPE pEscape);
  68. virtual HRESULT SetGain(DWORD gain);
  69. virtual HRESULT SendForceFeedbackCommand(DWORD state);
  70. virtual HRESULT GetForceFeedbackState(DIDEVICESTATE* pDeviceState);
  71. virtual HRESULT CreateEffect(const InternalEffect& effect, DWORD diFlags);
  72. virtual HRESULT ModifyEffect(InternalEffect& currentEffect, InternalEffect& newEffect, DWORD modFlags);
  73. virtual HRESULT DestroyEffect(DWORD downloadID);
  74. virtual HRESULT StartEffect(DWORD downloadID, DWORD mode, DWORD count);
  75. virtual HRESULT StopEffect(DWORD downloadID);
  76. virtual HRESULT GetEffectStatus(DWORD downloadID);
  77. virtual HRESULT SetMidiChannel(BYTE channel);
  78. virtual HRESULT ForceOut(LONG lForceData, ULONG ulAxisMask);
  79. // Access to packages
  80. USHORT GetNumDataPackets() const { return m_NumDataPackets; }
  81. DataPacket* GetPacket(USHORT packet) const;
  82. void ClearPackets();
  83. BOOL AllocateDataPackets(USHORT numPackets);
  84. private:
  85. DataPacket* m_pDataPackets;
  86. DataPacket m_pStaticPackets[3];
  87. USHORT m_NumDataPackets;
  88. DWORD m_DirectInputVersion;
  89. };
  90. //
  91. // @class DataPackager class
  92. //
  93. class DataPackager100 : public DataPackager
  94. {
  95. //@access Constructor
  96. public:
  97. //@cmember constructor
  98. DataPackager100() : DataPackager() {};
  99. // Commands to be packaged
  100. override HRESULT SetGain(DWORD gain);
  101. override HRESULT SendForceFeedbackCommand(DWORD state);
  102. override HRESULT GetForceFeedbackState(DIDEVICESTATE* pDeviceState);
  103. override HRESULT DestroyEffect(DWORD downloadID);
  104. override HRESULT StartEffect(DWORD downloadID, DWORD mode, DWORD count);
  105. override HRESULT StopEffect(DWORD downloadID);
  106. override HRESULT GetEffectStatus(DWORD downloadID);
  107. override HRESULT SetMidiChannel(BYTE channel);
  108. override HRESULT ForceOut(LONG lForceData, ULONG ulAxisMask);
  109. };
  110. //
  111. // @class DataPackager class
  112. //
  113. class DataPackager200 : public DataPackager
  114. {
  115. //@access Constructor
  116. public:
  117. //@cmember constructor
  118. DataPackager200() : DataPackager() {};
  119. // Commands to be packaged
  120. override HRESULT SetGain(DWORD gain);
  121. override HRESULT SendForceFeedbackCommand(DWORD state);
  122. override HRESULT GetForceFeedbackState(DIDEVICESTATE* pDeviceState);
  123. override HRESULT CreateEffect(const InternalEffect& effect, DWORD diFlags);
  124. override HRESULT DestroyEffect(DWORD downloadID);
  125. override HRESULT StartEffect(DWORD downloadID, DWORD mode, DWORD count);
  126. override HRESULT StopEffect(DWORD downloadID);
  127. override HRESULT GetEffectStatus(DWORD downloadID);
  128. override HRESULT ForceOut(LONG forceData, ULONG axisMask);
  129. private:
  130. BYTE EffectCommandParity(const DataPacket& packet) const;
  131. BYTE DeviceCommandParity(const DataPacket& packet) const;
  132. };
  133. extern DataPackager* g_pDataPackager;
  134. #endif __DPACK_H__