#ifndef TDIObjectDataFormatH #define TDIObjectDataFormatH // ========================================================================== // File: TDIObjectDataFormat.H // Authors: BCB_Code_Generator v1.70, // Darren Dwyer (source code, documentation, demos, website), // Hugh Edwards (documentation, icons, website), // Brian Austin (some source code, documentation) // Description: This file defines the TDIObjectDataFormat Component // // "TDx_Input_Library v1.70" // (c) 2003 BCB-Tools.com Pty. Ltd., Sydney, Australia. // All Rights Reserved. // // Refer to the 'Licence.Txt' file for licencing & copyright information. // ========================================================================== // -------------------------------------------------------------------------- #include "TDx_Library_Defns.H" #include "TDx_Library_Functions.H" // -------------------------------------------------------------------------- #include "TDx_Input_Library_Defns.H" #include "TDx_Input_Library_Functions.H" // ========================================================================== // Set: TDIObjectDataFormatFlags_Set // Description: A set of mangled DirectX flag names that are used to set the // TDIObjectDataFormat::Flags property using the BCB Object // Inspector. For detailed descriptions of each flag, see the // Flags property description below. // ========================================================================== enum TDIObjectDataFormat_Flags_Flags { didoi_aspectaccel_, didoi_aspectforce_, didoi_aspectposition_, didoi_aspectvelocity }; typedef Set< TDIObjectDataFormat_Flags_Flags, didoi_aspectaccel_, didoi_aspectvelocity > TDIObjectDataFormat_Flags_Set; // ========================================================================== // Set: TDIObjectDataFormatType_Set // Description: A set of mangled DirectX flag names that are used to set the // TDIObjectDataFormat::Type property using the BCB Object // Inspector. For detailed descriptions of each flag, see the // Type property description below. // ========================================================================== enum TDIObjectDataFormat_Type_Flags { didft_absaxis, didft_axis, didft_button, didft_ffactuator, didft_ffeffecttrigger, didft_pov, didft_pshbutton, didft_relaxis, didft_tglbutton, didft_vendordefined }; typedef Set< TDIObjectDataFormat_Type_Flags, didft_absaxis, didft_vendordefined > TDIObjectDataFormat_Type_Set; // -------------------------------------------------------------------------- // ========================================================================== // Class: TDIObjectDataFormat // Description: The TDIObjectDataFormat component wraps multiple DirectX // DIOBJECTDATAFORMAT structures, which describes a device // object's data format. // // This component is used with the // TDx_InputDevice::SetDataFormat() method to create the data // format for a specialized device as part of the TDIDataFormat // component defining the data format of a device's individual // controls. Eg: the buttons, sliders, x-axis or y-axis of a // joystick, etc. // // In most cases the use of predefined data formats for mice, // joysticks and keyboards make using this component // unneccessary. // // The data format must be set before a device can be acquired // with TDx_InputDevice::Acquire() and used. // While the device is acquired, the data format cannot be // changed but it should only be neccessary to set the data // format once. // // To setup this component, first set the // TDIObjectDataFormat::ArraySize property, then set each // property using array indexes, eg: // // // create internal storage for 5 DIOBJECTDATAFORMAT // structures // // DIObjectDataFormat->ArraySize = 5; // // // fill each array with appropriate data // // for (int i=0;i<5;i++) // { // DIObjectDataFormat1->Flags[i] = DIDOI_ASPECTFORCE; // } // // ========================================================================== #if (__BORLANDC__ >= 0x0530) // BCB Version 3 + class PACKAGE TDIObjectDataFormat : public TComponent { // -------------------------------------------------------------------------- #else // BCB Version 1 class TDIObjectDataFormat : public TComponent { #endif // ========================================================================== __published: // ========================================================================== // ---------------------------------------------------------------------- // Event: OnError() // Description: The OnError event is called when an error occurs in the // TDIObjectDataFormat component. // ---------------------------------------------------------------------- __property TDx_Error OnError = {read=FOnError, write=FOnError, nodefault}; // ========================================================================== public: // ========================================================================== // ---------------------------------------------------------------------- // Property: ArraySize // Description: The ArraySize property contains the number of internal // DIOBJECTDATAFORMAT structures wrapped inside the // TDIObjectDataFormat component. // By default the ArraySize is initialized to 1, meaning // that this TDIObjectDataFormat component wraps a single // DIOBJECTDATAFORMAT structure. To wrap multiple // structures, set the TDIObjectDataFormat::ArraySize to the // total number of internal structures desired. // ---------------------------------------------------------------------- __property dword ArraySize = { read=FGetArraySize, write=FSetArraySize, default=1 }; // ---------------------------------------------------------------------- // Property: ErrorValue // Description: The ErrorValue property contains the last error value // returned from a call to a TDIObjectDataFormat method or // fget/fset. eg. DI_OK or DDERR_SURFACELOST or TDX_ERROR // ---------------------------------------------------------------------- __property HRESULT ErrorValue = { read=FGetErrorValue, write=FSetErrorValue, default=DI_OK }; // ---------------------------------------------------------------------- // Property: Flags // Description: The Flags property defines flags indicating what // information is to be reported by the device. // The described effect applies when the flag is set. // Flags: DIDOI_ASPECTACCEL - // The object selected by TDx_InputDevice::SetDataFormat() // must report acceleration information. // DIDOI_ASPECTFORCE - // The object selected by TDx_InputDevice::SetDataFormat() // must report force information. // DIDOI_ASPECTPOSITION - // The object selected by TDx_InputDevice::SetDataFormat() // must report position information. // DIDOI_ASPECTVELOCITY - // The object selected by TDx_InputDevice::SetDataFormat() // must report velocity information. // ---------------------------------------------------------------------- __property dword Flags[dword pArrayIndex] = { read=FGetFlags, write=FSetFlags }; // ---------------------------------------------------------------------- // Property: Guid // Description: The Guid property identifies an object (axis, button, or // other input source). // // When requesting a data format, making this property NULL // indicates that any type of object is permissible. // // Possible values include: // // GUID_XAxis the left-right motion of a mouse. // GUID_YAxis forward-backward motion of a mouse. // GUID_ZAxis the wheel on a mouse // GUID_RxAxis Rotation around the x-axis. // GUID_RyAxis Rotation around the y-axis. // GUID_RzAxis Rotation around the z-axis. // GUID_Slider A slider axis. // GUID_Button A mouse button. // GUID_Key A keyboard key. // GUID_POV A point-of-view indicator. // GUID_Unknown Unknown. // ---------------------------------------------------------------------- __property const GUID* Guid[dword pArrayIndex] = { read=FGetGuid, write=FSetGuid }; // ---------------------------------------------------------------------- // Property: Ofs // Description: The Ofs property defines the data packet offset, in // bytes, where the objects data can be found. // // This property must be a multiple of four for dword size // data like axes, or byte aligned for buttons. // ---------------------------------------------------------------------- __property dword Ofs[dword pArrayIndex] = { read=FGetOfs, write=FSetOfs }; // ---------------------------------------------------------------------- // Property: Size // Description: The Size property contains the size in bytes of a single // internal DIOBJECTDATAFORMAT structure. // ---------------------------------------------------------------------- __property dword Size = { read=FGetSize, write=FSetSize, nodefault }; // ---------------------------------------------------------------------- // Property: SizeAll // Description: The SizeAll property contains the size in bytes of all // internal DIOBJECTDATAFORMAT structures. This result is // the same as multiplying TDIObjectDataFormat::ArraySize // and TDIObjectDataFormat::Size. // ---------------------------------------------------------------------- __property dword SizeAll = { read=FGetSizeAll, nodefault }; // ---------------------------------------------------------------------- // Property: Type // Description: The Type property is unusual, in that it defines flags // indicating the object type and it also identifies the // object instance number in the middle 16 bits. // // Set the instance portion to DIDFT_ANYINSTANCE or // DIDFT_MAKEINSTANCE(n) when requesting a data format to // indicate either that any instance is permissible or to // restrict the request to a specific instance. // // The object instance number can be extracted using the // DIDFT_GETINSTANCE macro: // // DIDFT_GETINSTANCE(n) LOWORD((n) >> 8) // // where n is one of the TDIObjectDataFormat::Type flag // values. // // The described effect applies when the flag is set. // Flags: DIDFT_ABSAXIS - // The object selected by TDx_Input::SetDataFormat() must // be an absolute axis. // DIDFT_AXIS - // The object selected by TDx_Input::SetDataFormat() must // be an absolute or relative axis. // DIDFT_BUTTON - // The object selected by TDx_Input::SetDataFormat() must // be a push or toggle button. // DIDFT_FFACTUATOR - // The object selected by TDx_Input::SetDataFormat() must // contain a force feedback actuator so that it is // possible to apply forces to the object. // DIDFT_FFEFFECTTRIGGER - // The object selected by TDx_Input::SetDataFormat() must // be a valid force feedback effect trigger. // DIDFT_POV - // The object selected by TDx_Input::SetDataFormat() must // be a point of view controller. // DIDFT_PSHBUTTON - // The object selected by TDx_Input::SetDataFormat() must // be a push button. // DIDFT_RELAXIS - // The object selected by TDx_InputDevice::SetDataFormat() // must be a relative axis. // DIDFT_TGLBUTTON - // The object selected by TDx_InputDevice::SetDataFormat() // must be a toggle button. // DIDFT_VENDORDEFINED - // The object selected by TDx_InputDevice::SetDataFormat() // must be manufacturer defined. // ---------------------------------------------------------------------- __property dword Type[dword pArrayIndex] = { read=FGetType, write=FSetType }; // ---------------------------------------------------------------------- // Method: Clear() // Description: The Clear() method can be used to clear the contents of // the TDIObjectDataFormat's internal DIOBJECTDATAFORMAT // structure. // Note: if you have manually linked a structure member to a // chunk of memory, make sure you release this memory before // calling Clear(). // Params: pArrayIndex - // The ArrayIndex parameter determines which internal // structure needs to be cleared. Correct values range from // 0 to TDIObjectDataFormat::ArraySize-1. // ---------------------------------------------------------------------- virtual void __fastcall Clear( dword pArrayIndex ); // ---------------------------------------------------------------------- // Method: ClearAll() // Description: The ClearAll() method can be used to clear the contents // of all the internal DIOBJECTDATAFORMAT structures of the // TDIObjectDataFormat component. // Note: if you have manually linked a structure member to a // chunk of memory, make sure you release this memory before // calling Clear(). // ---------------------------------------------------------------------- virtual void __fastcall ClearAll(); // ---------------------------------------------------------------------- // Property: Flags_Strings() // Description: This property returns a TStringList containing current // flag values for the Flags property. Note: Any memory // associated with these strings is released on destruction. // ---------------------------------------------------------------------- __property TStringList* Flags_Strings[dword pArrayIndex] = { read=FGetFlags_Strings }; // ---------------------------------------------------------------------- // Property: Type_Strings() // Description: This property returns a TStringList containing current // flag values for the Type property. Note: Any memory // associated with these strings is released on destruction. // ---------------------------------------------------------------------- __property TStringList* Type_Strings[dword pArrayIndex] = { read=FGetType_Strings }; // ---------------------------------------------------------------------- // Property: Flags_ // Description: The Flags property defines flags indicating what // information is to be reported by the device. // The described effect applies when the flag is set. // Note: This property is used to set the various DirectX Flags // for the 'Flags' property via the BCB Object Inspector. // For detailed descriptions of each flag, see the Flags // property description below. // ---------------------------------------------------------------------- __property TDIObjectDataFormat_Flags_Set Flags_[dword pArrayIndex] = { read=FGetFlags_, write=FSetFlags_ }; // ---------------------------------------------------------------------- // Property: Type_ // Description: The Type property is unusual, in that it defines flags // indicating the object type and it also identifies the // object instance number in the middle 16 bits. // // Set the instance portion to DIDFT_ANYINSTANCE or // DIDFT_MAKEINSTANCE(n) when requesting a data format to // indicate either that any instance is permissible or to // restrict the request to a specific instance. // // The object instance number can be extracted using the // DIDFT_GETINSTANCE macro: // // DIDFT_GETINSTANCE(n) LOWORD((n) >> 8) // // where n is one of the TDIObjectDataFormat::Type flag // values. // // The described effect applies when the flag is set. // Note: This property is used to set the various DirectX Flags // for the 'Type' property via the BCB Object Inspector. // For detailed descriptions of each flag, see the Type // property description below. // ---------------------------------------------------------------------- __property TDIObjectDataFormat_Type_Set Type_[dword pArrayIndex] = { read=FGetType_, write=FSetType_ }; // ---------------------------------------------------------------------- // Constructor() and Destructor() // ---------------------------------------------------------------------- __fastcall TDIObjectDataFormat(TComponent* Owner); virtual __fastcall ~TDIObjectDataFormat(); // ---------------------------------------------------------------------- // Internal Structure Access // ---------------------------------------------------------------------- __property DIOBJECTDATAFORMAT* Internal_DIOBJECTDATAFORMAT_Ptr = { read=FGetInternal_DIOBJECTDATAFORMAT_Ptr, nodefault }; void __fastcall Internal_DIOBJECTDATAFORMAT_Update(); // ========================================================================== protected: // ========================================================================== // ---------------------------------------------------------------------- // Object Inspector 'Flag' Access Methods // ---------------------------------------------------------------------- TDIObjectDataFormat_Flags_Set __fastcall FGetFlags_( dword pArrayIndex ); void __fastcall FSetFlags_( dword pArrayIndex, TDIObjectDataFormat_Flags_Set pFlags_ ); TDIObjectDataFormat_Type_Set __fastcall FGetType_( dword pArrayIndex ); void __fastcall FSetType_( dword pArrayIndex, TDIObjectDataFormat_Type_Set pType_ ); // ---------------------------------------------------------------------- // Property Access Methods // ---------------------------------------------------------------------- dword __fastcall FGetArraySize(); void __fastcall FSetArraySize( dword pArraySize ); HRESULT __fastcall FGetErrorValue(); void __fastcall FSetErrorValue( HRESULT pErrorValue ); dword __fastcall FGetFlags( dword pArrayIndex ); void __fastcall FSetFlags( dword pArrayIndex, dword pFlags ); const GUID* __fastcall FGetGuid( dword pArrayIndex ); void __fastcall FSetGuid( dword pArrayIndex, const GUID* pGuid ); dword __fastcall FGetOfs( dword pArrayIndex ); void __fastcall FSetOfs( dword pArrayIndex, dword pOfs ); dword __fastcall FGetSize(); void __fastcall FSetSize( dword pSize ); dword __fastcall FGetSizeAll(); dword __fastcall FGetType( dword pArrayIndex ); void __fastcall FSetType( dword pArrayIndex, dword pType ); // ---------------------------------------------------------------------- // Flag_Strings Access Methods // ---------------------------------------------------------------------- TStringList* __fastcall FGetFlags_Strings( dword pArrayIndex ); TStringList* __fastcall FGetType_Strings( dword pArrayIndex ); // ========================================================================== private: // ========================================================================== // ---------------------------------------------------------------------- // Internal Structure Access // ---------------------------------------------------------------------- DIOBJECTDATAFORMAT* __fastcall FGetInternal_DIOBJECTDATAFORMAT_Ptr(); void __fastcall FSetInternal_DIOBJECTDATAFORMAT( dword pArrayIndex, DIOBJECTDATAFORMAT* pDIOBJECTDATAFORMAT ); // ---------------------------------------------------------------------- // Property Variables // ---------------------------------------------------------------------- dword fArraySize; HRESULT fErrorValue; dword fSize; dword fSizeAll; // ---------------------------------------------------------------------- // Flags_Strings Variables // ---------------------------------------------------------------------- TStringList* fFlags_Strings; TStringList* fType_Strings; // ---------------------------------------------------------------------- // Structure Variables // ---------------------------------------------------------------------- DIOBJECTDATAFORMAT* fDIOBJECTDATAFORMAT; // ---------------------------------------------------------------------- // Event Variables // ---------------------------------------------------------------------- TDx_Error FOnError; }; // -------------------------------------------------------------------------- #endif // --------------------------------------------------------------------------