mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-03-03 16:56:07 +00:00
use friendlier event enums
This commit is contained in:
parent
af482d3da1
commit
e382737fda
@ -6,9 +6,9 @@ from trezor.utils import unimport_func
|
||||
def multiplex_touch_events(gens):
|
||||
while True:
|
||||
e, (x, y) = yield loop.Wait([
|
||||
loop.EVT_TSTART,
|
||||
loop.EVT_TMOVE,
|
||||
loop.EVT_TEND,
|
||||
loop.TOUCH_START,
|
||||
loop.TOUCH_MOVE,
|
||||
loop.TOUCH_END,
|
||||
])
|
||||
for gen in gens:
|
||||
gen.send((e, (x, y)))
|
||||
@ -23,7 +23,7 @@ def in_area(pos, area):
|
||||
def click_in(area, enter, leave):
|
||||
while True:
|
||||
e, pos = yield
|
||||
if e is not loop.EVT_TSTART or not in_area(pos, area):
|
||||
if e is not loop.TOUCH_START or not in_area(pos, area):
|
||||
continue
|
||||
|
||||
inside = True
|
||||
@ -31,7 +31,7 @@ def click_in(area, enter, leave):
|
||||
|
||||
while True:
|
||||
e, pos = yield
|
||||
if e is loop.EVT_TMOVE:
|
||||
if e is loop.TOUCH_MOVE:
|
||||
if in_area(pos, area):
|
||||
if not inside:
|
||||
enter()
|
||||
@ -40,7 +40,7 @@ def click_in(area, enter, leave):
|
||||
if inside:
|
||||
leave()
|
||||
inside = False
|
||||
elif e is loop.EVT_TEND:
|
||||
elif e is loop.TOUCH_END:
|
||||
if in_area(pos, area):
|
||||
return
|
||||
else:
|
||||
|
@ -5,16 +5,16 @@ from .utils import type_gen
|
||||
from . import msg
|
||||
from . import log
|
||||
|
||||
EVT_TSTART = const(-1)
|
||||
EVT_TMOVE = const(-2)
|
||||
EVT_TEND = const(-3)
|
||||
EVT_MSG = const(-4)
|
||||
TOUCH_START = const(-1)
|
||||
TOUCH_MOVE = const(-2)
|
||||
TOUCH_END = const(-3)
|
||||
MESSAGE = const(-4)
|
||||
|
||||
event_handlers = {
|
||||
EVT_TSTART: None,
|
||||
EVT_TMOVE: None,
|
||||
EVT_TEND: None,
|
||||
EVT_MSG: None,
|
||||
TOUCH_START: None,
|
||||
TOUCH_MOVE: None,
|
||||
TOUCH_END: None,
|
||||
MESSAGE: None,
|
||||
}
|
||||
time_queue = []
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user