diff options
Diffstat (limited to 'source/modules/asura-core/input')
21 files changed, 137 insertions, 431 deletions
diff --git a/source/modules/asura-core/input/button.h b/source/modules/asura-core/input/button.h new file mode 100644 index 0000000..0df8ed2 --- /dev/null +++ b/source/modules/asura-core/input/button.h @@ -0,0 +1,32 @@ +#ifndef __BUTTON_H__ +#define __BUTTON_H__ + +namespace AsuraEngine +{ + namespace Input + { + + /// keyboard button \ mouse button \ joystick button + class Button + { + public: + inline Button(int key, bool state) : + key(key), + state(state) + { + } + + inline int GetKey(void) const { return this->key; } + inline bool GetState(void) const { return this->state; } + + private: + int key; + bool state; + + }; + + } +} + + +#endif
\ No newline at end of file diff --git a/source/modules/asura-core/input/clipboard.h b/source/modules/asura-core/input/clipboard.h index 1b7c2b8..e69de29 100644 --- a/source/modules/asura-core/input/clipboard.h +++ b/source/modules/asura-core/input/clipboard.h @@ -1,35 +0,0 @@ -#ifndef __ASURA_ENGINE_CLIPBOARD_H__ -#define __ASURA_ENGINE_CLIPBOARD_H__ - -#include "Text/String.hpp" -#include "InputDevice.hpp" - -namespace AsuraEngine -{ - namespace Input - { - - class Clipboard ASURA_FINAL : public InputDevice<Clipboard> - { - public: - - Clipboard(); - - Text::String GetString(); - - void SetString(const Text::String& text); - - private: - - ~Clipboard(); - - luaxport: - - LUAX_DECL_SINGLETON(Clipboard); - - }; - - }; -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-core/input/cursor.h b/source/modules/asura-core/input/cursor.h deleted file mode 100644 index e3df7ee..0000000 --- a/source/modules/asura-core/input/cursor.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef __ASURA_ENGINE_CURSOR_H__ -#define __ASURA_ENGINE_CURSOR_H__ - -#include <SDL2/SDL.h> - -#include <asura-utils/scripting/portable.hpp> - -#include "../graphics/image_data.h" - -#include "input_device.hpp" - -namespace AsuraEngine -{ - namespace Input - { - - class CursorImpl; - - // Types of system cursors. - enum SystemCursor - { - CURSOR_ARROW, - CURSOR_IBEAM, - CURSOR_WAIT, - CURSOR_CROSSHAIR, - CURSOR_WAITARROW, - CURSOR_SIZENWSE, - CURSOR_SIZENESW, - CURSOR_SIZEWE, - CURSOR_SIZENS, - CURSOR_SIZEALL, - CURSOR_NO, - CURSOR_HAND, - CURSOR_MAX_ENUM - }; - - enum CursorType - { - CURSORTYPE_SYSTEM, - CURSORTYPE_IMAGE, - CURSORTYPE_MAX_ENUM - }; - - // ָö -#include "Cursor.defs" - - class Cursor - : public AEScripting::Portable<Cursor> - { - public: - - Cursor(Graphics::ImageData& imageData, int hotx, int hoty); - Cursor(SystemCursor cursortype); - - ~Cursor(); - - SDL_Cursor* GetHandle() const; - CursorType GetType() const; - SystemCursor GetSystemType() const; - - private: - - CursorType mType; - SystemCursor mSystemType; - CursorImpl* mImpl; - - luaxport: - - LUAX_DECL_FACTORY(Cursor); - - }; - - ASURA_ABSTRACT class CursorImpl - { - - }; - - } -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-core/input/equeue.cpp b/source/modules/asura-core/input/equeue.cpp deleted file mode 100644 index e165393..0000000 --- a/source/modules/asura-core/input/equeue.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "equeue.h" - -namespace AsuraEngine -{ - namespace Input - { - - EQueue::EQueue() - { - // try create queue - - ASSERT(mImpl); - } - - EQueue::~EQueue() - { - if(mImpl) - delete mImpl; - } - - bool EQueue::Poll(const Event& e) - { - ASSERT(mImpl); - return mImpl->Poll(e); - } - - } -}
\ No newline at end of file diff --git a/source/modules/asura-core/input/equeue.h b/source/modules/asura-core/input/equeue.h deleted file mode 100644 index 495c869..0000000 --- a/source/modules/asura-core/input/equeue.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef __ASURA_EQUEUE_H__ -#define __ASURA_EQUEUE_H__ - -#include <asura-utils/type.h> - -#include "event.h" - -namespace AsuraEngine -{ - namespace Input - { - - class EQueueImpl; - - /// - /// Event queue. - /// - class EQueue - { - public: - - EQueue(); - ~EQueue(); - - bool Poll(const Event& e); - - private: - - EQueueImpl* mImpl; - - }; - - ASURA_ABSTRACT class EQueueImpl - { - public: - - EQueueImpl() {}; - virtual ~EQueueImpl() {}; - - /// - /// Ӳϵͳ¼óһءзtrue,ûзfalseص - /// װЩͬʵֵ¼ʹͳһתΪAsura event - /// - virtual bool Poll(const Event&) = 0; - - }; - - } -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-core/input/equeue_impl_win32.h b/source/modules/asura-core/input/equeue_impl_win32.h deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-core/input/equeue_impl_win32.h +++ /dev/null diff --git a/source/modules/asura-core/input/event.h b/source/modules/asura-core/input/event.h deleted file mode 100644 index a24e806..0000000 --- a/source/modules/asura-core/input/event.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef __ASURA_ENGINE_EVENT_H__ -#define __ASURA_ENGINE_EVENT_H__ - -namespace AsuraEngine -{ - namespace Input - { - - enum EventType - { - EVENT_BEGIN_MOUSE__ , - EVENT_LEFT_DOWN , - EVENT_LEFT_UP , - EVENT_LEFT_DCLICK , - EVENT_MIDDLE_DOWN , - EVENT_MIDDLE_UP , - EVENT_MIDDLE_DCLICK , - EVENT_RIGHT_DOWN , - EVENT_RIGHT_UP , - EVENT_RIGHT_DCLICK , - EVENT_MOTION , - EVENT_END_MOUSE__ , - EVENT_ENTER_WINDOW , - EVENT_LEAVE_WINDOW , - EVENT_MOUSEWHEEL - }; - - struct Event - { - int type; - union - { - // 갴¼ - struct { - int id; - } button; - }; - }; - - } -} - -namespace AEInput = AsuraEngine::Input; - -#endif
\ No newline at end of file diff --git a/source/modules/asura-core/input/event_manager.h b/source/modules/asura-core/input/event_manager.h deleted file mode 100644 index b81b7ff..0000000 --- a/source/modules/asura-core/input/event_manager.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef __ASURA_EVENT_MANANGER_H__ -#define __ASURA_EVENT_MANANGER_H__ - -#include "equeue.h" - -namespace AsuraEngine -{ - namespace Input - { - - class EventManager - { - public: - - private: - - EQueue mQueue; - - }; - - } -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-core/input/cursor.cpp b/source/modules/asura-core/input/input_device.cpp index e69de29..e69de29 100644 --- a/source/modules/asura-core/input/cursor.cpp +++ b/source/modules/asura-core/input/input_device.cpp diff --git a/source/modules/asura-core/input/input_device.h b/source/modules/asura-core/input/input_device.h new file mode 100644 index 0000000..7082ea3 --- /dev/null +++ b/source/modules/asura-core/input/input_device.h @@ -0,0 +1,41 @@ +#ifndef __ASURA_ENGINE_INPUT_BASE_H__ +#define __ASURA_ENGINE_INPUT_BASE_H__ + +#include <asura-utils/math/vector2.hpp> +#include <asura-utils/scripting/portable.hpp> +#include <asura-utils/singleton.hpp> + +#include "../core_config.h" + +#include "keyboard_state.h" + +namespace AsuraEngine +{ + namespace Input + { + + /// ͬƽ̨̳ಢʵhandleӿ + ASURA_ABSTRACT class InputDevice : public Singleton<InputDevice> + { + protected: + + void OnKeyDown(int key); + void OnKeyUp(int key); + + void OnMouseMove(const AEMath::Vector2f& position); + + void OnMouseButtonDown(int key); + void OnMouseButtonUp(int key); + + void OnMouseWheel(); + + void OnInputChar(); + + }; + + } +} + +namespace AEInput = AsuraEngine::Input; + +#endif
\ No newline at end of file diff --git a/source/modules/asura-core/input/input_device.hpp b/source/modules/asura-core/input/input_device.hpp deleted file mode 100644 index 4d82343..0000000 --- a/source/modules/asura-core/input/input_device.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef __ASURA_ENGINE_INPUT_BASE_H__ -#define __ASURA_ENGINE_INPUT_BASE_H__ - -#include <asura-utils/scripting/portable.hpp> -#include <asura-utils/singleton.hpp> - -#include "../core_config.h" - -namespace AsuraEngine -{ - namespace Input - { - - /// - /// 豸һ - /// - template<class T> - ASURA_ABSTRACT class InputDevice - : virtual public Scripting::Portable<T> - , virtual public Singleton<T> - { - public: - InputDevice(); - virtual ~InputDevice(); - - }; - - } -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-core/input/cursor_impl_sdl.cpp b/source/modules/asura-core/input/input_manager.cpp index e69de29..e69de29 100644 --- a/source/modules/asura-core/input/cursor_impl_sdl.cpp +++ b/source/modules/asura-core/input/input_manager.cpp diff --git a/source/modules/asura-core/input/input_manager.h b/source/modules/asura-core/input/input_manager.h new file mode 100644 index 0000000..4597d39 --- /dev/null +++ b/source/modules/asura-core/input/input_manager.h @@ -0,0 +1,25 @@ +#ifndef __INPUT_MAMANGER_H__ +#define __INPUT_MAMANGER_H__ + +#include <asura-utils/scripting/portable.hpp> +#include <asura-utils/singleton.hpp> + +namespace AsuraEngine +{ + namespace Input + { + + /// + class InputManager : public Singleton<InputManager> + { + public : + + + private : + + }; + + } +} + +#endif
\ No newline at end of file diff --git a/source/modules/asura-core/input/joypad.h b/source/modules/asura-core/input/joypad.h deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-core/input/joypad.h +++ /dev/null diff --git a/source/modules/asura-core/input/cursor_impl_sdl.h b/source/modules/asura-core/input/joystick_state.h index e69de29..e69de29 100644 --- a/source/modules/asura-core/input/cursor_impl_sdl.h +++ b/source/modules/asura-core/input/joystick_state.h diff --git a/source/modules/asura-core/input/keyboard.cpp b/source/modules/asura-core/input/keyboard.cpp deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-core/input/keyboard.cpp +++ /dev/null diff --git a/source/modules/asura-core/input/keyboard.h b/source/modules/asura-core/input/keyboard.h deleted file mode 100644 index d1d7b48..0000000 --- a/source/modules/asura-core/input/keyboard.h +++ /dev/null @@ -1,73 +0,0 @@ -//#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 "keys.h" -// -// 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
\ No newline at end of file diff --git a/source/modules/asura-core/input/keyboard_state.h b/source/modules/asura-core/input/keyboard_state.h new file mode 100644 index 0000000..f6aa5ea --- /dev/null +++ b/source/modules/asura-core/input/keyboard_state.h @@ -0,0 +1,39 @@ +#ifndef __KEYBOARD_STATE_H__ +#define __KEYBOARD_STATE_H__ + +#include <vector> + +#include "button.h" + +namespace AsuraEngine +{ + namespace Input + { + + typedef std::vector<Button> Buttons; + + class KeyboardState + { + private: + Buttons buttons; + + public: + inline KeyboardState(void) + { + this->buttons.reserve(256); + } + + inline const Buttons &GetButtons(void) const { return this->buttons; } + inline void AddButton(int key, bool state) { this->buttons.push_back(Button(key, state)); } + + void Reset(bool full) + { + this->buttons.clear(); + } + + }; + + } +} + +#endif
\ No newline at end of file diff --git a/source/modules/asura-core/input/mouse.cpp b/source/modules/asura-core/input/mouse.cpp deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-core/input/mouse.cpp +++ /dev/null diff --git a/source/modules/asura-core/input/mouse.h b/source/modules/asura-core/input/mouse.h deleted file mode 100644 index 4a5a4ba..0000000 --- a/source/modules/asura-core/input/mouse.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef __ASURA_ENGINE_MOUSE_H__ -#define __ASURA_ENGINE_MOUSE_H__ - -#include "cursor.h" -#include "input_device.hpp" - -namespace AsuraEngine -{ - namespace Input - { - - enum MouseButton - { - MOUSE_BUTTON_LEFT, - MOUSE_BUTTON_MIDDLE, - MOUSE_BUTTON_RIGHT, - }; - - class Mouse : public InputDevice<Mouse> - { - public: - - /// - /// ͼƬйָʹϵͳָ - /// - Cursor *CreateCursor(Graphics::ImageData *data, int hotx, int hoty); - Cursor *GetSystemCursor(Cursor::SystemCursor cursortype); - - void SetCursor(Cursor *cursor); - void SetCursor() ; - - Cursor* GetCursor() const; - - bool IsCursorSupported() const; - - double GetX() const; - double GetY() const; - void GetPosition(double &x, double &y) const; - void GetX(double x) ; - void SetY(double y) ; - void SetPosition(double x, double y) ; - void SetVisible(bool visible) ; - bool IsDown(const std::vector<int> &buttons) const; - bool IsVisible() const; - void SetGrabbed(bool grab) ; - bool IsGrabbed() const; - bool SetRelativeMode(bool relative) ; - bool GetRelativeMode() const; - - //----------------------------------------------------------------------------// - - LUAX_DECL_SINGLETON(Mouse); - - //----------------------------------------------------------------------------// - - private: - - }; - - } -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-core/input/equeue_impl_sdl.h b/source/modules/asura-core/input/mouse_state.h index e69de29..e69de29 100644 --- a/source/modules/asura-core/input/equeue_impl_sdl.h +++ b/source/modules/asura-core/input/mouse_state.h |