summaryrefslogtreecommitdiff
path: root/Source/Asura.Engine/Input/Keyboard.h
blob: 488209bd12f0fa8e82ceb5a1cec5d55520caff65 (plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef __ASURA_INPUT_KEYBOARD_H__
#define __ASURA_INPUT_KEYBOARD_H__

#include <SDL2/SDL.h>

#include "InputDevice.hpp"
#include "Scripting/Portable.h"

namespace AsuraEngine
{
	namespace Input
	{

		class Keyboard ASURA_FINAL : public InputDevice<Keyboard>
		{
		public:

			// صö
			#include "Keyboard.defs"

			Keyboard();

			void SetKeyRepeat(bool enable);
			bool HasKeyRepeat() const;
			bool IsDown(const std::vector<Key> &keylist) const;
			bool IsScancodeDown(const std::vector<Scancode> &scancodelist) const;

			Key GetKeyFromScancode(Scancode scancode) const;
			Scancode GetScancodeFromKey(Key key) const;

			void SetTextInput(bool enable);
			void SetTextInput(bool enable, double x, double y, double w, double h);
			bool HasTextInput() const;
			bool HasScreenKeyboard() const;

			bool GetConstant(Scancode in, SDL_Scancode &out);
			bool GetConstant(SDL_Scancode in, Scancode &out);

		private:

			~Keyboard();
		
		public:

			//----------------------------------------------------------------------------------------------------------

			LUAX_DECL_SINGLETON(Keyboard); // ͨAsuraEngine.KeyboardֱӷʣûNew

			LUAX_DECL_ENUM(Key);
			LUAX_DECL_ENUM(ScanCode);

			LUAX_DECL_METHOD(SetKeyRepeat);
			LUAX_DECL_METHOD(HasKeyRepeat);
			LUAX_DECL_METHOD(IsDown);
			LUAX_DECL_METHOD(IsScancodeDown);

			LUAX_DECL_METHOD(GetKeyFromScancode);
			LUAX_DECL_METHOD(GetScancodeFromKey);

			LUAX_DECL_METHOD(SetTextInput);
			LUAX_DECL_METHOD(HasTextInput);
			LUAX_DECL_METHOD(HasScreenKeyboard);

			LUAX_DECL_METHOD(GetConstant);

			//----------------------------------------------------------------------------------------------------------

		};

	}
}

#endif