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

#include <TInputInterface.h>

Inheritance diagram for TInputDevice:
TObject TNodeList< T >::TNode TInputDeviceController TInputDeviceKeyboard TInputDeviceMouse TInputDXDeviceController TInputDXDeviceKeyboard TInputDXDeviceMouse TInputDeviceController_XInput TInputWiinDeviceController

Classes

struct  DoodadProperties
 
struct  RepeatInfo
 

Public Types

using EventEmitter = TInputInterface::EventEmitter
 
using Doodad = TINT
 
- Public Types inherited from TObject
enum  { IsTObject = TTRUE }
 

Public Member Functions

 TDECLARE_CLASS (TInputDevice, TObject)
 
 TInputDevice ()
 
 ~TInputDevice ()=default
 
virtual TBOOL Acquire ()=0
 
virtual TBOOL Unacquire ()=0
 
virtual void Release ()=0
 
virtual void Update (TFLOAT deltaTime)=0
 
virtual TBOOL Flush ()
 
virtual TINT ProcessEvents (EventEmitter &emitter, TFLOAT deltaTime)=0
 
virtual TINT GetButtonCount () const =0
 
virtual TINT GetAxisCount () const =0
 
virtual TBOOL GetDoodadProperties (Doodad a_iDoodad, DoodadProperties &a_rProperties) const =0
 
virtual TBOOL StartRepeat (Doodad a_iDoodad, TFLOAT a_fFirstRepeatTime, TFLOAT a_fRepeatTime)
 
virtual void StopRepeat (Doodad a_iDoodad)
 
virtual void StopAllRepeats ()
 
virtual TBOOL IsForceFeedbackDevice ()
 
virtual const TCHARGetButtonFromDoodad (Doodad a_iDoodad) const =0
 
virtual TBOOL IsDown (Doodad a_iDoodad) const =0
 
virtual TINT GetAxisInt (Doodad a_iDoodad, TINT axis) const =0
 
virtual TINT GetAxisInt2 (Doodad a_iDoodad, TINT axis) const
 
virtual TFLOAT GetAxisFloat (Doodad a_iDoodad, TINT axis) const =0
 
virtual TFLOAT GetAxisFloat2 (Doodad a_iDoodad, TINT axis) const
 
virtual TBOOL IsEnabled () const =0
 
virtual void ThrowRepeatEvent (EventEmitter &emitter, RepeatInfo *repeatInfo, TFLOAT deltaTime)
 
TBOOL IsAcquired () const
 
void SetAcquired (TBOOL a_bAcquired)
 
TInputInterfaceGetInputInterface ()
 
void SetInputInterface (TInputInterface *a_pInterface)
 
- 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 TNodeList< T >::TNode
constexpr TNode ()
 
constexpr TNode (const TNode &a_rcNode)
 
 TNode (TNode &&a_rNode)
 
T * Next () const
 
T * Prev () const
 
void Remove ()
 
void SetList (TNodeList *list)
 
TNodeListGetList () const
 
TBOOL IsLinked () const
 

Static Public Member Functions

static TInputDevice ** GetRegisteredDevices ()
 
static TUINT GetNumRegisteredDevices ()
 
- 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 Attributes

static constexpr TINT INPUT_DEVICE_MOUSE_BUTTONS = 3
 
static constexpr TINT INPUT_DEVICE_MOUSE_WHEEL = 4
 
- 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

TINT ProcessRepeats (EventEmitter &a_rEmitter, TFLOAT a_fDeltaTime)
 

Protected Attributes

TUINT m_uiDeviceIndex
 
TArray< RepeatInfom_Repeats
 
TArray< void * > m_Array2
 
TBOOL m_bUnknown
 
TBOOL m_bIsAcquired
 
TInputInterfacem_pInputInterface
 
- Protected Attributes inherited from TNodeList< T >::TNode
friend TNodeList
 
TNodeListm_pList
 
