Make a tap on the page number key go to page 1 outright.
The converted key's "startup" page resolves to the current page on surfaces set to "use last page", so a tap did nothing. The tap page is now nav_tap_page in config.json (1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+8
-5
@@ -136,12 +136,13 @@ NAV_LOCATIONS = {"pageup": ("0", "0"), "pagenum": ("1", "0"), "pagedown": ("2",
|
||||
NAV_MARKER = "STATUS nav key"
|
||||
|
||||
|
||||
def nav_key(kind, names, status_page=None, hold_ms=1000):
|
||||
def nav_key(kind, names, status_page=None, hold_ms=1000, tap_page=1):
|
||||
"""Companion's own UP / page number / DOWN key, coloured like the ALL button.
|
||||
|
||||
For the page number key, status_page adds: tap = Companion's usual "go to the
|
||||
start page" (moved to release, so a hold does not flash through it first),
|
||||
hold for hold_ms = go to the status page.
|
||||
For the page number key, status_page adds: tap = go to tap_page (on release,
|
||||
so a hold does not flash through it first), hold for hold_ms = go to the
|
||||
status page. The tap names the page outright: the converted key's "startup"
|
||||
means the current page on surfaces set to "use last page".
|
||||
"""
|
||||
templates = json.load(open(os.path.join(HERE, "nav_templates.json")))
|
||||
key = json.loads(json.dumps(templates[kind]))
|
||||
@@ -163,6 +164,7 @@ def nav_key(kind, names, status_page=None, hold_ms=1000):
|
||||
if kind == "pagenum" and status_page:
|
||||
step = key["steps"]["0"]
|
||||
tap = step["action_sets"]["down"]
|
||||
tap[0]["options"]["page"] = prop(tap_page)
|
||||
hold = [{"type": "action", "id": stable_id("nav", "hold"), "definitionId": "set_page",
|
||||
"connectionId": "internal",
|
||||
"options": {"surfaceId": prop("self"), "page": prop(status_page)}, "children": {}}]
|
||||
@@ -177,7 +179,8 @@ def build(cfg):
|
||||
controls = {}
|
||||
coloured = cfg.get("nav_keys", list(NAV_LOCATIONS)) # which nav keys follow the ALL button
|
||||
for kind, (r, c) in NAV_LOCATIONS.items():
|
||||
controls.setdefault(r, {})[c] = (nav_key(kind, cfg["variables"], cfg["page"], cfg.get("nav_hold_ms", 1000))
|
||||
controls.setdefault(r, {})[c] = (nav_key(kind, cfg["variables"], cfg["page"], cfg.get("nav_hold_ms", 1000),
|
||||
cfg.get("nav_tap_page", 1))
|
||||
if kind in coloured else {"type": kind})
|
||||
for tile in cfg["tiles"]:
|
||||
if "pos" not in tile:
|
||||
|
||||
Reference in New Issue
Block a user