Pārlūkot izejas kodu

tform: Add `MouseWatcher::is_raw_button_down()`

rdb 3 gadi atpakaļ
vecāks
revīzija
b5e92e29f5

+ 9 - 0
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

+ 5 - 1
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;
       }

+ 2 - 0
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;