spacebox/src/Input.hpp

60 lines
1.2 KiB
C++

#ifndef Input_h_
#define Input_h_
#include <string>
#include <map>
#include <list>
#include <functional>
#include "SDL.h"
#include "Node.hpp"
struct KeyCombination
{
std::string command;
int key;
bool ctrl;
bool shift;
bool alt;
};
struct Input : Node
{
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},
{"f12", SDLK_F11},
{"enter", SDLK_RETURN},
{"space", SDLK_SPACE}
};
std::vector<KeyCombination> key_map;
Input(Node*);
void respond(SDL_Event&);
void load_key_map();
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"; }
};
#endif