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.

607 lines
20 KiB

  1. /****************************************************************************
  2. MODULE: MIDI_OBJ.HPP
  3. Tab Settings: 5 9
  4. PURPOSE: Header to define SWFF MIDI device objects
  5. FUNCTIONS:
  6. Classes with members and methods are kept in this header file
  7. Version Date Author Comments
  8. 0.1 10-Sep-96 MEA original
  9. 1.1 17-Mar-97 MEA DX-FF mode
  10. ****************************************************************************/
  11. #ifndef MIDI_OBJ_SEEN
  12. #define MIDI_OBJ_SEEN
  13. #include <windows.h>
  14. #include <mmsystem.h>
  15. #include <assert.h>
  16. #include "hau_midi.hpp"
  17. #include "midi.hpp"
  18. #include "dinput.h"
  19. #include "vxdioctl.hpp"
  20. #include "sw_error.hpp"
  21. #define MAX_SCALE 1.27 // 1 to 100 = 1 to 127
  22. #define TICKRATE 2 // 2 ms per tick divisor
  23. #define SWFF_SHAREDMEM_FILE "SWFF_SharedMemFile"
  24. #define SWFF_MIDIEVENT "SWFFMidiEvent\0"
  25. #define SWFF_SHAREDMEM_MUTEX "SWFFSharedMemMutex\0"
  26. #define SWFF_JOLTOUTPUTDATA_MUTEX "SWFFJoltOutputDataMutex\0"
  27. #define SIZE_SHARED_MEMORY 1024 // 1024 bytes
  28. #define MUTEX_TIMEOUT 10000 // 10 seconds timeout
  29. // spring
  30. #define DEF_SCALE_KX 100
  31. #define DEF_SCALE_KY 100
  32. // damper
  33. #define DEF_SCALE_BX 100
  34. #define DEF_SCALE_BY 100
  35. // inertia
  36. #define DEF_SCALE_MX 80
  37. #define DEF_SCALE_MY 80
  38. // friction
  39. #define DEF_SCALE_FX 100
  40. #define DEF_SCALE_FY 100
  41. // wall
  42. #define DEF_SCALE_W 100
  43. typedef struct _FIRMWARE_PARAMS
  44. {
  45. DWORD dwScaleKx;
  46. DWORD dwScaleKy;
  47. DWORD dwScaleBx;
  48. DWORD dwScaleBy;
  49. DWORD dwScaleMx;
  50. DWORD dwScaleMy;
  51. DWORD dwScaleFx;
  52. DWORD dwScaleFy;
  53. DWORD dwScaleW;
  54. } FIRMWARE_PARAMS, *PFIRMWARE_PARAMS;
  55. void GetFirmwareParams(UINT nJoystickID, PFIRMWARE_PARAMS pFirmwareParams);
  56. typedef struct _SYSTEM_PARAMS
  57. {
  58. RTCSPRING_PARAM RTCSpringParam;
  59. } SYSTEM_PARAMS, *PSYSTEM_PARAMS;
  60. void GetSystemParams(UINT nJoystickID, PSYSTEM_PARAMS pSystemParams);
  61. #define DEF_XY_CONST 22500
  62. #define DEF_ROT_CONST 17272
  63. #define DEF_SLDR_CONST 126
  64. #define DEF_AJ_POS 4
  65. #define DEF_AJ_ROT 2
  66. #define DEF_AJ_SLDR 2
  67. #define DEF_SPR_SCL ((DWORD)-256)
  68. #define DEF_BMP_SCL 60
  69. #define DEF_DMP_SCL ((DWORD)-3436)
  70. #define DEF_INERT_SCL ((DWORD)-2562)
  71. #define DEF_VEL_OFFSET_SCL 54
  72. #define DEF_ACC_OFFSET_SCL 40
  73. #define DEF_Y_MOT_BOOST 19661
  74. #define DEF_X_MOT_SATURATION 254
  75. typedef struct _JOYSTICK_PARAMS
  76. {
  77. DWORD dwXYConst;
  78. DWORD dwRotConst;
  79. DWORD dwSldrConst;
  80. DWORD dwAJPos;
  81. DWORD dwAJRot;
  82. DWORD dwAJSldr;
  83. DWORD dwSprScl;
  84. DWORD dwBmpScl;
  85. DWORD dwDmpScl;
  86. DWORD dwInertScl;
  87. DWORD dwVelOffScl;
  88. DWORD dwAccOffScl;
  89. DWORD dwYMotBoost;
  90. DWORD dwXMotSat;
  91. DWORD dwReserved;
  92. DWORD dwMasterGain;
  93. } JOYSTICK_PARAMS, *PJOYSTICK_PARAMS;
  94. void GetJoystickParams(UINT nJoystickID, PJOYSTICK_PARAMS pJoystickParams);
  95. void UpdateJoystickParams(PJOYSTICK_PARAMS pJoystickParams);
  96. // Shared Memory data structure
  97. typedef struct _SHARED_MEMORY {
  98. char m_cWaterMark[MAX_SIZE_SNAME];
  99. ULONG m_RefCnt;
  100. HANDLE m_hMidiOut;
  101. MIDIINFO m_MidiOutInfo;
  102. } SHARED_MEMORY, *PSHARED_MEMORY;
  103. // Effect Types conversion structure
  104. typedef struct _EFFECT_TYPE {
  105. ULONG ulHostSubType;
  106. BYTE bDeviceSubType;
  107. } EFFECT_TYPE, *PEFFECT_TYPE;
  108. //
  109. // --- ROM Effects default parameters structure
  110. //
  111. typedef struct _ROM_FX_PARAM {
  112. ULONG m_ROM_Id;
  113. ULONG m_ForceOutputRate;
  114. ULONG m_Gain;
  115. ULONG m_Duration;
  116. } ROM_FX_PARAM, *PROM_FX_PARAM;
  117. // Structure to pass instance data from the application
  118. // to the low-level callback function. (Output done notification)
  119. typedef struct callbackInstance_tag
  120. {
  121. HWND hWnd;
  122. HANDLE hSelf;
  123. DWORD dwDevice;
  124. HMIDIOUT hMapper;
  125. } CALLBACKINSTANCEDATA;
  126. typedef CALLBACKINSTANCEDATA FAR *LPCALLBACKINSTANCEDATA;
  127. class CJoltMidi;
  128. // --- MIDI Effect base class
  129. class CMidiEffect : public SYS_EX_HDR
  130. {
  131. protected:
  132. BYTE m_OpCode; // Sub-command opcode: e.g. DNLOAD_DATA
  133. BYTE m_SubType; // Effect SubType: e.g. BE_SPRING
  134. BYTE m_bEffectID; // 0x7F = Create New, else valid Effect ID
  135. MIDI_EFFECT Effect;
  136. MIDI_ENVELOPE Envelope;
  137. BYTE m_bAxisMask;
  138. BYTE m_bPlayMode; // DL_PLAY_SUPERIMPOSE || DL_PLAY_SOLO
  139. LPSTR m_pBuffer; // Ptr to a Midi SYS_EX Buffer
  140. int m_MidiBufferSize; // Size of SYS_EX buffer
  141. int m_LoopCount; // Loop Count for the playback
  142. LONG m_Duration; // Atomic Effect Duration (for 1 cycle)
  143. ENVELOPE m_Envelope; // Atomic Envelope (no loop count)
  144. EFFECT m_OriginalEffectParam; // the effect param when the effect was created
  145. public:
  146. // Constructor/Destructor
  147. CMidiEffect(ULONG ulButtonPlayMask);
  148. CMidiEffect(PEFFECT pEffect, PENVELOPE pEnvelope);
  149. virtual ~CMidiEffect(void);
  150. // Methods
  151. ULONG SubTypeOf(void);
  152. BYTE EffectIDOf(void) { return m_bEffectID; }
  153. ULONG DurationOf(void) { return m_Duration * TICKRATE; }
  154. BYTE AxisMaskOf(void) { return m_bAxisMask; }
  155. ULONG DirectionAngle2DOf(void)
  156. { return(Effect.bAngleL+((USHORT)Effect.bAngleH<<7));}
  157. BYTE GainOf(void) { return Effect.bGain; }
  158. ULONG ButtonPlayMaskOf(void)
  159. { return(Effect.bButtonPlayL+((USHORT)Effect.bButtonPlayH<<7));}
  160. ULONG ForceOutRateOf(void)
  161. { return (Effect.bForceOutRateL+((USHORT)Effect.bForceOutRateH<<7));}
  162. ULONG PlayModeOf(void) {
  163. if (DL_PLAY_SOLO == m_bPlayMode)
  164. return PLAY_SOLO;
  165. else
  166. return PLAY_SUPERIMPOSE; }
  167. int MidiBufferSizeOf(void) { return m_MidiBufferSize; }
  168. LPSTR LockedBufferPtrOf(void) { return m_pBuffer; }
  169. int LoopCountOf(void) { return m_LoopCount; }
  170. PEFFECT OriginalEffectParamOf() { return &m_OriginalEffectParam; }
  171. ENVELOPE * EnvelopePtrOf() { return &m_Envelope; }
  172. void SetSubType(ULONG ulArg);
  173. void SetEffectID(BYTE bArg) { m_bEffectID = bArg; }
  174. void SetDuration(ULONG ulArg);
  175. void SetAxisMask(BYTE bArg) { m_bAxisMask = bArg; }
  176. void SetDirectionAngle(ULONG ulArg)
  177. { Effect.bAngleL = (BYTE) ulArg & 0x7f;
  178. Effect.bAngleH = (BYTE) ((ulArg >> 7) & 0x03); }
  179. void SetGain(BYTE bArg) { Effect.bGain = (BYTE) (bArg * MAX_SCALE); }
  180. void SetButtonPlaymask(ULONG ulArg)
  181. { Effect.bButtonPlayL = (BYTE) ulArg & 0x7f;
  182. Effect.bButtonPlayH = (BYTE) ((ulArg >> 7) & 0x03);}
  183. void SetForceOutRate(ULONG ulArg)
  184. { Effect.bForceOutRateL = (BYTE) ulArg & 0x7f;
  185. Effect.bForceOutRateH = (BYTE) ((ulArg >> 7) & 0x03); }
  186. void SetMidiBufferSize(int nArg) { m_MidiBufferSize = nArg; }
  187. void SetMidiBufferPtr(LPSTR pArg) { m_pBuffer = pArg; }
  188. void SetPlayMode(ULONG ulArg) {
  189. if (PLAY_SOLO == ulArg)
  190. m_bPlayMode = DL_PLAY_SOLO;
  191. else
  192. m_bPlayMode = DL_PLAY_SUPERIMPOSE; }
  193. void SetLoopCount(ULONG ulAction)
  194. { m_LoopCount = ((ulAction >> 16) & 0xffff); }
  195. void SetTotalDuration(void);
  196. void SetEnvelope(PENVELOPE pArg)
  197. { m_Envelope.m_Type = pArg->m_Type;
  198. m_Envelope.m_Attack = pArg->m_Attack;
  199. m_Envelope.m_Sustain = pArg->m_Sustain;
  200. m_Envelope.m_Decay = pArg->m_Decay;
  201. m_Envelope.m_StartAmp = pArg->m_StartAmp;
  202. m_Envelope.m_SustainAmp = pArg->m_SustainAmp;
  203. m_Envelope.m_EndAmp = pArg->m_EndAmp; }
  204. void ComputeEnvelope(void);
  205. BYTE ComputeChecksum(PBYTE pArg, int nBufferSize);
  206. virtual PBYTE GenerateSysExPacket(void) = 0;
  207. HRESULT SendPacket(PDNHANDLE pDnloadID, int nPacketSize);
  208. virtual HRESULT DestroyEffect();
  209. };
  210. // --- MIDI Behavioral Effect derived class
  211. class CMidiBehavioral : public CMidiEffect
  212. {
  213. protected:
  214. BE_XXX m_BE_XXXParam; // Behavioral Parameters (non scaled)
  215. public:
  216. // Constructor/Destructor
  217. CMidiBehavioral(PEFFECT pEffect, PENVELOPE pEnvelope, PBE_XXX pBE_XXX);
  218. virtual ~CMidiBehavioral(void);
  219. // Methods
  220. LONG XConstantOf(void) { return m_BE_XXXParam.m_XConstant; }
  221. LONG YConstantOf(void) { return m_BE_XXXParam.m_YConstant; }
  222. LONG Param3Of(void) { return m_BE_XXXParam.m_Param3; }
  223. LONG Param4Of(void) { return m_BE_XXXParam.m_Param4; }
  224. void SetEffectParams(PEFFECT pEffect, PBE_XXX pBE_XXX);
  225. void SetXConstant(LONG lArg) { m_BE_XXXParam.m_XConstant = lArg; }
  226. void SetYConstant(LONG lArg) { m_BE_XXXParam.m_YConstant = lArg; }
  227. void SetParam3(LONG lArg) { m_BE_XXXParam.m_Param3 = lArg; }
  228. void SetParam4(LONG lArg) { m_BE_XXXParam.m_Param4 = lArg; }
  229. virtual PBYTE GenerateSysExPacket(void);
  230. };
  231. // --- MIDI Friction Effect derived class
  232. class CMidiFriction : public CMidiBehavioral
  233. {
  234. protected:
  235. public:
  236. // Constructor/Destructor
  237. CMidiFriction(PEFFECT pEffect, PENVELOPE pEnvelope, PBE_XXX pBE_XXX);
  238. virtual ~CMidiFriction(void);
  239. // Methods
  240. virtual PBYTE GenerateSysExPacket(void);
  241. };
  242. // --- MIDI Wall Effect derived class
  243. class CMidiWall : public CMidiBehavioral
  244. {
  245. protected:
  246. public:
  247. // Constructor/Destructor
  248. CMidiWall(PEFFECT pEffect, PENVELOPE pEnvelope, PBE_XXX pBE_XXX);
  249. virtual ~CMidiWall(void);
  250. // Methods
  251. virtual PBYTE GenerateSysExPacket(void);
  252. };
  253. // --- MIDI RTC Spring Effect derived class
  254. class CMidiRTCSpring : public CMidiEffect
  255. {
  256. protected:
  257. RTCSPRING_PARAM m_RTCSPRINGParam; // RTCSpring Parameters (non scaled)
  258. public:
  259. // Constructor/Destructor
  260. CMidiRTCSpring(PRTCSPRING_PARAM pRTCSpring);
  261. virtual ~CMidiRTCSpring(void);
  262. // Methods
  263. LONG XKConstantOf(void) { return m_RTCSPRINGParam.m_XKConstant; }
  264. LONG YKConstantOf(void) { return m_RTCSPRINGParam.m_YKConstant; }
  265. LONG XAxisCenterOf(void) { return m_RTCSPRINGParam.m_XAxisCenter; }
  266. LONG YAxisCenterOf(void) { return m_RTCSPRINGParam.m_YAxisCenter; }
  267. LONG XSaturationOf(void) { return m_RTCSPRINGParam.m_XSaturation; }
  268. LONG YSaturationOf(void) { return m_RTCSPRINGParam.m_YSaturation; }
  269. LONG XDeadBandOf(void) { return m_RTCSPRINGParam.m_XDeadBand; }
  270. LONG YDeadBandOf(void) { return m_RTCSPRINGParam.m_YDeadBand; }
  271. void SetEffectParams(PRTCSPRING_PARAM pRTCSpring);
  272. // Methods
  273. virtual PBYTE GenerateSysExPacket(void);
  274. };
  275. // --- MIDI Delay Effect derived class
  276. class CMidiDelay : public CMidiEffect
  277. {
  278. protected:
  279. public:
  280. // Constructor/Destructor
  281. CMidiDelay(PEFFECT pEffect);
  282. virtual ~CMidiDelay(void);
  283. // Methods
  284. virtual PBYTE GenerateSysExPacket(void);
  285. };
  286. // --- MIDI Synthesized Effect derived class
  287. class CMidiSynthesized : public CMidiEffect
  288. {
  289. protected:
  290. ULONG m_Freq; // Frequency
  291. LONG m_MaxAmp; // Maximum Amplitude
  292. LONG m_MinAmp; // Minimum Amplitude
  293. public:
  294. // Constructor/Destructor
  295. CMidiSynthesized(PEFFECT pEffect, PENVELOPE pEnvelope, PSE_PARAM pParam);
  296. virtual ~CMidiSynthesized(void);
  297. // Methods
  298. ULONG FreqOf(void) { return m_Freq; }
  299. LONG MaxAmpOf(void) { return m_MaxAmp; }
  300. LONG MinAmpOf(void) { return m_MinAmp; }
  301. void SetEffectParams(PEFFECT pEffect, PSE_PARAM pParam, ULONG ulMode);
  302. void SetFreq(ULONG ulArg) { m_Freq = ulArg; }
  303. void SetMaxAmp(LONG lArg) { m_MaxAmp = lArg; }
  304. void SetMinAmp(LONG lArg) { m_MinAmp = lArg; }
  305. virtual PBYTE GenerateSysExPacket(void);
  306. };
  307. // --- MIDI UD_Waveform Effect derived class
  308. class CMidiUD_Waveform : public CMidiEffect
  309. {
  310. protected:
  311. EFFECT m_Effect;
  312. int m_NumberOfVectors;// Size of the Array
  313. PBYTE m_pArrayData; // Pointer to an scaled (+/-127) array of forces
  314. PBYTE m_pRawData; // Pointer to unscaled array of forces
  315. public:
  316. // Constructor/Destructor
  317. CMidiUD_Waveform(PEFFECT pEffect);
  318. CMidiUD_Waveform(PEFFECT pEffect, ULONG ulNumVectors, PLONG pArray);
  319. virtual ~CMidiUD_Waveform(void);
  320. // Methods
  321. PEFFECT EffectPtrOf() { return (PEFFECT) &m_Effect.m_Bytes; }
  322. int NumberOfVectorsOf(void) { return m_NumberOfVectors; }
  323. PBYTE ArrayDataPtrOf(void) { return m_pArrayData; }
  324. int CompressWaveform(PBYTE pSrcArray, PBYTE pDestArray, int nSrcSize, ULONG *pNewRate);
  325. void SetEffectParams(PEFFECT pEffect);
  326. int SetTypeParams(int nSize, PLONG pArray, ULONG *pNewRate);
  327. virtual PBYTE GenerateSysExPacket(void);
  328. };
  329. // --- MIDI Process List Effect derived class
  330. class CMidiProcessList : public CMidiEffect
  331. {
  332. protected:
  333. ULONG m_NumEffects;
  334. ULONG m_ProcessMode; // PL_SUPERIMPOSE or PL_CONCATENATE
  335. PBYTE m_pEffectArray; // Effect ID[0} . . .
  336. public:
  337. // Constructor/Destructor
  338. CMidiProcessList(ULONG ulButtonPlayMask, PPLIST pParam);
  339. virtual ~CMidiProcessList(void);
  340. // Methods
  341. ULONG NumEffectsOf(void) { return (ULONG) m_NumEffects; }
  342. PBYTE EffectArrayOf(void) { return m_pEffectArray; }
  343. void SetProcessMode(ULONG ulArg) { m_ProcessMode = ulArg; }
  344. void SetParams(ULONG ulButtonPlayMask, PPLIST pPlist);
  345. virtual PBYTE GenerateSysExPacket(void);
  346. };
  347. // --- MIDI Process List Effect derived class
  348. class CMidiVFXProcessList : public CMidiProcessList
  349. {
  350. protected:
  351. public:
  352. // Constructor/Destructor
  353. CMidiVFXProcessList(ULONG ulButtonPlayMask, PPLIST pParam);
  354. // Methods
  355. virtual HRESULT DestroyEffect();
  356. };
  357. // --- MIDI Assign Midi channel command "Effect" derived class
  358. class CMidiAssign : public CMidiEffect
  359. {
  360. protected:
  361. ULONG m_Channel; // Channel 0 - 15
  362. public:
  363. // Constructor/Destructor
  364. CMidiAssign(void);
  365. virtual ~CMidiAssign(void);
  366. // Methods
  367. ULONG MidiAssignChannelOf(void) { return m_Channel; }
  368. void SetMidiAssignChannel(ULONG ulArg) { m_Channel = ulArg; }
  369. virtual PBYTE GenerateSysExPacket(void);
  370. };
  371. // --- Jolt Device base class
  372. class CJoltMidi
  373. {
  374. protected:
  375. LOCAL_PRODUCT_ID m_ProductID; // Device information
  376. FIRMWARE_PARAMS m_FirmwareParams; // Behavioral effect fudge factors
  377. DELAY_PARAMS m_DelayParams; // Timing parameters
  378. // Power Cycle Restore Thread variables
  379. #if 0
  380. DWORD m_dwThreadID;
  381. HANDLE m_hDataEvent;
  382. HANDLE m_hDataThread;
  383. DWORD m_dwThreadSignal;
  384. DWORD m_dwThreadStatus; // TRUE = thread is alive, else FALSE
  385. #endif
  386. ULONG m_COMMInterface; // COMM_WINMM || COMM_MIDI_BACKDOOR || COMM_SERIAL_BACKDOOR || COMM_SERIAL_FILE
  387. ULONG m_COMMPort; // e.g. 330, 3F8, or 0 for winmm
  388. HANDLE m_hVxD; // Handle to VxD for IOCTL interface
  389. HANDLE m_hMidiOutputEvent; // Handle to Midi Output Event
  390. MIDIOUTCAPS m_MidiOutCaps; // MIDI Output Device capabilities structures
  391. int m_MidiOutDeviceID; // Midi Output device ID
  392. BOOL m_MidiOutOpened; // TRUE = MidiOutOpen called
  393. LPCALLBACKINSTANCEDATA m_lpCallbackInstanceData;
  394. CMidiEffect *m_pJoltEffectList[MAX_EFFECT_IDS]; // Array of Downloaded Effects IPTrs
  395. BYTE m_MidiChannel; // Midi Channel
  396. SWFF_ERROR m_Error; // System Error codes
  397. MIDIINFO m_MidiOutInfo; // Midi output Info structure
  398. BOOL m_ShutdownSent; // TRUE = Last command sent was Shutdown
  399. DIAG_COUNTER m_DiagCounter; // For debugging, Diagnostics counter
  400. SWDEVICESTATE m_DeviceState;
  401. HANDLE m_hPrimaryBuffer; // Handle to locked memory
  402. LPBYTE m_pPrimaryBuffer; // Pointer to the Primary buffer memory
  403. PROM_FX_PARAM m_pRomFxTable; // Default settings for ROM Effects
  404. HANDLE m_hSharedMemoryFile; // Handle to a memory mapped file
  405. PSHARED_MEMORY m_pSharedMemory; // Pointer to a Shared Memory structure
  406. HANDLE m_hSWFFDataMutex; // Local copy of Mutex handle
  407. // HANDLE m_hJoltOutputDataMutex; // Local copy of Mutex handle (locks Jolt to
  408. // // single output command at a time.
  409. public:
  410. // Constructor/Destructor
  411. CJoltMidi(void);
  412. ~CJoltMidi(void);
  413. // Methods
  414. HANDLE SWFFDataMutexHandleOf() { return m_hSWFFDataMutex; }
  415. HRESULT Initialize(DWORD dwDeviceID);
  416. #if 0
  417. HANDLE JoltOutputDataMutexHandleOf() { return m_hJoltOutputDataMutex; }
  418. DWORD ThreadIDOf(void) { return m_dwThreadID; }
  419. HANDLE DataEventOf(void) {return m_hDataEvent; }
  420. HANDLE DataThreadOf(void) {return m_hDataThread; }
  421. DWORD ThreadSignalOf(void) { return m_dwThreadSignal; }
  422. DWORD ThreadStatusOf(void) { return m_dwThreadStatus; }
  423. #endif
  424. HANDLE MidiOutputEventHandleOf(void) { return m_hMidiOutputEvent; }
  425. HMIDIOUT MidiOutHandleOf(void) { return HMIDIOUT(m_pSharedMemory->m_hMidiOut); }
  426. int MidiOutDeviceIDOf(void) { return m_MidiOutDeviceID; }
  427. LPCALLBACKINSTANCEDATA CallbackInstanceDataOf(void)
  428. { return m_lpCallbackInstanceData; }
  429. BYTE MidiChannelOf(void) { return m_MidiChannel; }
  430. void CJoltGetLastError(PSWFF_ERROR pError)
  431. { pError->HCode = m_Error.HCode;
  432. pError->ulDriverCode = m_Error.ulDriverCode; }
  433. MIDIINFO *MidiOutInfoOf(void) { return &m_MidiOutInfo; }
  434. BOOL ShutdownSentOf(void) { return m_ShutdownSent; }
  435. PDIAG_COUNTER DiagCounterPtrOf() { return &m_DiagCounter; }
  436. PBYTE PrimaryBufferPtrOf() { return m_pPrimaryBuffer; }
  437. LOCAL_PRODUCT_ID* ProductIDPtrOf() { return &m_ProductID; }
  438. PFIRMWARE_PARAMS FirmwareParamsPtrOf() {return &m_FirmwareParams; }
  439. PDELAY_PARAMS DelayParamsPtrOf() {return &m_DelayParams; }
  440. ULONG COMMInterfaceOf() { return m_COMMInterface; }
  441. ULONG COMMPortOf() { return m_COMMPort; }
  442. #if 0
  443. void SetThreadIDOf(DWORD dwArg) { m_dwThreadID = dwArg; }
  444. void SetDataEvent(HANDLE hArg) { m_hDataEvent = hArg; }
  445. void SetDataThread(HANDLE hArg) { m_hDataThread = hArg; }
  446. void SetThreadSignal(DWORD dwArg) { m_dwThreadSignal = dwArg; }
  447. void SetThreadStatus(DWORD dwArg) { m_dwThreadStatus = dwArg; }
  448. BOOL LockJoltOutputData(void);
  449. void UnlockJoltOutputData(void);
  450. #endif
  451. BOOL LockSharedMemory(void);
  452. void UnlockSharedMemory(void);
  453. void SetSWFFDataMutexHandle(HANDLE hArg) { m_hSWFFDataMutex = hArg;}
  454. // void SetJoltOutputDataMutexHandle(HANDLE hArg) { m_hJoltOutputDataMutex = hArg;}
  455. void SetMidiOutHandle(HMIDIOUT hArg) { LockSharedMemory();
  456. m_pSharedMemory->m_hMidiOut = hArg;
  457. UnlockSharedMemory();}
  458. void SetMidiOutDeviceID(int nArg) {m_MidiOutDeviceID = nArg; }
  459. void SetCallbackInstanceData(LPCALLBACKINSTANCEDATA pArg)
  460. { m_lpCallbackInstanceData = pArg; }
  461. void SetMidiChannel(BYTE nArg) { m_MidiChannel = nArg; }
  462. void SetShutdownSent(BOOL bArg) { m_ShutdownSent = bArg; }
  463. void ClearDiagCounters(void) { m_DiagCounter.m_NACKCounter = 0;
  464. m_DiagCounter.m_LongMsgCounter = 0;
  465. m_DiagCounter.m_ShortMsgCounter = 0;
  466. m_DiagCounter.m_RetryCounter = 0; }
  467. void BumpNACKCounter(void) { m_DiagCounter.m_NACKCounter++; }
  468. void BumpLongMsgCounter(void) { m_DiagCounter.m_LongMsgCounter++; }
  469. void BumpShortMsgCounter(void) { m_DiagCounter.m_ShortMsgCounter++; }
  470. void BumpRetryCounter(void) { m_DiagCounter.m_RetryCounter++; }
  471. HRESULT LogError(HRESULT hSystemError, HRESULT DriverError);
  472. void SetJoltStatus(JOYCHANNELSTATUS* pJoyStatus);
  473. HRESULT GetJoltStatus(LPDIDEVICESTATE);
  474. HRESULT GetJoltStatus(PSWDEVICESTATE);
  475. SWDEVICESTATE GetSWDeviceStateNoUpdate() const { return m_DeviceState; }
  476. void UpdateDeviceMode(ULONG ulMode);
  477. HRESULT GetJoltID(LOCAL_PRODUCT_ID* pProductID);
  478. // Downloaded Effects management
  479. CMidiEffect *GetEffectByID(DNHANDLE hID)
  480. { assert(hID < 0x7f);
  481. if (hID >= 0x7f)
  482. return NULL;
  483. else
  484. return m_pJoltEffectList[hID]; }
  485. void SetEffectByID(DNHANDLE hID, CMidiEffect *pArg)
  486. { m_pJoltEffectList[hID] = pArg; }
  487. BOOL NewEffectID(PDNHANDLE pDnloadID);
  488. void DeleteDownloadedEffects(void);
  489. void RestoreDownloadedEffects(void);
  490. // Midi management
  491. BOOL DetectMidiDevice(DWORD dwDeviceID, UINT *pDeviceOutID,
  492. ULONG *pCOMMInterface, ULONG *pCOMMPort);
  493. HRESULT ValidateMidiHandle(void);
  494. HRESULT OpenOutput(int nDeviceID);
  495. BOOL IsMidiOutputOpened(void) { return m_MidiOutOpened; }
  496. HRESULT MidiSendShortMsg(BYTE cStatus, BYTE cData1,BYTE cData2);
  497. HRESULT MidiSendLongMsg(void);
  498. HRESULT MidiAssignBuffer(LPSTR lpData, DWORD dwBufferLength, BOOL fAssign);
  499. // Response from Jolt management
  500. HRESULT GetAckNackData(int nTimeWait, PACKNACK pAckNack, USHORT regindex);
  501. HRESULT GetEffectStatus(DWORD DnloadID, PBYTE pStatusCode);
  502. BOOL QueryForJolt(void);
  503. BOOL FindJoltWinMM(UINT *pDeviceOutID,ULONG *pCOMMInterface,ULONG *pCOMMPort);
  504. BOOL FindJoltBackdoor(UINT *pDeviceOutID,ULONG *pCOMMInterface,ULONG *pCOMMPort);
  505. // Instance Data management
  506. LPCALLBACKINSTANCEDATA AllocCallbackInstanceData(void);
  507. void FreeCallbackInstanceData(void);
  508. // Digital OverDrive interface
  509. HRESULT InitDigitalOverDrive(DWORD dwDeviceID);
  510. HANDLE VxDHandleOf(void) { return m_hVxD; }
  511. // ROM Effects
  512. HRESULT SetupROM_Fx(PEFFECT pEffect);
  513. // Thread
  514. // HRESULT PowerCycleThreadCreate(void);
  515. };
  516. extern CJoltMidi* g_pJoltMidi; // Global Jolt Object
  517. #endif // of ifndef MIDI_OBJ_SEEN