From f1e1c2b891fbfb19ae7e4a277390c4db21018206 Mon Sep 17 00:00:00 2001 From: fireclawthefox Date: Wed, 8 Feb 2017 00:16:06 +0100 Subject: [PATCH] Fixes for device button handling Made State enum accessible from python side Fixed missing state changing in evdevInputDevice class --- panda/src/device/evdevInputDevice.cxx | 15 +++++++++++++++ panda/src/device/inputDevice.h | 3 +-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/panda/src/device/evdevInputDevice.cxx b/panda/src/device/evdevInputDevice.cxx index 7a71e5f222..ca2247c012 100644 --- a/panda/src/device/evdevInputDevice.cxx +++ b/panda/src/device/evdevInputDevice.cxx @@ -574,6 +574,21 @@ process_events() { case EV_KEY: button = map_button(code); _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; default: diff --git a/panda/src/device/inputDevice.h b/panda/src/device/inputDevice.h index d964b80781..0850d4a1d3 100644 --- a/panda/src/device/inputDevice.h +++ b/panda/src/device/inputDevice.h @@ -243,14 +243,13 @@ protected: PT(ButtonEventList) _button_events; PT(PointerEventList) _pointer_events; -public: +PUBLISHED: enum State { S_unknown, S_up, S_down }; -PUBLISHED: class ButtonState { public: INLINE ButtonState();