T * m_pNext
 
T * m_pPrev
 

Static Protected Attributes

static constexpr TUINT MAX_DEVICE_COUNT = 14
 
static TInputDevices_aDevices [MAX_DEVICE_COUNT]
 
static TUINT s_uiDeviceCount
 

Detailed Description

Definition at line 114 of file TInputInterface.h.

Member Typedef Documentation

◆ Doodad

Definition at line 125 of file TInputInterface.h.

◆ EventEmitter

Constructor & Destructor Documentation

◆ TInputDevice()

TInputDevice::TInputDevice ( )

Definition at line 15 of file TInputDevice.cpp.

16 : m_Repeats( 0, 16 ), m_Array2( 0, 16 )
17{
21}
#define TNULL
Definition Typedefs.h:23
#define TFALSE
Definition Typedefs.h:24
TArray< void * > m_Array2
TArray< RepeatInfo > m_Repeats
TInputInterface * m_pInputInterface

◆ ~TInputDevice()

TInputDevice::~TInputDevice ( )
default

Member Function Documentation

◆ Acquire()

virtual TBOOL TInputDevice::Acquire ( )
pure virtual

◆ Flush()

TBOOL TInputDevice::Flush ( )
virtual

Reimplemented in TInputDXDeviceKeyboard, and TInputDXDeviceMouse.

Definition at line 23 of file TInputDevice.cpp.

24{
25 return TTRUE;
26}
#define TTRUE
Definition Typedefs.h:25

◆ GetAxisCount()

virtual TINT TInputDevice::GetAxisCount ( ) const
pure virtual

◆ GetAxisFloat()

virtual TFLOAT TInputDevice::GetAxisFloat ( Doodad a_iDoodad,
TINT axis ) const
pure virtual

◆ GetAxisFloat2()

virtual TFLOAT TInputDevice::GetAxisFloat2 ( Doodad a_iDoodad,
TINT axis ) const
inlinevirtual

Definition at line 162 of file TInputInterface.h.

162{ return GetAxisFloat( a_iDoodad, axis ); }
virtual TFLOAT GetAxisFloat(Doodad a_iDoodad, TINT axis) const =0

◆ GetAxisInt()

virtual TINT TInputDevice::GetAxisInt ( Doodad a_iDoodad,
TINT axis ) const
pure virtual

◆ GetAxisInt2()

virtual TINT TInputDevice::GetAxisInt2 ( Doodad a_iDoodad,
TINT axis ) const
inlinevirtual

Definition at line 160 of file TInputInterface.h.

160{ return GetAxisInt( a_iDoodad, axis ); }
virtual TINT GetAxisInt(Doodad a_iDoodad, TINT axis) const =0

◆ GetButtonCount()

virtual TINT TInputDevice::GetButtonCount ( ) const
pure virtual

◆ GetButtonFromDoodad()

virtual const TCHAR * TInputDevice::GetButtonFromDoodad ( Doodad a_iDoodad) const
pure virtual

◆ GetDoodadProperties()

virtual TBOOL TInputDevice::GetDoodadProperties ( Doodad a_iDoodad,
DoodadProperties & a_rProperties ) const
pure virtual

◆ GetInputInterface()

TInputInterface * TInputDevice::GetInputInterface ( )
inline

Definition at line 176 of file TInputInterface.h.

177 {
178 return m_pInputInterface;
179 }

◆ GetNumRegisteredDevices()

static TUINT TInputDevice::GetNumRegisteredDevices ( )
inlinestatic

Definition at line 195 of file TInputInterface.h.

196 {
197 return s_uiDeviceCount;
198 }
static TUINT s_uiDeviceCount

◆ GetRegisteredDevices()

static TInputDevice ** TInputDevice::GetRegisteredDevices ( )
inlinestatic

Definition at line 190 of file TInputInterface.h.

191 {
192 return s_aDevices;
193 }
static TInputDevice * s_aDevices[MAX_DEVICE_COUNT]

