diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-20 14:33:09 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-20 14:33:09 +1000 |
commit | 6352e8e3196f78388b6c771073f9e03eaa612673 (patch) | |
tree | e23772f79a7fbc41bc9108951e9e136857484bf4 /source/windowing/StarKeyBindings.hpp | |
parent | 6741a057e5639280d85d0f88ba26f000baa58f61 (diff) |
everything everywhere
all at once
Diffstat (limited to 'source/windowing/StarKeyBindings.hpp')
-rw-r--r-- | source/windowing/StarKeyBindings.hpp | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/source/windowing/StarKeyBindings.hpp b/source/windowing/StarKeyBindings.hpp new file mode 100644 index 0000000..e544a3a --- /dev/null +++ b/source/windowing/StarKeyBindings.hpp @@ -0,0 +1,119 @@ +#ifndef STAR_KEY_BINDINGS_HPP +#define STAR_KEY_BINDINGS_HPP + +#include "StarInputEvent.hpp" +#include "StarSet.hpp" +#include "StarJson.hpp" + +namespace Star { + +enum class InterfaceAction { + None, + PlayerUp, + PlayerDown, + PlayerLeft, + PlayerRight, + PlayerJump, + PlayerMainItem, + PlayerAltItem, + PlayerDropItem, + PlayerInteract, + PlayerShifting, + PlayerTechAction1, + PlayerTechAction2, + PlayerTechAction3, + EmoteBlabbering, + EmoteShouting, + EmoteHappy, + EmoteSad, + EmoteNeutral, + EmoteLaugh, + EmoteAnnoyed, + EmoteOh, + EmoteOooh, + EmoteBlink, + EmoteWink, + EmoteEat, + EmoteSleep, + ShowLabels, + CameraShift, + TitleBack, + CinematicSkip, + CinematicNext, + GuiClose, + GuiShifting, + KeybindingClear, + KeybindingCancel, + ChatPageUp, + ChatPageDown, + ChatPreviousLine, + ChatNextLine, + ChatSendLine, + ChatBegin, + ChatBeginCommand, + ChatStop, + InterfaceShowHelp, + InterfaceHideHud, + InterfaceChangeBarGroup, + InterfaceDeselectHands, + InterfaceBar1, + InterfaceBar2, + InterfaceBar3, + InterfaceBar4, + InterfaceBar5, + InterfaceBar6, + InterfaceBar7, + InterfaceBar8, + InterfaceBar9, + InterfaceBar10, + EssentialBar1, + EssentialBar2, + EssentialBar3, + EssentialBar4, + InterfaceRepeatCommand, + InterfaceToggleFullscreen, + InterfaceReload, + InterfaceEscapeMenu, + InterfaceInventory, + InterfaceCodex, + InterfaceQuest, + InterfaceCrafting, +}; +extern EnumMap<InterfaceAction> const InterfaceActionNames; + +// Maps the mod keys that can used in key chords to its associated KeyMod. +extern HashMap<Key, KeyMod> const KeyChordMods; + +struct KeyChord { + Key key; + KeyMod mods; + + bool operator<(KeyChord const& rhs) const; +}; + +KeyChord inputDescriptorFromJson(Json const& json); +Json inputDescriptorToJson(KeyChord const& chord); + +String printInputDescriptor(KeyChord chord); + +STAR_CLASS(KeyBindings); + +class KeyBindings { +public: + KeyBindings(); + explicit KeyBindings(Json const& json); + + Set<InterfaceAction> actions(Key key) const; + Set<InterfaceAction> actions(InputEvent const& event) const; + Set<InterfaceAction> actions(KeyChord chord) const; + Set<InterfaceAction> actionsForKey(Key key) const; + +private: + // Maps the primary key to a list of InterfaceActions, and any mods that they + // require to be held. + Map<Key, List<pair<KeyMod, InterfaceAction>>> m_actions; +}; + +} + +#endif |