opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
liboscar
platform
key_modifier.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <
liboscar/utilities/flags.h
>
4
5
#include <cstdint>
6
7
namespace
osc
8
{
9
// Represents a single keyboard key modifier.
10
//
11
// `KeyModifier`s are virtual, which means that don't necessarily
12
// represent what's physically written on the keyboard. For
13
// example, MacOS tends to use the Command key in place of the
14
// Ctrl key for many application keybinds. With this in mind, the
15
// backend maps (virtualizes) the Command key to `KeyModifier::Ctrl`
16
// so that application code can just write keybinds "as if" only
17
// writing for Windows/Linux. See `PhysicalKeyModifier` (and related
18
// `Converter`s) if you need to know the underlying physical key.
19
enum class
KeyModifier
:
uint16_t
{
20
// No modifier key is pressed.
21
None
= 0,
22
23
// A shift key on the keyboard is pressed.
24
Shift
= 1<<0,
25
26
// If on MacOS, a command key on the keyboard is pressed.
27
// Otherwise, a ctrl key on the keyboard is pressed.
28
//
29
// The difference between MacOS and the others is to normalize
30
// how the modifier key is actually used on those OSes. E.g.
31
// `Ctrl+V` on Windows usually has the same intent as `Command+V`
32
// on MacOS. With this in mind, you should write your keybinds
33
// as-if designing for Windows.
34
Ctrl
= 1<<1,
35
36
// If on MacOS, a ctrl key on the keyboard is pressed.
37
// Otherwise, a meta (e.g. Windows) key on the keyboard is pressed.
38
//
39
// The difference between MacOS and the others is to normalize
40
// how a key is actually used between OSes. E.g. `Ctrl+V` on
41
// Windows usually has the same intent as `Command+V` on MacOS.
42
// With this in mind, you should write your keybinds as-if
43
// designing for Windows.
44
Meta
= 1<<2,
45
46
// An alt key on the keyboard is pressed.
47
Alt
= 1<<3,
48
49
NUM_FLAGS
= 4,
50
};
51
using
KeyModifiers
=
Flags<KeyModifier>
;
52
53
constexpr
KeyModifiers
operator|
(
KeyModifier
lhs
,
KeyModifier
rhs
)
54
{
55
return
KeyModifiers
{
lhs
,
rhs
};
56
}
57
}
osc::Flags< KeyModifier >
flags.h
osc
Definition
custom_decoration_generator.h:5
osc::operator|
constexpr KeyCombination operator|(KeyModifiers modifiers, Key key)
Definition
key_combination.h:27
osc::to
constexpr U to(T &&value)
Definition
conversion.h:56
osc::KeyModifier
KeyModifier
Definition
key_modifier.h:19
osc::KeyModifier::Ctrl
@ Ctrl
osc::KeyModifier::NUM_FLAGS
@ NUM_FLAGS
osc::KeyModifier::Shift
@ Shift
osc::KeyModifier::Alt
@ Alt
osc::KeyModifier::Meta
@ Meta
osc::ImageLoadingFlag::None
@ None
Generated by
1.9.8