30 template<
typename T,
typename ...Args>
35 Event(
Event&& other) noexcept : ptr(other.ptr) { other.ptr =
nullptr; }
40 [[nodiscard]]
explicit operator bool()
const {
return ptr; }
55[[nodiscard]]
EventType getType(
const Event& event);
58[[nodiscard]] std::string
toString(
const Event& event);
61[[nodiscard]] TclObject
toTclList(
const Event& event);
63[[nodiscard]]
bool operator==(
const Event& x,
const Event& y);
68[[nodiscard]]
bool isRepeatStopper(
const Event& self,
const Event& other);
73[[nodiscard]]
bool matches(
const Event& self,
const Event& other);
83 [[nodiscard]] uint64_t
getRealTime()
const {
return realtime; }
95 [[nodiscard]] uint32_t
getUnicode()
const {
return unicode; }
99 : keyCode(keyCode_), scanCode(scanCode_), unicode(unicode_) {}
104 const uint32_t unicode;
114 :
KeyEvent(keyCode_, scanCode_, 0) {}
130 :
KeyEvent(keyCode_, scanCode_, unicode_) {}
137 static constexpr unsigned LEFT = 1;
139 static constexpr unsigned RIGHT = 3;
141 [[nodiscard]]
unsigned getButton()
const {
return button; }
148 const unsigned button;
171 [[nodiscard]]
int getX()
const {
return x; }
172 [[nodiscard]]
int getY()
const {
return y; }
183 : xrel(xrel_), yrel(yrel_)
184 , xabs(xabs_), yabs(yabs_) {}
186 [[nodiscard]]
int getX()
const {
return xrel; }
187 [[nodiscard]]
int getY()
const {
return yrel; }
188 [[nodiscard]]
int getAbsX()
const {
return xabs; }
189 [[nodiscard]]
int getAbsY()
const {
return yabs; }
206 : joystick(joystick_) {}
215 [[nodiscard]]
unsigned getButton()
const {
return button; }
222 const unsigned button;
248 [[nodiscard]]
unsigned getAxis()
const {
return axis; }
249 [[nodiscard]]
int getValue()
const {
return value; }
262 [[nodiscard]]
unsigned getHat()
const {
return hat; }
263 [[nodiscard]]
unsigned getValue()
const {
return value; }
267 const unsigned value;
277 [[nodiscard]]
bool getGain()
const {
return gain; }
290 [[nodiscard]]
unsigned getX()
const {
return x; }
291 [[nodiscard]]
unsigned getY()
const {
return y; }
325 [[nodiscard]]
unsigned getButton()
const {
return button; }
335 : origEvent(
std::move(origEvent_)), button(button_) {}
338 const Event origEvent;
339 const unsigned button;
361 : typesToMatch(typesToMatch_)
362 , tclListComponents(
std::move(tclListComponents_)) {}
388 : thisSource(thisSource_), selectedSource(selectedSource_)
393 [[nodiscard]]
int getSource()
const {
return thisSource; }
395 [[nodiscard]]
bool isSkipped()
const {
return skipped; }
396 [[nodiscard]]
bool needRender()
const {
return !skipped && (thisSource == selectedSource); }
399 const int thisSource;
400 const int selectedSource;
509 KEY_UP = event_index<KeyUpEvent>,
510 KEY_DOWN = event_index<KeyDownEvent>,
516 JOY_HAT = event_index<JoystickHatEvent>,
521 FOCUS = event_index<FocusEvent>,
522 RESIZE = event_index<ResizeEvent>,
524 QUIT = event_index<QuitEvent>,
525 GROUP = event_index<GroupEvent>,
526 BOOT = event_index<BootEvent>,
529 BREAK = event_index<BreakEvent>,
537 EXPOSE = event_index<ExposeEvent>,
551 template<
typename ...Args>
586template<
typename T,
typename ...Args>
590 return Event(
eventPool.emplace(std::in_place_type_t<T>{}, std::forward<Args>(args)...).ptr);
601 if (
this != &other) {
611 if (
this != &other) {
619inline void Event::incr()
627inline void Event::decr()
644 return *
event.getPtr();
654template<
typename Visitor>
660template<
typename Visitor>
663 assert(event1 && event2);
691 default:
return nullptr;
702 default:
return nullptr;
715 default:
return nullptr;
724 return helper(event);
730 const T*
t = get_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.
const CliConnection * getId() const
zstring_view getCommand() const
CliCommandEvent(std::string_view command_, const CliConnection *id_)
Event(const Event &other)
Event(Event &&other) noexcept
static Event create(Args &&...args)
Event & operator=(const Event &other)
const RcEvent * getPtr() const
Send when (part of) the openMSX window gets exposed, and thus should be repainted.
FileDropEvent(std::string_view fileName_)
zstring_view getFileName() const
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
static constexpr unsigned X_AXIS
JoystickAxisMotionEvent(int joystick_, unsigned axis_, int value_)
static constexpr unsigned Y_AXIS
JoystickEvent(int joystick_)
JoystickHatEvent(int joystick_, unsigned hat_, unsigned value_)
unsigned getValue() const
KeyDownEvent(Keys::KeyCode keyCode_)
KeyDownEvent(Keys::KeyCode keyCode_, uint32_t unicode_)
KeyDownEvent(Keys::KeyCode keyCode_, Keys::KeyCode scanCode_, uint32_t unicode_)
KeyDownEvent(Keys::KeyCode keyCode_, Keys::KeyCode scanCode_)
Keys::KeyCode getKeyCode() const
KeyEvent(Keys::KeyCode keyCode_, Keys::KeyCode scanCode_, uint32_t unicode_)
Keys::KeyCode getScanCode() const
uint32_t getUnicode() const
KeyUpEvent(Keys::KeyCode keyCode_)
KeyUpEvent(Keys::KeyCode keyCode_, Keys::KeyCode scanCode_)
Send when a machine is (de)activated.
Send when a (new) machine configuration is loaded.
MouseMotionEvent(int xrel_, int yrel_, int xabs_, int yabs_)
MouseWheelEvent(int x_, int y_)
OSD events are triggered by other events.
const Event & getOrigEvent() const
Get the event that actually triggered the creation of this event.
OsdControlEvent(unsigned button_, Event origEvent_)
unsigned getButton() const
OsdControlPressEvent(unsigned button_, Event origEvent_)
OsdControlReleaseEvent(unsigned button_, Event origEvent_)
ResizeEvent(unsigned x_, unsigned y_)
Used to schedule 'taking reverse snapshots' between Z80 instructions.
uint64_t getRealTime() const
Like std::string_view, but with the extra guarantee that it refers to a zero-terminated string.
constexpr vecN< N, T > max(const vecN< N, T > &x, const vecN< N, T > &y)
KeyCode
Constants that identify keys and key modifiers.
bool isMainThread()
Returns true when called from the main thread.
uint64_t getTime()
Get current (real) time in us.
This file implemented 3 utility functions:
auto visit(Visitor &&visitor, const Event &event1, const Event &event2)
constexpr uint8_t event_index
@ MIDI_IN_COREMIDI_VIRTUAL
bool operator==(const Event &x, const Event &y)
bool isRepeatStopper(const Event &self, const Event &other)
Should 'bind -repeat' be stopped by 'other' event.
const T & get(const Event &event)
bool matches(const Event &self, const Event &other)
Does this event 'match' the given event.
const T * get_if(const Event &event)
auto visit(Visitor &&visitor, const Event &event)
std::variant< KeyUpEvent, KeyDownEvent, MouseMotionEvent, MouseButtonUpEvent, MouseButtonDownEvent, MouseWheelEvent, JoystickAxisMotionEvent, JoystickHatEvent, JoystickButtonUpEvent, JoystickButtonDownEvent, OsdControlReleaseEvent, OsdControlPressEvent, FocusEvent, ResizeEvent, FileDropEvent, QuitEvent, FinishFrameEvent, CliCommandEvent, GroupEvent, BootEvent, FrameDrawnEvent, BreakEvent, SwitchRendererEvent, TakeReverseSnapshotEvent, AfterTimedEvent, MachineLoadedEvent, MachineActivatedEvent, MachineDeactivatedEvent, ExposeEvent, MidiInReaderEvent, MidiInWindowsEvent, MidiInCoreMidiEvent, MidiInCoreMidiVirtualEvent, MidiInALSAEvent, Rs232TesterEvent > EventVariant
const EventVariant & getVariant(const Event &event)
TclObject toTclList(const Event &event)
Similar to toString(), but retains the structure of the event.
EventType getType(const Event &event)
std::recursive_mutex eventPoolMutex
ObjectPool< RcEvent > eventPool
std::string toString(const Event &event)
Get a string representation of this event.
const JoystickEvent * operator()(const Event &event)
const KeyEvent * operator()(const Event &event)
const TimedEvent * operator()(const Event &event)
const T * operator()(const Event &event)