1
0
Fork 0

wasp: Introduce a NEXT event

This is useful for devices that do not have touchscreens. It can be used
to cycle through the quick ring and to check out notifications.

Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
This commit is contained in:
Daniel Thompson 2020-08-15 17:00:49 +01:00
parent a87b3faa4a
commit 5ae327ea54
3 changed files with 22 additions and 4 deletions

View file

@ -124,6 +124,9 @@ class CST816SSim():
self.regs[1] = 4
elif key.keysym.sym == sdl2.SDLK_RIGHT:
self.regs[1] = 3
elif key.keysym.sym == sdl2.SDLK_n:
# Allow NEXT to be tested on the simulator
self.regs[1] = 253
self.regs[3] = 0x80
self.raise_interrupt(pins)

View file

@ -40,7 +40,7 @@ class TouchButton:
def get_touch_data(self, pin_obj):
"""Synthesize a right swipe during interrupt.
"""
self.event[0] = 4
self.event[0] = 253 # NEXT
if self.schedule:
self.schedule(self)

View file

@ -43,8 +43,9 @@ class EventType():
RIGHT = 4
TOUCH = 5
HOME = 256
BACK = 257
HOME = 255
BACK = 254
NEXT = 253
class EventMask():
"""Enumerated event masks.
@ -53,6 +54,7 @@ class EventMask():
SWIPE_LEFTRIGHT = 0x0002
SWIPE_UPDOWN = 0x0004
BUTTON = 0x0008
NEXT = 0x0010
class PinHandler():
"""Pin (and Signal) event generator.
@ -285,8 +287,20 @@ class Manager():
"""Process a touch event.
"""
self.keep_awake()
event_mask = self.event_mask
# Handle context sensitive events such as NEXT
if event[0] == EventType.NEXT:
if bool(event_mask & EventMask.NEXT) and not self.app.swipe(event):
# The app has already handled this one (mark as no event)
event[0] = 0
elif self.app == self.quick_ring[0] and len(self.notifications):
event[0] = EventType.DOWN
elif self.app == self.notifier:
event[0] = EventType.UP
else:
event[0] = EventType.RIGHT
if event[0] < 5:
updown = event[0] == 1 or event[0] == 2
if (bool(event_mask & EventMask.SWIPE_UPDOWN) and updown) or \
@ -297,6 +311,7 @@ class Manager():
self.navigate(event[0])
elif event[0] == 5 and self.event_mask & EventMask.TOUCH:
self.app.touch(event)
watch.touch.reset_touch_data()
def _tick(self):