From 0c391fdbce5a079cf03e483eb6174dd47806163d Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 7 Aug 2019 21:08:47 +0800 Subject: *misc --- Source/modules/asura-core/Input/InputDevice.h | 82 +++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 Source/modules/asura-core/Input/InputDevice.h (limited to 'Source/modules/asura-core/Input/InputDevice.h') diff --git a/Source/modules/asura-core/Input/InputDevice.h b/Source/modules/asura-core/Input/InputDevice.h new file mode 100644 index 0000000..2b3ff9b --- /dev/null +++ b/Source/modules/asura-core/Input/InputDevice.h @@ -0,0 +1,82 @@ +#ifndef _ASURA_ENGINE_INPUT_BASE_H_ +#define _ASURA_ENGINE_INPUT_BASE_H_ + +#include +#include +#include + +#include + +#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, AEMath::Vector2f& newPos); + +#elif ASURA_RUNNER + + bool Open(); + void Close(); + +#endif + + bool Activate(bool active); + + bool GetJoystickNames(std::vector &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 \ No newline at end of file -- cgit v1.1-26-g67d0