EN
RU
Portals
0.7.0 · dev
0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Toggle main menu visibility
Loading...
Searching...
No Matches
input_match.hpp
1
// Copyright (c) 2026 ttldtor.
2
// SPDX-License-Identifier: BSL-1.0
3
#pragma once
4
5
#include <portals/input.hpp>
6
7
#include <algorithm>
8
#include <initializer_list>
9
10
namespace
portals
{
18
constexpr
bool
keyPressed
(
const
InputEvent
&event,
InputKey
key)
noexcept
{
19
const
auto
*value = std::get_if<KeyEvent>(&event);
20
21
return
value && value->key == key && value->action !=
KeyAction::RELEASE
;
22
}
23
31
constexpr
bool
keyPressed
(
const
InputEvent
&event,
InputKey
key,
InputModifiers
modifiers)
noexcept
{
32
const
auto
*value = std::get_if<KeyEvent>(&event);
33
34
return
keyPressed
(event, key) && value->modifiers == modifiers;
35
}
36
44
constexpr
bool
keyPressed
(
const
InputEvent
&event, std::initializer_list<InputKey> keys)
noexcept
{
45
const
auto
*value = std::get_if<KeyEvent>(&event);
46
47
return
value && value->action !=
KeyAction::RELEASE
&& std::ranges::contains(keys, value->key);
48
}
49
}
// namespace portals
portals
Public Portals API.
Definition
action.hpp:8
portals::KeyAction::RELEASE
@ RELEASE
Key release reported by a native adapter.
Definition
input.hpp:209
portals::InputEvent
std::variant< KeyEvent, TextInputEvent, MouseInputEvent, PasteInputEvent, InputProbeCandidate, InputIssue > InputEvent
Independent owning result, usable beyond decoder reset/destruction.
Definition
input.hpp:378
portals::keyPressed
constexpr bool keyPressed(const InputEvent &event, InputKey key) noexcept
Match a semantic key press or repeat without extracting the event variant.
Definition
input_match.hpp:18
portals::InputKey
InputKey
Semantic key identities; character uses KeyEvent::scalar.
Definition
input.hpp:64
portals::InputModifiers
Observed modifiers, also usable by a native input adapter.
Definition
input.hpp:34
include
portals
input_match.hpp