I have a class "Person" like so:
typedef void (*action)();
typedef std::unordered_map<int, action> keybindMap; // maps keycodes to functions
class Person {
keybindMap keybinds;
void doSomething();
}
I use this to call the functions at the right times:
iter = keybinds.find(event.key.keysym.sym); // event.key.keysym.sym is the key code
if (iter != keybinds.end())
{
(*iter->second)(); // call whatever function that key is bound to.
}
To bind a key, I used keybinds.insert_or_assign(SDLK_a, doSomething). However, this doesn't work (because doSomething is non-static). How do I change the binding code and/or the (*iter->second)() part so that I can call something equivalent to person.doSomething?