// -------------------------------------------------------------------------- // ========================================================================== // File: TDx9_InputDevice.CPP // Authors: BCB_Code_Generator v2.00, // Darren Dwyer (source code, documentation, demos, website), // Hugh Edwards (documentation, icons) // Description: This file contains the code for the TDx9_InputDevice // Component // // "TDx9_Input_Library v1.00" // (c) 2005 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 "TDx9_InputDevice.H" // -------------------------------------------------------------------------- // external classes used by TDx9_InputDevice methods. #include "TDIActionFormat.H" #include "TDIEffect.H" #include "TDx_InputEffect.H" #include "TDIEffEscape.H" #include "TDIDevCaps.H" #include "TDIDeviceObjectData.H" #include "TDIDeviceInstance.H" #include "TDIEffectInfo.H" #include "TDIDeviceImageInfoHeader.H" #include "TDIDeviceObjectInstance.H" #include "TDIPropHeader.H" #include "TDIDataFormat.H" #include "TDIFileEffect.H" // -------------------------------------------------------------------------- #pragma link "TDx_Library_Defns" #pragma link "TDx_Library_Functions" #pragma link "TDx9_Input_Library_Defns" #pragma link "TDx9_Input_Library_Functions" // -------------------------------------------------------------------------- // Object Registration... // -------------------------------------------------------------------------- #if (__BORLANDC__ >= 0x0530) // BCB Version 3+ #pragma package(smart_init) #endif // -------------------------------------------------------------------------- static inline void ValidCtrCheck(TDx9_InputDevice*) { new TDx9_InputDevice(NULL); } // -------------------------------------------------------------------------- namespace Tdx9_inputdevice { #if (__BORLANDC__ >= 0x0530) // BCB Version 3+ void __fastcall PACKAGE Register() #else void __fastcall Register() #endif { TComponentClass classes[1] = {__classid(TDx9_InputDevice)}; RegisterComponents("", classes, 0); } } // -------------------------------------------------------------------------- // Constructor: TDx9_InputDevice::TDx9_InputDevice() // Description: The default constructor for the TDx9_InputDevice object. // -------------------------------------------------------------------------- __fastcall TDx9_InputDevice::TDx9_InputDevice(TComponent* Owner) : TComponent(Owner) { fErrorValue = DI_OK; fCreated = false; } // -------------------------------------------------------------------------- // Destructor: TDx9_InputDevice::~TDx9_InputDevice() // Description: The destructor for the TDx9_InputDevice object. // -------------------------------------------------------------------------- __fastcall TDx9_InputDevice::~TDx9_InputDevice() { // destroy internals if (Created) Destroy(); } // -------------------------------------------------------------------------- // Property: Created // Description: The Created property is true if the internal // LPDIRECTINPUTDEVICE8 used in this component has been // successfully created, otherwise Created is false. // // To create the internal LPDIRECTINPUTDEVICE8, call the // TDx9_InputDevice::Create() method. // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::FGetCreated() { return fCreated; } // -------------------------------------------------------------------------- void __fastcall TDx9_InputDevice::FSetCreated( bool pCreated ) { fCreated = (pCreated && (fLPDIRECTINPUTDEVICE8==NULL)); } // -------------------------------------------------------------------------- // Property: ErrorValue // Description: The ErrorValue property contains the last error value // returned from a call to a TDx9_InputDevice method or // fget/fset. eg. DI_OK or DDERR_SURFACELOST or TDX_ERROR // -------------------------------------------------------------------------- HRESULT __fastcall TDx9_InputDevice::FGetErrorValue() { return fErrorValue; } // -------------------------------------------------------------------------- void __fastcall TDx9_InputDevice::FSetErrorValue( HRESULT pErrorValue ) { fErrorValue = pErrorValue; } // -------------------------------------------------------------------------- // Method: Acquire() // Description: The Acquire method is used to ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::Acquire() { // Original Function Definition // HRESULT Acquire(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::Acquire()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->Acquire( ); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::Acquire()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: BuildActionMap() // Description: The BuildActionMap method is used to ... // Params: plpdiaf - // The lpdiaf parameter ... // pUserName - // The UserName parameter ... // pFlags - // The Flags parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::BuildActionMap( TDIActionFormat* plpdiaf, AnsiString* pUserName, dword pFlags ) { // Original Function Definition // HRESULT BuildActionMap( // LPDIACTIONFORMAT lpdiaf, // LPCTSTR lpszUserName, // DWORD dwFlags // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::BuildActionMap()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Translate Parameters before calling Original Function AnsiString TempUserName = pUserName; // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->BuildActionMap( (plpdiaf==NULL) ? NULL : plpdiaf->Internal_DIACTIONFORMAT_Ptr, (LPCTSTR) TempUserName.c_str(), (DWORD) pFlags ); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::BuildActionMap()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: Create() // Description: The Create() method is used to automatically create the // internal LPDIRECTINPUTDEVICE8 interface used in the // TDx9_InputDevice component and must be called before any // methods of the TDx9_InputDevice component will function. // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::Create() { fCreated = true; if (fCreated && FOnCreate) FOnCreate(this); return fCreated; } // -------------------------------------------------------------------------- // Method: CreateEffect() // Description: The CreateEffect method is used to ... // Params: prguid - // The rguid parameter ... // plpeff - // The lpeff parameter ... // p*ppdeff - // The *ppdeff parameter ... // pOuter - // The Outer parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::CreateEffect( REFGUID prguid, TDIEffect* plpeff, TDx_InputEffect* p*ppdeff, LPUNKNOWN pOuter ) { // Original Function Definition // HRESULT CreateEffect( // REFGUID rguid, // LPCDIEFFECT lpeff, // LPDIRECTINPUTEFFECT *ppdeff, // LPUNKNOWN punkOuter // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::CreateEffect()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->CreateEffect( prguid, (plpeff==NULL) ? NULL : plpeff->Internal_DIEFFECT_Ptr, (p*ppdeff==NULL) ? NULL : p*ppdeff->Internal_LPDIRECTINPUTEFFECT_Ptr, pOuter ); // Translate Data returned from Function if (plpeff!=NULL) plpeff->Internal_DIEFFECT_Update(); if (p*ppdeff!=NULL) p*ppdeff->Internal_LPDIRECTINPUTEFFECT_Update(); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::CreateEffect()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: Destroy() // Description: The Destroy() method is used to automatically destroy the // internal LPDIRECTINPUTDEVICE8 interface used in the // TDx9_InputDevice 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 TDx9_InputDevice::Destroy() { fCreated = false; if (FOnDestroy) FOnDestroy(this); return !fCreated; } // -------------------------------------------------------------------------- // Method: EnumCreatedEffectObjects() // Description: The EnumCreatedEffectObjects method is used to ... // Params: pRef - // The Ref parameter ... // pfl - // The fl parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::EnumCreatedEffectObjects( void* pRef, dword pfl ) { // Original Function Definition // HRESULT EnumCreatedEffectObjects( // LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, // LPVOID pvRef, // DWORD fl // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::EnumCreatedEffectObjects()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function TDx9_InputDevice_OnEnumCreatedEffectObjectsOwner = this; fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->EnumCreatedEffectObjects( Internal_EnumCreatedEffectObjectsCallback, (LPVOID) pRef, (DWORD) pfl ); TDx9_InputDevice_OnEnumCreatedEffectObjectsOwner = NULL; // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::EnumCreatedEffectObjects()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: EnumEffects() // Description: The EnumEffects method is used to ... // Params: pRef - // The Ref parameter ... // pEffType - // The EffType parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::EnumEffects( void* pRef, dword pEffType ) { // Original Function Definition // HRESULT EnumEffects( // LPDIENUMEFFECTSCALLBACK lpCallback, // LPVOID pvRef, // DWORD dwEffType // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::EnumEffects()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function TDx9_InputDevice_OnEnumEffectsOwner = this; fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->EnumEffects( Internal_EnumEffectsCallback, (LPVOID) pRef, (DWORD) pEffType ); TDx9_InputDevice_OnEnumEffectsOwner = NULL; // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::EnumEffects()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: EnumEffectsInFile() // Description: The EnumEffectsInFile method is used to ... // Params: pFileName - // The FileName parameter ... // pRef - // The Ref parameter ... // pFlags - // The Flags parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::EnumEffectsInFile( AnsiString* pFileName, void* pRef, dword pFlags ) { // Original Function Definition // HRESULT EnumEffectsInFile( // LPCSTR lpszFileName, // LPENUMEFFECTSINFILECALLBACK pec, // LPVOID pvRef, // DWORD dwFlags // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::EnumEffectsInFile()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function TDx9_InputDevice_OnEnumEffectsInFileOwner = this; fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->EnumEffectsInFile( (LPCSTR) pFileName, Internal_EnumEffectsInFileCallback, (LPVOID) pRef, (DWORD) pFlags ); TDx9_InputDevice_OnEnumEffectsInFileOwner = NULL; // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::EnumEffectsInFile()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: EnumObjects() // Description: The EnumObjects method is used to ... // Params: pRef - // The Ref parameter ... // pFlags - // The Flags parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::EnumObjects( void* pRef, dword pFlags ) { // Original Function Definition // HRESULT EnumObjects( // LPDIENUMDEVICEOBJECTSCALLBACK lpCallback, // LPVOID pvRef, // DWORD dwFlags // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::EnumObjects()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function TDx9_InputDevice_OnEnumObjectsOwner = this; fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->EnumObjects( Internal_EnumObjectsCallback, (LPVOID) pRef, (DWORD) pFlags ); TDx9_InputDevice_OnEnumObjectsOwner = NULL; // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::EnumObjects()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: Escape() // Description: The Escape method is used to ... // Params: ppesc - // The pesc parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::Escape( TDIEffEscape* ppesc ) { // 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; } // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->Escape( (ppesc==NULL) ? NULL : ppesc->Internal_DIEFFESCAPE_Ptr ); // Translate Data returned from Function if (ppesc!=NULL) ppesc->Internal_DIEFFESCAPE_Update(); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::Escape()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetCapabilities() // Description: The GetCapabilities method is used to ... // Params: pDIDevCaps - // The DIDevCaps parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::GetCapabilities( TDIDevCaps* pDIDevCaps ) { // Original Function Definition // HRESULT GetCapabilities( // LPDIDEVCAPS lpDIDevCaps // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetCapabilities()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->GetCapabilities( (pDIDevCaps==NULL) ? NULL : pDIDevCaps->Internal_DIDEVCAPS_Ptr ); // Translate Data returned from Function if (pDIDevCaps!=NULL) pDIDevCaps->Internal_DIDEVCAPS_Update(); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetCapabilities()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetDeviceData() // Description: The GetDeviceData method is used to ... // Params: pObjectData - // The ObjectData parameter ... // prgdod - // The rgdod parameter ... // pInOut - // The InOut parameter ... // pFlags - // The Flags parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::GetDeviceData( dword pObjectData, TDIDeviceObjectData* prgdod, dword* pInOut, dword pFlags ) { // Original Function Definition // HRESULT GetDeviceData( // DWORD cbObjectData, // LPDIDEVICEOBJECTDATA rgdod, // LPDWORD pdwInOut, // DWORD dwFlags // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetDeviceData()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->GetDeviceData( (DWORD) pObjectData, (prgdod==NULL) ? NULL : prgdod->Internal_DIDEVICEOBJECTDATA_Ptr, (LPDWORD) pInOut, (DWORD) pFlags ); // Translate Data returned from Function if (prgdod!=NULL) prgdod->Internal_DIDEVICEOBJECTDATA_Update(); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetDeviceData()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetDeviceInfo() // Description: The GetDeviceInfo method is used to ... // Params: ppdidi - // The pdidi parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::GetDeviceInfo( TDIDeviceInstance* ppdidi ) { // Original Function Definition // HRESULT GetDeviceInfo( // LPDIDEVICEINSTANCE pdidi // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetDeviceInfo()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->GetDeviceInfo( (ppdidi==NULL) ? NULL : ppdidi->Internal_DIDEVICEINSTANCE_Ptr ); // Translate Data returned from Function if (ppdidi!=NULL) ppdidi->Internal_DIDEVICEINSTANCE_Update(); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetDeviceInfo()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetDeviceState() // Description: The GetDeviceState method is used to ... // Params: pData - // The Data parameter ... // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- // Method: GetEffectInfo() // Description: The GetEffectInfo method is used to ... // Params: ppdei - // The pdei parameter ... // prguid - // The rguid parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::GetEffectInfo( TDIEffectInfo* ppdei, REFGUID prguid ) { // Original Function Definition // HRESULT GetEffectInfo( // LPDIEFFECTINFO pdei, // REFGUID rguid // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetEffectInfo()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->GetEffectInfo( (ppdei==NULL) ? NULL : ppdei->Internal_DIEFFECTINFO_Ptr, prguid ); // Translate Data returned from Function if (ppdei!=NULL) ppdei->Internal_DIEFFECTINFO_Update(); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetEffectInfo()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetForceFeedbackState() // Description: The GetForceFeedbackState method is used to ... // Params: pOut - // The Out parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::GetForceFeedbackState( dword* pOut ) { // Original Function Definition // HRESULT GetForceFeedbackState( // LPDWORD pdwOut // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetForceFeedbackState()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->GetForceFeedbackState( (LPDWORD) pOut ); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetForceFeedbackState()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetImageInfo() // Description: The GetImageInfo method is used to ... // Params: pDevImageInfoHeader - // The DevImageInfoHeader parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::GetImageInfo( TDIDeviceImageInfoHeader* pDevImageInfoHeader ) { // Original Function Definition // HRESULT GetImageInfo( // LPDIDEVICEIMAGEINFOHEADER lpdiDevImageInfoHeader // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetImageInfo()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->GetImageInfo( (pDevImageInfoHeader==NULL) ? NULL : pDevImageInfoHeader->Internal_DIDEVICEIMAGEINFOHEADER_Ptr ); // Translate Data returned from Function if (pDevImageInfoHeader!=NULL) pDevImageInfoHeader->Internal_DIDEVICEIMAGEINFOHEADER_Update(); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetImageInfo()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetObjectInfo() // Description: The GetObjectInfo method is used to ... // Params: ppdidoi - // The pdidoi parameter ... // pObj - // The Obj parameter ... // pHow - // The How parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::GetObjectInfo( TDIDeviceObjectInstance* ppdidoi, dword pObj, dword pHow ) { // Original Function Definition // HRESULT GetObjectInfo( // LPDIDEVICEOBJECTINSTANCE pdidoi, // DWORD dwObj, // DWORD dwHow // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetObjectInfo()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->GetObjectInfo( (ppdidoi==NULL) ? NULL : ppdidoi->Internal_DIDEVICEOBJECTINSTANCE_Ptr, (DWORD) pObj, (DWORD) pHow ); // Translate Data returned from Function if (ppdidoi!=NULL) ppdidoi->Internal_DIDEVICEOBJECTINSTANCE_Update(); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetObjectInfo()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetProperty() // Description: The GetProperty method is used to ... // Params: pProp - // The Prop parameter ... // ppdiph - // The pdiph parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::GetProperty( REFGUID pProp, TDIPropHeader* ppdiph ) { // Original Function Definition // HRESULT GetProperty( // REFGUID rguidProp, // LPDIPROPHEADER pdiph // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetProperty()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->GetProperty( pProp, (ppdiph==NULL) ? NULL : ppdiph->Internal_DIPROPHEADER_Ptr ); // Translate Data returned from Function if (ppdiph!=NULL) ppdiph->Internal_DIPROPHEADER_Update(); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetProperty()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: Initialize() // Description: The Initialize method is used to ... // Params: phinst - // The hinst parameter ... // pVersion - // The Version parameter ... // prguid - // The rguid parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::Initialize( HINSTANCE phinst, dword pVersion, REFGUID prguid ) { // Original Function Definition // HRESULT Initialize( // HINSTANCE hinst, // DWORD dwVersion, // REFGUID rguid // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::Initialize()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->Initialize( phinst, (DWORD) pVersion, prguid ); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::Initialize()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: Poll() // Description: The Poll method is used to ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::Poll() { // Original Function Definition // HRESULT Poll(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::Poll()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->Poll( ); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::Poll()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: RunControlPanel() // Description: The RunControlPanel method is used to ... // Params: pOwner - // The Owner parameter ... // pFlags - // The Flags parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::RunControlPanel( HWND pOwner, dword pFlags ) { // Original Function Definition // HRESULT RunControlPanel( // HWND hwndOwner, // DWORD dwFlags // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::RunControlPanel()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->RunControlPanel( pOwner, (DWORD) pFlags ); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::RunControlPanel()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SendDeviceData() // Description: The SendDeviceData method is used to ... // Params: pObjectData - // The ObjectData parameter ... // prgdod - // The rgdod parameter ... // pInOut - // The InOut parameter ... // pfl - // The fl parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::SendDeviceData( dword pObjectData, TDIDeviceObjectData* prgdod, dword* pInOut, dword pfl ) { // Original Function Definition // HRESULT SendDeviceData( // DWORD cbObjectData, // LPCDIDEVICEOBJECTDATA rgdod, // LPDWORD pdwInOut, // DWORD fl // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SendDeviceData()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->SendDeviceData( (DWORD) pObjectData, (prgdod==NULL) ? NULL : prgdod->Internal_DIDEVICEOBJECTDATA_Ptr, (LPDWORD) pInOut, (DWORD) pfl ); // Translate Data returned from Function if (prgdod!=NULL) prgdod->Internal_DIDEVICEOBJECTDATA_Update(); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SendDeviceData()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SendForceFeedbackCommand() // Description: The SendForceFeedbackCommand method is used to ... // Params: pFlags - // The Flags parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::SendForceFeedbackCommand( dword pFlags ) { // Original Function Definition // HRESULT SendForceFeedbackCommand( // DWORD dwFlags // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SendForceFeedbackCommand()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->SendForceFeedbackCommand( (DWORD) pFlags ); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SendForceFeedbackCommand()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetActionMap() // Description: The SetActionMap method is used to ... // Params: pActionFormat - // The ActionFormat parameter ... // pUserName - // The UserName parameter ... // pFlags - // The Flags parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::SetActionMap( TDIActionFormat* pActionFormat, AnsiString* pUserName, dword pFlags ) { // Original Function Definition // HRESULT SetActionMap( // LPCDIACTIONFORMAT lpdiActionFormat, // LPCTSTR lptszUserName, // DWORD dwFlags // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetActionMap()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Translate Parameters before calling Original Function AnsiString TempUserName = pUserName; // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->SetActionMap( (pActionFormat==NULL) ? NULL : pActionFormat->Internal_DIACTIONFORMAT_Ptr, (LPCTSTR) TempUserName.c_str(), (DWORD) pFlags ); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetActionMap()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetCooperativeLevel() // Description: The SetCooperativeLevel method is used to ... // Params: phwnd - // The hwnd parameter ... // pFlags - // The Flags parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::SetCooperativeLevel( HWND phwnd, dword pFlags ) { // Original Function Definition // HRESULT SetCooperativeLevel( // HWND hwnd, // DWORD dwFlags // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetCooperativeLevel()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->SetCooperativeLevel( phwnd, (DWORD) pFlags ); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetCooperativeLevel()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetDataFormat() // Description: The SetDataFormat method is used to ... // Params: plpdf - // The lpdf parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::SetDataFormat( TDIDataFormat* plpdf ) { // Original Function Definition // HRESULT SetDataFormat( // LPCDIDATAFORMAT lpdf // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetDataFormat()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->SetDataFormat( (plpdf==NULL) ? NULL : plpdf->Internal_DIDATAFORMAT_Ptr ); // Translate Data returned from Function if (plpdf!=NULL) plpdf->Internal_DIDATAFORMAT_Update(); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetDataFormat()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetEventNotification() // Description: The SetEventNotification method is used to ... // Params: pEvent - // The Event parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::SetEventNotification( HANDLE pEvent ) { // Original Function Definition // HRESULT SetEventNotification( // HANDLE hEvent // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetEventNotification()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->SetEventNotification( pEvent ); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetEventNotification()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetProperty() // Description: The SetProperty method is used to ... // Params: pProp - // The Prop parameter ... // ppdiph - // The pdiph parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::SetProperty( REFGUID pProp, TDIPropHeader* ppdiph ) { // Original Function Definition // HRESULT SetProperty( // REFGUID rguidProp, // LPCDIPROPHEADER pdiph // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetProperty()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->SetProperty( pProp, (ppdiph==NULL) ? NULL : ppdiph->Internal_DIPROPHEADER_Ptr ); // Translate Data returned from Function if (ppdiph!=NULL) ppdiph->Internal_DIPROPHEADER_Update(); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetProperty()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: Unacquire() // Description: The Unacquire method is used to ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::Unacquire() { // Original Function Definition // HRESULT Unacquire(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::Unacquire()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->Unacquire( ); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::Unacquire()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: WriteEffectToFile() // Description: The WriteEffectToFile method is used to ... // Params: pFileName - // The FileName parameter ... // pEntries - // The Entries parameter ... // pDiFileEft - // The DiFileEft parameter ... // pFlags - // The Flags parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_InputDevice::WriteEffectToFile( AnsiString* pFileName, dword pEntries, TDIFileEffect* pDiFileEft, dword pFlags ) { // Original Function Definition // HRESULT WriteEffectToFile( // LPCSTR lpszFileName, // DWORD dwEntries, // LPCDIFILEEFFECT rgDiFileEft, // DWORD dwFlags // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::WriteEffectToFile()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECTINPUTDEVICE8->WriteEffectToFile( (LPCSTR) pFileName, (DWORD) pEntries, (pDiFileEft==NULL) ? NULL : pDiFileEft->Internal_DIFILEEFFECT_Ptr, (DWORD) pFlags ); // Translate Data returned from Function if (pDiFileEft!=NULL) pDiFileEft->Internal_DIFILEEFFECT_Update(); // Handle any Known Results if (fErrorValue!=DI_OK) { // Failure. if (FOnError) FOnError( this, Name+"::WriteEffectToFile()", TDx9_Input_Library_ErrorString(fErrorValue), TDx9_Input_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Internal Interface Access // -------------------------------------------------------------------------- LPDIRECTINPUTDEVICE8 __fastcall TDx9_InputDevice::FGetInternal_LPDIRECTINPUTDEVICE8() { return fLPDIRECTINPUTDEVICE8; } // -------------------------------------------------------------------------- LPDIRECTINPUTDEVICE8* __fastcall TDx9_InputDevice::FGetInternal_LPDIRECTINPUTDEVICE8_Ptr() { return &fLPDIRECTINPUTDEVICE8; } // -------------------------------------------------------------------------- void __fastcall TDx9_InputDevice::FSetInternal_LPDIRECTINPUTDEVICE8( LPDIRECTINPUTDEVICE8 pLPDIRECTINPUTDEVICE8 ) { if (!fCreated) { fLPDIRECTINPUTDEVICE8 = pLPDIRECTINPUTDEVICE8; fCreated = (fLPDIRECTINPUTDEVICE8!=NULL); } } // -------------------------------------------------------------------------- void __fastcall TDx9_InputDevice::Internal_LPDIRECTINPUTDEVICE8_Update() { fCreated = (fLPDIRECTINPUTDEVICE8!=NULL); } // --------------------------------------------------------------------------