/** * @author: Thomas Brandého */ #include "keybindings.h" #include /* Implementation of KeysMap class * @author: Thomas Brandého * @info: This class register all the association between key and action. */ KeysMap::KeysMap() { } KeysMap::KeysMap(std::string keysmapping, int nb_actions):keysmapping_file(keysmapping), size_keys_map(nb_actions*2) { keys_map = (int*) malloc(size_keys_map*sizeof(int)); loadKeysMap(); } int KeysMap::getKeyBinding(int action,int num) { return keys_map[action*NB_BINDINGS+num]; } void KeysMap::setKeyBinding(int action, int num, int key) { keys_map[(action*NB_BINDINGS)+num] = key; } void KeysMap::saveKeysMap() { //TODO: Serialize map_keys //use keysmapping_file } void KeysMap::loadKeysMap() { //TODO: Load map_keys //use keysmapping_file } /* Implementation of KeyBindings class * @author: Thomas Brandého * @info: This class map a list of action with the associated keys, for a quick access in-game. * The map is read-only, so if you want to add of remove action from the map, you have to create a new instance of KeyBindings */ KeyBindings::KeyBindings() { } KeyBindings::KeyBindings(std::vector action_list, KeysMap* keysmap) { for (int action : action_list){ for(int i=0; igetKeyBinding(action,i),action); } } int KeyBindings::getAction(int key) { // return bindings.; } void KeyBindings::setKeyBinding(int key, int action) { // bindings.set(key,action); }