// -------------------------------------------------------------------------- // ========================================================================== // File: TDIJoyState2.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 TDIJoyState2 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 "TDIJoyState2.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(TDIJoyState2*) { new TDIJoyState2(NULL); } // -------------------------------------------------------------------------- namespace Tdijoystate2 { #if (__BORLANDC__ >= 0x0530) // BCB Version 3+ void __fastcall PACKAGE Register() #else void __fastcall Register() #endif { TComponentClass classes[1] = {__classid(TDIJoyState2)}; RegisterComponents("", classes, 0); } } // -------------------------------------------------------------------------- // Constructor: TDIJoyState2::TDIJoyState2() // Description: The default constructor for the TDIJoyState2 object. // -------------------------------------------------------------------------- __fastcall TDIJoyState2::TDIJoyState2(TComponent* Owner) : TComponent(Owner) { Clear(); } // -------------------------------------------------------------------------- // Destructor: TDIJoyState2::~TDIJoyState2() // Description: The destructor for the TDIJoyState2 object. // -------------------------------------------------------------------------- __fastcall TDIJoyState2::~TDIJoyState2() { } // -------------------------------------------------------------------------- // Property: ARx // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetARx() { return fJOYSTATE2.lARx; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetARx( long pARx ) { fJOYSTATE2.lARx = pARx; } // -------------------------------------------------------------------------- // Property: ARy // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetARy() { return fJOYSTATE2.lARy; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetARy( long pARy ) { fJOYSTATE2.lARy = pARy; } // -------------------------------------------------------------------------- // Property: ARz // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetARz() { return fJOYSTATE2.lARz; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetARz( long pARz ) { fJOYSTATE2.lARz = pARz; } // -------------------------------------------------------------------------- // Property: ASlider // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetASlider( dword pIndex ) { if (pIndex>=2) { fErrorValue = TDX_ERROR; if (FOnError) FOnError(this, "TDIJoyState2::FGetASlider()", "TDX_ERROR", "'pIndex' parameter is out of bounds." ); return (LONG) NULL; } return fJOYSTATE2.rglASlider[pIndex]; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetASlider( dword pIndex, long pASlider ) { fJOYSTATE2.rglASlider[pIndex] = pASlider; } // -------------------------------------------------------------------------- // Property: AX // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetAX() { return fJOYSTATE2.lAX; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetAX( long pAX ) { fJOYSTATE2.lAX = pAX; } // -------------------------------------------------------------------------- // Property: AY // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetAY() { return fJOYSTATE2.lAY; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetAY( long pAY ) { fJOYSTATE2.lAY = pAY; } // -------------------------------------------------------------------------- // Property: AZ // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetAZ() { return fJOYSTATE2.lAZ; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetAZ( long pAZ ) { fJOYSTATE2.lAZ = pAZ; } // -------------------------------------------------------------------------- // Property: Buttons // Description: ... // -------------------------------------------------------------------------- byte __fastcall TDIJoyState2::FGetButtons( dword pIndex ) { if (pIndex>=128) { fErrorValue = TDX_ERROR; if (FOnError) FOnError(this, "TDIJoyState2::FGetButtons()", "TDX_ERROR", "'pIndex' parameter is out of bounds." ); return (BYTE) NULL; } return fJOYSTATE2.rgbButtons[pIndex]; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetButtons( dword pIndex, byte pButtons ) { fJOYSTATE2.rgbButtons[pIndex] = pButtons; } // -------------------------------------------------------------------------- // Property: ErrorValue // Description: The ErrorValue property contains the last error value // returned from a call to a TDIJoyState2 method or fget/fset. // eg. DI_OK or DDERR_SURFACELOST or TDX_ERROR // -------------------------------------------------------------------------- HRESULT __fastcall TDIJoyState2::FGetErrorValue() { return fErrorValue; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetErrorValue( HRESULT pErrorValue ) { fErrorValue = pErrorValue; } // -------------------------------------------------------------------------- // Property: FRx // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetFRx() { return fJOYSTATE2.lFRx; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetFRx( long pFRx ) { fJOYSTATE2.lFRx = pFRx; } // -------------------------------------------------------------------------- // Property: FRy // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetFRy() { return fJOYSTATE2.lFRy; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetFRy( long pFRy ) { fJOYSTATE2.lFRy = pFRy; } // -------------------------------------------------------------------------- // Property: FRz // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetFRz() { return fJOYSTATE2.lFRz; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetFRz( long pFRz ) { fJOYSTATE2.lFRz = pFRz; } // -------------------------------------------------------------------------- // Property: FSlider // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetFSlider( dword pIndex ) { if (pIndex>=2) { fErrorValue = TDX_ERROR; if (FOnError) FOnError(this, "TDIJoyState2::FGetFSlider()", "TDX_ERROR", "'pIndex' parameter is out of bounds." ); return (LONG) NULL; } return fJOYSTATE2.rglFSlider[pIndex]; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetFSlider( dword pIndex, long pFSlider ) { fJOYSTATE2.rglFSlider[pIndex] = pFSlider; } // -------------------------------------------------------------------------- // Property: FX // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetFX() { return fJOYSTATE2.lFX; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetFX( long pFX ) { fJOYSTATE2.lFX = pFX; } // -------------------------------------------------------------------------- // Property: FY // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetFY() { return fJOYSTATE2.lFY; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetFY( long pFY ) { fJOYSTATE2.lFY = pFY; } // -------------------------------------------------------------------------- // Property: FZ // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetFZ() { return fJOYSTATE2.lFZ; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetFZ( long pFZ ) { fJOYSTATE2.lFZ = pFZ; } // -------------------------------------------------------------------------- // Property: POV // Description: ... // -------------------------------------------------------------------------- dword __fastcall TDIJoyState2::FGetPOV( dword pIndex ) { if (pIndex>=4) { fErrorValue = TDX_ERROR; if (FOnError) FOnError(this, "TDIJoyState2::FGetPOV()", "TDX_ERROR", "'pIndex' parameter is out of bounds." ); return (DWORD) NULL; } return fJOYSTATE2.rgdwPOV[pIndex]; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetPOV( dword pIndex, dword pPOV ) { fJOYSTATE2.rgdwPOV[pIndex] = pPOV; } // -------------------------------------------------------------------------- // Property: Rx // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetRx() { return fJOYSTATE2.lRx; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetRx( long pRx ) { fJOYSTATE2.lRx = pRx; } // -------------------------------------------------------------------------- // Property: Ry // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetRy() { return fJOYSTATE2.lRy; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetRy( long pRy ) { fJOYSTATE2.lRy = pRy; } // -------------------------------------------------------------------------- // Property: Rz // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetRz() { return fJOYSTATE2.lRz; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetRz( long pRz ) { fJOYSTATE2.lRz = pRz; } // -------------------------------------------------------------------------- // Property: Size // Description: The Size property contains the size in bytes of the internal // { structure. // -------------------------------------------------------------------------- dword __fastcall TDIJoyState2::FGetSize() { return fSize; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetSize( dword pSize ) { fSize = pSize; } // -------------------------------------------------------------------------- // Property: Slider // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetSlider( dword pIndex ) { if (pIndex>=2) { fErrorValue = TDX_ERROR; if (FOnError) FOnError(this, "TDIJoyState2::FGetSlider()", "TDX_ERROR", "'pIndex' parameter is out of bounds." ); return (LONG) NULL; } return fJOYSTATE2.rglSlider[pIndex]; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetSlider( dword pIndex, long pSlider ) { fJOYSTATE2.rglSlider[pIndex] = pSlider; } // -------------------------------------------------------------------------- // Property: VRx // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetVRx() { return fJOYSTATE2.lVRx; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetVRx( long pVRx ) { fJOYSTATE2.lVRx = pVRx; } // -------------------------------------------------------------------------- // Property: VRy // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetVRy() { return fJOYSTATE2.lVRy; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetVRy( long pVRy ) { fJOYSTATE2.lVRy = pVRy; } // -------------------------------------------------------------------------- // Property: VRz // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetVRz() { return fJOYSTATE2.lVRz; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetVRz( long pVRz ) { fJOYSTATE2.lVRz = pVRz; } // -------------------------------------------------------------------------- // Property: VSlider // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetVSlider( dword pIndex ) { if (pIndex>=2) { fErrorValue = TDX_ERROR; if (FOnError) FOnError(this, "TDIJoyState2::FGetVSlider()", "TDX_ERROR", "'pIndex' parameter is out of bounds." ); return (LONG) NULL; } return fJOYSTATE2.rglVSlider[pIndex]; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetVSlider( dword pIndex, long pVSlider ) { fJOYSTATE2.rglVSlider[pIndex] = pVSlider; } // -------------------------------------------------------------------------- // Property: VX // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetVX() { return fJOYSTATE2.lVX; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetVX( long pVX ) { fJOYSTATE2.lVX = pVX; } // -------------------------------------------------------------------------- // Property: VY // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetVY() { return fJOYSTATE2.lVY; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetVY( long pVY ) { fJOYSTATE2.lVY = pVY; } // -------------------------------------------------------------------------- // Property: VZ // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetVZ() { return fJOYSTATE2.lVZ; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetVZ( long pVZ ) { fJOYSTATE2.lVZ = pVZ; } // -------------------------------------------------------------------------- // Property: X // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetX() { return fJOYSTATE2.lX; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetX( long pX ) { fJOYSTATE2.lX = pX; } // -------------------------------------------------------------------------- // Property: Y // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetY() { return fJOYSTATE2.lY; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetY( long pY ) { fJOYSTATE2.lY = pY; } // -------------------------------------------------------------------------- // Property: Z // Description: ... // -------------------------------------------------------------------------- long __fastcall TDIJoyState2::FGetZ() { return fJOYSTATE2.lZ; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetZ( long pZ ) { fJOYSTATE2.lZ = pZ; } // -------------------------------------------------------------------------- // Method: Clear() // Description: The Clear() method can be used to clear the contents of the // TDIJoyState2's internal JOYSTATE2 structure. // Note: if you have manually linked a structure member to a // chunk of memory, make sure you release this memory before // calling Clear(). // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::Clear() { fJOYSTATE2.lARx = 0; fJOYSTATE2.lARy = 0; fJOYSTATE2.lARz = 0; for (int ASlider_index=0;ASlider_index<2;ASlider_index++) fJOYSTATE2.rglASlider[ASlider_index] = 0; fJOYSTATE2.lAX = 0; fJOYSTATE2.lAY = 0; fJOYSTATE2.lAZ = 0; for (int Buttons_index=0;Buttons_index<128;Buttons_index++) fJOYSTATE2.rgbButtons[Buttons_index] = 0; fErrorValue = DI_OK; fJOYSTATE2.lFRx = 0; fJOYSTATE2.lFRy = 0; fJOYSTATE2.lFRz = 0; for (int FSlider_index=0;FSlider_index<2;FSlider_index++) fJOYSTATE2.rglFSlider[FSlider_index] = 0; fJOYSTATE2.lFX = 0; fJOYSTATE2.lFY = 0; fJOYSTATE2.lFZ = 0; for (int POV_index=0;POV_index<4;POV_index++) fJOYSTATE2.rgdwPOV[POV_index] = 0; fJOYSTATE2.lRx = 0; fJOYSTATE2.lRy = 0; fJOYSTATE2.lRz = 0; fSize = sizeof({); for (int Slider_index=0;Slider_index<2;Slider_index++) fJOYSTATE2.rglSlider[Slider_index] = 0; fJOYSTATE2.lVRx = 0; fJOYSTATE2.lVRy = 0; fJOYSTATE2.lVRz = 0; for (int VSlider_index=0;VSlider_index<2;VSlider_index++) fJOYSTATE2.rglVSlider[VSlider_index] = 0; fJOYSTATE2.lVX = 0; fJOYSTATE2.lVY = 0; fJOYSTATE2.lVZ = 0; fJOYSTATE2.lX = 0; fJOYSTATE2.lY = 0; fJOYSTATE2.lZ = 0; } // -------------------------------------------------------------------------- // Internal Structure Access // -------------------------------------------------------------------------- JOYSTATE2* __fastcall TDIJoyState2::FGetInternal_JOYSTATE2_Ptr() { return &fJOYSTATE2; } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::FSetInternal_JOYSTATE2( JOYSTATE2* pJOYSTATE2 ) { if (pJOYSTATE2==NULL) { fErrorValue = TDX_ERROR; if (FOnError) FOnError(this, "TDIJoyState2::FSetInternal_JOYSTATE2()", "TDX_ERROR", "The supplied JOYSTATE2* was NULL" ); return; } CopyMemory( &fJOYSTATE2, pJOYSTATE2, sizeof(JOYSTATE2) ); Internal_JOYSTATE2_Update(); } // -------------------------------------------------------------------------- void __fastcall TDIJoyState2::Internal_JOYSTATE2_Update() { } // --------------------------------------------------------------------------