1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-03-03 08:46:05 +00:00

use friendlier event enums

This commit is contained in:
Jan Pochyla 2016-05-05 14:28:10 +02:00 committed by Pavol Rusnak
parent af482d3da1
commit e382737fda
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 14 additions and 14 deletions

View File

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

View File

@ -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 = []