# keidan/asus-touchpad-numpad architecture

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

- Interactive diagram: https://gitdiagram.com/keidan/asus-touchpad-numpad
- Repository: https://github.com/keidan/asus-touchpad-numpad

## Overview

This is a Linux userspace driver that turns supported ASUS touchpads into configurable numpad overlays. At startup it locates or creates the adjacent configuration, resolves a layout and keymap, and identifies the touchpad; the driver then processes touch gestures and coordinates, emits virtual key events, and controls backlight brightness. The graph also preserves layout defaults and keyboard-layout detection. Main runtime relationships are supported by the excerpts, SOURCE INDEX references, or README; unsampled touchpad details are represented only where the README documents them.

Main entry points: [`src/main.rs`](https://github.com/keidan/asus-touchpad-numpad/blob/master/src/main.rs) (Application startup), [`src/sys/touchpad.rs`](https://github.com/keidan/asus-touchpad-numpad/blob/master/src/sys/touchpad.rs) (Touchpad event driver), [`src/config/models.rs`](https://github.com/keidan/asus-touchpad-numpad/blob/master/src/config/models.rs) (Config and layout), [`src/config/parser.rs`](https://github.com/keidan/asus-touchpad-numpad/blob/master/src/config/parser.rs) (JSON parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Startup and configuration"]
  node_main["Application startup<br/>[main.rs]"]
  node_defaults["Bundled layouts<br/>[defaults.rs]"]
  node_parser["JSON parser<br/>[parser.rs]"]
  node_models["Config and layout<br/>[models.rs]"]
end

subgraph group_input["Device detection"]
  node_proc["Input device scan<br/>[proc.rs]"]
end

subgraph group_driver["Touchpad driver"]
  node_touchpad["Touchpad event driver<br/>[touchpad.rs]"]
end

subgraph group_support["Runtime support"]
  node_utils["System utilities<br/>[utils.rs]"]
  node_keyboard["Keyboard layout detection<br/>[keyboard.rs]"]
  node_logger["Application logger<br/>[logger.rs]"]
end

node_user(("Driver user"))
node_configfile["Adjacent config"]
node_procfs["Linux input registry"]
node_dmi["DMI board identity"]
node_rawinput["Touchpad input device"]
node_virtualkeys["Virtual key device"]
node_i2c["I2C backlight controller"]
node_calculator["System calculator"]

node_user -->|"starts"| node_main
node_main -->|"creates if missing"| node_configfile
node_main -->|"requests defaults"| node_defaults
node_defaults -->|"writes JSON"| node_configfile
node_main -->|"loads configuration"| node_parser
node_parser -->|"reads JSON"| node_configfile
node_parser -->|"deserializes into"| node_models
node_main -->|"selects and validates"| node_models
node_models -->|"detects auto layout"| node_utils
node_utils -->|"reads board name"| node_dmi
node_main -->|"scans for touchpad"| node_proc
node_proc -->|"reads device entries"| node_procfs
node_main -->|"initializes and runs"| node_touchpad
node_main -->|"configures logging"| node_logger
node_touchpad -->|"uses layout settings"| node_models
node_touchpad -->|"reads touch events"| node_rawinput
node_touchpad -->|"emits key events"| node_virtualkeys
node_touchpad -->|"controls backlight"| node_i2c
node_touchpad -->|"launches on zone tap"| node_calculator
node_touchpad -->|"uses layout detection"| node_keyboard

click node_main "https://github.com/keidan/asus-touchpad-numpad/blob/master/src/main.rs"
click node_defaults "https://github.com/keidan/asus-touchpad-numpad/blob/master/src/config/defaults.rs"
click node_parser "https://github.com/keidan/asus-touchpad-numpad/blob/master/src/config/parser.rs"
click node_models "https://github.com/keidan/asus-touchpad-numpad/blob/master/src/config/models.rs"
click node_proc "https://github.com/keidan/asus-touchpad-numpad/blob/master/src/sys/proc.rs"
click node_utils "https://github.com/keidan/asus-touchpad-numpad/blob/master/src/sys/utils.rs"
click node_touchpad "https://github.com/keidan/asus-touchpad-numpad/blob/master/src/sys/touchpad.rs"
click node_keyboard "https://github.com/keidan/asus-touchpad-numpad/blob/master/src/sys/keyboard.rs"
click node_logger "https://github.com/keidan/asus-touchpad-numpad/blob/master/src/logger.rs"

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_main,node_defaults,node_parser,node_models,node_user toneBlue
class node_proc toneAmber
class node_touchpad toneMint
class node_utils,node_keyboard,node_logger toneRose
class node_configfile,node_procfs,node_dmi,node_rawinput,node_virtualkeys,node_i2c,node_calculator toneIndigo
```

## Components

### Startup and configuration

- [Application startup](https://github.com/keidan/asus-touchpad-numpad/blob/master/src/main.rs): `src/main.rs`
- [Bundled layouts](https://github.com/keidan/asus-touchpad-numpad/blob/master/src/config/defaults.rs): `src/config/defaults.rs`
- [JSON parser](https://github.com/keidan/asus-touchpad-numpad/blob/master/src/config/parser.rs): `src/config/parser.rs`
- [Config and layout](https://github.com/keidan/asus-touchpad-numpad/blob/master/src/config/models.rs): `src/config/models.rs`

### Device detection

- [Input device scan](https://github.com/keidan/asus-touchpad-numpad/blob/master/src/sys/proc.rs): `src/sys/proc.rs`

### Touchpad driver

- [Touchpad event driver](https://github.com/keidan/asus-touchpad-numpad/blob/master/src/sys/touchpad.rs): `src/sys/touchpad.rs`

### Runtime support

- [System utilities](https://github.com/keidan/asus-touchpad-numpad/blob/master/src/sys/utils.rs): `src/sys/utils.rs`
- [Keyboard layout detection](https://github.com/keidan/asus-touchpad-numpad/blob/master/src/sys/keyboard.rs): `src/sys/keyboard.rs`
- [Application logger](https://github.com/keidan/asus-touchpad-numpad/blob/master/src/logger.rs): `src/logger.rs`

### Other components

- **Driver user**
- **Adjacent config**
- **Linux input registry**
- **DMI board identity**
- **Touchpad input device**
- **Virtual key device**
- **I2C backlight controller**
- **System calculator**

## Connections

- Driver user → Application startup: starts (evidence: `README.md`)
- Application startup → Adjacent config: creates if missing (evidence: `src/main.rs`)
- Application startup → Bundled layouts: requests defaults (evidence: `src/main.rs`)
- Bundled layouts → Adjacent config: writes JSON (evidence: `src/config/defaults.rs`)
- Application startup → JSON parser: loads configuration (evidence: `src/main.rs`)
- JSON parser → Adjacent config: reads JSON (evidence: `src/config/parser.rs`)
- JSON parser → Config and layout: deserializes into (evidence: `src/config/parser.rs`)
- Application startup → Config and layout: selects and validates (evidence: `src/main.rs`)
- Config and layout → System utilities: detects auto layout (evidence: `src/config/parser.rs`)
- System utilities → DMI board identity: reads board name (evidence: `src/sys/utils.rs`)
- Application startup → Input device scan: scans for touchpad (evidence: `src/main.rs`)
- Input device scan → Linux input registry: reads device entries (evidence: `src/sys/proc.rs`)
- Application startup → Touchpad event driver: initializes and runs (evidence: `src/main.rs`)
- Application startup → Application logger: configures logging (evidence: `src/main.rs`)
- Touchpad event driver → Config and layout: uses layout settings (evidence: `src/sys/touchpad.rs`)
- Touchpad event driver → Touchpad input device: reads touch events (evidence: `README.md`)
- Touchpad event driver → Virtual key device: emits key events (evidence: `README.md`)
- Touchpad event driver → I2C backlight controller: controls backlight (evidence: `README.md`)
- Touchpad event driver → System calculator: launches on zone tap (evidence: `README.md`)
- Touchpad event driver → Keyboard layout detection: uses layout detection (evidence: `src/sys/touchpad.rs`)
