Revert "Supress touch events after swipe"

This reverts commit 9267705f29.
This commit is contained in:
Thomas Farstrike
2025-05-24 07:16:27 +02:00
parent 9267705f29
commit ae10c369c5
2 changed files with 17 additions and 30 deletions
@@ -2,14 +2,17 @@ import time
import mpos.config
import mpos.ui
import mpos.apps
# screens:
main_screen = None
settings_screen = None
# Settings screen implementation
class SettingsScreen():
def __init__(self):
#super().__init__(None)
self.prefs = mpos.config.SharedPreferences("com.lightningpiggy.displaywallet")
self.settings = [
{"title": "Wallet Type", "key": "wallet_type", "value_label": None},
+14 -30
View File
@@ -33,13 +33,13 @@ mouse = sdl_pointer.SDLPointer()
#keyboard.add_event_cb(keyboard_cb, lv.EVENT.ALL, None)
# Swipe detection state
# Swipe detection state
start_y = None # Store the starting Y-coordinate of the mouse press
start_x = None # Store the starting X-coordinate for left-edge swipe
swipe_detected = False # Track if a swipe was detected to suppress widget events
def swipe_read_cb(indev_drv, data):
global start_y, start_x, swipe_detected
global start_y, start_x
pressed = mouse.get_state() # Get mouse/touch pressed state
point = lv.point_t()
@@ -50,59 +50,43 @@ def swipe_read_cb(indev_drv, data):
# Mouse/touch pressed (start of potential swipe)
start_y = y # Store Y for vertical swipe detection
start_x = x # Store X for horizontal swipe detection
swipe_detected = False # Reset swipe flag
print(f"Mouse press at X={start_x}, Y={start_y}")
# Check if press is in notification bar (for swipe down)
if y <= mpos.ui.NOTIFICATION_BAR_HEIGHT:
print(f"Press in notification bar at Y={start_y}")
# Check if press is near left edge (for swipe right)
if x <= 20: # Adjust threshold for left edge (e.g., 20 pixels)
print(f"Press near left edge at X={start_x}")
elif pressed and (start_y is not None or start_x is not None):
# Mouse/touch dragged while pressed (potential swipe in progress)
# Check for downward swipe (y increased significantly)
if start_y is not None and y > start_y + 50: # Threshold for swipe down
print("Long swipe down")
if start_y <= mpos.ui.NOTIFICATION_BAR_HEIGHT:
print("Swipe Down Detected from Notification Bar")
mpos.ui.open_drawer()
swipe_detected = True # Mark swipe detected
start_y = None # Reset Y after swipe
start_x = None # Reset X to avoid conflicts
start_y = None # Reset Y after swipe
start_x = None # Reset X to avoid conflicts
# Check for rightward swipe from left edge (x increased significantly)
if start_x is not None and x > start_x + 50: # Threshold for swipe right
print("Long swipe right")
if start_x <= 20: # Confirm swipe started near left edge
print("Swipe Right Detected from Left Edge")
mpos.ui.back_screen() # Navigate to previous screen
swipe_detected = True # Mark swipe detected
start_y = None # Reset Y after swipe
start_x = None # Reset X after swipe
mpos.ui.back_screen() # Call custom method for left menu
start_y = None # Reset Y after swipe
start_x = None # Reset X after swipe
else:
# Mouse/touch released
if start_y is not None:
if y < start_y - 50: # Threshold for swipe-up
print("Swipe Up Detected")
mpos.ui.close_drawer()
swipe_detected = True # Mark swipe detected
# Reset coordinates
if start_y is not None and y < start_y - 50: # Threshold for swipe-up
print("Swipe Up Detected")
mpos.ui.close_drawer()
# Reset both coordinates on release
start_y = None
start_x = None
# Suppress widget events if any swipe was detected
if swipe_detected:
data.state = lv.INDEV_STATE.RELEASED # Ensure release state
data.point.x = -1 # Move point off-screen to prevent widget interaction
data.point.y = -1
swipe_detected = False # Reset flag after suppression
print("Suppressing widget events after swipe")
# Register the custom read callback with the input device
indev = lv.indev_create()
indev.set_type(lv.INDEV_TYPE.POINTER)