mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-22 20:42:03 +00:00
core/debug: simplify swipe
This commit is contained in:
parent
865057723a
commit
818e2e2827
@ -64,34 +64,18 @@ if __debug__:
|
||||
layout_change_chan.publish(storage.current_content)
|
||||
|
||||
async def _dispatch_debuglink_decision(msg: DebugLinkDecision) -> None:
|
||||
from trezor.enums import DebugButton, DebugSwipeDirection
|
||||
from trezor.ui import (
|
||||
Result,
|
||||
SWIPE_UP,
|
||||
SWIPE_DOWN,
|
||||
SWIPE_LEFT,
|
||||
SWIPE_RIGHT,
|
||||
)
|
||||
from trezor.enums import DebugButton
|
||||
from trezor.ui import Result
|
||||
|
||||
button = msg.button # local_cache_attribute
|
||||
swipe = msg.swipe # local_cache_attribute
|
||||
|
||||
if button is not None:
|
||||
if button == DebugButton.NO:
|
||||
if msg.button is not None:
|
||||
if msg.button == DebugButton.NO:
|
||||
await confirm_chan.put(Result(trezorui2.CANCELLED))
|
||||
elif button == DebugButton.YES:
|
||||
elif msg.button == DebugButton.YES:
|
||||
await confirm_chan.put(Result(trezorui2.CONFIRMED))
|
||||
elif button == DebugButton.INFO:
|
||||
elif msg.button == DebugButton.INFO:
|
||||
await confirm_chan.put(Result(trezorui2.INFO))
|
||||
if swipe is not None:
|
||||
if swipe == DebugSwipeDirection.UP:
|
||||
await swipe_chan.put(SWIPE_UP)
|
||||
elif swipe == DebugSwipeDirection.DOWN:
|
||||
await swipe_chan.put(SWIPE_DOWN)
|
||||
elif swipe == DebugSwipeDirection.LEFT:
|
||||
await swipe_chan.put(SWIPE_LEFT)
|
||||
elif swipe == DebugSwipeDirection.RIGHT:
|
||||
await swipe_chan.put(SWIPE_RIGHT)
|
||||
if msg.swipe is not None:
|
||||
await swipe_chan.put(msg.swipe)
|
||||
if msg.input is not None:
|
||||
await input_chan.put(Result(msg.input))
|
||||
|
||||
|
@ -17,14 +17,6 @@ MONO: int = Display.FONT_MONO
|
||||
WIDTH: int = Display.WIDTH
|
||||
HEIGHT: int = Display.HEIGHT
|
||||
|
||||
if __debug__:
|
||||
# common symbols to transfer swipes between debuglink and the UI
|
||||
SWIPE_UP = const(0x01)
|
||||
SWIPE_DOWN = const(0x02)
|
||||
SWIPE_LEFT = const(0x04)
|
||||
SWIPE_RIGHT = const(0x08)
|
||||
|
||||
|
||||
# channel used to cancel layouts, see `Cancelled` exception
|
||||
layout_chan = loop.chan()
|
||||
|
||||
|
@ -83,21 +83,16 @@ class RustLayout(ui.Layout):
|
||||
|
||||
async def handle_swipe(self):
|
||||
from apps.debug import notify_layout_change, swipe_signal
|
||||
from trezor.ui import (
|
||||
SWIPE_UP,
|
||||
SWIPE_DOWN,
|
||||
SWIPE_LEFT,
|
||||
SWIPE_RIGHT,
|
||||
)
|
||||
from trezor.enums import DebugSwipeDirection
|
||||
|
||||
while True:
|
||||
direction = await swipe_signal()
|
||||
orig_x = orig_y = 120
|
||||
off_x, off_y = {
|
||||
SWIPE_UP: (0, -30),
|
||||
SWIPE_DOWN: (0, 30),
|
||||
SWIPE_LEFT: (-30, 0),
|
||||
SWIPE_RIGHT: (30, 0),
|
||||
DebugSwipeDirection.UP: (0, -30),
|
||||
DebugSwipeDirection.DOWN: (0, 30),
|
||||
DebugSwipeDirection.LEFT: (-30, 0),
|
||||
DebugSwipeDirection.RIGHT: (30, 0),
|
||||
}[direction]
|
||||
|
||||
for event, x, y in (
|
||||
|
Loading…
Reference in New Issue
Block a user