Skip to content

Instantly share code, notes, and snippets.

@haleyjd
Created March 3, 2020 05:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haleyjd/355f836551832e781e1cb18c4a2fafd1 to your computer and use it in GitHub Desktop.
Save haleyjd/355f836551832e781e1cb18c4a2fafd1 to your computer and use it in GitHub Desktop.
enum class YourKeys
{
A,
B,
Subtract
};
using keymap_t = std::unordered_map<std::string, YourKeys>;
const keymap_t g_theKeysDukeTheKeys =
{
{ "A", YourKeys::A },
{ "B", YourKeys::B },
{ "Select", YourKeys::Select }
};
int32_t InputManager::findBindByString(const std::string &str)
{
if(keymap_t::const_iterator itr = g_theKeysDukeTheKeys.find(str); itr != g_theKeysDukeTheKeys.cend())
{
return static_cast<int32_t>(itr->second);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment