From 980399d14239ab516da5498520b7d06599628794 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 28 Nov 2021 14:36:20 +0100 Subject: [PATCH] event: Expose ButtonEvent to Python --- panda/src/event/buttonEvent.I | 32 +++++++++++++++++++++++++++++++ panda/src/event/buttonEvent.h | 16 +++++++++++++++- panda/src/event/buttonEventList.h | 2 ++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/panda/src/event/buttonEvent.I b/panda/src/event/buttonEvent.I index f082a4bee9..959f66dc47 100644 --- a/panda/src/event/buttonEvent.I +++ b/panda/src/event/buttonEvent.I @@ -149,3 +149,35 @@ update_mods(ModifierButtons &mods) const { return false; } } + +/** + * + */ +INLINE ButtonHandle ButtonEvent:: +get_button() const { + return _button; +} + +/** + * + */ +INLINE int ButtonEvent:: +get_keycode() const { + return _keycode; +} + +/** + * + */ +INLINE ButtonEvent::Type ButtonEvent:: +get_type() const { + return _type; +} + +/** + * + */ +INLINE double ButtonEvent:: +get_time() const { + return _time; +} diff --git a/panda/src/event/buttonEvent.h b/panda/src/event/buttonEvent.h index b5f338bfb9..9da453a827 100644 --- a/panda/src/event/buttonEvent.h +++ b/panda/src/event/buttonEvent.h @@ -44,7 +44,7 @@ class DatagramIterator; * character set. */ class EXPCL_PANDA_EVENT ButtonEvent { -public: +PUBLISHED: enum Type { // T_down is sent when a button was just pressed. T_down, @@ -85,6 +85,7 @@ public: T_raw_up, }; +public: INLINE ButtonEvent(); INLINE ButtonEvent(ButtonHandle button, Type type, double time = ClockObject::get_global_clock()->get_frame_time()); INLINE ButtonEvent(int keycode, double time = ClockObject::get_global_clock()->get_frame_time()); @@ -93,17 +94,30 @@ public: INLINE ButtonEvent(const ButtonEvent ©); INLINE void operator = (const ButtonEvent ©); +PUBLISHED: INLINE bool operator == (const ButtonEvent &other) const; INLINE bool operator != (const ButtonEvent &other) const; INLINE bool operator < (const ButtonEvent &other) const; +public: INLINE bool update_mods(ModifierButtons &mods) const; + INLINE ButtonHandle get_button() const; + INLINE int get_keycode() const; + INLINE Type get_type() const; + INLINE double get_time() const; + void output(std::ostream &out) const; void write_datagram(Datagram &dg) const; void read_datagram(DatagramIterator &scan); +PUBLISHED: + MAKE_PROPERTY(button, get_button); + MAKE_PROPERTY(keycode, get_keycode); + MAKE_PROPERTY(type, get_type); + MAKE_PROPERTY(time, get_time); + public: // _button will be filled in if type is T_down, T_resume_down, or T_up. ButtonHandle _button; diff --git a/panda/src/event/buttonEventList.h b/panda/src/event/buttonEventList.h index 0a7822fc63..a3cbcfb1e7 100644 --- a/panda/src/event/buttonEventList.h +++ b/panda/src/event/buttonEventList.h @@ -47,6 +47,8 @@ PUBLISHED: virtual void output(std::ostream &out) const; void write(std::ostream &out, int indent_level = 0) const; + MAKE_SEQ_PROPERTY(events, get_num_events, get_event); + private: typedef pvector Events; Events _events;