OpenBarnyard
 
Loading...
Searching...
No Matches
TInputInterface Class Referenceabstract

#include <TInputInterface.h>

Inheritance diagram for TInputInterface:
TObject TSingleton< TInputInterface > TInputDXInterface

Classes

class  InputEvent
 

Public Types

enum  EVENT_TYPE {
  EVENT_TYPE_GONE_DOWN , EVENT_TYPE_GONE_UP , EVENT_TYPE_REPEAT , EVENT_TYPE_VIRTUAL ,
  EVENT_TYPE_MOVED
}
 
using EventEmitter = TEmitter<TInputInterface, TInputInterface::InputEvent>
 
- Public Types inherited from TObject
enum  { IsTObject = TTRUE }
 

Public Member Functions

 TDECLARE_CLASS (TInputInterface, TObject)
 
 TInputInterface ()
 
 ~TInputInterface ()
 
virtual TBOOL Initialise ()=0
 
virtual TBOOL Deinitialise ()=0
 
virtual TBOOL AcquireAll ()
 
virtual TBOOL UnacquireAll ()
 
virtual TBOOL FlushAll ()
 
virtual void SetExclusiveMode (TBOOL a_bIsExclusive)
 
virtual TBOOL GetExclusiveMode () const
 
virtual TINT ProcessEvents (TFLOAT a_fDeltaTime)
 
virtual void StopAllRepeats ()
 
void AddDevice (TInputDevice *device)
 
void RemoveDevice (TInputDevice *device)
 
void ReleaseAllDevices ()
 
TInputDeviceGetDeviceByIndex (TClass *a_pClass, TUINT a_uiIndex)
 
EventEmitterGetInputEventEmitter ()
 
template<class C>
C * GetDeviceByIndex (TUINT a_uiIndex=0)
 
- Public Member Functions inherited from TObject
virtual Toshi::TClass * GetClass ()
 
virtual void Delete ()
 
virtual ~TObject ()
 
TBOOL IsExactly (TClass *a_pClass)
 
TBOOL IsA (TClass *a_pClass)
 
- Public Member Functions inherited from TSingleton< TInputInterface >
 TSingleton (const TSingleton &)=delete
 
 TSingleton (const TSingleton &&)=delete
 
TSingletonoperator= (const TSingleton &)=delete
 
TSingletonoperator= (const TSingleton &&)=delete
 

Additional Inherited Members

- Static Public Member Functions inherited from TObject
static Toshi::TObject * CreateTObject ()
 
static Toshi::TObject * CreateTObjectInPlace (void *a_pPtr)
 
static void InitialiseClass ()
 
static void DeinitialiseClass ()
 
static TFORCEINLINE TClassGetClassStatic ()
 
- Static Public Member Functions inherited from TSingleton< TInputInterface >
static TFORCEINLINE TInputInterfaceCreateSingleton (Args &&... args)
 
static TFORCEINLINE D * CreateSingleton (Args &&... args)
 
static TFORCEINLINE void DestroySingleton ()
 
static TFORCEINLINE TInputInterfaceGetSingletonSafe ()
 
static TFORCEINLINE TBOOL IsSingletonCreated ()
 
static TFORCEINLINE TInputInterfaceGetSingleton ()
 
- Static Public Attributes inherited from TObject
static constexpr Toshi::TClass * PARENTCLASS = TNULL
 
static constinit Toshi::TClass ms_oClass = Toshi::TClass( "TObject", TObject::CreateTObject, TObject::CreateTObjectInPlace, TObject::InitialiseClass, TObject::DeinitialiseClass, 0, 2, sizeof( TObject ), alignof( TObject ) )
 
- Protected Member Functions inherited from TSingleton< TInputInterface >
TFORCEINLINE TSingleton ()
 
TFORCEINLINE ~TSingleton ()
 
- Static Protected Attributes inherited from TSingleton< TInputInterface >
static TInputInterfacems_pSingleton
 

Detailed Description

Definition at line 20 of file TInputInterface.h.

Member Typedef Documentation

◆ EventEmitter

Member Enumeration Documentation

◆ EVENT_TYPE

Enumerator
EVENT_TYPE_GONE_DOWN 
EVENT_TYPE_GONE_UP 
EVENT_TYPE_REPEAT 
EVENT_TYPE_VIRTUAL 
EVENT_TYPE_MOVED 

Definition at line 27 of file TInputInterface.h.

Constructor & Destructor Documentation

◆ TInputInterface()

TInputInterface::TInputInterface ( )

Definition at line 159 of file TInputInterface.cpp.

160 : m_InputEventEmitter( this )
161{
162 m_bIsExclusiveMode = TFALSE;
163}
#define TFALSE
Definition Typedefs.h:24

◆ ~TInputInterface()

TInputInterface::~TInputInterface ( )

Definition at line 166 of file TInputInterface.cpp.

167{
168}

Member Function Documentation

◆ AcquireAll()

TBOOL TInputInterface::AcquireAll ( )
virtual

Definition at line 63 of file TInputInterface.cpp.

64{
65 TBOOL bResult = TTRUE;
66
67 for ( auto it = m_DeviceList.Begin(); it != m_DeviceList.End(); ++it )
68 {
69 bResult &= it->Acquire();
70 }
71
72 return bResult;
73}
#define TTRUE
Definition Typedefs.h:25
bool TBOOL
Definition Typedefs.h:6

◆ AddDevice()

void TInputInterface::AddDevice ( TInputDevice * device)

Definition at line 43 of file TInputInterface.cpp.

