76 lines
1.7 KiB
C++
76 lines
1.7 KiB
C++
/**
|
|
* @author: Thomas Brandého
|
|
*/
|
|
|
|
#ifndef INPUT_H
|
|
#define INPUT_H
|
|
#include "keybindings.h"
|
|
#include <queue>
|
|
#include <vector>
|
|
#include <unordered_map>
|
|
#include "textbuffer.h"
|
|
|
|
class Input{
|
|
public:
|
|
/* Constructors */
|
|
Input(sf::Window *w);
|
|
|
|
/* general action-mapping functions */
|
|
void setKeysMap(IKeysMap km);
|
|
void updateEvents();
|
|
int getAction();
|
|
|
|
/* context-related functions */
|
|
void addContext(Context context);
|
|
void setCurrentContext(std::string context_name);
|
|
void updateKeyBindings();
|
|
|
|
/* window-related function */
|
|
bool isCloseRequested() const;
|
|
bool isResized() const;
|
|
|
|
/* keyboard-related functions */
|
|
bool isKeyPressed(int key) const;
|
|
|
|
/* mouse-related function */
|
|
sf::Vector2i getPosition() const;
|
|
sf::Vector2i getDeltaPosition() const;
|
|
float getDeltaVerticalScroll() const;
|
|
|
|
/* text-related function */
|
|
std::string getText();
|
|
|
|
void test();
|
|
|
|
private:
|
|
/* window-related variables */
|
|
sf::Window* window;
|
|
bool closeRequested;
|
|
bool hasBeenResized;
|
|
|
|
/* general action-mapping variables */
|
|
IKeysMap 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::vector<Context> 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;
|
|
sf::Vector2i last_mouse_position;
|
|
float delta_vertical_scroll;
|
|
|
|
/* text-related variable */
|
|
std::string buffer;
|
|
};
|
|
|
|
#endif //INPUT_H
|