The open source repository for the action RPG game in development by Sig Productions titled 'Adventures in Lestoria'! https://forums.lestoria.net
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AdventuresInLestoria/Crawler/Key.h

43 lines
916 B

#pragma once
#include "olcPixelGameEngine.h"
#include <set>
//Future-proof game controller support.
enum InputType{
KEY,
MOUSE,
CONTROLLER
};
//A generic class that represents any type of input.
class Input{
friend class InputGroup;
InputType type;
int key; //This will be interpreted differently depending on input type.
public:
Input(InputType type,int key);
bool Pressed();
bool Held();
bool Released();
std::string GetDisplayName();
bool operator<(const Input&rhs)const{
return type<rhs.type||(type==rhs.type&&key<rhs.key);
}
};
class InputGroup{
std::set<Input>keys;
public:
InputGroup();
void AddKeybind(Input bind);
void RemoveKeybind(Input bind);
bool Pressed();
bool Held();
bool Released();
std::string GetDisplayName();
};
class GenericKey{
public:
static std::map<std::pair<InputType,int>,std::string>keyLiteral; //The displayed text for a given key for a given input type.
};