# subhashish-mishra/gamypad architecture

> Architecture diagram of the GitHub repository subhashish-mishra/gamypad, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/subhashish-mishra/gamypad
- Repository: https://github.com/subhashish-mishra/gamypad

## Overview

Gamypad pairs an Android touch controller with a Linux UDP server. The user starts the PC server, scans its QR code or enters its address, connects, and opens the controller; input is streamed over WiFi and exposed to Linux games as an Xbox 360-style device through uinput. The Android app also supports editable layouts, stick deadzone tuning, haptics, digital triggers, and connection monitoring. The graph retains these documented capabilities, but Dart networking and UI call paths were not sampled, so some internal links are dashed and unverified.

Main entry points: [`gamypad_controller/lib/src/ui/view/home_view.dart`](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/ui/view/home_view.dart) (Pairing home), [`gamypad_pc/lib/src/ui/view/home_view.dart`](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_pc/lib/src/ui/view/home_view.dart) (Server controls), [`gamypad_pc/lib/src/transport/udp_socket.dart`](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_pc/lib/src/transport/udp_socket.dart) (UDP server), [`gamypad_controller/lib/src/ui/view/controller_view.dart`](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/ui/view/controller_view.dart) (Controller view)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_phone_ui["Android experience"]
  node_android_app["Android app<br/>[app.dart]"]
  node_home["Pairing home<br/>[home_view.dart]"]
  node_qr_scan["QR scanning<br/>[qr_scan_view.dart]"]
  node_controller_view["Controller view"]
  node_pad_renderer["Pad rendering<br/>[pad_renderer.dart]"]
  node_editor["Layout editor"]
end

subgraph group_phone_runtime["Android runtime"]
  node_layout_state["Layout management"]
  node_layout_store["Layout storage"]
  node_settings["Settings"]
  node_input["Input shaping<br/>[gamepad_input.dart]"]
  node_connection_state["Connection state"]
  node_transport["UDP transport<br/>[udp_transport.dart]"]
  node_target["Connection target"]
end

subgraph group_pc_runtime["Linux runtime"]
  node_pc_app["Linux app<br/>[app.dart]"]
  node_pc_home["Server controls<br/>[home_view.dart]"]
  node_pc_transport["UDP server<br/>[udp_socket.dart]"]
  node_session["Gamepad session"]
  node_device["Device interface"]
  node_ffi["Native bridge<br/>[gamepad_ffi.dart]"]
  node_uinput["uinput device<br/>[Gamepad.cpp]"]
  node_api["Native gamepad API<br/>[GamepadApi.cpp]"]
  node_gamepad_header["Gamepad interface<br/>[Gamepad.h]"]
  node_linux_host["Linux desktop host<br/>[my_application.cc]"]
end

subgraph group_shared["Shared protocol"]
  node_protocol["Message protocol<br/>[messages.dart]"]
end

node_player(("Player"))
node_network(("Local WiFi"))
node_games(("Linux games"))

node_player -->|"pairs from"| node_home
node_player -->|"starts server"| node_pc_home
node_pc_home -.->|"starts server"| node_pc_transport
node_pc_home -->|"shows QR address"| node_target
node_home -->|"opens scanner"| node_qr_scan
node_qr_scan -->|"fills address"| node_target
node_player -->|"opens controller"| node_controller_view
node_controller_view -.->|"renders controls"| node_pad_renderer
node_player -->|"edits layout"| node_editor
node_editor -.->|"configures layout"| node_layout_state
node_layout_state -.->|"persists layout"| node_layout_store
node_player -->|"tunes options"| node_settings
node_controller_view -.->|"streams input"| node_input
node_home -.->|"connects"| node_connection_state
node_connection_state -.->|"sends input"| node_transport
node_transport -->|"sends UDP"| node_network
node_network -->|"delivers UDP"| node_pc_transport
node_pc_transport -.->|"dispatches input"| node_session
node_session -.->|"updates device"| node_device
node_device -.->|"calls native API"| node_ffi
node_ffi -.->|"invokes functions"| node_api
node_api -->|"uses interface"| node_gamepad_header
node_api -->|"creates and updates"| node_uinput
node_uinput -->|"emulates controller"| node_games
node_transport -.->|"encodes messages"| node_protocol
node_pc_transport -.->|"decodes messages"| node_protocol
node_android_app -.->|"hosts"| node_home
node_pc_app -.->|"hosts"| node_pc_home
node_linux_host -->|"hosts Flutter app"| node_pc_app

