add dora-joy node publishing gamepad axes and buttons
validate / validate (pull_request) Successful in 58m42s
validate / test (pull_request) Successful in 58m47s
validate / markdownlint (pull_request) Successful in 58m40s

This commit is contained in:
2026-09-16 05:10:33 -05:00
parent 9f56aa8f75
commit 3624c63ead
24 changed files with 1478 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
# Manifest for the printer.
#
# dora resolves a node's manifest from its `path:`, so without this file the
# printer would be validated against the joy node's own contract and its one
# port would look wrong.
apiVersion: 1
name: printer
namespace: liria
description: Prints every joy reading, so the repo's dataflow runs with no consumer
runtime: python
entrypoint: printer.py
dora: ">=1.0"
inputs:
joy:
description: One reading. Printed, then forgotten.
+30
View File
@@ -0,0 +1,30 @@
"""Prints every `joy` message, so `dataflow.yml` is self-contained.
It exists so the repo's own dataflow can be validated and run by CI with no
gamepad and no consumer attached. It is not a test of anything: it prints what
arrived and forgets it.
"""
from dora import Node
def main() -> None:
"""Print one line per reading."""
node = Node("printer")
count = 0
for event in node:
if event["type"] != "INPUT" or event["id"] != "joy":
continue
row = event["value"][0].as_py()
count += 1
if not row["present"]:
print(f"joy {count:5d} no gamepad", flush=True)
continue
axes = " ".join(f"{value:+6.3f}" for value in row["axes"])
held = ",".join(str(index) for index, down in enumerate(row["buttons"]) if down) or "-"
print(f"joy {count:5d} axes [{axes}] buttons [{held}]", flush=True)
if __name__ == "__main__":
main()