OpenMiner/include/core/Keyboard.hpp

60 lines
1.0 KiB
C++
Raw Normal View History

2014-12-20 01:46:31 +01:00
/*
* =====================================================================================
*
* Filename: Keyboard.hpp
*
2018-06-05 01:24:54 +02:00
* Description:
2014-12-20 01:46:31 +01:00
*
* Version: 1.0
* Created: 20/12/2014 00:52:04
* Revision: none
* Compiler: gcc
*
* Author: Quentin BAZIN, <quent42340@gmail.com>
2018-06-05 01:24:54 +02:00
* Company:
2014-12-20 01:46:31 +01:00
*
* =====================================================================================
*/
#ifndef KEYBOARD_HPP_
#define KEYBOARD_HPP_
#include <map>
#include "Types.hpp"
class Keyboard {
public:
enum Key {
D,
Q,
S,
W,
X,
Z,
2018-06-05 01:24:54 +02:00
2014-12-20 01:46:31 +01:00
Left,
Right,
Up,
Down,
2018-06-05 01:24:54 +02:00
2014-12-20 01:46:31 +01:00
BackSpace,
2014-12-20 16:22:52 +01:00
LeftShift,
Space,
Return,
RightShift
2014-12-20 01:46:31 +01:00
};
2018-06-05 01:24:54 +02:00
2014-12-20 01:46:31 +01:00
static bool isKeyPressed(Key key);
static bool isKeyPressedOnce(Key key);
static bool isKeyPressedWithDelay(Key key, u16 delay);
2018-06-05 01:24:54 +02:00
2014-12-20 01:46:31 +01:00
private:
static const u8 *getState();
2018-06-05 01:24:54 +02:00
2014-12-20 01:46:31 +01:00
static std::map<Key, bool> pressed;
static std::map<Key, u32> lastTimePressed;
static std::map<Key, u32> keysCode;
};
#endif // KEYBOARD_HPP_