OpenBarnyard
 
Loading...
Searching...
No Matches
AInputMapManager.h
Go to the documentation of this file.
1#pragma once
2#include "AInputMap.h"
3
5#include <Toshi/TPString8.h>
6#include <Toshi/T2Vector.h>
7#include <Toshi/T2Map.h>
8
10{
11 static constexpr TUINT MAX_NUM_COMMANDS = 40;
12
13 void Clear()
14 {
15 for ( TINT i = 0; i < iNumCommands; i++ )
16 {
18 }
19
20 iNumCommands = 0;
21 }
22
23 void AddCommand( AInputCommand a_eCommand )
24 {
26 {
27 aCommands[ iNumCommands++ ] = a_eCommand;
28 }
29 }
30
33};
34
35class AInputMapManager : public Toshi::TObject
36 , public Toshi::TSingleton<AInputMapManager>
37{
38public:
39 TDECLARE_CLASS( AInputMapManager, Toshi::TObject );
40
42
44 {
46 InputEvent_GoneDown = BITFLAG( Toshi::TInputInterface::EVENT_TYPE_GONE_DOWN ),
47 InputEvent_GoneUp = BITFLAG( Toshi::TInputInterface::EVENT_TYPE_GONE_UP ),
48 InputEvent_Repeat = BITFLAG( Toshi::TInputInterface::EVENT_TYPE_REPEAT ),
49 InputEvent_Virtual = BITFLAG( Toshi::TInputInterface::EVENT_TYPE_VIRTUAL ),
50 InputEvent_Moved = BITFLAG( Toshi::TInputInterface::EVENT_TYPE_MOVED ),
51 };
52
53 struct Command
54 {
55 Toshi::TPString8 Name;
58
59 TBOOL IsEventTypeAllowed( Toshi::TInputInterface::EVENT_TYPE a_eEventType )
60 {
61 return HASANYFLAG( uiEventType, ( 1 << ( a_eEventType & 0x1F ) ) );
62 }
63 };
64
65 static constexpr TUINT MAX_NUM_INPUT_MAPS = 32;
66
67public:
69
71
72 void PushInputMap( AInputMap* a_pInputMap );
74
75 AInputMap* FindMap( const Toshi::TPString8& a_rMapName );
76 TBOOL SetMap( const Toshi::TPString8& a_rMapName );
77
78 void GetEventCommands( const Toshi::TInputInterface::InputEvent* a_pEvent, AInputCommandArray& a_rCommandArray );
79
80 AInputCommand GetCommandCode( const Toshi::TPString8& a_rCommandName );
81 Toshi::TInputDevice::Doodad GetDoodadFromKey( const Toshi::TPString8& a_rKey );
82
83private:
84 void InitMouseDoodads();
85 void InitKeyboardDoodads();
86 void InitGamepadDoodads();
87 void InitCommandMap();
88
89 void BindDoodad( Toshi::TInputDevice::Doodad a_iDoodad, const Toshi::TPString8& a_ButtonName, ActionId a_uiAction );
90
91private:
92 Toshi::T2Vector<AInputMap*, MAX_NUM_INPUT_MAPS> m_InputMaps;
93 AInputMap* m_pActiveInputMap;
94 Toshi::T2Map<Toshi::TInputDevice::Doodad, Toshi::TPString8> m_oDoodadToNameMap;
95 Toshi::T2Map<Toshi::TInputDevice::Doodad, ActionId> m_oKeyMap;
96 Toshi::T2Map<AInputCommand, Command> m_oCommandMap;
97 Toshi::T2RedBlackTree<void*> m_UnkMap;
98 TINT m_iNumPushedInputMaps;
99 // ...
100 AInputMap* m_apPushedInputMaps[ MAX_NUM_INPUT_MAPS ];
101};
Input system interface for the Toshi engine.
#define HASANYFLAG(STATE, FLAG)
Definition Defines.h:5
#define BITFLAG(x)
Definition Defines.h:10
#define TDECLARE_CLASS(THIS_CLASS, PARENT_CLASS)
Definition TObject.h:38
int32_t TINT32
Definition Typedefs.h:12
unsigned int TUINT
Definition Typedefs.h:8
uint32_t TUINT32
Definition Typedefs.h:13
int TINT
Definition Typedefs.h:7
bool TBOOL
Definition Typedefs.h:6
AInputCommand
Definition AInputMap.h:12
@ AInputCommand_Empty
Definition AInputMap.h:14
void AddCommand(AInputCommand a_eCommand)
static constexpr TUINT MAX_NUM_COMMANDS
AInputCommand aCommands[MAX_NUM_COMMANDS]
AInputMap * PopInputMap()
void PushInputMap(AInputMap *a_pInputMap)
void GetEventCommands(const Toshi::TInputInterface::InputEvent *a_pEvent, AInputCommandArray &a_rCommandArray)
static constexpr TUINT MAX_NUM_INPUT_MAPS
AInputCommand GetCommandCode(const Toshi::TPString8 &a_rCommandName)
Toshi::TInputDevice::Doodad GetDoodadFromKey(const Toshi::TPString8 &a_rKey)
AInputMap * FindMap(const Toshi::TPString8 &a_rMapName)
TBOOL SetMap(const Toshi::TPString8 &a_rMapName)
TBOOL IsEventTypeAllowed(Toshi::TInputInterface::EVENT_TYPE a_eEventType)