diff --git a/panda/src/tform/mouseWatcher.I b/panda/src/tform/mouseWatcher.I index 2a45ea5cf2..b0ab269fb0 100644 --- a/panda/src/tform/mouseWatcher.I +++ b/panda/src/tform/mouseWatcher.I @@ -144,6 +144,15 @@ is_button_down(ButtonHandle button) const { return _inactivity_state != IS_inactive && _current_buttons_down.get_bit(button.get_index()); } +/** + * Similar to is_button_down(), but uses the raw button handle as reported by + * the raw- prefixed events, and is not subject to the inactivity timer. + */ +INLINE bool MouseWatcher:: +is_raw_button_down(ButtonHandle button) const { + return _current_raw_buttons_down.get_bit(button.get_index()); +} + /** * Sets the pattern string that indicates how the event names are generated * when a button is depressed. This is a string that may contain any of the diff --git a/panda/src/tform/mouseWatcher.cxx b/panda/src/tform/mouseWatcher.cxx index 54caa1cd88..3b63380548 100644 --- a/panda/src/tform/mouseWatcher.cxx +++ b/panda/src/tform/mouseWatcher.cxx @@ -1427,8 +1427,12 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, break; case ButtonEvent::T_raw_down: + _current_raw_buttons_down.set_bit(be._button.get_index()); + new_button_events.add_event(be); + break; + case ButtonEvent::T_raw_up: - // These are passed through. + _current_raw_buttons_down.clear_bit(be._button.get_index()); new_button_events.add_event(be); break; } diff --git a/panda/src/tform/mouseWatcher.h b/panda/src/tform/mouseWatcher.h index fa012e5780..d901e777ef 100644 --- a/panda/src/tform/mouseWatcher.h +++ b/panda/src/tform/mouseWatcher.h @@ -84,6 +84,7 @@ PUBLISHED: MouseWatcherRegion *get_over_region(const LPoint2 &pos) const; INLINE bool is_button_down(ButtonHandle button) const; + INLINE bool is_raw_button_down(ButtonHandle button) const; INLINE void set_button_down_pattern(const std::string &pattern); INLINE const std::string &get_button_down_pattern() const; @@ -214,6 +215,7 @@ private: LPoint2 _mouse; LPoint2 _mouse_pixel; BitArray _current_buttons_down; + BitArray _current_raw_buttons_down; LVecBase4 _frame;