click node_android_app "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/app.dart"
click node_home "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/ui/view/home_view.dart"
click node_qr_scan "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/ui/view/qr_scan_view.dart"
click node_controller_view "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/ui/view/controller_view.dart"
click node_pad_renderer "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/ui/widgets/pad/pad_renderer.dart"
click node_editor "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/ui/view/controller_editor_view.dart"
click node_layout_state "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/ui/state/layout_controller.dart"
click node_layout_store "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/layout/layout_repository.dart"
click node_settings "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/settings/setting_repository.dart"
click node_input "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/input/gamepad_input.dart"
click node_connection_state "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/ui/state/connection_controller.dart"
click node_transport "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/connection/udp_transport.dart"
click node_target "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/connection/connection_target.dart"
click node_pc_app "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_pc/lib/app.dart"
click node_pc_home "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_pc/lib/src/ui/view/home_view.dart"
click node_pc_transport "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_pc/lib/src/transport/udp_socket.dart"
click node_session "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_pc/lib/src/session/gamepad_session.dart"
click node_device "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_pc/lib/src/device/gamepad_device.dart"
click node_ffi "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_pc/lib/src/device/gamepad_ffi.dart"
click node_uinput "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_pc/native/Gamepad.cpp"
click node_api "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_pc/native/GamepadApi.cpp"
click node_gamepad_header "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_pc/native/Gamepad.h"
click node_linux_host "https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_pc/linux/runner/my_application.cc"
click node_protocol "https://github.com/subhashish-mishra/gamypad/blob/main/protocol/lib/src/messages.dart"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_android_app,node_home,node_qr_scan,node_controller_view,node_pad_renderer,node_editor toneBlue
class node_layout_state,node_layout_store,node_settings,node_input,node_connection_state,node_transport,node_target toneAmber
class node_pc_app,node_pc_home,node_pc_transport,node_session,node_device,node_ffi,node_uinput,node_api,node_gamepad_header,node_linux_host toneMint
class node_protocol toneRose
class node_player,node_network,node_games toneIndigo
```

## Components

### Android experience

- [Android app](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/app.dart): `gamypad_controller/lib/app.dart`
- [Pairing home](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/ui/view/home_view.dart): `gamypad_controller/lib/src/ui/view/home_view.dart`
- [QR scanning](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/ui/view/qr_scan_view.dart): `gamypad_controller/lib/src/ui/view/qr_scan_view.dart`
- [Controller view](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/ui/view/controller_view.dart): `gamypad_controller/lib/src/ui/view/controller_view.dart`
- [Pad rendering](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/ui/widgets/pad/pad_renderer.dart): `gamypad_controller/lib/src/ui/widgets/pad/pad_renderer.dart`
- [Layout editor](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/ui/view/controller_editor_view.dart): `gamypad_controller/lib/src/ui/view/controller_editor_view.dart`

### Android runtime

- [Layout management](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/ui/state/layout_controller.dart): `gamypad_controller/lib/src/ui/state/layout_controller.dart`
- [Layout storage](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/layout/layout_repository.dart): `gamypad_controller/lib/src/layout/layout_repository.dart`
- [Settings](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/settings/setting_repository.dart): `gamypad_controller/lib/src/settings/setting_repository.dart`
- [Input shaping](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/input/gamepad_input.dart): `gamypad_controller/lib/src/input/gamepad_input.dart`
- [Connection state](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/ui/state/connection_controller.dart): `gamypad_controller/lib/src/ui/state/connection_controller.dart`
- [UDP transport](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/connection/udp_transport.dart): `gamypad_controller/lib/src/connection/udp_transport.dart`
- [Connection target](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_controller/lib/src/connection/connection_target.dart): `gamypad_controller/lib/src/connection/connection_target.dart`

### Linux runtime

- [Linux app](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_pc/lib/app.dart): `gamypad_pc/lib/app.dart`
- [Server controls](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_pc/lib/src/ui/view/home_view.dart): `gamypad_pc/lib/src/ui/view/home_view.dart`
- [UDP server](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_pc/lib/src/transport/udp_socket.dart): `gamypad_pc/lib/src/transport/udp_socket.dart`
- [Gamepad session](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_pc/lib/src/session/gamepad_session.dart): `gamypad_pc/lib/src/session/gamepad_session.dart`
- [Device interface](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_pc/lib/src/device/gamepad_device.dart): `gamypad_pc/lib/src/device/gamepad_device.dart`
- [Native bridge](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_pc/lib/src/device/gamepad_ffi.dart): `gamypad_pc/lib/src/device/gamepad_ffi.dart`
- [uinput device](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_pc/native/Gamepad.cpp): `gamypad_pc/native/Gamepad.cpp`
- [Native gamepad API](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_pc/native/GamepadApi.cpp): `gamypad_pc/native/GamepadApi.cpp`
- [Gamepad interface](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_pc/native/Gamepad.h): `gamypad_pc/native/Gamepad.h`
- [Linux desktop host](https://github.com/subhashish-mishra/gamypad/blob/main/gamypad_pc/linux/runner/my_application.cc): `gamypad_pc/linux/runner/my_application.cc`

### Shared protocol

- [Message protocol](https://github.com/subhashish-mishra/gamypad/blob/main/protocol/lib/src/messages.dart): `protocol/lib/src/messages.dart`

### Other components

- **Player**
- **Local WiFi**
- **Linux games**

## Connections

- Player → Pairing home: pairs from (evidence: `README.md`)
- Player → Server controls: starts server (evidence: `README.md`)
- Server controls → UDP server: starts server
- Server controls → Connection target: shows QR address (evidence: `README.md`)
- Pairing home → QR scanning: opens scanner (evidence: `README.md`)
- QR scanning → Connection target: fills address (evidence: `README.md`)
- Player → Controller view: opens controller (evidence: `README.md`)
- Controller view → Pad rendering: renders controls
- Player → Layout editor: edits layout (evidence: `README.md`)
- Layout editor → Layout management: configures layout
- Layout management → Layout storage: persists layout
- Player → Settings: tunes options (evidence: `README.md`)
- Controller view → Input shaping: streams input
- Pairing home → Connection state: connects
- Connection state → UDP transport: sends input
- UDP transport → Local WiFi: sends UDP (evidence: `README.md`)
- Local WiFi → UDP server: delivers UDP (evidence: `README.md`)
- UDP server → Gamepad session: dispatches input
- Gamepad session → Device interface: updates device
- Device interface → Native bridge: calls native API
- Native bridge → Native gamepad API: invokes functions
- Native gamepad API → Gamepad interface: uses interface (evidence: `gamypad_pc/native/GamepadApi.cpp`)
- Native gamepad API → uinput device: creates and updates (evidence: `gamypad_pc/native/GamepadApi.cpp`)
- uinput device → Linux games: emulates controller (evidence: `README.md`)
- UDP transport → Message protocol: encodes messages
- UDP server → Message protocol: decodes messages
- Android app → Pairing home: hosts
- Linux app → Server controls: hosts
- Linux desktop host → Linux app: hosts Flutter app (evidence: `gamypad_pc/linux/runner/my_application.cc`)
