MGL(Win32)
読み取り中…
検索中…
一致する文字列を見つけられません
mgl_touch_state.h
[詳解]
1// SPDX-License-Identifier: Zlib
2/* ------------------------------------------------------------------------- */
9/* ------------------------------------------------------------------------- */
10
11#ifndef INCGUARD_MGL_TOUCH_STATE_H_1613412992
12#define INCGUARD_MGL_TOUCH_STATE_H_1613412992
13
14#include <array>
15
17
18namespace MGL::Input
19{
21constexpr size_t kMultiTouchCount = 5;
22
24enum class TouchID : uint32_t
25{
26 Invalid = 0xFFFFFFFF
27};
28
30constexpr TouchID operator++(TouchID &rhs) noexcept
31{
32 rhs = TouchID{static_cast<std::underlying_type_t<TouchID>>(rhs) + 1};
33 if (rhs >= TouchID::Invalid)
34 {
35 rhs = TouchID{0};
36 }
37
38 return rhs;
39}
40
42constexpr TouchID operator++(TouchID &rhs, int) noexcept
43{
44 auto ret = rhs;
45 rhs = TouchID{static_cast<std::underlying_type_t<TouchID>>(rhs) + 1};
46 if (rhs >= TouchID::Invalid)
47 {
48 rhs = TouchID{0};
49 }
50
51 return ret;
52}
53
54
57{
58 bool isEnabled{false};
59 uint64_t deviceID{0};
60 TouchID touchID{TouchID::Invalid};
61 uint32_t touchFrameCount{0};
68
69
70 /* ------------------------------------------------------------------------- */
75 /* ------------------------------------------------------------------------- */
76 void Update(const TouchState &newState) noexcept
77 {
78 isEnabled = newState.isEnabled;
79
80 if (isEnabled)
81 {
82 deviceID = newState.deviceID;
83 touchID = newState.touchID;
86 position = newState.position;
89 uvPosition = newState.uvPosition;
91 }
92 else
93 {
94 *this = TouchState();
95 }
96 }
97};
98
100using TouchStateArray = std::array<TouchState, kMultiTouchCount>;
101
102} // namespace MGL::Input
103
104#endif // INCGUARD_MGL_TOUCH_STATE_H_1613412992
105
106// vim: et ts=4 sw=4 sts=4
@ Invalid
無効値
std::array< TouchState, kMultiTouchCount > TouchStateArray
タッチステートの配列
Definition mgl_touch_state.h:100
constexpr TouchID operator++(TouchID &rhs) noexcept
TouchIDのプリインクリメントのオーバーロード
Definition mgl_touch_state.h:30
TouchID
タッチ識別番号の型
Definition mgl_touch_state.h:25
constexpr size_t kMultiTouchCount
< マルチタッチの最大認識数
Definition mgl_touch_state.h:21
MGL 2Dベクトル
タッチステート
Definition mgl_touch_state.h:57
uint64_t deviceID
デバイス側の識別番号
Definition mgl_touch_state.h:59
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
void Update(const TouchState &newState) noexcept
タッチステートの更新処理
Definition mgl_touch_state.h:76
Vector2 position
タッチ位置
Definition mgl_touch_state.h:62
2Dベクトル
Definition mgl_vector2.h:23