Add held mouse buttons (Left click / Right click toggles) to the Touchpad tab

Two toggle buttons in the free corners of the D-pad press and hold the PC's
left or right mouse button until tapped again, for drag and drop, text
selection and window moves, with the touchpad moving the pointer in between.

- New input action "button" ({button, pressed}); the state carries
  input.buttons. VirtualInput remembers which connection pressed each button.
- A click on a held button is ignored so a touchpad tap does not drop the
  drag; the other button stays usable. Repeating a state is a no-op.
- A held button is always released: when its client disconnects (only its own
  buttons), when the server stops, and in the client when the tab is left or
  the page is hidden.
- Incoming states are set aside for 500 ms after a local tap, so a state
  already in flight cannot undo the toggle for a moment.
- D-pad rows are equal-sized (minmax(0, 1fr)) so the corner buttons do not
  stretch the top row.

tests/test_input.py covers the device logic and the full server (disconnect,
several clients); tests/test_ui_mouse_hold.py drives a real Chromium. Also
checked through the real uinput device with its pointer grabbed exclusively.
README (fr/en) and CLAUDE.md are updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Denis
2026-10-31 08:46:48 +01:00
parent c6523ac213
commit 851b7681ff
11 changed files with 549 additions and 16 deletions
+10 -2
View File
@@ -49,6 +49,10 @@ async def _websocket(request: web.Request) -> web.WebSocketResponse:
async for message in socket_:
if message.type == WSMsgType.ERROR:
break
# Un test peut enregistrer les messages du client et répondre (voir make_app)
handler = request.app.get("on_message")
if message.type == WSMsgType.TEXT and handler is not None:
await handler(json.loads(message.data), socket_)
return socket_
@@ -56,9 +60,13 @@ async def _index(_request: web.Request) -> web.Response:
return render_page("index.html")
def make_app() -> web.Application:
"""La vraie page et les vrais fichiers statiques (mêmes fonctions que le serveur), avec un état de démonstration."""
def make_app(on_message: Any = None) -> web.Application:
"""La vraie page et les vrais fichiers statiques (mêmes fonctions que le serveur), avec un état de démonstration.
``on_message(message, socket)`` : appelé pour chaque message reçu du client (coroutine)."""
app = web.Application()
if on_message is not None:
app["on_message"] = on_message
app.router.add_get("/", _index)
app.router.add_get("/ws", _websocket)
app.router.add_get("/static/{version}/{path:.+}", versioned_static)