OpenBarnyard
 
Loading...
Searching...
No Matches
AInputHandler_Win.cpp
Go to the documentation of this file.
1#include "pch.h"
4#include "Tasks/ARootTask.h"
5
7
8//-----------------------------------------------------------------------------
9// Enables memory debugging.
10// Note: Should be the last include!
11//-----------------------------------------------------------------------------
12#include <Core/TMemoryDebugOn.h>
13
15
17
19{
20 TIMPLEMENT();
21
22 auto pInputInterfaceClass = TClass::Find( "TInputDXInterface" );
23 auto pInputInterface = pInputInterfaceClass->CreateObject();
24 TASSERT( pInputInterface && pInputInterface->IsA( &TGetClass( TInputInterface ) ) );
25
26 m_pMouseDevice = TNULL;
27 m_pKeyboardDevice = TNULL;
28 m_pMainController = TNULL;
29
30 m_bIsPaused = TFALSE;
31 m_bHadInputLastFrame = TFALSE;
32}
33
41
43{
44 TIMPLEMENT();
48
49 m_InputListener.Connect(
50 TInputInterface::GetSingleton()->GetInputEventEmitter(),
51 this,
52 []( AInputHandler* a_pInputHandler, TInputInterface* a_pInputInterface, TInputInterface::InputEvent* a_pEvent ) {
53 return a_pInputHandler->ProcessInputEvent( a_pInputInterface, a_pEvent );
54 },
55 0
56 );
57
58 return TTRUE;
59}
60
62{
63 TIMPLEMENT();
64 m_bHadInputLastFrame = TFALSE;
65 m_fDeltaTime = a_fDeltaTime;
66
69 return TTRUE;
70}
71
72TBOOL AInputHandler::ProcessInputEvent( Toshi::TInputInterface* a_pInputInterface, Toshi::TInputInterface::InputEvent* a_pEvent )
73{
74 if ( m_bIsPaused )
75 {
76 return TFALSE;
77 }
78
79 auto pInputSource = a_pEvent->GetSource();
80
81 if ( pInputSource != m_pMouseDevice && pInputSource != m_pKeyboardDevice )
82 {
83 if ( m_Devices.Find( pInputSource ) == m_Devices.End() )
84 {
85 return TFALSE;
86 }
87 }
88
89 if ( m_pMainController == TNULL )
90 {
91 if ( pInputSource->GetClass()->IsA( &TGetClass( TInputDeviceController ) ) )
92 {
93 if ( a_pEvent->GetEventType() == Toshi::TInputInterface::EVENT_TYPE_GONE_DOWN &&
94 pInputSource == m_Devices[ 0 ] )
95 {
96 m_pMainController = TSTATICCAST( TInputDeviceController, pInputSource );
97 }
98 }
99 }
100
101 if ( !AGameStateController::GetSingleton()->ProcessInput( a_pEvent ) )
102 {
103 TFIXME( "Do some check with AControlComponentManager" );
104 if ( !ARootTask::GetSingleton()->IsGameSystemCreated() && TTRUE )
105 {
106 if ( pInputSource->GetClass()->IsA( &TGetClass( TInputDeviceMouse ) ) )
107 {
108 m_bHadInputLastFrame = TTRUE;
109 }
110
111 return TFALSE;
112 }
113 }
114
115 m_bHadInputLastFrame = TTRUE;
116 return TTRUE;
117}
Input system interface for the Toshi engine.
#define TIMPLEMENT()
Definition Defines.h:136
#define TASSERT(X,...)
Definition Defines.h:138
#define TSTATICCAST(POINTERTYPE, VALUE)
Definition Defines.h:69
#define TFIXME(DESC)
Definition Defines.h:135
#define TOSHI_NAMESPACE_USING
Definition Defines.h:46
#define TGetClass(CLASS)
Definition TObject.h:13
#define TDEFINE_CLASS(...)
Definition TObject.h:120
float TFLOAT
Definition Typedefs.h:4
#define TNULL
Definition Typedefs.h:23
#define TFALSE
Definition Typedefs.h:24
#define TTRUE
Definition Typedefs.h:25
bool TBOOL
Definition Typedefs.h:6
TInputDevice * GetDeviceByIndex(TClass *a_pClass, TUINT a_uiIndex)
virtual TBOOL Initialise()=0
virtual TINT ProcessEvents(TFLOAT a_fDeltaTime)
virtual TBOOL AcquireAll()
static TClass * Find(const TCHAR *name, TClass *parent=TNULL)
Definition TClass.cpp:110
static TFORCEINLINE void DestroySingleton()
Definition TSingleton.h:30
static TFORCEINLINE TInputInterface * GetSingleton()
Definition TSingleton.h:49
virtual TBOOL OnUpdate(TFLOAT a_fDeltaTime) override
virtual TBOOL OnCreate() override