// -------------------------------------------------------------------------- // ========================================================================== // File: TDx_InputEffect.CPP // Authors: BCB_Code_Generator v1.62, // Darren Dwyer (source code, documentation, demos, website), // Hugh Edwards (documentation, icons, website), // Brian Austin (some source code, documentation) // Description: This file contains the code for the TDx_InputEffect // Component // // "TDx_Input_Library v1.62" // (c) 2002 BCB-Tools.com Pty. Ltd., Sydney, Australia. // All Rights Reserved. // // Refer to the 'Licence.Txt' file for licencing & copyright information. // ========================================================================== // -------------------------------------------------------------------------- // #includes ... // -------------------------------------------------------------------------- #include #pragma hdrstop // -------------------------------------------------------------------------- #include "TDx_InputEffect.H" // -------------------------------------------------------------------------- // external classes used by the TDx_InputEffect component. #include "TDx_InputDevice.H" // -------------------------------------------------------------------------- // external classes used by TDx_InputEffect methods. #include "TDIEffEscape.H" #include "TDIEffect.H" // -------------------------------------------------------------------------- #pragma link "TDx_Library_Defns" #pragma link "TDx_Library_Functions" #pragma link "TDx_Input_Library_Defns" #pragma link "TDx_Input_Library_Functions" // -------------------------------------------------------------------------- // Object Registration... // -------------------------------------------------------------------------- #if (__BORLANDC__ >= 0x0530) // BCB Version 3+ #pragma package(smart_init) #endif // -------------------------------------------------------------------------- static inline void ValidCtrCheck(TDx_InputEffect*) { new TDx_InputEffect(NULL); } // -------------------------------------------------------------------------- namespace Tdx_inputeffect { #if (__BORLANDC__ >= 0x0530) // BCB Version 3+ void __fastcall PACKAGE Register() #else void __fastcall Register() #endif { TComponentClass classes[1] = {__classid(TDx_InputEffect)}; RegisterComponents("TDx_Input", classes, 0); } } // -------------------------------------------------------------------------- // Constructor: TDx_InputEffect::TDx_InputEffect() // Description: The default constructor for the TDx_InputEffect object. // -------------------------------------------------------------------------- __fastcall TDx_InputEffect::TDx_InputEffect(TComponent* Owner) : TComponent(Owner) { fCreated = false; fErrorValue = DI_OK; } // -------------------------------------------------------------------------- // Destructor: TDx_InputEffect::~TDx_InputEffect() // Description: The destructor for the TDx_InputEffect object. // -------------------------------------------------------------------------- __fastcall TDx_InputEffect::~TDx_InputEffect() { // destroy internals if (Created) Destroy(); } // -------------------------------------------------------------------------- // Property: Created // Description: The Created property is true if the internal // LPDIRECTINPUTEFFECT used in this component has been // successfully created, otherwise Created is false. // // To create the internal LPDIRECTINPUTEFFECT, call the // TDx_InputEffect::Create() method. // -------------------------------------------------------------------------- bool __fastcall TDx_InputEffect::FGetCreated() { return fCreated; } // -------------------------------------------------------------------------- void __fastcall TDx_InputEffect::FSetCreated( bool pCreated ) { fCreated = (pCreated && (fLPDIRECTINPUTEFFECT==NULL)); } // -------------------------------------------------------------------------- // Property: ErrorValue // Description: The ErrorValue property contains the last error value // returned from a call to a TDx_InputEffect method or // fget/fset. eg. DI_OK or DDERR_SURFACELOST or TDX_ERROR // -------------------------------------------------------------------------- HRESULT __fastcall TDx_InputEffect::FGetErrorValue() { return fErrorValue; } // -------------------------------------------------------------------------- void __fastcall TDx_InputEffect::FSetErrorValue( HRESULT pErrorValue ) { fErrorValue = pErrorValue; } // -------------------------------------------------------------------------- // Method: Create() // Description: The Create() method is used to automatically create the // internal LPDIRECTINPUTEFFECT interface used in the // TDx_InputEffect component and must be called before any // methods of the TDx_InputEffect component will function. // Params: pGuid - // Contains the GUID of the Effect to create. // Possible values are: // // GUID_ConstantForce // GUID_RampForce // GUID_Square // GUID_Sine // GUID_Triangle // GUID_SawtoothUp // GUID_SawtoothDown // GUID_Spring // GUID_Damper // GUID_Inertia // GUID_Friction // GUID_CustomForce // pEffect - // A pointer to a TDIEffect object that contains information // about the effect to be created. // pInput - // A pointer to the TDx_InputDevice object that the effect is to // be created for. // -------------------------------------------------------------------------- bool __fastcall TDx_InputEffect::Create( GUID pGuid, TDIEffect* pEffect, TDx_InputDevice* pInput ) { // if the component internals have already been created, exit if (fCreated) { if (FOnError) FOnError( this, Name+"::Create()", "TDX_ALREADYCREATED", "The "+Name+"::Create() method was called when the component has already been created successfully." ); return false; } // check params for accuracy if (pInput==NULL) { if (FOnError) FOnError( this, Name+"::Create()", "TDX_BADPARAMS", "The 'pInput' parameter must point to an existing TDx_Input component and cannot be NULL." ); return false; } // code that creates the internal IDirectInputEffect interface if (pInput->CreateEffect( pGuid, pEffect, this )) { fCreated = true; if (FOnCreate) FOnCreate(this); } // return true if created return fCreated; } // -------------------------------------------------------------------------- // Method: Destroy() // Description: The Destroy() method is used to automatically destroy the // internal LPDIRECTINPUTEFFECT interface used in the // TDx_InputEffect component and should be called when the // internal interface is no longer required. // // Note: This method is called by the component's destructor. // -------------------------------------------------------------------------- bool __fastcall TDx_InputEffect::Destroy() { // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::Destroy()", "TDX_NOTCREATED", "The "+Name+"::Destroy() method was called before being created successfully." ); return false; } // code that destroys the internal interface if (FOnDestroy) FOnDestroy(this); if (fLPDIRECTINPUTEFFECT==NULL) { fErrorValue = TDX_ERROR; if (FOnError) FOnError( this, Name+"::Destroy()", "TDX_ERROR", "The "+Name+" component's internal LPDIRECTINPUTEFFECT is NULL but the TDx_InputEffect component is expecting it to be not NULL. Aborting the Destroy()." ); return false; } try { fLPDIRECTINPUTEFFECT->Release(); } catch (...) { fErrorValue = TDX_ERROR; if (FOnError) FOnError( this, Name+"::Destroy()", "TDX_ERROR", "An exception has occurred within LPDIRECTINPUTEFFECT->Release(). Check that you are destroying all components in reverse order of creation." ); } // successful destruction fLPDIRECTINPUTEFFECT = NULL; fCreated = false; return true; } // -------------------------------------------------------------------------- // Method: Download() // Description: The Download() method will download an effect to a device, // updating any effect properties that may have been modified // using TDx_InputEffect::SetParameters() since the last // Download() call. // // Effect properties specified in TDIEffectInfo::DynamicParams // can be modified while the effect is still playing. // // Error values that can be generated are: // // DIERR_NOTINITIALIZED // DIERR_DEVICEFULL // DIERR_INCOMPLETEEFFECT // DIERR_INPUTLOST // DIERR_NOTEXCLUSIVEACQUIRED // DIERR_INVALIDPARAM // DIERR_EFFECTPLAYING // -------------------------------------------------------------------------- bool __fastcall TDx_InputEffect::Download() { // Original Function Definition // HRESULT Download(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::Download()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECTINPUTEFFECT->Download( ); // Handle any Known Results if ((fErrorValue!=DI_OK) && (fErrorValue!=S_FALSE)) { // Failure. if (FOnError) FOnError( this, Name+"::Download()", TDx_Input_Library_ErrorString(fErrorValue), TDx_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: Escape() // Description: The Escape() method will send a hardware-specific command // directly to the device driver. // // TDIDeviceInstance::FFDriver should be checked against the // expected driver identifier to ensure the escape is sent to // the right driver. // // The driver documentation should list and describe the comands // that are valid for the driver. // // Error values that can be generated are: // // DIERR_NOTINITIALIZED // DIERR_DEVICEFULL // Params: pEffectEscape - // The EffectEscape parameter references a TDIEffEscape // component describing the command to be sent to the driver. // // On returning, the TDIEffEscape::OutBufferSize property will // define amount of data, in bytes, written to // TDIEffEscape::OutBuffer. // -------------------------------------------------------------------------- bool __fastcall TDx_InputEffect::Escape( TDIEffEscape* pEffectEscape ) { // Original Function Definition // HRESULT Escape( // LPDIEFFESCAPE pesc // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::Escape()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Check Parameters for Accuracy if (pEffectEscape==NULL) { fErrorValue = TDX_BADPARAMS; if (FOnError) FOnError( this, Name+"::Escape()", "TDX_BADPARAMS", "'pEffectEscape' cannot be 'NULL'"); return false; } // Call Original Function fErrorValue = fLPDIRECTINPUTEFFECT->Escape( pEffectEscape->Internal_DIEFFESCAPE_Ptr ); // Translate Data returned from Function pEffectEscape->Internal_DIEFFESCAPE_Update(); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::Escape()", TDx_Input_Library_ErrorString(fErrorValue), TDx_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetEffectGuid() // Description: The GetEffectGuid() method retrieves the GUID identifying the // effect described by this TDx_InputEffect object. // Once the GUID is obtained, more effect information can be // retrieved with TDx_InputDevice::GetEffectInfo(). // // Error values that can be generated are: // // DIERR_INVALIDPARAM // DIERR_NOTINITIALIZED // Params: pGUID - // Contains a GUID object for holding the effect GUID if this // method returns successfully. // -------------------------------------------------------------------------- bool __fastcall TDx_InputEffect::GetEffectGuid( GUID* pGUID ) { // Original Function Definition // HRESULT GetEffectGuid( // LPGUID pguid // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetEffectGuid()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECTINPUTEFFECT->GetEffectGuid( (LPGUID) pGUID ); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetEffectGuid()", TDx_Input_Library_ErrorString(fErrorValue), TDx_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetEffectStatus() // Description: The GetEffectStatus() method will return the effect's current // status. // // Error values that can be generated are: // // DIERR_INVALIDPARAM // DIERR_NOTINITIALIZED // Params: pFlags - // The Flags parameter defines flags indicating the current // status of the effect. // The described effect applies when the flag is set. // Flags: // DIEGES_EMULATED - // The effect is being emulated by TDx_Input. // DIEGES_PLAYING - // This effect is currently playing. // -------------------------------------------------------------------------- bool __fastcall TDx_InputEffect::GetEffectStatus( dword* pFlags ) { // Original Function Definition // HRESULT GetEffectStatus( // LPDWORD pdwFlags // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetEffectStatus()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECTINPUTEFFECT->GetEffectStatus( (LPDWORD) pFlags ); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetEffectStatus()", TDx_Input_Library_ErrorString(fErrorValue), TDx_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetParameters() // Description: The GetParameters() method retrieves the current settings of // the effect. // // Error values that can be generated are: // // DIERR_INVALIDPARAM // DIERR_MOREDATA // DIERR_NOTINITIALIZED // Params: pEffect - // The Effect parameter references a TDIEffect component for // holding the effect information if this method returns // successfully. // pFlags - // The Flags parameter defines flags indicating which properties // of the TDIEffect component referenced by the Effect parameter // are to be retrieved. // The described effect applies when the flag is set. // Flags: // DIEP_ALLPARAMS - // All the TDIEffect properties are to be retrieved. // // This is equivilent to setting all the other flags of // this parameter. // DIEP_ALLPARAMS_DX5 - // All the TDIEffect properties except // TDIEffect::StartDelay are to be retrieved. // // This is equivilent to setting all the other flags of // this parameter except DIEP_STARTDELAY. // DIEP_AXES - // TDIEffect::NumAxes and TDIEffect::Axes are to be // retrieved. // // TDIEffect::NumAxes holds the size of the buffer // referenced by TDIEffect::Axes. // When the TDIEffect::Axes buffer is too small, a // DIERR_MOREDATA error is generated and // TDIEffect::NumAxes will indicate the required buffer // size. // DIEP_DIRECTION - // TDIEffect::NumAxes and TDIEffect::Direction are to be // retrieved. // // TDIEffect::NumAxes holds the size of the buffer // referenced by TDIEffect::Direction. // When the TDIEffect::Direction buffer is too small, a // DIERR_MOREDATA error is generated and // TDIEffect::NumAxes will indicate the required buffer // size. // // One or more of the DIEFF_CARTESIAN, DIEFF_POLAR or // DIEFF_SPHERICAL flags must be set in TDIEffect::Flags // to indicate in which coordinate system the directions // should be reported. // Setting all three will result in the coordinates being // retrieved using the same system as when they were set. // On returning, only one of the coordinate system flags // will be set, indicating how the TDIEffect::Direction // coordinates should be interpreted. // DIEP_DURATION - // TDIEffect::Duration is to be retrieved. // DIEP_ENVELOPE - // The TDIEnvelope component referenced by // TDIEffect::Envelope is to be filled and retrieved. // // When there is no envelope TDIEffect::Envelope will be // NULL when the method returns. // DIEP_GAIN - // TDIEffect::GAIN is to be retrieved. // DIEP_SAMPLEPERIOD - // TDIEffect::SamplePeriod is to be retrieved. // DIEP_STARTDELAY - // TDIEffect::StartDelay is to be retrieved. // DIEP_TRIGGERBUTTON - // TDIEffect::TriggerButton is to be retrieved. // DIEP_TRIGGERREPEATINTERVAL - // TDIEffect::TriggerRepeatInterval is to be retrieved. // DIEP_TYPESPECIFICPARAMS - // Any type specific parameters referenced by // TDIEffect::TypeSpecificParams are retrieved. // // TDIEffect::TypeSpecificParamsSize initially holds the // size the TDIEffect::TypeSpecificParams buffer and the // actual amount of data written to the buffer on return. // When the TDIEffect::TypeSpecificParams buffer is too // small, a DIERR_MOREDATA error is generated and // TDIEffect::TypeSpecificParamsSize will indicate the // required buffer size. // -------------------------------------------------------------------------- bool __fastcall TDx_InputEffect::GetParameters( TDIEffect* pEffect, dword pFlags ) { // Original Function Definition // HRESULT GetParameters( // LPDIEFFECT peff, // DWORD dwFlags // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetParameters()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Check Parameters for Accuracy if (pEffect==NULL) { fErrorValue = TDX_BADPARAMS; if (FOnError) FOnError( this, Name+"::GetParameters()", "TDX_BADPARAMS", "'pEffect' cannot be 'NULL'"); return false; } // Call Original Function fErrorValue = fLPDIRECTINPUTEFFECT->GetParameters( pEffect->Internal_DIEFFECT_Ptr, (DWORD) pFlags ); // Translate Data returned from Function pEffect->Internal_DIEFFECT_Update(); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetParameters()", TDx_Input_Library_ErrorString(fErrorValue), TDx_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetParameters() // Description: The SetParameters() method sets the properties of this // effect. // // Only one or less of the DIEP_NODOWNLOAD, DIEP_START and // DIEP_NORESTART flags should be set in the Flags parameter of // this method. // // The effect will be automatically downloaded to the device // unless the DIEP_NODOWNLOAD flag is set. // // TDIEffectInfo::DynamicParams indicates which parameters may // be dynamically updated while the effect is playing. // // Updating an effects parameters while it is playing causes the // effect to behave as if the new parameters are the ones with // which it started playing. // For example : If a 10 second effect is playing, and the // duration of the effect is changed to 4 seconds, the effect // will stop 4 seconds after it began. If the effect has been // going for more than four seconds, it will stop immediately. // // Error values that can be generated are: // // DIERR_NOTINITIALIZED // DIERR_INCOMPLETEEFFECT // DIERR_INPUTLOST // DIERR_INVALIDPARAM // DIERR_EFFECTPLAYING // Params: pEffect - // The Effect parameter references a TDIEffect component for // holding the effect information if this method returns // successfully. // pFlags - // The Flags parameter defines flags indicating which properties // of TDIEffect contain valid data and how that data should be // applied to the device. // The described effect applies when the flag is set. // Flags: // DIEP_AXES - // TDIEffect::NumAxes and TDIEffect::Axes hold valid data. // // TDIEffect::NumAxes should hold the size of the buffer // referenced by TDIEffect::Axes. // DIEP_DIRECTION - // TDIEffect::NumAxes and TDIEffect::Direction hold valid // data. // // TDIEffect::NumAxes should hold the size of the buffer // referenced by TDIEffect::Direction. // // One of the DIEFF_CARTESIAN, DIEFF_POLAR or // DIEFF_SPHERICAL flags must be set in TDIEffect::Flags // to indicate which coordinate system is being used. // DIEP_DURATION - // TDIEffect::Duration holds valid data. // DIEP_ENVELOPE - // The TDIEnvelope component referenced by // TDIEffect::Envelope contains valid data. // // Setting TDIEffect::Envelope to NULL with this flag set // will detach any existing envelope from this effect. // DIEP_GAIN - // TDIEffect::Gain holds valid data. // DIEP_NODOWNLOAD - // The updated properties should not be downloaded to the // device until TDx_InputEffect::Download() is called. // DIEP_NORESTART - // If the effect is already playing, it should not be // stopped and restarted in order to update its // properties. // // This means that if the driver doesnt support "on the // fly" modifications and this flag is set, the effect // parameters will not be updated and a // DIERR_EFFECTPLAYING error returned. // DIEP_SAMPLEPERIOD - // TDIEffect::SamplePeriod holds valid data. // DIEP_START - // The effect should be started or restarted after the // properties are updated. // DIEP_STARTDELAY - // TDIEffect::StartDelay holds valid data. // DIEP_TRIGGERBUTTON - // TDIEffect::TriggerButton holds valid data. // DIEP_TRIGGERDELAY - // TDIEffect::TriggerDelay holds valid data. // DIEP_TRIGGERREPEATINTERVAL - // TDIEffect::TriggerRepeatInterval holds valid data. // DIEP_TYPESPECIFICPARAMS - // TDIEffect::TypeSpecificParams and // TDIEffect::TypeSpecificParamsSize contain valid data. // // TDIEffect::TypeSpecificParamsSize holds the size of the // data referenced by TDIEffect::TypeSpecificParams. // -------------------------------------------------------------------------- bool __fastcall TDx_InputEffect::SetParameters( TDIEffect* pEffect, dword pFlags ) { // Original Function Definition // HRESULT SetParameters( // LPCDIEFFECT peff, // DWORD dwFlags // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetParameters()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECTINPUTEFFECT->SetParameters( (pEffect==NULL) ? NULL : pEffect->Internal_DIEFFECT_Ptr, (DWORD) pFlags ); // Translate Data returned from Function if (pEffect!=NULL) pEffect->Internal_DIEFFECT_Update(); // Handle any Known Results if ((fErrorValue!=DI_OK) && (fErrorValue!=DI_EFFECTRESTARTED) && (fErrorValue!=DI_DOWNLOADSKIPPED) && (fErrorValue!=DI_TRUNCATED) && (fErrorValue!=DI_TRUNCATEDANDRESTARTED)) { // Failure. if (FOnError) FOnError( this, Name+"::SetParameters()", TDx_Input_Library_ErrorString(fErrorValue), TDx_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: Start() // Description: The Start() method downloads and plays an effect from the // beginning, restarting the effect if neccessary. // // The download only occurs when the effect has been modified or // is not already present and the DIES_NODOWNLOAD flag is not // set. // // Exclusive level access to the acquired device is required. // // Error values that can be generated are: // // DIERR_INVALIDPARAM // DIERR_INCOMPLETEEFFECT // DIERR_NOTEXCLUSIVEACQUIRED // DIERR_NOTINITIALIZED // DIERR_UNSUPPORTED // Params: pIterations - // The Iterations parameter defines how many times the effect // should be played. // // This value can be set from 1 to INFINITE, but not all devices // support multiple iterations. // // If the effect has an envelope, it will be applied each time // the effect is repeated. // // To play an effect indefinitely without re-applying the // envelope each time, change TDIEffect::Duration to INFINITE // with TDx_InputEffect::SetParameters(). // pFlags - // The Flags parameter defines flags indicating how the device // should play the effect. // The described effect applies when the flag is set. // Flags: // DIES_NODOWNLOAD - // The effect should not be automatically downloaded to // the device. // DIES_SOLO - // Clear all other effects from the device before playing // starting this one. // -------------------------------------------------------------------------- bool __fastcall TDx_InputEffect::Start( dword pIterations, dword pFlags ) { // Original Function Definition // HRESULT Start( // DWORD dwIterations, // DWORD dwFlags // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::Start()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECTINPUTEFFECT->Start( (DWORD) pIterations, (DWORD) pFlags ); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::Start()", TDx_Input_Library_ErrorString(fErrorValue), TDx_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: Stop() // Description: The Stop() method will halt the playing of an effect. // // Exclusive level access to the acquired device the effect is // playing on is required. // // Error values that can be generated are: // // DIERR_NOTEXCLUSIVEACQUIRED // DIERR_NOTINITIALIZED // -------------------------------------------------------------------------- bool __fastcall TDx_InputEffect::Stop() { // Original Function Definition // HRESULT Stop(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::Stop()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECTINPUTEFFECT->Stop( ); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::Stop()", TDx_Input_Library_ErrorString(fErrorValue), TDx_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: Unload() // Description: The Unload() method will stop and remove the effect from the // device. // // Error values that can be generated are: // // DIERR_INPUTLOST // DIERR_INVALIDPARAM // DIERR_NOTEXCLUSIVEACQUIRED // DIERR_NOTINITIALIZED // -------------------------------------------------------------------------- bool __fastcall TDx_InputEffect::Unload() { // Original Function Definition // HRESULT Unload(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::Unload()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECTINPUTEFFECT->Unload( ); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::Unload()", TDx_Input_Library_ErrorString(fErrorValue), TDx_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Internal Interface Access // -------------------------------------------------------------------------- LPDIRECTINPUTEFFECT __fastcall TDx_InputEffect::FGetInternal_LPDIRECTINPUTEFFECT() { return fLPDIRECTINPUTEFFECT; } // -------------------------------------------------------------------------- LPDIRECTINPUTEFFECT* __fastcall TDx_InputEffect::FGetInternal_LPDIRECTINPUTEFFECT_Ptr() { return &fLPDIRECTINPUTEFFECT; } // -------------------------------------------------------------------------- void __fastcall TDx_InputEffect::FSetInternal_LPDIRECTINPUTEFFECT( LPDIRECTINPUTEFFECT pLPDIRECTINPUTEFFECT ) { if (!fCreated) { fLPDIRECTINPUTEFFECT = pLPDIRECTINPUTEFFECT; fCreated = (fLPDIRECTINPUTEFFECT!=NULL); } } // -------------------------------------------------------------------------- void __fastcall TDx_InputEffect::Internal_LPDIRECTINPUTEFFECT_Update() { fCreated = (fLPDIRECTINPUTEFFECT!=NULL); } // --------------------------------------------------------------------------