summaryrefslogtreecommitdiff
path: root/source/modules/asura-core/Input/InputDevice.h
blob: 42dfe4392a7451a866b338ad1e588661197864c0 (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
74
75
76
77
78
79
80
81
82
83
#ifndef _ASURA_ENGINE_INPUT_BASE_H_
#define _ASURA_ENGINE_INPUT_BASE_H_

#include <asura-base/Math/Vector2.hpp>
#include <asura-base/Scripting/Scripting.h>
#include <asura-base/Singleton.hpp>

#include <windows.h>

#include "../CoreConfig.h"

#include "KeyboardState.h"
#include "MouseState.h"
#include "JoystickState.h"

namespace_begin(AsuraEngine)
namespace_begin(Input)

// Ӳϵͳ
class InputDevice ASURA_FINAL
{
public: 

	InputDevice();
	~InputDevice();

#if ASURA_EDITOR 

	bool Open(HWND window);
	void Close();

	bool ToggleFullscreen(bool fullscreen, HWND window);

	bool Process(bool discard);
	LRESULT OnKey(HWND window, UINT message, WPARAM wParam, LPARAM lParam);
	LRESULT OnInput(HWND window, UINT message, WPARAM wParam, LPARAM lParam);
	LRESULT OnDeviceChange(LPCWSTR name, bool add);

	static bool ConvertPositionToClientAreaCoord(HWND activeWindow, POINT position, Vector2f& newPos);

#elif ASURA_RUNNER 

	bool Open(); 
	void Close();

#endif

	bool Activate(bool active);

	bool GetJoystickNames(std::vector<std::string> &names);

protected: 

	bool UpdateState();

	MouseState    m_Mouse;
	KeyboardState m_Keyboard;
	JoystickState m_Joysticks;

private:

	bool UpdateMousePosition();

};

extern InputDevice g_InputDevice;

#if ASURA_EDITOR 

bool ConvertPositionToClientAreaCoord();

#elif ASURA_RUNNER 

bool ConvertPositionToClientAreaCoord();

#endif

namespace_end
namespace_end

namespace AEInput = AsuraEngine::Input;

#endif