UdonLibrary
1.0.0
機械システム研究部 C++ ライブラリ
読み取り中…
検索中…
一致する文字列を見つけられません
Input.hpp
[詳解]
1
//
2
// 入力クラス
3
//
4
// Copyright (c) 2022 udonrobo
5
//
6
7
#pragma once
8
9
#include <
Udon/Utility/Show.hpp
>
10
11
namespace
Udon
12
{
13
16
struct
Input
17
{
18
// │
19
// [input:true ] │ ┌─────────────┐ ┌─────────────┐ ┌──
20
// │ │ │ │ │ │
21
// [input:false] ┼────────────┘ └─────────────┘ └─────────────┘
22
// │
23
// ↓
24
// │
25
// [press:true ] │ ┌─────────────┐ ┌─────────────┐ ┌──
26
// │ │ │ │ │ │
27
// [press:false] ┼────────────┘ └─────────────┘ └─────────────┘
28
// │
29
// [unpress:true ] ┼────────────┐ ┌─────────────┐ ┌─────────────┐
30
// │ │ │ │ │ │
31
// [unpress:false] │ └─────────────┘ └─────────────┘ └──
32
// │
33
// [click:true ] │ ┌┐ ┌┐ ┌┐
34
// │ ││ ││ ││
35
// [click:false] ┼────────────┘└──────────────────────────┘└──────────────────────────┘└─
36
// │
37
// [release:true ] │ ┌┐ ┌┐
38
// │ ││ ││
39
// [release:false] ┼──────────────────────────┘└──────────────────────────┘└───────────────
40
// │
41
// [toggle:true ] │ ┌───────────────────────────┐ ┌──
42
// │ │ │ │
43
// [toggle:false] ┼────────────┘ └───────────────────────────┘
44
// │
45
47
bool
press
=
false
;
48
50
bool
unpress
=
true
;
51
53
bool
click
=
false
;
54
56
bool
release
=
false
;
57
59
bool
toggle
=
false
;
60
62
void
show
() const noexcept
63
{
64
Udon::ShowRaw
(
press
);
65
}
66
69
void
update
(
bool
input)
noexcept
70
{
71
press
= input;
72
73
unpress
= not input;
74
75
click
= not previous and input;
76
77
release
= previous and not input;
78
79
toggle
^=
click
;
80
81
previous = input;
82
}
83
84
private
:
86
bool
previous =
false
;
87
};
88
}
// namespace Udon
Show.hpp
Udon
Definition
Bit.hpp:12
Udon::ShowRaw
void ShowRaw(Args &&... args)
改行、区切り文字なしで出力する
Definition
Show.hpp:362
Udon::Input
入力値
Definition
Input.hpp:17
Udon::Input::toggle
bool toggle
トグル値
Definition
Input.hpp:59
Udon::Input::press
bool press
押されているか
Definition
Input.hpp:47
Udon::Input::unpress
bool unpress
押されていないか
Definition
Input.hpp:50
Udon::Input::release
bool release
離された瞬間か
Definition
Input.hpp:56
Udon::Input::click
bool click
押された瞬間か
Definition
Input.hpp:53
Udon::Input::update
void update(bool input) noexcept
更新
Definition
Input.hpp:69
Udon::Input::show
void show() const noexcept
表示
Definition
Input.hpp:62