Initial late commit
This commit is contained in:
61
open_engine/include/open_engine/input/input_system.hpp
Normal file
61
open_engine/include/open_engine/input/input_system.hpp
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef INPUT_HPP
|
||||
#define INPUT_HPP
|
||||
|
||||
#include "../core.hpp"
|
||||
#include <map>
|
||||
|
||||
#define MAX_AXIS 10
|
||||
|
||||
namespace OpenEngine {
|
||||
class OE_API Input
|
||||
{
|
||||
public:
|
||||
Input(const Input&) = delete;
|
||||
Input& operator=(const Input&) = delete;
|
||||
|
||||
inline static bool IsKeyPressed(int keycode) { return instance->IsKeyPressedImpl(keycode); };
|
||||
|
||||
inline static bool IsMouseButtonPressed(int button) { return instance->IsMouseButtonPressedImpl(button); };
|
||||
|
||||
inline static std::pair<float, float> GetMousePosition() { return instance->GetMousePositionImpl(); };
|
||||
inline static bool GetMouseX() { return instance->GetMouseXImpl(); };
|
||||
inline static bool GetMouseY() { return instance->GetMouseYImpl(); };
|
||||
|
||||
inline static bool JoystickExists(unsigned int joystick) { return instance->JoystickExistsImpl(joystick); };
|
||||
inline static std::map<unsigned int, std::string> GetJoystickList() { return instance->GetJoystickListImpl(); };
|
||||
|
||||
inline static float GetJoystickAxis(unsigned int joystick, unsigned int axis) { return instance->GetJoystickAxisImpl(joystick, axis); };
|
||||
inline static const float* GetJoystickAxes(unsigned int joystick) { return instance->GetJoystickAxesImpl(joystick); };
|
||||
inline static unsigned int GetJoystickAxesCount(unsigned int joystick) { return instance->GetJoystickAxesCountImpl(joystick); };
|
||||
|
||||
inline static bool IsJoystickButtonPressed(unsigned int joystick, unsigned int button) { return instance->IsJoystickButtonPressedImpl(joystick, button); };
|
||||
|
||||
protected:
|
||||
Input() = default;
|
||||
|
||||
virtual bool IsKeyPressedImpl(int keycode) = 0;
|
||||
|
||||
virtual bool IsMouseButtonPressedImpl(int button) = 0;
|
||||
|
||||
virtual std::pair<float, float> GetMousePositionImpl() = 0;
|
||||
virtual float GetMouseXImpl() = 0;
|
||||
virtual float GetMouseYImpl() = 0;
|
||||
|
||||
virtual bool JoystickExistsImpl(unsigned int joystick) = 0;
|
||||
virtual std::map<unsigned int, std::string> GetJoystickListImpl() = 0;
|
||||
virtual const std::string GetJoystickNameImpl(unsigned int joystick) = 0;
|
||||
|
||||
virtual float GetJoystickAxisImpl(unsigned int joystick, unsigned int axis) = 0;
|
||||
virtual const float* GetJoystickAxesImpl(unsigned int joystick) = 0;
|
||||
virtual unsigned int GetJoystickAxesCountImpl(unsigned int joystick) = 0;
|
||||
|
||||
virtual bool IsJoystickButtonPressedImpl(unsigned int joystick, unsigned int button) = 0;
|
||||
|
||||
private:
|
||||
inline static const std::string GetJoystickName(unsigned int joystick) { return instance->GetJoystickNameImpl(joystick); };
|
||||
|
||||
static Input* instance;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // INPUT_HPP
|
||||
127
open_engine/include/open_engine/input/keycodes.hpp
Normal file
127
open_engine/include/open_engine/input/keycodes.hpp
Normal file
@@ -0,0 +1,127 @@
|
||||
#ifndef KEYCODES_HPP
|
||||
#define KEYCODES_HPP
|
||||
|
||||
#define OE_KEY_SPACE 32
|
||||
#define OE_KEY_APOSTROPHE 39 /* ' */
|
||||
#define OE_KEY_COMMA 44 /* , */
|
||||
#define OE_KEY_MINUS 45 /* - */
|
||||
#define OE_KEY_PERIOD 46 /* . */
|
||||
#define OE_KEY_SLASH 47 /* / */
|
||||
#define OE_KEY_0 48
|
||||
#define OE_KEY_1 49
|
||||
#define OE_KEY_2 50
|
||||
#define OE_KEY_3 51
|
||||
#define OE_KEY_4 52
|
||||
#define OE_KEY_5 53
|
||||
#define OE_KEY_6 54
|
||||
#define OE_KEY_7 55
|
||||
#define OE_KEY_8 56
|
||||
#define OE_KEY_9 57
|
||||
#define OE_KEY_SEMICOLON 59 /* ; */
|
||||
#define OE_KEY_EQUAL 61 /* = */
|
||||
#define OE_KEY_A 65
|
||||
#define OE_KEY_B 66
|
||||
#define OE_KEY_C 67
|
||||
#define OE_KEY_D 68
|
||||
#define OE_KEY_E 69
|
||||
#define OE_KEY_F 70
|
||||
#define OE_KEY_G 71
|
||||
#define OE_KEY_H 72
|
||||
#define OE_KEY_I 73
|
||||
#define OE_KEY_J 74
|
||||
#define OE_KEY_K 75
|
||||
#define OE_KEY_L 76
|
||||
#define OE_KEY_M 77
|
||||
#define OE_KEY_N 78
|
||||
#define OE_KEY_O 79
|
||||
#define OE_KEY_P 80
|
||||
#define OE_KEY_Q 81
|
||||
#define OE_KEY_R 82
|
||||
#define OE_KEY_S 83
|
||||
#define OE_KEY_T 84
|
||||
#define OE_KEY_U 85
|
||||
#define OE_KEY_V 86
|
||||
#define OE_KEY_W 87
|
||||
#define OE_KEY_X 88
|
||||
#define OE_KEY_Y 89
|
||||
#define OE_KEY_Z 90
|
||||
#define OE_KEY_LEFT_BRACKET 91 /* [ */
|
||||
#define OE_KEY_BACKSLASH 92 /* \ */
|
||||
#define OE_KEY_RIGHT_BRACKET 93 /* ] */
|
||||
#define OE_KEY_GRAVE_ACCENT 96 /* ` */
|
||||
#define OE_KEY_WORLD_1 161 /* non-US #1 */
|
||||
#define OE_KEY_WORLD_2 162 /* non-US #2 */
|
||||
|
||||
/* FunctOEn keys */
|
||||
#define OE_KEY_ESCAPE 256
|
||||
#define OE_KEY_ENTER 257
|
||||
#define OE_KEY_TAB 258
|
||||
#define OE_KEY_BACKSPACE 259
|
||||
#define OE_KEY_INSERT 260
|
||||
#define OE_KEY_DELETE 261
|
||||
#define OE_KEY_RIGHT 262
|
||||
#define OE_KEY_LEFT 263
|
||||
#define OE_KEY_DOWN 264
|
||||
#define OE_KEY_UP 265
|
||||
#define OE_KEY_PAGE_UP 266
|
||||
#define OE_KEY_PAGE_DOWN 267
|
||||
#define OE_KEY_HOME 268
|
||||
#define OE_KEY_END 269
|
||||
#define OE_KEY_CAPS_LOCK 280
|
||||
#define OE_KEY_SCROLL_LOCK 281
|
||||
#define OE_KEY_NUM_LOCK 282
|
||||
#define OE_KEY_PRINT_SCREEN 283
|
||||
#define OE_KEY_PAUSE 284
|
||||
#define OE_KEY_F1 290
|
||||
#define OE_KEY_F2 291
|
||||
#define OE_KEY_F3 292
|
||||
#define OE_KEY_F4 293
|
||||
#define OE_KEY_F5 294
|
||||
#define OE_KEY_F6 295
|
||||
#define OE_KEY_F7 296
|
||||
#define OE_KEY_F8 297
|
||||
#define OE_KEY_F9 298
|
||||
#define OE_KEY_F10 299
|
||||
#define OE_KEY_F11 300
|
||||
#define OE_KEY_F12 301
|
||||
#define OE_KEY_F13 302
|
||||
#define OE_KEY_F14 303
|
||||
#define OE_KEY_F15 304
|
||||
#define OE_KEY_F16 305
|
||||
#define OE_KEY_F17 306
|
||||
#define OE_KEY_F18 307
|
||||
#define OE_KEY_F19 308
|
||||
#define OE_KEY_F20 309
|
||||
#define OE_KEY_F21 310
|
||||
#define OE_KEY_F22 311
|
||||
#define OE_KEY_F23 312
|
||||
#define OE_KEY_F24 313
|
||||
#define OE_KEY_F25 314
|
||||
#define OE_KEY_KP_0 320
|
||||
#define OE_KEY_KP_1 321
|
||||
#define OE_KEY_KP_2 322
|
||||
#define OE_KEY_KP_3 323
|
||||
#define OE_KEY_KP_4 324
|
||||
#define OE_KEY_KP_5 325
|
||||
#define OE_KEY_KP_6 326
|
||||
#define OE_KEY_KP_7 327
|
||||
#define OE_KEY_KP_8 328
|
||||
#define OE_KEY_KP_9 329
|
||||
#define OE_KEY_KP_DECIMAL 330
|
||||
#define OE_KEY_KP_DIVIDE 331
|
||||
#define OE_KEY_KP_MULTIPLY 332
|
||||
#define OE_KEY_KP_SUBTRACT 333
|
||||
#define OE_KEY_KP_ADD 334
|
||||
#define OE_KEY_KP_ENTER 335
|
||||
#define OE_KEY_KP_EQUAL 336
|
||||
#define OE_KEY_LEFT_SHIFT 340
|
||||
#define OE_KEY_LEFT_CONTROL 341
|
||||
#define OE_KEY_LEFT_ALT 342
|
||||
#define OE_KEY_LEFT_SUPER 343
|
||||
#define OE_KEY_RIGHT_SHIFT 344
|
||||
#define OE_KEY_RIGHT_CONTROL 345
|
||||
#define OE_KEY_RIGHT_ALT 346
|
||||
#define OE_KEY_RIGHT_SUPER 347
|
||||
#define OE_KEY_MENU 348
|
||||
|
||||
#endif // KEYCODES_HPP
|
||||
33
open_engine/include/open_engine/input/linux_input.hpp
Normal file
33
open_engine/include/open_engine/input/linux_input.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef LINUX_INPUT_HPP
|
||||
#define LINUX_INPUT_HPP
|
||||
|
||||
#include "input_system.hpp"
|
||||
|
||||
namespace OpenEngine {
|
||||
class LinuxInput : public Input
|
||||
{
|
||||
protected:
|
||||
virtual bool IsKeyPressedImpl(int keycode) override;
|
||||
|
||||
virtual bool IsMouseButtonPressedImpl(int button) override;
|
||||
|
||||
virtual std::pair<float, float> GetMousePositionImpl() override;
|
||||
virtual float GetMouseXImpl() override;
|
||||
virtual float GetMouseYImpl() override;
|
||||
|
||||
virtual bool JoystickExistsImpl(unsigned int joystick) override;
|
||||
|
||||
virtual float GetJoystickAxisImpl(unsigned int joystick, unsigned int axis) override;
|
||||
virtual const std::string GetJoystickNameImpl(unsigned int joystick) override;
|
||||
|
||||
virtual std::map<unsigned int, std::string> GetJoystickListImpl() override;
|
||||
virtual const float* GetJoystickAxesImpl(unsigned int joystick) override;
|
||||
virtual unsigned int GetJoystickAxesCountImpl(unsigned int joystick) override;
|
||||
|
||||
virtual bool IsJoystickButtonPressedImpl(unsigned int joystick, unsigned int button) override;
|
||||
|
||||
private:
|
||||
};
|
||||
}
|
||||
|
||||
#endif // LINUX_INPUT_HPP
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef MOUSE_BUTTONS_CODES_HPP
|
||||
#define MOUSE_BUTTONS_CODES_HPP
|
||||
|
||||
#define HZ_MOUSE_BUTTON_1 0
|
||||
#define HZ_MOUSE_BUTTON_2 1
|
||||
#define HZ_MOUSE_BUTTON_3 2
|
||||
#define HZ_MOUSE_BUTTON_4 3
|
||||
#define HZ_MOUSE_BUTTON_5 4
|
||||
#define HZ_MOUSE_BUTTON_6 5
|
||||
#define HZ_MOUSE_BUTTON_7 6
|
||||
#define HZ_MOUSE_BUTTON_8 7
|
||||
#define HZ_MOUSE_BUTTON_LAST HZ_MOUSE_BUTTON_8
|
||||
#define HZ_MOUSE_BUTTON_LEFT HZ_MOUSE_BUTTON_1
|
||||
#define HZ_MOUSE_BUTTON_RIGHT HZ_MOUSE_BUTTON_2
|
||||
#define HZ_MOUSE_BUTTON_MIDDLE HZ_MOUSE_BUTTON_3
|
||||
|
||||
#endif // MOUSE_BUTTONS_CODES_HPP
|
||||
Reference in New Issue
Block a user