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.

158 lines
5.9 KiB

  1. //@doc
  2. /******************************************************
  3. **
  4. ** @module FFDEVICE.H | Definition file for FFDevice class
  5. **
  6. ** Description:
  7. ** This is the generic FF device. Independant of
  8. ** Firmawate and how data reaches the device
  9. ** This first implementation uses the old CJoltMidi to
  10. ** minimize new code.
  11. **
  12. ** History:
  13. ** Created 11/17/97 Matthew L. Coill (mlc)
  14. **
  15. ** (c) 1986-1997 Microsoft Corporation. All Rights Reserved.
  16. ******************************************************/
  17. #ifndef __FFDEVICE_H__
  18. #define __FFDEVICE_H__
  19. #include <dinput.h>
  20. #include "vxdioctl.hpp" // Joychannel status def
  21. #include "Effect.h"
  22. #include "Hau_Midi.hpp" // For definition of MAX_EFFECT_IDS
  23. #define RAW_FORCE_ALIAS 0xFF
  24. // Currently there is some extra stuff in here, that should be part of other objects
  25. struct DEVICESTATE200 // sizeof DWORD
  26. {
  27. #pragma pack(1)
  28. unsigned short m_ErrorStatus : 3;
  29. unsigned short m_HardwareReset : 1;
  30. unsigned short m_Uncalibrated : 1;
  31. unsigned short m_HostDisable : 1;
  32. unsigned short m_HostPause : 1;
  33. unsigned short m_UserDisable : 1;
  34. unsigned short m_RS232Mode : 1;
  35. unsigned short m_BandwidthExceeded : 1;
  36. unsigned short m_HostReset : 1;
  37. unsigned short m_NoPedals : 1;
  38. unsigned short m_Fluff : 4;
  39. unsigned short m_Fluff2 : 16;
  40. #pragma pack()
  41. };
  42. //
  43. // @class ForceFeedbackDevice class
  44. //
  45. class ForceFeedbackDevice
  46. {
  47. //@access Constructor/Destructor
  48. public:
  49. //@cmember constructor
  50. ForceFeedbackDevice();
  51. //@cmember destructor
  52. ~ForceFeedbackDevice();
  53. BOOL DetectHardware();
  54. // Effect related functions
  55. InternalEffect* GetEffect(DWORD effectID) const;
  56. InternalEffect* RemoveEffect(DWORD effectID);
  57. InternalEffect* CreateEffect(DWORD effectType, const DIEFFECT& diEffect, DWORD& dnloadID, HRESULT& hr, BOOL paramCheck);
  58. void SetEffect(BYTE globalID, InternalEffect* pEffect);
  59. BYTE GetNextCreationID() const;
  60. HRESULT InitRTCSpring(DWORD dwDeviceID);
  61. HRESULT InitJoystickParams(DWORD dwDeviceID);
  62. void StateChange(DWORD dwDeviceID, DWORD newStateFlags); // Called after new state sent to the stick
  63. DWORD GetDIState() const { return m_DIStateFlags; }
  64. // OS Version functions
  65. DWORD GetPlatform() const { return m_OSVersion.dwPlatformId; }
  66. DWORD GetPlatformMajorVersion() const { return m_OSVersion.dwMajorVersion; }
  67. DWORD GetPlatformMinorVersion() const { return m_OSVersion.dwMinorVersion; }
  68. DWORD GetOSBuildNumber() const { return m_OSVersion.dwBuildNumber; }
  69. BOOL IsOSNT5() const { return ((m_OSVersion.dwPlatformId == VER_PLATFORM_WIN32_NT) && (m_OSVersion.dwMajorVersion == 5)); }
  70. // Firmware version functions
  71. void SetFirmwareVersion(DWORD dwDeviceID, DWORD major, DWORD minor);
  72. DWORD GetFirmwareVersionMajor() const { return m_FirmwareVersionMajor; }
  73. DWORD GetFirmwareVersionMinor() const { return m_FirmwareVersionMinor; }
  74. USHORT GetAckNackMethod(USHORT methodIndex) const { return USHORT((m_FirmwareAckNackValues >> methodIndex) & 0x00000003); }
  75. short GetYMappingPercent(UINT index) const;
  76. DWORD GetSpringOffset() const { return m_SpringOffset; }
  77. // Driver version functions
  78. DWORD GetDriverVersionMajor() const { return m_DriverVersionMajor; }
  79. DWORD GetDriverVersionMinor() const { return m_DriverVersionMinor; }
  80. void SetDriverVersion(DWORD major, DWORD minor);
  81. // Status update and retreival
  82. HRESULT QueryStatus();
  83. DEVICESTATE200 GetState200() const { return m_Version200State; }
  84. SWDEVICESTATE GetState1XX() const { return m_Version1XXState; }
  85. // If we were supporting jolt switch off firmware version
  86. BOOL IsHardwareReset() const { return (m_Version200State.m_HardwareReset != 0); }
  87. BOOL IsSerial() const { return (m_Version200State.m_RS232Mode != 0); }
  88. BOOL IsHostReset() const { return (m_Version200State.m_HostReset != 0); }
  89. BOOL IsShutdown() const { return IsHostReset(); }
  90. BOOL IsHostPause() const { return (m_Version200State.m_HostPause != 0); }
  91. BOOL IsUserDisable() const { return (m_Version200State.m_UserDisable != 0); }
  92. BOOL IsHostDisable() const { return (m_Version200State.m_HostDisable != 0); }
  93. unsigned short ErrorStatus() const { return m_Version200State.m_ErrorStatus; }
  94. // Status packet ptr
  95. JOYCHANNELSTATUS* GetLastStatusPacket() { return &m_LastStatusPacket; }
  96. void SetDeviceIDFromStatusPacket(DWORD globalID);
  97. //@access private data members
  98. private:
  99. HRESULT InitRTCSpring1XX(DWORD dwDeviceID);
  100. HRESULT InitRTCSpring200(DWORD dwDeviceID);
  101. InternalEffect* CreateConditionEffect(DWORD minorType, const DIEFFECT& diEffect, HRESULT& hr);
  102. InternalEffect* CreateCustomForceEffect(DWORD minorType, const DIEFFECT& diEffect, HRESULT& hr);
  103. InternalEffect* CreatePeriodicEffect(DWORD minorType, const DIEFFECT& diEffect, HRESULT& hr);
  104. InternalEffect* CreateConstantForceEffect(DWORD minorType, const DIEFFECT& diEffect, HRESULT& hr);
  105. InternalEffect* CreateRampForceEffect(DWORD minorType, const DIEFFECT& diEffect, HRESULT& hr);
  106. InternalEffect* CreateRTCSpringEffect(DWORD minorType, const DIEFFECT& diEffect);
  107. InternalEffect* CreateVFXEffect(const DIEFFECT& diEffect, HRESULT& hr);
  108. InternalEffect* CreateVFXEffectFromBuffer(const DIEFFECT& diEffect, BYTE* pEffectBuffer, ULONG numBufferBytes, HRESULT& hr);
  109. HRESULT SendRawForce(const DIEFFECT& diEffect, BOOL paramCheck);
  110. InternalEffect* m_EffectList[MAX_EFFECT_IDS];
  111. InternalEffect* m_SystemEffect;
  112. // Device state
  113. SWDEVICESTATE m_Version1XXState;
  114. DEVICESTATE200 m_Version200State;
  115. DWORD m_DIStateFlags;
  116. JOYCHANNELSTATUS m_LastStatusPacket;
  117. // Version crap
  118. OSVERSIONINFO m_OSVersion;
  119. DWORD m_FirmwareVersionMajor;
  120. DWORD m_FirmwareVersionMinor;
  121. DWORD m_FirmwareAckNackValues;
  122. DWORD m_DriverVersionMajor;
  123. DWORD m_DriverVersionMinor;
  124. DWORD m_SpringOffset;
  125. DWORD m_Mapping;
  126. long int m_RawForceX;
  127. long int m_RawForceY;
  128. short m_PercentMappings[14];
  129. };
  130. extern ForceFeedbackDevice g_ForceFeedbackDevice;
  131. #endif __FFDEVICE_H__