◆ IsAcquired()

TBOOL TInputDevice::IsAcquired ( ) const
inline

Definition at line 166 of file TInputInterface.h.

167 {
168 return m_bIsAcquired;
169 }

◆ IsDown()

virtual TBOOL TInputDevice::IsDown ( Doodad a_iDoodad) const
pure virtual

◆ IsEnabled()

virtual TBOOL TInputDevice::IsEnabled ( ) const
pure virtual

◆ IsForceFeedbackDevice()

TBOOL TInputDevice::IsForceFeedbackDevice ( )
virtual

Definition at line 123 of file TInputDevice.cpp.

124{
125 return TFALSE;
126}

◆ ProcessEvents()

virtual TINT TInputDevice::ProcessEvents ( EventEmitter & emitter,
TFLOAT deltaTime )
pure virtual

◆ ProcessRepeats()

TINT TInputDevice::ProcessRepeats ( EventEmitter & a_rEmitter,
TFLOAT a_fDeltaTime )
protected

Definition at line 29 of file TInputDevice.cpp.

30{
31 TINT iNumProcessed = 0;
32
33 for ( TINT i = 0; i < m_Repeats.Size(); i++ )
34 {
35 auto& rRepeat = m_Repeats[ i ];
36
37 if ( IsDown( rRepeat.iDoodad ) )
38 {
39 rRepeat.fLeftTime -= a_fDeltaTime;
40
41 if ( rRepeat.fLeftTime <= 0.0f )
42 {
43 rRepeat.fLeftTime = rRepeat.fRepeatTime;
44 ThrowRepeatEvent( a_rEmitter, &rRepeat, a_fDeltaTime );
45 iNumProcessed += 1;
46 }
47 }
48 else
49 {
50 if ( m_Repeats.Size() > 1 )
51 {
52 auto& rLastRepeat = m_Repeats[ m_Repeats.Size() - 1 ];
53 rRepeat.iDoodad = rLastRepeat.iDoodad;
54 rRepeat.fLeftTime = rLastRepeat.fLeftTime;
55 rRepeat.fRepeatTime = rLastRepeat.fRepeatTime;
56 }
57
58 if ( 0 < m_Repeats.Size() )
59 {
60 m_Repeats.Pop();
61 }
62 }
63 }
64
65 return iNumProcessed;
66}
int TINT
Definition Typedefs.h:7
virtual TBOOL IsDown(Doodad a_iDoodad) const =0
virtual void ThrowRepeatEvent(EventEmitter &emitter, RepeatInfo *repeatInfo, TFLOAT deltaTime)

◆ Release()

virtual void TInputDevice::Release ( )
pure virtual

◆ SetAcquired()

void TInputDevice::SetAcquired ( TBOOL a_bAcquired)
inline

Definition at line 171 of file TInputInterface.h.

172 {
173 m_bIsAcquired = a_bAcquired;
174 }

◆ SetInputInterface()

void TInputDevice::SetInputInterface ( TInputInterface * a_pInterface)
inline

Definition at line 181 of file TInputInterface.h.

182 {
183 m_pInputInterface = a_pInterface;
184 }

◆ StartRepeat()

TBOOL TInputDevice::StartRepeat ( Doodad a_iDoodad,
TFLOAT a_fFirstRepeatTime,
TFLOAT a_fRepeatTime )
virtual

Definition at line 69 of file TInputDevice.cpp.

70{
71 for ( auto it = m_Repeats.Begin(); it.IsOver() == TFALSE; ++it )
72 {
73 if ( it->iDoodad == a_iDoodad )
74 {
75 it->fRepeatTime = a_fRepeatTime;
76 return TTRUE;
77 }
78 }
79
80 m_Repeats.Push( { .iDoodad = a_iDoodad,
81 .fLeftTime = a_fFirstRepeatTime,
82 .fRepeatTime = a_fRepeatTime } );
83
84 return TTRUE;
85}

