spacebox/src/Input.hpp

60 lines
1.2 KiB
C++
Raw Normal View History

2019-05-03 02:09:48 -04:00
#ifndef Input_h_
#define Input_h_
2019-05-07 03:33:54 -04:00
#include <string>
#include <map>
2019-05-07 03:33:54 -04:00
#include <list>
#include <functional>
2019-05-03 02:09:48 -04:00
#include "SDL.h"
#include "Node.hpp"
struct KeyCombination
{
2019-05-04 03:25:35 -04:00
std::string command;
int key;
bool ctrl;
bool shift;
2019-05-04 03:25:35 -04:00
bool alt;
};
2019-05-03 02:09:48 -04:00
struct Input : Node
{
2019-05-04 03:25:35 -04:00
std::map<std::string, SDL_Keycode> key_ids
{
{"up", SDLK_UP},
{"right", SDLK_RIGHT},
{"down", SDLK_DOWN},
{"left", SDLK_LEFT},
{"f1", SDLK_F1},
{"f2", SDLK_F2},
{"f3", SDLK_F3},
{"f4", SDLK_F4},
{"f5", SDLK_F5},
{"f6", SDLK_F6},
{"f7", SDLK_F7},
{"f8", SDLK_F8},
{"f9", SDLK_F9},
{"f10", SDLK_F10},
{"f11", SDLK_F11},
2019-05-16 03:51:36 -04:00
{"f12", SDLK_F11},
{"enter", SDLK_RETURN},
{"space", SDLK_SPACE}
};
2019-05-07 03:33:54 -04:00
std::vector<KeyCombination> key_map;
2019-05-03 02:09:48 -04:00
Input(Node*);
2019-05-04 03:25:35 -04:00
void respond(SDL_Event&);
void load_key_map();
2019-05-04 03:25:35 -04:00
SDL_Keycode get_key_code(std::string);
void add_to_key_map(
std::string, SDL_Keycode, bool = false, bool = false, bool = false);
void print_key_combination(KeyCombination&);
std::string get_class_name() { return "Input"; }
2019-05-03 02:09:48 -04:00
};
#endif