SparrowInput/input.h
2015-07-17 20:04:19 +02:00

69 lines
1.6 KiB
C++

/**
* @author: Thomas Brandého
*/
#ifndef INPUT_H
#define INPUT_H
#include "keybindings.h"
#include <queue>
#include <vector>
#include <unordered_map>
class Input{
public:
/* Constructors */
Input(sf::Window* w, std::string keysmappings, int nb_actions);
// enum SpecialAction {}
/* general action-mapping functions */
void updateEvents();
int getAction();
int getKeyBinding(int action, int num);
void setkeyBinding(int action, int num, sf::Keyboard::Key key);
void setTypeAction(int action, int type);
/* context-related functions */
void createContext(std::string context_name, std::vector<int> action_list);
void setCurrentContext(std::string context_name);
void reloadKeyBindings();
/* window-related function */
bool isCloseRequested();
/* keyboard-related functions */
bool isKeyPressed(int key);
/* mouse-related function */
sf::Vector2i getPosition();
sf::Vector2i getDeltaPosition();
int getDeltaVerticalScroll();
void test();
private:
/* window-related variables */
sf::Window* window;
bool closeRequested;
/* general action-mapping variables */
KeysMap keysmap;
std::queue<int> action_file;
int nb_actions;
/* context-related variables */
std::string current_context;
std::unordered_map<std::string, std::vector<int>> contexts;
std::unordered_map<std::string,KeyBindings> keybindings;
/* keyboard-related variables */
std::vector<sf::Keyboard::Key> heldkeys;
void releaseHeldKeys(sf::Keyboard::Key keycode);
/* mouse-related variables */
sf::Vector2i mouse_position;
int delta_vertical_scroll;
};
#endif //INPUT_H