mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-07 18:58:03 +02:00
tools: per-slot-delta: skip the extra evbit indirection
e.code is the evbit anyway, we don't have to convert it Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
e48a316c02
commit
d107d58cd2
1 changed files with 12 additions and 13 deletions
|
|
@ -208,17 +208,16 @@ def main(argv):
|
||||||
for evdev in event['evdev']:
|
for evdev in event['evdev']:
|
||||||
s = slots[slot]
|
s = slots[slot]
|
||||||
e = InputEvent(evdev)
|
e = InputEvent(evdev)
|
||||||
evbit = libevdev.evbit(e.evtype, e.evcode)
|
|
||||||
|
|
||||||
if evbit in tool_bits:
|
if e.code in tool_bits:
|
||||||
tool_bits[evbit] = e.value
|
tool_bits[e.code] = e.value
|
||||||
|
|
||||||
if args.use_st:
|
if args.use_st:
|
||||||
# Note: this relies on the EV_KEY events to come in before the
|
# Note: this relies on the EV_KEY events to come in before the
|
||||||
# x/y events, otherwise the last/first event in each slot will
|
# x/y events, otherwise the last/first event in each slot will
|
||||||
# be wrong.
|
# be wrong.
|
||||||
if (evbit == libevdev.EV_KEY.BTN_TOOL_FINGER or
|
if (e.code == libevdev.EV_KEY.BTN_TOOL_FINGER or
|
||||||
evbit == libevdev.EV_KEY.BTN_TOOL_PEN):
|
e.code == libevdev.EV_KEY.BTN_TOOL_PEN):
|
||||||
slot = 0
|
slot = 0
|
||||||
s = slots[slot]
|
s = slots[slot]
|
||||||
s.dirty = True
|
s.dirty = True
|
||||||
|
|
@ -226,7 +225,7 @@ def main(argv):
|
||||||
s.state = SlotState.BEGIN
|
s.state = SlotState.BEGIN
|
||||||
else:
|
else:
|
||||||
s.state = SlotState.END
|
s.state = SlotState.END
|
||||||
elif evbit == libevdev.EV_KEY.BTN_TOOL_DOUBLETAP:
|
elif e.code == libevdev.EV_KEY.BTN_TOOL_DOUBLETAP:
|
||||||
if len(slots) > 1:
|
if len(slots) > 1:
|
||||||
slot = 1
|
slot = 1
|
||||||
s = slots[slot]
|
s = slots[slot]
|
||||||
|
|
@ -235,18 +234,18 @@ def main(argv):
|
||||||
s.state = SlotState.BEGIN
|
s.state = SlotState.BEGIN
|
||||||
else:
|
else:
|
||||||
s.state = SlotState.END
|
s.state = SlotState.END
|
||||||
elif evbit == libevdev.EV_ABS.ABS_X:
|
elif e.code == libevdev.EV_ABS.ABS_X:
|
||||||
if s.state == SlotState.UPDATE:
|
if s.state == SlotState.UPDATE:
|
||||||
s.dx = e.value - s.x
|
s.dx = e.value - s.x
|
||||||
s.x = e.value
|
s.x = e.value
|
||||||
s.dirty = True
|
s.dirty = True
|
||||||
elif evbit == libevdev.EV_ABS.ABS_Y:
|
elif e.code == libevdev.EV_ABS.ABS_Y:
|
||||||
if s.state == SlotState.UPDATE:
|
if s.state == SlotState.UPDATE:
|
||||||
s.dy = e.value - s.y
|
s.dy = e.value - s.y
|
||||||
s.y = e.value
|
s.y = e.value
|
||||||
s.dirty = True
|
s.dirty = True
|
||||||
else:
|
else:
|
||||||
if evbit == libevdev.EV_ABS.ABS_MT_SLOT:
|
if e.code == libevdev.EV_ABS.ABS_MT_SLOT:
|
||||||
slot = e.value
|
slot = e.value
|
||||||
s = slots[slot]
|
s = slots[slot]
|
||||||
s.dirty = True
|
s.dirty = True
|
||||||
|
|
@ -254,7 +253,7 @@ def main(argv):
|
||||||
# our current slot number was used
|
# our current slot number was used
|
||||||
for sl in slots[:slot + 1]:
|
for sl in slots[:slot + 1]:
|
||||||
sl.used = True
|
sl.used = True
|
||||||
elif evbit == libevdev.EV_ABS.ABS_MT_TRACKING_ID:
|
elif e.code == libevdev.EV_ABS.ABS_MT_TRACKING_ID:
|
||||||
if e.value == -1:
|
if e.value == -1:
|
||||||
s.state = SlotState.END
|
s.state = SlotState.END
|
||||||
else:
|
else:
|
||||||
|
|
@ -262,18 +261,18 @@ def main(argv):
|
||||||
s.dx = 0
|
s.dx = 0
|
||||||
s.dy = 0
|
s.dy = 0
|
||||||
s.dirty = True
|
s.dirty = True
|
||||||
elif evbit == libevdev.EV_ABS.ABS_MT_POSITION_X:
|
elif e.code == libevdev.EV_ABS.ABS_MT_POSITION_X:
|
||||||
if s.state == SlotState.UPDATE:
|
if s.state == SlotState.UPDATE:
|
||||||
s.dx = e.value - s.x
|
s.dx = e.value - s.x
|
||||||
s.x = e.value
|
s.x = e.value
|
||||||
s.dirty = True
|
s.dirty = True
|
||||||
elif evbit == libevdev.EV_ABS.ABS_MT_POSITION_Y:
|
elif e.code == libevdev.EV_ABS.ABS_MT_POSITION_Y:
|
||||||
if s.state == SlotState.UPDATE:
|
if s.state == SlotState.UPDATE:
|
||||||
s.dy = e.value - s.y
|
s.dy = e.value - s.y
|
||||||
s.y = e.value
|
s.y = e.value
|
||||||
s.dirty = True
|
s.dirty = True
|
||||||
|
|
||||||
if evbit == libevdev.EV_SYN.SYN_REPORT:
|
if e.code == libevdev.EV_SYN.SYN_REPORT:
|
||||||
if last_time is None:
|
if last_time is None:
|
||||||
last_time = e.sec * 1000000 + e.usec
|
last_time = e.sec * 1000000 + e.usec
|
||||||
tdelta = 0
|
tdelta = 0
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue