diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-07-02 06:34:43 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-07-02 06:34:43 +1000 |
commit | 15b0e9946049946133c9c932ef23d06a665f63fb (patch) | |
tree | 019c61db7b31ede553c9daaab8c1e331e32a5c69 /source/game/StarInput.cpp | |
parent | 2c43b505311b9c7f2a0ee2b798cf4c39b2b0d2b7 (diff) |
Initial setup of input stuff
Diffstat (limited to 'source/game/StarInput.cpp')
-rw-r--r-- | source/game/StarInput.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/source/game/StarInput.cpp b/source/game/StarInput.cpp new file mode 100644 index 0000000..0a9b56d --- /dev/null +++ b/source/game/StarInput.cpp @@ -0,0 +1,58 @@ +#include "StarInput.hpp" +#include "StarAssets.hpp" +#include "StarRoot.hpp" + +namespace Star { + +size_t hash<InputVariant>::operator()(InputVariant const& v) const { + size_t indexHash = hashOf(v.typeIndex()); + if (auto key = v.ptr<Key>()) + hashCombine(indexHash, hashOf(*key)); + else if (auto mButton = v.ptr<MouseButton>()) + hashCombine(indexHash, hashOf(*mButton)); + else if (auto cButton = v.ptr<ControllerButton>()) + hashCombine(indexHash, hashOf(*cButton)); + + return indexHash; +} + +Input* Input::s_singleton; + +Input* Input::singletonPtr() { + return s_singleton; +} + +Input& Input::singleton() { + if (!s_singleton) + throw InputException("Input::singleton() called with no Input instance available"); + else + return *s_singleton; +} + +Input::Input() { + if (s_singleton) + throw InputException("Singleton Input has been constructed twice"); + + s_singleton = this; + +} + +Input::~Input() { + s_singleton = nullptr; +} + +void Input::reset() { + +} + +void Input::reload() { + reset(); + + auto assets = Root::singleton().assets(); + + for (auto& bindPath : assets->scanExtension("binds")) { + Json config = assets->json(bindPath); + } +} + +}
\ No newline at end of file |