57 lines
1.2 KiB
C++
57 lines
1.2 KiB
C++
/**
|
|
* @author: Thomas Brandého
|
|
*/
|
|
|
|
#include "input.h"
|
|
|
|
#include <SFML/Window.hpp>
|
|
|
|
Input::Input(sf::Window* w, std::string keysmappings, int nb_actions): window(w)
|
|
{
|
|
keysmap= KeysMap(keysmappings, nb_actions);
|
|
// action_file = std::queue<int>();
|
|
// keysmap = KeysMap(false);
|
|
// context_maps.push_back(new Context());
|
|
}
|
|
|
|
int Input::getKeyBinding(int action,int num){
|
|
return keysmap.getKeyBinding(action,num-1); //offset num between 0 and 1
|
|
}
|
|
|
|
void Input::setkeyBinding(int action, int num, sf::Keyboard::Key key){
|
|
keysmap.setKeyBinding(action,num-1,key);
|
|
}
|
|
|
|
|
|
/*
|
|
void Input::updateEvents(){
|
|
sf::Event event;
|
|
//WARNING : may cause lag if continuously fed with event?
|
|
while(window->pollEvent(event)){
|
|
if (event.type == sf::Event::KeyPressed){
|
|
switch(event.KeyPressed){
|
|
// handle keypressed
|
|
default:
|
|
break;
|
|
}
|
|
}else{
|
|
//handle other kind of event
|
|
}
|
|
}
|
|
}
|
|
|
|
int Input::getAction(){
|
|
//return action_file.first();
|
|
}
|
|
|
|
void Input::reloadKeyBindings(){
|
|
for (int i = 0; i < NB_CONTEXT; i++){
|
|
keybindings[i] = KeyBindings(contexts[i],&keysmap);
|
|
}
|
|
}
|
|
|
|
void Input::setContext(Context context){
|
|
current_context = context;
|
|
}
|
|
*/
|