MGL(Win32)
読み取り中…
検索中…
一致する文字列を見つけられません
mgl_touch.h
[詳解]
1// SPDX-License-Identifier: Zlib
2/* ------------------------------------------------------------------------- */
9/* ------------------------------------------------------------------------- */
10
11#ifndef INCGUARD_MGL_TOUCH_H_1613419314
12#define INCGUARD_MGL_TOUCH_H_1613419314
13
16#include <mgl/mgl_environment.h>
17
18namespace MGL::Input
19{
21class Touch
22{
23public:
24 /* ------------------------------------------------------------------------- */
29 /* ------------------------------------------------------------------------- */
30 Touch(size_t index = 0) noexcept
31 : _state(TouchServer::GetInstance().GetState(index))
32 {
33 }
34
35 /* ------------------------------------------------------------------------- */
40 /* ------------------------------------------------------------------------- */
41 Touch(TouchID touchID) noexcept
42 : _state(TouchServer::GetInstance().GetState(touchID))
43 {
44 }
45
46 /* ------------------------------------------------------------------------- */
52 /* ------------------------------------------------------------------------- */
53 Touch(const Rectangle &rectangle) noexcept
54 : _state(TouchServer::GetInstance().GetState(rectangle))
55 {
56 }
57
58 /* ------------------------------------------------------------------------- */
64 /* ------------------------------------------------------------------------- */
65 static bool IsAvailable() noexcept
66 {
67 return TouchServer::GetInstance().IsAvailable();
68 }
69
70 /* ------------------------------------------------------------------------- */
76 /* ------------------------------------------------------------------------- */
77 [[nodiscard]] constexpr bool IsEnabled() const noexcept
78 {
79 return _state.isEnabled;
80 }
81
82 /* ------------------------------------------------------------------------- */
87 /* ------------------------------------------------------------------------- */
88 [[nodiscard]] constexpr TouchID GetTouchID() const noexcept
89 {
90 return _state.touchID;
91 }
92
93 /* ------------------------------------------------------------------------- */
98 /* ------------------------------------------------------------------------- */
99 [[nodiscard]] constexpr uint32_t GetTouchFrameCount() const noexcept
100 {
101 return _state.touchFrameCount;
102 }
103
104 /* ------------------------------------------------------------------------- */
110 /* ------------------------------------------------------------------------- */
111 [[nodiscard]] constexpr bool IsTouchedFirst() const noexcept
112 {
113 return _state.isEnabled && (_state.touchFrameCount == 1);
114 }
115
116 /* ------------------------------------------------------------------------- */
121 /* ------------------------------------------------------------------------- */
122 [[nodiscard]] constexpr const Vector2 &GetPosition() const noexcept
123 {
124 return _state.position;
125 }
126
127 /* ------------------------------------------------------------------------- */
132 /* ------------------------------------------------------------------------- */
133 [[nodiscard]] constexpr const Vector2 &GetPrevPosition() const noexcept
134 {
135 return _state.prevPosition;
136 }
137
138 /* ------------------------------------------------------------------------- */
143 /* ------------------------------------------------------------------------- */
144 [[nodiscard]] constexpr const Vector2 &GetDeltaMove() const noexcept
145 {
146 return _state.deltaMove;
147 }
148
149 /* ------------------------------------------------------------------------- */
154 /* ------------------------------------------------------------------------- */
155 [[nodiscard]] constexpr const Vector2 &GetUVPosition() const noexcept
156 {
157 return _state.uvPosition;
158 }
159
160 /* ------------------------------------------------------------------------- */
165 /* ------------------------------------------------------------------------- */
166 [[nodiscard]] constexpr const Vector2 &GetUVPrevPosition() const noexcept
167 {
168 return _state.uvPrevPosition;
169 }
170
171 /* ------------------------------------------------------------------------- */
176 /* ------------------------------------------------------------------------- */
177 [[nodiscard]] constexpr const Vector2 &GetUVDeltaMove() const noexcept
178 {
179 return _state.uvDeltaMove;
180 }
181
182 /* ------------------------------------------------------------------------- */
188 /* ------------------------------------------------------------------------- */
189 explicit constexpr operator bool() const noexcept
190 {
191 return IsEnabled();
192 }
193
194 /* ------------------------------------------------------------------------- */
200 /* ------------------------------------------------------------------------- */
201 constexpr bool operator!() const noexcept
202 {
203 return !static_cast<bool>(*this);
204 }
205
206private:
207 const TouchState &_state;
208};
209} // namespace MGL::Input
210
211#endif // INCGUARD_MGL_TOUCH_H_1613419314
212
213// vim: et ts=4 sw=4 sts=4
MGL タッチ入力取得クラス
Definition mgl_touch.h:22
constexpr bool IsEnabled() const noexcept
タッチの有効状態を取得
Definition mgl_touch.h:77
constexpr bool operator!() const noexcept
有効状態を否定演算子で取得
Definition mgl_touch.h:201
static bool IsAvailable() noexcept
タッチサーバの有効状態を取得
Definition mgl_touch.h:65
constexpr TouchID GetTouchID() const noexcept
タッチの識別番号を取得
Definition mgl_touch.h:88
constexpr const Vector2 & GetUVDeltaMove() const noexcept
前回のタッチ位置からの移動量をUV座標で取得
Definition mgl_touch.h:177
constexpr const Vector2 & GetPrevPosition() const noexcept
前回のタッチ位置の取得
Definition mgl_touch.h:133
Touch(const Rectangle &rectangle) noexcept
矩形指定によるコンストラクタ
Definition mgl_touch.h:53
constexpr const Vector2 & GetDeltaMove() const noexcept
前回のタッチ位置からの移動量を取得
Definition mgl_touch.h:144
Touch(size_t index=0) noexcept
インデックス指定によるコンストラクタ
Definition mgl_touch.h:30
constexpr const Vector2 & GetUVPosition() const noexcept
タッチ位置をUV座標で取得
Definition mgl_touch.h:155
constexpr const Vector2 & GetPosition() const noexcept
タッチ位置の取得
Definition mgl_touch.h:122
Touch(TouchID touchID) noexcept
タッチ識別番号の指定によるコンストラクタ
Definition mgl_touch.h:41
constexpr uint32_t GetTouchFrameCount() const noexcept
タッチされているフレーム数を取得
Definition mgl_touch.h:99
constexpr bool IsTouchedFirst() const noexcept
タッチされた最初のフレームかを取得
Definition mgl_touch.h:111
constexpr const Vector2 & GetUVPrevPosition() const noexcept
前回のタッチ位置をUV座標で取得
Definition mgl_touch.h:166
タッチサーバクラス
Definition mgl_touch_server.h:29
static TouchServer & GetInstance() noexcept
Definition mgl_singleton.h:74
MGL 環境定義
MGL タッチ入力サーバ
MGL タッチ入力設定
TouchID
タッチ識別番号の型
Definition mgl_touch_state.h:25
タッチステート
Definition mgl_touch_state.h:57
bool isEnabled
有効フラグ
Definition mgl_touch_state.h:58
Vector2 uvDeltaMove
タッチ移動量(UV座標)
Definition mgl_touch_state.h:67
TouchID touchID
タッチ識別番号
Definition mgl_touch_state.h:60
uint32_t touchFrameCount
タッチフレーム数
Definition mgl_touch_state.h:61
Vector2 deltaMove
タッチ移動量
Definition mgl_touch_state.h:64
Vector2 uvPrevPosition
前回のタッチ位置(UV座標)
Definition mgl_touch_state.h:66
Vector2 prevPosition
前回のタッチ位置
Definition mgl_touch_state.h:63
Vector2 uvPosition
タッチ位置(UV座標)
Definition mgl_touch_state.h:65
Vector2 position
タッチ位置
Definition mgl_touch_state.h:62
矩形
Definition mgl_rectangle.h:20
2Dベクトル
Definition mgl_vector2.h:23