How kartik13-op/mobile-gamepad works
TouchKeys is a Windows virtual gamepad controlled from a phone browser over a local network. The principal workflow runs from the desktop monitor starting the phone server, through the phone’s WebSocket input, to local event routing and Windows input. The README documents the layout editor, multi-client slots, and optional screen streaming; those branches are included. Unsampled implementation details are represented only where documented, and edges use README or excerpt evidence.
Main entry points: server.py HTTP and WebSocket server · app.js Client app startup · events.py Input event router · websocket.js WebSocket client
Components 24
Desktop and Servers
- Desktop control center
backend/gui.py - HTTP and WebSocket server
backend/server.py - LAN TLS certificate
backend/tls.py
Phone and Monitor UI
- Controller page
templates/mobile.html - Monitor page
templates/monitor.html - Client app startup
static/js/app.js - WebSocket client
static/js/websocket.js - Touch controls
static/js/controller.js - Layout editor
static/js/layout.js - UI and status
static/js/ui.js - Motion controls
static/js/motion.js
Input and Layout
- Input event router
controller/events.py - Client and slot manager
controller/network.py - Virtual gamepad output
controller/keyboard.py - Mouse and keyboard output
controller/mouse.py - Layout management
controller/layout.py - Controller configuration
controller/config.py - JSON file storage
controller/storage.py
Streaming
- Phone stream viewer
static/js/streaming.js - Screen capture and WebRTC
backend/streaming.py
Other components
- PC operator
- Phone browser
- Windows and games
- ViGEmBus driver
Connections 29
- PC operator → Desktop control center: starts
README.md - Desktop control center → HTTP and WebSocket server: starts locally
backend/gui.py - Desktop control center → LAN TLS certificate: prepares phone TLS
backend/gui.py - Phone browser → HTTP and WebSocket server: loads page and connects
README.md - HTTP and WebSocket server → Controller page: serves
backend/server.py - HTTP and WebSocket server → Monitor page: serves
backend/server.py - Controller page → Client app startup: starts client
- Client app startup → WebSocket client: connects through
static/js/app.js - Client app startup → Touch controls: initializes
static/js/app.js - Client app startup → Layout editor: initializes
static/js/app.js - Client app startup → UI and status: initializes
static/js/app.js - Touch controls → WebSocket client: sends input
static/js/controller.js - Motion controls → WebSocket client: sends motion
static/js/motion.js - WebSocket client → HTTP and WebSocket server: sends events
README.md - HTTP and WebSocket server → Input event router: routes messages
backend/server.py - Input event router → Client and slot manager: resolves client slot
controller/events.py - Input event router → Virtual gamepad output: dispatches gamepad input
controller/events.py - Input event router → Mouse and keyboard output: dispatches mouse input
controller/events.py - Virtual gamepad output → ViGEmBus driver: creates virtual controller
README.md - ViGEmBus driver → Windows and games: exposes XInput
README.md - Mouse and keyboard output → Windows and games: sends mouse and keys
README.md - Layout editor → HTTP and WebSocket server: exchanges layout
README.md - HTTP and WebSocket server → Layout management: routes layout actions
backend/server.py - Layout management → JSON file storage: loads and saves
controller/layout.py - Controller configuration → JSON file storage: uses file storage
controller/config.py - HTTP and WebSocket server → Screen capture and WebRTC: handles stream endpoints
backend/server.py - Phone stream viewer → HTTP and WebSocket server: requests stream
- Screen capture and WebRTC → Phone browser: streams desktop frames
README.md - Monitor page → HTTP and WebSocket server: uses monitor endpoints
README.md