From 5e3a2492c7bb73daa4e27398daaf490d09980ff3 Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Wed, 22 Jun 2022 17:41:59 -0400 Subject: Base system viewer with data loaded from csv files --- include/keybind.hpp | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 include/keybind.hpp (limited to 'include/keybind.hpp') diff --git a/include/keybind.hpp b/include/keybind.hpp new file mode 100644 index 0000000..6541a21 --- /dev/null +++ b/include/keybind.hpp @@ -0,0 +1,71 @@ +#ifndef KEYBIND_HPP +#define KEYBIND_HPP 1 + +#include +#include +#include +#include + +#define CTX_GLOBAL "Global" +#define CTX_SYSTEMVIEW "System View" +#define CTX_TIMEMAN "Time Manager" + +#define BIND_G_QUIT "G_Quit" +#define BIND_G_NEXTWIN "G_NextWindow" +#define BIND_G_PREVWIN "G_PrevWindow" +#define BIND_G_EDITBINDS "G_EditBinds" +#define BIND_G_ESCAPE "G_Escape" +#define BIND_G_SELECT "G_Select" + +#define BIND_SYSTEMVIEW_PANUP "Systemview_PanUp" +#define BIND_SYSTEMVIEW_PANDOWN "Systemview_PanDown" +#define BIND_SYSTEMVIEW_PANLEFT "Systemview_PanLeft" +#define BIND_SYSTEMVIEW_PANRIGHT "Systemview_PanRight" +#define BIND_SYSTEMVIEW_DECSCALE "Systemview_DecScale" +#define BIND_SYSTEMVIEW_INCSCALE "Systemview_IncScale" +#define BIND_SYSTEMVIEW_SEARCH "Systemview_Search" + +#define BIND_SYSTEMVIEW_SEARCH_PREV "Systemview_Search_Prev" +#define BIND_SYSTEMVIEW_SEARCH_NEXT "Systemview_Search_Next" +#define BIND_SYSTEMVIEW_SEARCH_TOP "Systemview_Search_Top" +#define BIND_SYSTEMVIEW_SEARCH_BOTTOM "Systemview_Search_Bottom" +#define BIND_SYSTEMVIEW_SEARCH_COLLAPSE "Systemview_Search_Collapse" + +#define BIND_TIMEMAN_STEP "Timeman_Step" +#define BIND_TIMEMAN_INCSTEP "Timeman_IncStep" +#define BIND_TIMEMAN_DECSTEP "Timeman_DecStep" +#define BIND_TIMEMAN_TOGGLEAUTO "Timeman_ToggleAuto" + +class KeyMan { +public: + struct Bind { + int code; + std::string name; + std::string ctx; + std::string desc; + }; + + struct Binds { + std::vector operator()() { + std::vector bindList; + std::transform( + KeyMan::m_keybinds.begin(), + KeyMan::m_keybinds.end(), + std::back_inserter(bindList), [](auto &pair){return pair.second;}); + return bindList; + } + Bind &operator[](const std::string &name) { return KeyMan::m_keybinds[name]; } + }; + static Binds binds; + + static void registerBind(int def, const std::string &name, const std::string &context, const std::string &desc); + static void loadKeybindsFrom(const std::string &csvPath); + static void writeKeybindsTo(const std::string &csvPath); + static std::string translateCode(int code); + +private: + static std::unordered_map m_keybinds; + static std::unordered_map m_keybindContexts; +}; + +#endif -- cgit v1.2.1