OpenBarnyard
 
Loading...
Searching...
No Matches
TInputDevice.cpp
Go to the documentation of this file.
1#include "ToshiPCH.h"
2#include "TInputInterface.h"
3
4//-----------------------------------------------------------------------------
5// Enables memory debugging.
6// Note: Should be the last include!
7//-----------------------------------------------------------------------------
9
11
13
14// $Barnyard: FUNCTION 006d98e0
22
24{
25 return TTRUE;
26}
27
28// $Barnyard: FUNCTION 006d9740
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}
67
68// $Barnyard: FUNCTION 006d9950
69TBOOL TInputDevice::StartRepeat( Doodad a_iDoodad, TFLOAT a_fFirstRepeatTime, TFLOAT a_fRepeatTime )
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}
86
87// $Barnyard: FUNCTION 006d9a00
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}
116
117// $Barnyard: FUNCTION 006d9a70
119{
120 m_Repeats.Clear();
121}
122
127
128// $Barnyard: FUNCTION 006d9800
130{
131 emitter.Throw(
133 this,
134 repeatInfo->iDoodad,
136 )
137 );
138}
139
Input system interface for the Toshi engine.
#define TOSHI_NAMESPACE_START
Definition Defines.h:47
#define TOSHI_NAMESPACE_END
Definition Defines.h:50
#define TDEFINE_CLASS_NORUNTIME(...)
Definition TObject.h:138
float TFLOAT
Definition Typedefs.h:4
#define TNULL
Definition Typedefs.h:23
int TINT
Definition Typedefs.h:7
#define TFALSE
Definition Typedefs.h:24
#define TTRUE
Definition Typedefs.h:25
bool TBOOL
Definition Typedefs.h:6
virtual TBOOL IsForceFeedbackDevice()
virtual TBOOL StartRepeat(Doodad a_iDoodad, TFLOAT a_fFirstRepeatTime, TFLOAT a_fRepeatTime)
TArray< void * > m_Array2
virtual void StopAllRepeats()
TArray< RepeatInfo > m_Repeats
TINT ProcessRepeats(EventEmitter &a_rEmitter, TFLOAT a_fDeltaTime)
virtual void StopRepeat(Doodad a_iDoodad)
virtual TBOOL Flush()
TInputInterface * m_pInputInterface
TInputInterface::EventEmitter EventEmitter
virtual TBOOL IsDown(Doodad a_iDoodad) const =0
virtual void ThrowRepeatEvent(EventEmitter &emitter, RepeatInfo *repeatInfo, TFLOAT deltaTime)
void Throw(Data *pData)
Definition TEvent.h:56