tform: Add MouseWatcher::is_raw_button_down()

This commit is contained in:
rdb 2022-11-29 19:44:44 +01:00
parent 95b62ff198
commit b5e92e29f5
3 changed files with 16 additions and 1 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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;