Add configurable mouse movement and improve HID handling
This commit is contained in:
+8
-1
@@ -14,9 +14,12 @@ DEFAULTS = {
|
||||
"wifi_ssid": "CHANGE_ME",
|
||||
"wifi_password": "CHANGE_ME",
|
||||
"web_password": "change-this-before-deploying",
|
||||
# Set false when validating on a board without the T-Dongle-S3 display.
|
||||
"display_enabled": False,
|
||||
"enabled": True,
|
||||
"return_enabled": True,
|
||||
"mouse_enabled": True,
|
||||
"mouse_distance": 1,
|
||||
"return_min_seconds": 45,
|
||||
"return_max_seconds": 120,
|
||||
"mouse_min_seconds": 20,
|
||||
@@ -65,7 +68,7 @@ def apply_form(values, form):
|
||||
|
||||
for key in (
|
||||
"return_min_seconds", "return_max_seconds",
|
||||
"mouse_min_seconds", "mouse_max_seconds",
|
||||
"mouse_min_seconds", "mouse_max_seconds", "mouse_distance",
|
||||
):
|
||||
if key in form:
|
||||
try:
|
||||
@@ -81,6 +84,10 @@ def _validate(values):
|
||||
if not isinstance(values.get(key), str) or not values[key]:
|
||||
raise ValueError("%s must be a non-empty string" % key)
|
||||
|
||||
distance = values["mouse_distance"]
|
||||
if not isinstance(distance, int) or distance < 1 or distance > 127:
|
||||
raise ValueError("mouse distance must be between 1 and 127 pixels")
|
||||
|
||||
for prefix in ("return", "mouse"):
|
||||
minimum = values[prefix + "_min_seconds"]
|
||||
maximum = values[prefix + "_max_seconds"]
|
||||
|
||||
Reference in New Issue
Block a user