44{
45 if ( device != TNULL )
46 {
47 m_DeviceList.InsertTail( device );
48 device->SetInputInterface( this );
49 }
50}
#define TNULL
Definition Typedefs.h:23
void SetInputInterface(TInputInterface *a_pInterface)

◆ Deinitialise()

virtual TBOOL TInputInterface::Deinitialise ( )
pure virtual

Implemented in TInputDXInterface.

◆ FlushAll()

TBOOL TInputInterface::FlushAll ( )
virtual

Definition at line 89 of file TInputInterface.cpp.

90{
91 TBOOL bResult = TTRUE;
92
93 for ( auto it = m_DeviceList.Begin(); it != m_DeviceList.End(); ++it )
94 {
95 bResult &= it->Flush();
96 }
97
98 return bResult;
99}

◆ GetDeviceByIndex() [1/2]

TInputDevice * TInputInterface::GetDeviceByIndex ( TClass * a_pClass,
TUINT a_uiIndex )

Definition at line 17 of file TInputInterface.cpp.

18{
19 if ( m_DeviceList.Count() == 0 )
20 {
21 return TNULL;
22 }
23
24 for ( auto it = m_DeviceList.Begin(); it != m_DeviceList.End(); ++it )
25 {
26 if ( it->GetClass()->IsA( a_pClass ) )
27 {
28 if ( a_uiIndex == 0 )
29 {
30 return it;
31 }
32 else
33 {
34 a_uiIndex -= 1;
35 }
36 }
37 }
38
39 return TNULL;
40}

◆ GetDeviceByIndex() [2/2]

template<class C>
C * TInputInterface::GetDeviceByIndex ( TUINT a_uiIndex = 0)
inline

Definition at line 100 of file TInputInterface.h.

101 {
102 C* pDevice = TSTATICCAST( C, GetDeviceByIndex( &TGetClass( C ), a_uiIndex ) );
103 TASSERT( pDevice == TNULL || pDevice->GetClass()->IsA( &TGetClass( C ) ) );
104 return pDevice;
105 }
#define TASSERT(X,...)
Definition Defines.h:138
#define TSTATICCAST(POINTERTYPE, VALUE)
Definition Defines.h:69
#define TGetClass(CLASS)
Definition TObject.h:13
TInputDevice * GetDeviceByIndex(TClass *a_pClass, TUINT a_uiIndex)

◆ GetExclusiveMode()

TBOOL TInputInterface::GetExclusiveMode ( ) const
virtual

Definition at line 108 of file TInputInterface.cpp.

109{
110 return m_bIsExclusiveMode;
111}

◆ GetInputEventEmitter()

EventEmitter & TInputInterface::GetInputEventEmitter ( )
inline

Definition at line 97 of file TInputInterface.h.

97{ return m_InputEventEmitter; }

◆ Initialise()

virtual TBOOL TInputInterface::Initialise ( )
pure virtual

Implemented in TInputDXInterface.

◆ ProcessEvents()

TINT TInputInterface::ProcessEvents ( TFLOAT a_fDeltaTime)
virtual

Definition at line 114 of file TInputInterface.cpp.

115{
116 TINT iNumProcessed = 0;
117
118 for ( auto it = m_DeviceList.Begin(); it != m_DeviceList.End(); ++it )
119 {
120 if ( it->IsAcquired() )
121 {
122 it->Update( a_fDeltaTime );
123 }
124 }
125
126 for ( auto it = m_DeviceList.Begin(); it != m_DeviceList.End(); ++it )
127 {
128 if ( it->IsAcquired() )
129 {
130 iNumProcessed += it->ProcessEvents( m_InputEventEmitter, a_fDeltaTime );
131 }
132 }
133
134 return iNumProcessed;
135}
int TINT
Definition Typedefs.h:7

◆ ReleaseAllDevices()

void TInputInterface::ReleaseAllDevices ( )

Definition at line 147 of file TInputInterface.cpp.

148{
149 for ( auto it = m_DeviceList.Begin(); it != m_DeviceList.End(); ++it )
150 {
151 it->Unacquire();
152 it->Release();
153 it->Remove();
154 delete it.Get();
155 }
156}

◆ RemoveDevice()

void TInputInterface::RemoveDevice ( TInputDevice * device)

Definition at line 53 of file TInputInterface.cpp.

54{
55 if ( device != TNULL )
56 {
57 m_DeviceList.Remove( device );
58 device->SetInputInterface( TNULL );
59 }
60}

◆ SetExclusiveMode()

void TInputInterface::SetExclusiveMode ( TBOOL a_bIsExclusive)
virtual

Reimplemented in TInputDXInterface.

Definition at line 102 of file TInputInterface.cpp.

103{
104 m_bIsExclusiveMode = a_bIsExclusive;
105}

◆ StopAllRepeats()

void TInputInterface::StopAllRepeats ( )
virtual

Definition at line 138 of file TInputInterface.cpp.

139{
140 for ( auto it = m_DeviceList.Begin(); it != m_DeviceList.End(); ++it )
141 {
142 it->StopAllRepeats();
143 }
144}

◆ TDECLARE_CLASS()

TInputInterface::TDECLARE_CLASS ( TInputInterface ,
TObject  )

◆ UnacquireAll()

TBOOL TInputInterface::UnacquireAll ( )
virtual

Definition at line 76 of file TInputInterface.cpp.

77{
78 TBOOL bResult = TTRUE;
79
80 for ( auto it = m_DeviceList.Begin(); it != m_DeviceList.End(); ++it )
81 {
82 bResult &= it->Unacquire();
83 }
84
85 return bResult;
86}

The documentation for this class was generated from the following files: