Browse Source

Fixes for device button handling

Made State enum accessible from python side
Fixed missing state changing in evdevInputDevice class
fireclawthefox 8 years ago
parent
commit
f1e1c2b891
2 changed files with 16 additions and 2 deletions
  1. 15 0
      panda/src/device/evdevInputDevice.cxx
  2. 1 2
      panda/src/device/inputDevice.h

+ 15 - 0
panda/src/device/evdevInputDevice.cxx

@@ -574,6 +574,21 @@ process_events() {
     case EV_KEY:
     case EV_KEY:
       button = map_button(code);
       button = map_button(code);
       _button_events->add_event(ButtonEvent(button, events[i].value ? ButtonEvent::T_down : ButtonEvent::T_up, time));
       _button_events->add_event(ButtonEvent(button, events[i].value ? ButtonEvent::T_down : ButtonEvent::T_up, time));
+      // set the buttons state
+      State state;
+      if (events[i].value) {
+        state = S_down;
+      } else {
+        state = S_up;
+      }
+      for (int i = 0; i < _buttons.size(); ++i) {
+        if (get_button(i).handle == button) {
+          //NOTE: set_button_state doesn't work correct here.
+          //set_button_state(i, state);
+          _buttons[i].state = state;
+          break;
+        }
+      }
       break;
       break;
 
 
     default:
     default:

+ 1 - 2
panda/src/device/inputDevice.h

@@ -243,14 +243,13 @@ protected:
   PT(ButtonEventList) _button_events;
   PT(ButtonEventList) _button_events;
   PT(PointerEventList) _pointer_events;
   PT(PointerEventList) _pointer_events;
 
 
-public:
+PUBLISHED:
   enum State {
   enum State {
     S_unknown,
     S_unknown,
     S_up,
     S_up,
     S_down
     S_down
   };
   };
 
 
-PUBLISHED:
   class ButtonState {
   class ButtonState {
   public:
   public:
     INLINE ButtonState();
     INLINE ButtonState();