Add Pico touch routing abstraction
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
class TouchEvent:
|
||||
def __init__(self, x, y, pressed=True):
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.pressed = pressed
|
||||
|
||||
|
||||
class TouchController:
|
||||
def __init__(self, touch_device=None):
|
||||
self.touch_device = touch_device
|
||||
|
||||
def read_event(self):
|
||||
if not self.touch_device:
|
||||
return None
|
||||
|
||||
point = self.touch_device.read()
|
||||
|
||||
if not point:
|
||||
return None
|
||||
|
||||
return TouchEvent(point["x"], point["y"], point.get("pressed", True))
|
||||
|
||||
Reference in New Issue
Block a user