# pccria/alps-trackstick-daemon architecture

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

- Interactive diagram: https://gitdiagram.com/pccria/alps-trackstick-daemon
- Repository: https://github.com/pccria/alps-trackstick-daemon

## Overview

ALPS DualPoint is a Linux daemon that turns trackstick pressure and motion into tap, double-click, drag, and middle-button scrolling actions. Its runtime workflow is device discovery and event handling in the daemon, feature state-machine evaluation, then synthesized output through uinput. Calibration and configuration are distinct supporting workflows. The graph reflects documented capabilities and shown interfaces; some internal event-dispatch details are not visible in the excerpts, so those links are omitted.

Main entry points: [`src/main.c`](https://github.com/pccria/alps-trackstick-daemon/blob/master/src/main.c) (Daemon loop), [`src/features/calibrate.c`](https://github.com/pccria/alps-trackstick-daemon/blob/master/src/features/calibrate.c) (Calibration wizard), [`src/io/device.c`](https://github.com/pccria/alps-trackstick-daemon/blob/master/src/io/device.c) (Device discovery), [`src/features/tap_gesture.c`](https://github.com/pccria/alps-trackstick-daemon/blob/master/src/features/tap_gesture.c) (Tap and drag FSM)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Daemon Runtime"]
  node_main["Daemon loop<br/>[main.c]"]
end

subgraph group_features["Gesture Features"]
  node_calibrate["Calibration wizard<br/>[calibrate.c]"]
  node_tap["Tap and drag FSM<br/>[tap_gesture.c]"]
  node_scroll["Kinetic scroll FSM<br/>[scroll_wheel.c]"]
end

subgraph group_core["Core Logic"]
  node_config["Config parser<br/>[config.c]"]
  node_events["Normalized events<br/>[event.h]"]
  node_actions["Action descriptors<br/>[action.h]"]
end

subgraph group_io["Device I/O"]
  node_device["Device discovery<br/>[device.c]"]
  node_emitter["Virtual event emitter<br/>[emitter.c]"]
end

node_user(("User"))
node_evdev["Trackstick evdev"]
node_uinput["Linux uinput"]
node_config_file["Config file"]
node_systemd["systemd service"]

node_user -->|"configures"| node_main
node_main -->|"parses settings"| node_config
node_config_file -->|"provides settings"| node_config
node_main -->|"finds device"| node_device
node_evdev -->|"provides events"| node_device
node_main -->|"dispatches input"| node_tap
node_main -->|"dispatches input"| node_scroll
node_main -->|"launches wizard"| node_calibrate
node_tap -->|"returns actions"| node_actions
node_scroll -->|"returns actions"| node_actions
node_main -->|"dispatches actions"| node_emitter
node_emitter -->|"emits events"| node_uinput
node_calibrate -->|"samples pressure"| node_evdev
node_calibrate -->|"updates settings"| node_config_file
node_calibrate -->|"offers restart"| node_systemd
node_device -->|"restarts service"| node_systemd
node_device -.->|"adjusts pointer speed"| node_user
node_tap -->|"consumes events"| node_events
node_scroll -->|"consumes events"| node_events

click node_main "https://github.com/pccria/alps-trackstick-daemon/blob/master/src/main.c"
click node_calibrate "https://github.com/pccria/alps-trackstick-daemon/blob/master/src/features/calibrate.c"
click node_tap "https://github.com/pccria/alps-trackstick-daemon/blob/master/src/features/tap_gesture.c"
click node_scroll "https://github.com/pccria/alps-trackstick-daemon/blob/master/src/features/scroll_wheel.c"
click node_config "https://github.com/pccria/alps-trackstick-daemon/blob/master/src/core/config.c"
click node_events "https://github.com/pccria/alps-trackstick-daemon/blob/master/include/core/event.h"
click node_actions "https://github.com/pccria/alps-trackstick-daemon/blob/master/include/core/action.h"
click node_device "https://github.com/pccria/alps-trackstick-daemon/blob/master/src/io/device.c"
click node_emitter "https://github.com/pccria/alps-trackstick-daemon/blob/master/src/io/emitter.c"

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_user toneBlue
class node_calibrate,node_tap,node_scroll toneAmber
class node_config,node_events,node_actions toneMint
class node_device,node_emitter toneRose
class node_evdev,node_uinput,node_config_file,node_systemd toneIndigo
```

## Components

### Daemon Runtime

- [Daemon loop](https://github.com/pccria/alps-trackstick-daemon/blob/master/src/main.c): `src/main.c`

### Gesture Features

- [Calibration wizard](https://github.com/pccria/alps-trackstick-daemon/blob/master/src/features/calibrate.c): `src/features/calibrate.c`
- [Tap and drag FSM](https://github.com/pccria/alps-trackstick-daemon/blob/master/src/features/tap_gesture.c): `src/features/tap_gesture.c`
- [Kinetic scroll FSM](https://github.com/pccria/alps-trackstick-daemon/blob/master/src/features/scroll_wheel.c): `src/features/scroll_wheel.c`

### Core Logic

- [Config parser](https://github.com/pccria/alps-trackstick-daemon/blob/master/src/core/config.c): `src/core/config.c`
- [Normalized events](https://github.com/pccria/alps-trackstick-daemon/blob/master/include/core/event.h): `include/core/event.h`
- [Action descriptors](https://github.com/pccria/alps-trackstick-daemon/blob/master/include/core/action.h): `include/core/action.h`

### Device I/O

- [Device discovery](https://github.com/pccria/alps-trackstick-daemon/blob/master/src/io/device.c): `src/io/device.c`
- [Virtual event emitter](https://github.com/pccria/alps-trackstick-daemon/blob/master/src/io/emitter.c): `src/io/emitter.c`

### Other components

- **User**
- **Trackstick evdev**
- **Linux uinput**
- **Config file**
- **systemd service**

## Connections

- User → Daemon loop: configures (evidence: `README.md`)
- Daemon loop → Config parser: parses settings (evidence: `src/main.c`)
- Config file → Config parser: provides settings (evidence: `src/core/config.c`)
- Daemon loop → Device discovery: finds device (evidence: `src/main.c`)
- Trackstick evdev → Device discovery: provides events
- Daemon loop → Tap and drag FSM: dispatches input (evidence: `README.md`)
- Daemon loop → Kinetic scroll FSM: dispatches input (evidence: `README.md`)
- Daemon loop → Calibration wizard: launches wizard (evidence: `README.md`)
- Tap and drag FSM → Action descriptors: returns actions
- Kinetic scroll FSM → Action descriptors: returns actions
- Daemon loop → Virtual event emitter: dispatches actions (evidence: `src/main.c`)
- Virtual event emitter → Linux uinput: emits events
- Calibration wizard → Trackstick evdev: samples pressure (evidence: `src/features/calibrate.c`)
- Calibration wizard → Config file: updates settings (evidence: `src/features/calibrate.c`)
- Calibration wizard → systemd service: offers restart (evidence: `README.md`)
- Device discovery → systemd service: restarts service (evidence: `src/io/device.c`)
- Device discovery → User: adjusts pointer speed
- Tap and drag FSM → Normalized events: consumes events
- Kinetic scroll FSM → Normalized events: consumes events
