49 auto tokenizer = StringOp::split_view<StringOp::EmptyParts::REMOVE>(text,
' ');
50 auto it = tokenizer.begin();
51 auto et = tokenizer.end();
53 if (it == et)
return std::nullopt;
55 if (it == et)
return std::nullopt;
57 std::string key{*it++};
58 while (it != et)
strAppend(key,
' ', *it++);
60 if (keycode == SDLK_UNKNOWN)
return std::nullopt;
63 }
else if (type ==
"mouse") {
65 if (it != et)
return std::nullopt;
66 auto n = parseValueWithPrefix(button,
"button");
67 if (!n)
return std::nullopt;
68 if (*n > 255)
return std::nullopt;
71 }
else if (
auto joystick = parseValueWithPrefix(type,
"joy")) {
72 if (*joystick == 0)
return std::nullopt;
76 if (
auto button = parseValueWithPrefix(subType,
"button")) {
77 if (*button > 255)
return std::nullopt;
78 if (it != et)
return std::nullopt;
81 }
else if (
auto hat = parseValueWithPrefix(subType,
"hat")) {
82 if (*hat > 255)
return std::nullopt;
83 if (it == et)
return std::nullopt;
84 auto valueStr = *it++;
85 if (it != et)
return std::nullopt;
89 if (valueStr ==
"up" ) value = UP;
90 else if (valueStr ==
"right") value = RIGHT;
91 else if (valueStr ==
"down" ) value = DOWN;
92 else if (valueStr ==
"left" ) value = LEFT;
93 else return std::nullopt;
97 }
else if (
auto pAxis = parseValueWithPrefix(subType,
"+axis")) {
98 if (*pAxis > 255)
return std::nullopt;
99 if (it != et)
return std::nullopt;
101 }
else if (
auto nAxis = parseValueWithPrefix(subType,
"-axis")) {
102 if (*nAxis > 255)
return std::nullopt;
103 if (it != et)
return std::nullopt;
113 [](
const KeyDownEvent& e) -> std::optional<BooleanInput> {
123 auto value = e.getValue();
124 if (value !=
one_of(SDL_HAT_UP, SDL_HAT_RIGHT, SDL_HAT_DOWN, SDL_HAT_LEFT)) {
131 auto joyId = e.getJoystick();
132 int deadZone = getJoyDeadZone(joyId);
133 int threshold = (deadZone * 32768) / 100;
135 auto value = e.getValue();
136 if ((-threshold <= value) && (value <= threshold)) {
143 [](
const EventBase&) -> std::optional<BooleanInput> {
160 std::tuple(j2.getJoystick(), j2.getButton());
163 return std::tuple(j1.
getJoystick(), j1.getHat(), j1.getValue()) ==
164 std::tuple(j2.getJoystick(), j2.getHat(), j2.getValue());
167 return std::tuple(j1.
getJoystick(), j1.getAxis(), j1.getDirection()) ==
168 std::tuple(j2.getJoystick(), j2.getAxis(), j2.getDirection());
170 [](
const auto&,
const auto&) {
181 if (bind.
getKeyCode() == down.getKeyCode())
return true;
185 if (bind.
getKeyCode() == up.getKeyCode())
return false;
190 if (bind.getButton() == down.getButton())
return true;
194 if (bind.getButton() == up.getButton())
return false;
199 if (bind.getJoystick() != down.getJoystick())
return std::nullopt;
200 if (bind.getButton() == down.getButton())
return true;
204 if (bind.getJoystick() != up.getJoystick())
return std::nullopt;
205 if (bind.getButton() == up.getButton())
return false;
210 if (bind.getJoystick() != e.getJoystick())
return std::nullopt;
211 if (bind.getHat() != e.getHat())
return std::nullopt;
216 if (bind.getJoystick() != e.getJoystick())
return std::nullopt;
217 if (bind.getAxis() != e.getAxis())
return std::nullopt;
218 int deadZone = getJoyDeadZone(bind.getJoystick());
219 int threshold = (deadZone * 32768) / 100;
221 return e.getValue() > threshold;
223 return e.getValue() < -threshold;
227 [](
const auto& ,
const auto& ) -> std::optional<bool> {
std::variant< KeyUpEvent, KeyDownEvent, MouseMotionEvent, MouseButtonUpEvent, MouseButtonDownEvent, MouseWheelEvent, JoystickAxisMotionEvent, JoystickHatEvent, JoystickButtonUpEvent, JoystickButtonDownEvent, OsdControlReleaseEvent, OsdControlPressEvent, WindowEvent, TextEvent, FileDropEvent, QuitEvent, FinishFrameEvent, CliCommandEvent, GroupEvent, BootEvent, FrameDrawnEvent, BreakEvent, SwitchRendererEvent, TakeReverseSnapshotEvent, AfterTimedEvent, MachineLoadedEvent, MachineActivatedEvent, MachineDeactivatedEvent, MidiInReaderEvent, MidiInWindowsEvent, MidiInCoreMidiEvent, MidiInCoreMidiVirtualEvent, MidiInALSAEvent, Rs232TesterEvent, Rs232NetEvent, ImGuiDelayedActionEvent, ImGuiActiveEvent > Event