utility 2026.1.9
A comprehensive C++ utilities library tailored for the development of modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
hand_button_event.hpp
1/*
2 Copyright (c) 2026 ETIB Corporation
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in
6 the Software without restriction, including without limitation the rights to
7 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8 of the Software, and to permit persons to whom the Software is furnished to do
9 so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21 */
22
23#pragma once
24
25#include <memory>
26#include <ostream>
27
28#include "utility/event/hand_event.hpp"
29
30namespace utility::event
31{
32
37 {
38 public:
42 enum class Button {
43 Unknown = 0,
44 X = 1,
45 Y = 2,
46 A = 3,
47 B = 4,
48 Menu = 5,
49 System = 6,
50 };
51
58 static bool isButtonValidForHand(const HandType handType,
59 const Button button) noexcept;
60
65 {
66 public:
67 ~Factory(void) override;
68
73 std::shared_ptr<Event> create(void) const override;
74
79 std::shared_ptr<HandButtonEvent> createTyped(void) const;
80 };
81
82 private:
84 Button _button { Button::Unknown };
85
87 bool _isTouched { false };
88
90 bool _isClicked { false };
91
92 public:
96 explicit HandButtonEvent(void);
97
101 ~HandButtonEvent(void) override;
102
108 HandButtonEvent &setButton(const Button button) noexcept;
109
114 Button getButton(void) const noexcept;
115
120 bool isValidForCurrentHand(void) const noexcept;
121
127 HandButtonEvent &setTouched(const bool touched) noexcept;
128
133 bool isTouched(void) const noexcept;
134
140 HandButtonEvent &setButtonPressed(const bool clicked) noexcept;
141
146 bool isButtonPressed(void) const noexcept;
147 };
148
155 std::ostream &operator<<(std::ostream &stream,
156 const HandButtonEvent::Button button);
157
164 std::ostream &operator<<(std::ostream &stream,
165 const HandButtonEvent &handButtonEvent);
166
167} // namespace utility::event
Abstract factory interface for creating events.
Definition event.hpp:44
Factory for creating HandButtonEvent instances.
std::shared_ptr< Event > create(void) const override
Create a HandButtonEvent as base Event pointer.
std::shared_ptr< HandButtonEvent > createTyped(void) const
Create a strongly-typed HandButtonEvent.
HandButtonEvent & setButtonPressed(const bool clicked) noexcept
Set clicked state.
bool isTouched(void) const noexcept
Get touched state.
static bool isButtonValidForHand(const HandType handType, const Button button) noexcept
Check whether a button is valid for a given hand path.
HandButtonEvent & setTouched(const bool touched) noexcept
Set touched state.
HandButtonEvent(void)
Default constructor.
~HandButtonEvent(void) override
Default destructor.
Button getButton(void) const noexcept
Get button value.
HandButtonEvent & setButton(const Button button) noexcept
Set button value.
bool isValidForCurrentHand(void) const noexcept
Check whether current hand/button combination is valid.
bool isButtonPressed(void) const noexcept
Get clicked state.
Abstract base class for hand events.
HandType
Hand types for hand events. Defines the type of hand involved in the event (e.g., left or right).