7using namespace std::literals;
11[[nodiscard]]
static constexpr uint16_t normalizeKeyMod(uint16_t m)
14 if (m & KMOD_SHIFT) m |= KMOD_SHIFT;
15 if (m & KMOD_CTRL) m |= KMOD_CTRL;
16 if (m & KMOD_ALT) m |= KMOD_ALT;
17 if (m & KMOD_GUI) m |= KMOD_GUI;
19 m &= (KMOD_SHIFT | KMOD_CTRL | KMOD_ALT | KMOD_GUI | KMOD_MODE);
29 std::tuple(b.getKeyCode(), normalizeKeyMod(b.getModifiers()));
34 std::tuple(b.getKeyCode(), normalizeKeyMod(b.getModifiers()));
37 return std::tuple(a.getX(), a.getY(), a.getAbsX(), a.getAbsY()) ==
38 std::tuple(b.getX(), b.getY(), b.getAbsX(), b.getAbsY());
41 return a.getButton() == b.getButton();
44 return a.getButton() == b.getButton();
47 return std::tuple(a.getX(), a.getY()) ==
48 std::tuple(b.getX(), b.getY());
51 return std::tuple(a.getJoystick(), a.getAxis(), a.getValue()) ==
52 std::tuple(b.getJoystick(), b.getAxis(), b.getValue());
55 return std::tuple(a.getJoystick(), a.getHat(), a.getValue()) ==
56 std::tuple(b.getJoystick(), b.getHat(), b.getValue());
59 return std::tuple(a.getJoystick(), a.getButton()) ==
60 std::tuple(b.getJoystick(), b.getButton());
63 return std::tuple(a.getJoystick(), a.getButton()) ==
64 std::tuple(b.getJoystick(), b.getButton());
67 return a.getButton() == b.getButton();
70 return a.getButton() == b.getButton();
74 const auto& b = b_.getSdlWindowEvent();
76 if (a.event != b.event)
return false;
77 if (a.windowID != b.windowID)
return false;
82 return a.getFileName() == b.getFileName();
85 return std::tuple(a.getSource(), a.getSelectedSource(), a.isSkipped()) ==
86 std::tuple(b.getSource(), b.getSelectedSource(), b.isSkipped());
89 return a.getCommand() == b.getCommand();
92 return a.getTclListComponents() ==
93 b.getTclListComponents();
103 static constexpr std::array osdControlNames = {
104 "LEFT"sv,
"RIGHT"sv,
"UP"sv,
"DOWN"sv,
"A"sv,
"B"sv
120 auto result =
makeTclList(
"keyb",
e.getKey().toString());
121 if (
e.getUnicode() != 0) {
122 result.addListElement(
tmpStrCat(
"unicode",
e.getUnicode()));
127 return makeTclList(
"mouse",
"motion",
e.getX(),
e.getY(),
e.getAbsX(),
e.getAbsY());
142 const char* str = [&] {
143 switch (
e.getValue()) {
144 case SDL_HAT_UP:
return "up";
145 case SDL_HAT_RIGHT:
return "right";
146 case SDL_HAT_DOWN:
return "down";
147 case SDL_HAT_LEFT:
return "left";
148 case SDL_HAT_RIGHTUP:
return "rightup";
149 case SDL_HAT_RIGHTDOWN:
return "rightdown";
150 case SDL_HAT_LEFTUP:
return "leftup";
151 case SDL_HAT_LEFTDOWN:
return "leftdown";
152 default:
return "center";
164 return makeTclList(
"OSDcontrol", osdControlNames[
e.getButton()],
"RELEASE");
167 return makeTclList(
"OSDcontrol", osdControlNames[
e.getButton()],
"PRESS");
170 const auto&
e = e_.getSdlWindowEvent();
171 if (
e.event == SDL_WINDOWEVENT_FOCUS_GAINED) {
173 }
else if (
e.event == SDL_WINDOWEVENT_FOCUS_LOST) {
188 return makeTclList(
"finishframe",
int(
e.getSource()),
int(
e.getSelectedSource()),
e.isSkipped());
194 return e.getTclListComponents();
207 return std::string(
toTclList(event).getString());
217 return self == other;
Command received on CliComm connection.
This event is send when a device (v99x8, v9990, video9000, laserdisc) reaches the end of a frame.
SDL_Keycode getKeyCode() const
uint16_t getModifiers() const
const SDL_WindowEvent & getSdlWindowEvent() const
This file implemented 3 utility functions:
bool operator==(const BooleanInput &x, const BooleanInput &y)
bool matches(const Event &self, const Event &other)
Does this event 'match' the given event.
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, ImGuiDelayedActionEvent, ImGuiActiveEvent > Event
TclObject toTclList(const Event &event)
Similar to toString(), but retains the structure of the event.
EventType getType(const Event &event)
std::string toString(const BooleanInput &input)
TclObject makeTclList(Args &&... args)
constexpr bool contains(ITER first, ITER last, const VAL &val)
Check if a range contains a given value, using linear search.
TemporaryString tmpStrCat(Ts &&... ts)