sculpto
input.h
Go to the documentation of this file.
1/*!****************************************************************//*!*
2 * \file input.h
3 * \brief Abstract, platform independent input system definition mpdule.
4 *
5 * \author Sabitov Kirill
6 * \date 22 June 2022
7 *********************************************************************/
8
9#pragma once
10
11#include "base.h"
12#include "input_keycodes.h"
13
14namespace scl
15{
17 {
18 int PosX { 0 };
19 int PosY { 0 };
20 int PosZ { 0 };
21 int PosDeltaX { 0 };
22 int PosDeltaY { 0 };
23 int PosDeltaZ { 0 };
24 };
25
27 {
31 u8 Keys[256] { 0 };
32
36 u8 KeysOld[256] { 0 };
37
42 u8 KeysClick[256] { 0 };
43 };
44
46 {
47 private:
48 static shared<input_system> Instance;
49
50 protected:
53
54 public:
56 static int GetMousePosX() { return Instance->Mouse.PosX; }
58 static int GetMousePosY() { return Instance->Mouse.PosY; }
60 static int GetMousePosZ() { return Instance->Mouse.PosZ; }
62 static int GetMousePosDeltaX() { return Instance->Mouse.PosDeltaX; }
64 static int GetMousePosDeltaY() { return Instance->Mouse.PosDeltaY; }
66 static int GetMousePosDeltaZ() { return Instance->Mouse.PosDeltaZ; }
67
71 static bool GetKey(keycode Index) { return Instance->Keyboard.Keys[(int)Index]; };
72
76 static bool GetKeyOld(keycode Index) { return Instance->Keyboard.KeysOld[(int)Index]; };
77
82 static bool GetKeyClick(keycode Index) { return Instance->Keyboard.KeysClick[(int)Index]; };
83
84 /*!*
85 * Read all available human devies function.
86 *
87 * \param None.
88 * \return None.
89 */
90 static void Response() { Instance->SelfResponse(); }
91
92 public:
93 /*!*
94 * Input system instance reference getter function.
95 *
96 * \param None.
97 * \return input system instance reference.
98 */
99 static shared<input_system> &Get() { return Instance; }
100
101 /*!*
102 * Create input system depends on platform function.
103 *
104 * \param None.
105 * \Return Created input system pointer.
106 */
108
109 protected:
110 /*!*
111 * Read all available human devies function.
112 *
113 * \param None.
114 * \return None.
115 */
116 virtual void SelfResponse() {}
117 };
118}
Topology object basis class for mesh creating implementation module.
static shared< input_system > & Get()
Definition: input.h:99
mouse_data Mouse
Definition: input.h:51
static int GetMousePosDeltaX()
Definition: input.h:62
keyboard_data Keyboard
Definition: input.h:52
static int GetMousePosY()
Definition: input.h:58
static bool GetKeyClick(keycode Index)
Definition: input.h:82
static bool GetKey(keycode Index)
Definition: input.h:71
static int GetMousePosDeltaY()
Definition: input.h:64
static int GetMousePosX()
Definition: input.h:56
static unique< input_system > Create()
Definition: input.cpp:14
static int GetMousePosDeltaZ()
Definition: input.h:66
virtual void SelfResponse()
Definition: input.h:116
static bool GetKeyOld(keycode Index)
Definition: input.h:76
static void Response()
Definition: input.h:90
static int GetMousePosZ()
Definition: input.h:60
Definition: base.h:33
std::shared_ptr< T > shared
Definition: smart_ptr.h:15
std::unique_ptr< T > unique
Definition: smart_ptr.h:25
uint8_t u8
Definition: math_common.h:17
u8 Keys[256]
Definition: input.h:31
u8 KeysClick[256]
Definition: input.h:42
u8 KeysOld[256]
Definition: input.h:36
int PosDeltaX
Definition: input.h:21
int PosDeltaY
Definition: input.h:22
int PosDeltaZ
Definition: input.h:23