Fixes for device button handling

Made State enum accessible from python side
Fixed missing state changing in evdevInputDevice class
This commit is contained in:
fireclawthefox 2017-02-08 00:16:06 +01:00 committed by rdb
parent 8434914ab6
commit f1e1c2b891
2 changed files with 16 additions and 2 deletions

View File

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

View File

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