keyboard.hpp 579 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef __KEYBOARD_HPP__
#define __KEYBOARD_HPP__

#include <unordered_map>
#include <SDL.h>
#include <input/input.hpp>

namespace gdw{
	class keyboard{
		private:
			input *input_;
			std::unordered_map<int, int> key_map_;
			std::unordered_map<int, bool> released_map_;
			const Uint8 *key_state_;
		public:
			keyboard(input *input);
			~keyboard();
			void reset();

			int down(SDL_Keycode key);
			bool pressed(SDL_Keycode key);
			bool released(SDL_Keycode key);

			void down_event(const SDL_KeyboardEvent &e);
			void up_event(const SDL_KeyboardEvent &e);
	};
}

#endif