-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathKeyBindingCollection.h
37 lines (29 loc) · 1.67 KB
/
KeyBindingCollection.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once
#include <SDL2/SDL_scancode.h>
#include "InputLibraryDefine.h"
#include "Types.h"
class KeyBindingCollection {
public:
INPUT_API KeyBindingCollection();
INPUT_API ~KeyBindingCollection();
INPUT_API bool AddMappingWithName( const rString& keyName, ActionIdentifier action,
KeyBindingType keyBindType = KeyBindingType::Any, bool overwrite = false,
bool clearConflicting = false, rString* errorString = nullptr );
INPUT_API bool AddMappingWithScancode( SDL_Scancode scancode, ActionIdentifier action,
KeyBindingType keyBindType = KeyBindingType::Any, bool overwrite = false,
bool clearConflicting = false, rString* errorString = nullptr );
INPUT_API const rMap<SDL_Scancode, ActionIdentifier>* GetScancodeToActionMap( ) const;
INPUT_API const rVector<SDL_Scancode>& GetPrimaryBindings ( ) const;
INPUT_API const rVector<SDL_Scancode>& GetSecondaryBindings ( ) const;
INPUT_API ActionIdentifier GetGetActionFromScancode( SDL_Scancode scancode ) const;
INPUT_API const rString GetScancodeNameForAction( ActionIdentifier action, KeyBindingType bindType = KeyBindingType::Primary ) const;
INPUT_API SDL_Scancode GetPrimaryScancodeFromAction( ActionIdentifier action ) const;
INPUT_API SDL_Scancode GetSecondaryScancodeFromAction( ActionIdentifier action ) const;
INPUT_API bool BindAction( ActionIdentifier action, SDL_Scancode scancode, KeyBindingType keyBindType, bool overwrite );
private:
void FillTheVoid( ActionIdentifier action );
rMap<SDL_Scancode, ActionIdentifier> m_ScancodeToAction;
rVector<SDL_Scancode> m_ActionToScancodePrimary;
rVector<SDL_Scancode> m_ActionToScancodeSecondary;
static const size_t mc_OverflowLimit = 200;
};