ReXGlue SDK
Toggle main menu visibility
Loading...
Searching...
No Matches
input_system.h
Go to the documentation of this file.
1
10
11
#pragma once
12
13
#include <memory>
14
#include <span>
15
#include <string>
16
#include <string_view>
17
18
#include <
rex/hid/binding.h
>
19
#include <
rex/input_keys.h
>
20
#include <
rex/hid/pad.h
>
21
#include <
rex/module.h
>
22
#include <
rex/platform.h
>
23
#include <
rex/result.h
>
24
#include <
rex/setting.h
>
25
#include <
rex/settings_registry.h
>
26
#include <
rex/types.h
>
27
#include <
rex/utility.h
>
28
29
namespace
rex::hid {
30
31
class
REX_HID_API
InputSettings final :
public
SettingOwner
{
32
public
:
33
InputSettings();
34
35
REX_SETTING(std::string, drivers,
"sdl3"
,
"Input drivers in priority order, comma separated"
,
36
kStartupOnly);
37
REX_SETTING(
bool
, shared_pads,
false
,
"Every pad feeds user 0"
, kStartupOnly);
38
REX_SETTING(
bool
, vibration,
true
,
"Allow vibration"
);
39
REX_SETTING(
bool
, guide_button,
false
,
"Pass the guide button to the title"
);
40
REX_SETTING(f64, left_stick_deadzone, 0.0,
"Left stick deadzone"
,
Range
{0.0, 1.0});
41
REX_SETTING(f64, right_stick_deadzone, 0.0,
"Right stick deadzone"
,
Range
{0.0, 1.0});
42
REX_SETTING(
bool
, mnk_mode,
false
,
"Keyboard and mouse act as a pad"
);
43
REX_SETTING(
bool
, mnk_mouse,
false
,
"The mouse moves the right stick"
);
44
REX_SETTING(f64, mnk_sensitivity, 1.0,
"Mouse to stick sensitivity"
,
Range
{0.01, 100.0});
45
REX_SETTING(
bool
, mnk_passthrough,
false
,
"Keys reach the title as keystrokes"
);
46
};
47
54
REX_DECLARE_INTERFACE
(
IInputSystem
, 2)
55
static constexpr u32 kMaxUsers = 4;
56
58
static constexpr u32 kAnyUser = 0xFF;
59
60
struct PadReading {
61
u32 packet = 0;
62
PadState
state;
63
};
64
65
virtual
InputSettings
& GetSettings() = 0;
66
73
[[nodiscard]]
virtual
Result<PadReading>
GetState(u32 user) = 0;
74
81
[[nodiscard]]
virtual
Result<PadCapabilities>
GetCapabilities(u32 user) = 0;
82
89
[[nodiscard]]
virtual
Result<void>
SetVibration(u32 user,
const
PadVibration
& motors) = 0;
90
99
[[nodiscard]]
virtual
Result<PadKeystroke>
GetKeystroke(u32 user,
KeystrokeSource
sources) = 0;
100
106
[[nodiscard]]
virtual
Result<PadInfo>
GetPadInfo(u32 user) = 0;
107
115
[[nodiscard]]
virtual
ScopeGuard
OnConnectionChange(
116
MoveOnlyFunction
<
void
(u32 user,
bool
connected)> fn) = 0;
117
121
virtual
void
AcquireUIBlock() = 0;
122
123
virtual
void
ReleaseUIBlock() = 0;
124
125
virtual
bool
IsKeyDown(
VirtualKey
key)
const
= 0;
126
127
virtual
bool
IsAnyKeyDown()
const
= 0;
128
129
virtual
KeyModifiers GetModifiers()
const
= 0;
130
134
virtual
PointerState
GetPointer()
const
= 0;
135
136
virtual
bool
IsButtonDown(
MouseButton
button)
const
= 0;
137
138
virtual
bool
IsAnyButtonDown()
const
= 0;
139
141
virtual
bool
TakePointerMoved() = 0;
142
146
virtual
PointerDelta
TakeMotion() = 0;
147
151
virtual
PointerDelta
PeekMotion()
const
= 0;
152
156
virtual
i32 TakeWheel() = 0;
157
158
virtual
i32 GetWheel()
const
= 0;
159
163
virtual
void
SetPointerMode(
PointerMode
mode) = 0;
164
170
virtual
void
OnInputEvent(
InputEvent
& event) = 0;
171
172
virtual
void
SetInputCaptured(
bool
captured) = 0;
173
177
virtual
PointerMode
GetPointerModeToApply()
const
= 0;
178
185
[[nodiscard]]
virtual
ScopeGuard
SetPointerModeListener(
MoveOnlyFunction
<
void
()> listener) = 0;
186
191
virtual
hid::IBindingSet
& GetKeyBindings() = 0;
192
200
[[nodiscard]]
virtual
std::unique_ptr<hid::IBindingSet> CreateBindingSet(
201
std::span<const hid::BindingConfig> configs, std::string_view scope) = 0;
202
209
[[nodiscard]]
virtual
std::unique_ptr<hid::IKeyCapture> CreateKeyCapture(
210
hid::KeyCaptureConfig
config) = 0;
211
217
[[nodiscard]]
virtual
Result<KeyChord>
ParseKeyChord
(std::string_view text)
const
= 0;
218
224
[[nodiscard]]
virtual
std::string FormatKeyChord(
KeyChord
chord)
const
= 0;
225
232
[[nodiscard]]
virtual
VirtualKey
ParseVirtualKey
(std::string_view name)
const
= 0;
233
237
[[nodiscard]]
virtual
std::string
VirtualKeyToString
(
VirtualKey
key)
const
= 0;
238
246
[[nodiscard]]
virtual
Result<InputSource>
ParseInputSource
(std::string_view text)
const
= 0;
247
253
[[nodiscard]]
virtual
std::string
InputSourceToString
(
const
InputSource
& source)
const
= 0;
254
};
255
256
}
// namespace rex::hid
binding.h
Input bindings and key capture.
rex::ScopeGuard
Definition
utility.h:305
rex::SettingOwner::SettingOwner
SettingOwner(std::string_view scope)
rex::hid::IBindingSet
Definition
binding.h:75
rex::hid::IInputSystem
Definition
input_system.h:54
rex::hid::InputSettings
Definition
input_system.h:31
input_keys.h
module.h
Interfaces, factory and module declaration.
REX_DECLARE_INTERFACE
#define REX_DECLARE_INTERFACE(Name, version)
Definition
module.h:114
rex::ParseInputSource
Result< InputSource > ParseInputSource(std::string_view text)
rex::VirtualKey
VirtualKey
Definition
input_keys.h:35
rex::VirtualKeyToString
std::string VirtualKeyToString(VirtualKey key)
rex::MouseButton
MouseButton
Definition
input_keys.h:377
rex::ParseKeyChord
Result< KeyChord > ParseKeyChord(std::string_view text)
rex::InputSourceToString
std::string InputSourceToString(const InputSource &source)
rex::PointerMode
PointerMode
Definition
input_keys.h:371
rex::MoveOnlyFunction
typename detail::MoveOnlyFunctionFor< Signature >::type MoveOnlyFunction
Definition
utility.h:254
rex::Result
std::expected< T, Error > Result
Definition
result.h:98
rex::ParseVirtualKey
VirtualKey ParseVirtualKey(std::string_view name)
pad.h
rex::hid::KeystrokeSource
KeystrokeSource
Definition
pad.h:83
platform.h
Platform flags, packing macros and export markers.
REX_HID_API
#define REX_HID_API
Definition
platform.h:228
result.h
setting.h
Typed settings and the owners that declare them.
settings_registry.h
The registry of every registered setting.
rex::InputEvent
Definition
input_keys.h:417
rex::InputSource
Definition
input_keys.h:509
rex::KeyChord
Definition
input_keys.h:554
rex::PointerDelta
Definition
input_keys.h:406
rex::PointerState
Definition
input_keys.h:393
rex::Range
Definition
setting.h:78
rex::hid::KeyCaptureConfig
Definition
binding.h:180
rex::hid::PadState
Definition
pad.h:50
rex::hid::PadVibration
Definition
pad.h:61
types.h
Integer types, byte order wrappers and size literals.
utility.h
Move only function, const propagating pointer and scope guard.
rex
hid
input_system.h
Generated by
1.18.0