◆ StopAllRepeats()

void TInputDevice::StopAllRepeats ( )
virtual

Definition at line 118 of file TInputDevice.cpp.

119{
120 m_Repeats.Clear();
121}

◆ StopRepeat()

void TInputDevice::StopRepeat ( Doodad a_iDoodad)
virtual

Definition at line 88 of file TInputDevice.cpp.

89{
90 if ( m_Repeats.Size() != 0 )
91 {
92 auto it = m_Repeats.Begin();
93
94 TINT iIndex = 0;
95 while ( it->iDoodad != a_iDoodad )
96 {
97 ++it;
98 ++iIndex;
99 if ( it.IsOver() ) return;
100 }
101
102 if ( 1 < m_Repeats.Size() )
103 {
104 auto& rLastRepeat = m_Repeats[ m_Repeats.Size() - 1 ];
105 it->iDoodad = rLastRepeat.iDoodad;
106 it->fLeftTime = rLastRepeat.fLeftTime;
107 it->fRepeatTime = rLastRepeat.fRepeatTime;
108 }
109
110 if ( 0 < m_Repeats.Size() )
111 {
112 m_Repeats.Pop();
113 }
114 }
115}

◆ TDECLARE_CLASS()

TInputDevice::TDECLARE_CLASS ( TInputDevice ,
TObject  )

◆ ThrowRepeatEvent()

void TInputDevice::ThrowRepeatEvent ( EventEmitter & emitter,
RepeatInfo * repeatInfo,
TFLOAT deltaTime )
virtual

Definition at line 129 of file TInputDevice.cpp.

130{
131 emitter.Throw(
132 TInputInterface::InputEvent(
133 this,
134 repeatInfo->iDoodad,
136 )
137 );
138}

◆ Unacquire()

virtual TBOOL TInputDevice::Unacquire ( )
pure virtual

◆ Update()

virtual void TInputDevice::Update ( TFLOAT deltaTime)
pure virtual

Member Data Documentation

◆ INPUT_DEVICE_MOUSE_BUTTONS

TINT TInputDevice::INPUT_DEVICE_MOUSE_BUTTONS = 3
staticconstexpr

Definition at line 121 of file TInputInterface.h.

◆ INPUT_DEVICE_MOUSE_WHEEL

TINT TInputDevice::INPUT_DEVICE_MOUSE_WHEEL = 4
staticconstexpr

Definition at line 122 of file TInputInterface.h.

◆ m_Array2

TArray<void*> TInputDevice::m_Array2
protected

Definition at line 209 of file TInputInterface.h.

◆ m_bIsAcquired

TBOOL TInputDevice::m_bIsAcquired
protected

Definition at line 211 of file TInputInterface.h.

◆ m_bUnknown

TBOOL TInputDevice::m_bUnknown
protected

Definition at line 210 of file TInputInterface.h.

◆ m_pInputInterface

TInputInterface* TInputDevice::m_pInputInterface
protected

Definition at line 212 of file TInputInterface.h.

◆ m_Repeats

TArray<RepeatInfo> TInputDevice::m_Repeats
protected

Definition at line 208 of file TInputInterface.h.

◆ m_uiDeviceIndex

TUINT TInputDevice::m_uiDeviceIndex
protected

Definition at line 207 of file TInputInterface.h.

◆ MAX_DEVICE_COUNT

TUINT TInputDevice::MAX_DEVICE_COUNT = 14
staticconstexprprotected

Definition at line 201 of file TInputInterface.h.

◆ s_aDevices

TInputDevice* TInputDevice::s_aDevices[MAX_DEVICE_COUNT]
inlinestaticprotected

Definition at line 203 of file TInputInterface.h.

◆ s_uiDeviceCount

TUINT TInputDevice::s_uiDeviceCount
inlinestaticprotected

Definition at line 204 of file TInputInterface.h.


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