You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.3 KiB
C
69 lines
1.3 KiB
C
|
4 years ago
|
|
||
|
|
/******************************************************************************
|
||
|
|
* File - Keyboard.h
|
||
|
|
* Author - Joey Pollack
|
||
|
|
* Date - 2019/11/15 (y/m/d)
|
||
|
|
* Mod Date - 2019/11/15 (y/m/d)
|
||
|
|
* Description - Stores data about the keys on the keyboard
|
||
|
|
*
|
||
|
|
******************************************************************************/
|
||
|
|
|
||
|
|
#ifndef KEYBOARD_H_
|
||
|
|
#define KEYBOARD_H_
|
||
|
|
|
||
|
|
#include <map>
|
||
|
|
#include <string>
|
||
|
|
|
||
|
|
#include "keyCodes.h"
|
||
|
|
|
||
|
|
namespace lunarium
|
||
|
|
{
|
||
|
|
class Keyboard
|
||
|
|
{
|
||
|
|
friend class Core;
|
||
|
|
|
||
|
|
public: // Data structures
|
||
|
|
struct Key
|
||
|
|
{
|
||
|
|
KeyCode Code;
|
||
|
|
std::string Name;
|
||
|
|
std::string ShiftName;
|
||
|
|
char AsciiValue;
|
||
|
|
char ShiftAsciiValue;
|
||
|
|
|
||
|
|
static Key Unknown();
|
||
|
|
};
|
||
|
|
|
||
|
|
private: // Internal / Engine Only
|
||
|
|
Keyboard();
|
||
|
|
Keyboard(const Keyboard&) = delete;
|
||
|
|
Keyboard& operator=(const Keyboard&) = delete;
|
||
|
|
|
||
|
|
void Initialize();
|
||
|
|
static void Shutdown();
|
||
|
|
|
||
|
|
public: // Interface
|
||
|
|
|
||
|
|
static Keyboard* GetInstance();
|
||
|
|
|
||
|
|
Key GetKey(KeyCode code);
|
||
|
|
Key GetKey(std::string name);
|
||
|
|
Key GetKey(char ascii);
|
||
|
|
|
||
|
|
private: // The instance
|
||
|
|
static Keyboard* mpInstance;
|
||
|
|
|
||
|
|
private: // Data
|
||
|
|
std::map<KeyCode, Key> mKeyboard;
|
||
|
|
|
||
|
|
// Cross references
|
||
|
|
std::map<std::string, Key&> mKeysByName;
|
||
|
|
std::map<char, Key&> mKeysByAscii;
|
||
|
|
|
||
|
|
private: // Helper methods
|
||
|
|
void InitKeysByName();
|
||
|
|
void InitKeysByAscii();
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
#endif // KEYBOARD_H_
|