45 [[nodiscard]] SDL_Keycode
getKeyCode()
const {
return evt.key.keysym.sym; }
46 [[nodiscard]] SDL_Scancode
getScanCode()
const {
return evt.key.keysym.scancode; }
50 return evt.key.keysym.unused;
65 SDL_KeyboardEvent& e =
evt.key;
67 e.timestamp = SDL_GetTicks();
68 e.state = SDL_RELEASED;
82 SDL_KeyboardEvent& e =
evt.key;
84 e.timestamp = SDL_GetTicks();
85 e.state = SDL_PRESSED;
92 SDL_KeyboardEvent& e =
evt.key;
94 e.timestamp = timestamp;
95 e.state = SDL_PRESSED;
96 e.keysym.sym = SDLK_UNKNOWN;
97 e.keysym.mod = KMOD_NONE;
98 e.keysym.unused = unicode;
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;
149 [[nodiscard]]
int getX()
const {
return evt.motion.xrel; }
150 [[nodiscard]]
int getY()
const {
return evt.motion.yrel; }
172 [[nodiscard]]
unsigned getButton()
const {
return evt.jbutton.button; }
202 [[nodiscard]] uint8_t
getAxis()
const {
return evt.jaxis.axis; }
203 [[nodiscard]] int16_t
getValue()
const {
return evt.jaxis.value; }
212 [[nodiscard]] uint8_t
getHat()
const {
return evt.jhat.hat; }
228 [[nodiscard]]
static bool isMainWindow(
unsigned id) {
return id == mainWindowId; }
230 static inline uint32_t mainWindowId = unsigned(-1);
272 [[nodiscard]]
unsigned getButton()
const {
return button; }
301 : typesToMatch(typesToMatch_)
302 , tclListComponents(
std::move(tclListComponents_)) {}
328 : thisSource(thisSource_), selectedSource(selectedSource_)
333 [[nodiscard]]
int getSource()
const {
return thisSource; }
335 [[nodiscard]]
bool isSkipped()
const {
return skipped; }
336 [[nodiscard]]
bool needRender()
const {
return !skipped && (thisSource == selectedSource); }
464 KEY_UP = event_index<KeyUpEvent>,
465 KEY_DOWN = event_index<KeyDownEvent>,
471 JOY_HAT = event_index<JoystickHatEvent>,
476 WINDOW = event_index<WindowEvent>,
477 TEXT = event_index<TextEvent>,
479 QUIT = event_index<QuitEvent>,
480 GROUP = event_index<GroupEvent>,
481 BOOT = event_index<BootEvent>,
484 BREAK = event_index<BreakEvent>,
535 return std::get_if<T>(&event);
541 const auto& var = event;
555 default:
return nullptr;
562 const auto& var = event;
566 default:
return nullptr;
573 const auto& var = event;
579 default:
return nullptr;
587 return helper(event);
592 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 & 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
JoystickAxisMotionEvent(const SDL_Event &e)
JoystickEvent(const SDL_Event &e)
JoystickId getJoystick() const
JoystickHatEvent(const SDL_Event &e)
static KeyDownEvent create(SDL_Keycode code, SDL_Keymod mod=KMOD_NONE)
static KeyDownEvent create(uint32_t timestamp, unsigned unicode)
KeyDownEvent(const SDL_Event &e)
SDL_Keycode getKeyCode() const
KeyEvent(const SDL_Event &e)
uint32_t getUnicode() const
SDL_Scancode getScanCode() const
uint16_t getModifiers() const
static KeyUpEvent create(SDL_Keycode code, SDL_Keymod mod=KMOD_NONE)
KeyUpEvent(const SDL_Event &e)
Send when a machine is (de)activated.
Send when a (new) machine configuration is loaded.
MouseMotionEvent(const SDL_Event &e)
MouseWheelEvent(const SDL_Event &e)
OSD events are triggered by other events.
OsdControlEvent(unsigned button_)
unsigned getButton() const
OsdControlPressEvent(unsigned button_)
OsdControlReleaseEvent(unsigned 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.
TextEvent(const SDL_Event &e)
static uint32_t getMainWindowId()
bool isMainWindow() const
const SDL_WindowEvent & getSdlWindowEvent() const
static void setMainWindowId(uint32_t id)
static bool isMainWindow(unsigned id)
WindowEvent(const SDL_Event &e)
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 KeyEvent * operator()(const Event &event)
const SdlEvent * operator()(const Event &event)
const T * operator()(const Event &event)