47 [[nodiscard]] SDL_Keycode
getKeyCode()
const {
return evt.key.keysym.sym; }
48 [[nodiscard]] SDL_Scancode
getScanCode()
const {
return evt.key.keysym.scancode; }
52 return evt.key.keysym.unused;
60 using KeyEvent::KeyEvent;
64 evt.key = SDL_KeyboardEvent{};
68 e.timestamp = SDL_GetTicks();
69 e.state = SDL_RELEASED;
79 using KeyEvent::KeyEvent;
83 evt.key = SDL_KeyboardEvent{};
87 e.timestamp = SDL_GetTicks();
88 e.state = SDL_PRESSED;
95 evt.key = SDL_KeyboardEvent{};
99 e.timestamp = timestamp;
100 e.state = SDL_PRESSED;
101 e.keysym.sym = SDLK_UNKNOWN;
102 e.keysym.mod = KMOD_NONE;
103 e.keysym.unused = unicode;
120 using MouseButtonEvent::MouseButtonEvent;
126 using MouseButtonEvent::MouseButtonEvent;
134 [[nodiscard]]
int getX()
const {
return normalize(
evt.wheel.x); }
135 [[nodiscard]]
int getY()
const {
return normalize(
evt.wheel.y); }
138 [[nodiscard]]
int normalize(
int x)
const {
139 return evt.wheel.direction == SDL_MOUSEWHEEL_FLIPPED ? -x : x;
148 [[nodiscard]]
int getX()
const {
return evt.motion.xrel; }
149 [[nodiscard]]
int getY()
const {
return evt.motion.yrel; }
169 using JoystickEvent::JoystickEvent;
171 [[nodiscard]]
unsigned getButton()
const {
return evt.jbutton.button; }
177 using JoystickButtonEvent::JoystickButtonEvent;
183 using JoystickButtonEvent::JoystickButtonEvent;
192 using JoystickEvent::JoystickEvent;
194 [[nodiscard]] uint8_t
getAxis()
const {
return evt.jaxis.axis; }
195 [[nodiscard]] int16_t
getValue()
const {
return evt.jaxis.value; }
201 using JoystickEvent::JoystickEvent;
203 [[nodiscard]] uint8_t
getHat()
const {
return evt.jhat.hat; }
219 [[nodiscard]]
static bool isMainWindow(
unsigned id) {
return id == mainWindowId; }
221 static inline uint32_t mainWindowId = unsigned(-1);
291 : typesToMatch(typesToMatch_)
292 , tclListComponents(
std::move(tclListComponents_)) {}
318 : thisSource(thisSource_), selectedSource(selectedSource_)
323 [[nodiscard]]
int getSource()
const {
return thisSource; }
325 [[nodiscard]]
bool isSkipped()
const {
return skipped; }
326 [[nodiscard]]
bool needRender()
const {
return !skipped && (thisSource == selectedSource); }
455 KEY_UP = event_index<KeyUpEvent>,
456 KEY_DOWN = event_index<KeyDownEvent>,
462 JOY_HAT = event_index<JoystickHatEvent>,
467 WINDOW = event_index<WindowEvent>,
468 TEXT = event_index<TextEvent>,
470 QUIT = event_index<QuitEvent>,
471 GROUP = event_index<GroupEvent>,
472 BOOT = event_index<BootEvent>,
475 BREAK = event_index<BreakEvent>,
526 return std::get_if<T>(&event);
532 const auto& var = event;
535 case KEY_UP:
return &std::get<KeyUpEvent>(var);
536 case KEY_DOWN:
return &std::get<KeyDownEvent>(var);
539 case MOUSE_WHEEL:
return &std::get<MouseWheelEvent>(var);
540 case MOUSE_MOTION:
return &std::get<MouseMotionEvent>(var);
541 case JOY_BUTTON_UP:
return &std::get<JoystickButtonUpEvent>(var);
544 case JOY_HAT:
return &std::get<JoystickHatEvent>(var);
545 case WINDOW:
return &std::get<WindowEvent>(var);
546 case TEXT:
return &std::get<TextEvent>(var);
547 default:
return nullptr;
554 const auto& var = event;
557 case KEY_UP:
return &std::get<KeyUpEvent>(var);
558 case KEY_DOWN:
return &std::get<KeyDownEvent>(var);
559 default:
return nullptr;
566 const auto& var = event;
569 case JOY_BUTTON_UP:
return &std::get<JoystickButtonUpEvent>(var);
572 case JOY_HAT:
return &std::get<JoystickHatEvent>(var);
573 default:
return nullptr;
581 return helper(event);
586 const T*
t = get_event_if<T>(event);
std::unique_ptr< char, FreeStringStorage > StringStorage
StringStorage allocate_c_string(std::string_view s)
Allocate memory for and copy a c-string (zero-terminated string).
Send when an after-EmuTime command should be executed.
Sent when the MSX resets or powers up.
Command received on CliComm connection.
CliCommandEvent & operator=(CliCommandEvent &&)=default
const CliConnection * getId() const
CliCommandEvent(CliCommandEvent &&)=default
zstring_view getCommand() const
CliCommandEvent(const CliCommandEvent &)
CliCommandEvent(std::string_view command_, const CliConnection *id_)
~CliCommandEvent()=default
CliCommandEvent & operator=(const CliCommandEvent &)
FileDropEvent(std::string_view fileName_)
FileDropEvent & operator=(const FileDropEvent &)
zstring_view getFileName() const
FileDropEvent(const FileDropEvent &)
FileDropEvent & operator=(FileDropEvent &&)=default
FileDropEvent(FileDropEvent &&)=default
This event is send when a device (v99x8, v9990, video9000, laserdisc) reaches the end of a frame.
FinishFrameEvent(int thisSource_, int selectedSource_, bool skipped_)
int getSelectedSource() const
Sent when a FINISH_FRAME caused a redraw of the screen.
GroupEvent(std::initializer_list< EventType > typesToMatch_, TclObject tclListComponents_)
const auto & getTypesToMatch() const
const auto & getTclListComponents() const
ImGuiActiveEvent(bool active_)
static constexpr uint8_t X_AXIS
static constexpr uint8_t Y_AXIS
JoystickId getJoystick() const
static KeyDownEvent create(SDL_Keycode code, SDL_Keymod mod=KMOD_NONE)
static KeyDownEvent create(uint32_t timestamp, unsigned unicode)
SDL_Keycode getKeyCode() const
uint32_t getUnicode() const
SDL_Scancode getScanCode() const
uint16_t getModifiers() const
static KeyUpEvent create(SDL_Keycode code, SDL_Keymod mod=KMOD_NONE)
Send when a machine is (de)activated.
Send when a (new) machine configuration is loaded.
OSD events are triggered by other events.
OsdControlEvent(Button button_)
OsdControlPressEvent(Button button_)
OsdControlReleaseEvent(Button button_)
const SDL_CommonEvent & getCommonSdlEvent() const
SdlEvent(const SDL_Event &e)
const SDL_Event & getSdlEvent() const
Used to schedule 'taking reverse snapshots' between Z80 instructions.
static uint32_t getMainWindowId()
bool isMainWindow() const
const SDL_WindowEvent & getSdlWindowEvent() const
static void setMainWindowId(uint32_t id)
static bool isMainWindow(unsigned id)
Like std::string_view, but with the extra guarantee that it refers to a zero-terminated string.
This file implemented 3 utility functions:
constexpr uint8_t event_index
@ MIDI_IN_COREMIDI_VIRTUAL
const T * get_event_if(const Event &event)
bool operator==(const BooleanInput &x, const BooleanInput &y)
bool matches(const Event &self, const Event &other)
Does this event 'match' the given 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)
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
const T & get_event(const Event &event)
const JoystickEvent * operator()(const Event &event) const
const KeyEvent * operator()(const Event &event) const
const SdlEvent * operator()(const Event &event) const
const T * operator()(const Event &event)