41 lines
796 B
C++
41 lines
796 B
C++
/**
|
|
* @author: Thomas Brandého
|
|
*/
|
|
|
|
#ifndef KEYBINDINGS_H
|
|
#define KEYBINDINGS_H
|
|
|
|
#include <SFML/Window.hpp>
|
|
|
|
#include <unordered_map>
|
|
|
|
class KeysMap {
|
|
public:
|
|
enum {PRIMARY,SECONDARY,NB_BINDINGS};
|
|
|
|
KeysMap();
|
|
KeysMap(std::string keysmapping, int nb_actions);
|
|
|
|
int getKeyBinding(int action,int num);
|
|
void setKeyBinding(int action, int num, int key);
|
|
|
|
void saveKeysMap();
|
|
void loadKeysMap();
|
|
private:
|
|
std::string keysmapping_file;
|
|
int size_keys_map = 0;
|
|
int* keys_map;
|
|
};
|
|
|
|
class KeyBindings {
|
|
public:
|
|
KeyBindings();
|
|
KeyBindings(const std::vector<int> action_list, KeysMap* keysmap);
|
|
int getAction(int key);
|
|
private:
|
|
std::unordered_map<int,int> bindings;
|
|
void setKeyBinding(int key, int action);
|
|
};
|
|
|
|
#endif
|