# jameslockman/griffin-powermate-driver architecture

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

- Interactive diagram: https://gitdiagram.com/jameslockman/griffin-powermate-driver
- Repository: https://github.com/jameslockman/griffin-powermate-driver

## Overview

PowerMate Agent turns physical knob and button input into scroll, audio, keystroke, and configured press actions, with menu-bar configuration and automatic per-app overrides. The graph includes the HID driver, settings/UI, audio and LED capabilities, and status presentation. Some helper implementations were indexed or read but their call sites were not shown; those links are omitted rather than inferred.

Main entry points: [`Sources/PowerMateAgent/main.swift`](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/main.swift) (Agent runtime), [`Sources/PowerMateDriver/PowerMateDriver.swift`](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateDriver/PowerMateDriver.swift) (HID driver), [`Sources/PowerMateAgent/Menu.swift`](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/Menu.swift) (Menu controls), [`Sources/PowerMateAgent/AudioControl.swift`](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/AudioControl.swift) (Audio control)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Device Input"]
  node_hid_driver["HID driver"]
  node_device_events["Button and rotation events"]
  node_demo["Driver demo<br/>[main.swift]"]
end

subgraph group_agent["Agent Behavior"]
  node_agent_runtime["Agent runtime<br/>[main.swift]"]
  node_keypress_config["Keypress mode<br/>[KeypressMode.swift]"]
  node_event_posting["Input event posting<br/>[EventPosting.swift]"]
  node_scripts["Script actions"]
  node_audio_control["Audio control<br/>[AudioControl.swift]"]
  node_delegate["App lifecycle<br/>[AppDelegate.swift]"]
  node_update_check["Update check<br/>[UpdateCheck.swift]"]
  node_self_test["Self-test<br/>[SelfTest.swift]"]
end

subgraph group_config["Configuration"]
  node_settings["Settings and actions<br/>[Settings.swift]"]
  node_menu["Menu controls<br/>[Menu.swift]"]
  node_app_overrides["Per-app settings UI"]
  node_override_model["Per-app overrides<br/>[AppOverrides.swift]"]
end

subgraph group_system["System Feedback"]
  node_audio_volume["System volume API<br/>[CAudioVolume.c]"]
  node_audio_meter["Audio VU meter<br/>[AudioMeter.swift]"]
  node_led_control["LED control<br/>[LEDControl.swift]"]
  node_led_usb["USB LED requests"]
  node_status_icon["Menu and Dock icons<br/>[StatusIcon.swift]"]
end

node_person(("Mac user"))
node_powermate["PowerMate"]

node_person -->|"turns or presses"| node_powermate
node_powermate -->|"sends HID reports"| node_hid_driver
node_hid_driver -->|"decodes reports"| node_device_events
node_agent_runtime -->|"starts driver"| node_hid_driver
node_device_events -->|"invokes callbacks"| node_agent_runtime
node_person -->|"configures behavior"| node_menu
node_menu -->|"saves defaults"| node_settings
node_person -->|"sets app options"| node_app_overrides
node_app_overrides -->|"edits overrides"| node_override_model
node_agent_runtime -->|"reads active settings"| node_settings
node_agent_runtime -->|"creates delegate"| node_delegate
node_agent_runtime -.->|"posts input actions"| node_event_posting
node_agent_runtime -.->|"handles keypress mode"| node_keypress_config
node_agent_runtime -.->|"adjusts volume"| node_audio_control
node_audio_control -.->|"sets system volume"| node_audio_volume
node_agent_runtime -.->|"drives VU display"| node_audio_meter
node_agent_runtime -.->|"updates device LED"| node_led_control
node_led_control -.->|"sends LED requests"| node_led_usb
node_agent_runtime -.->|"runs configured scripts"| node_scripts
node_menu -.->|"reflects mode state"| node_status_icon
node_hid_driver -->|"used by demo"| node_demo
node_person -->|"views status"| node_status_icon

click node_agent_runtime "https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/main.swift"
click node_hid_driver "https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateDriver/PowerMateDriver.swift"
click node_device_events "https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateDriver/PowerMateDriver.swift"
click node_settings "https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/Settings.swift"
click node_menu "https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/Menu.swift"
click node_app_overrides "https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/AppOverridesWindow.swift"
click node_override_model "https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/AppOverrides.swift"
click node_keypress_config "https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/KeypressMode.swift"
click node_event_posting "https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/EventPosting.swift"
click node_scripts "https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/ScriptSupport.swift"
click node_audio_control "https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/AudioControl.swift"
click node_audio_volume "https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/CAudioVolume/CAudioVolume.c"
click node_audio_meter "https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/AudioMeter.swift"
click node_led_control "https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/LEDControl.swift"
click node_led_usb "https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/CPowerMateLED/PowerMateLEDControl.c"
click node_status_icon "https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/StatusIcon.swift"
click node_delegate "https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/AppDelegate.swift"
click node_demo "https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateDemo/main.swift"
click node_update_check "https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/UpdateCheck.swift"
click node_self_test "https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/SelfTest.swift"

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_hid_driver,node_device_events,node_demo,node_person toneBlue
class node_agent_runtime,node_keypress_config,node_event_posting,node_scripts,node_audio_control,node_delegate,node_update_check,node_self_test toneAmber
class node_settings,node_menu,node_app_overrides,node_override_model toneMint
class node_audio_volume,node_audio_meter,node_led_control,node_led_usb,node_status_icon toneRose
class node_powermate toneIndigo
```

## Components

### Device Input

- [HID driver](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateDriver/PowerMateDriver.swift): `Sources/PowerMateDriver/PowerMateDriver.swift`
- [Button and rotation events](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateDriver/PowerMateDriver.swift): `Sources/PowerMateDriver/PowerMateDriver.swift`
- [Driver demo](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateDemo/main.swift): `Sources/PowerMateDemo/main.swift`

### Agent Behavior

- [Agent runtime](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/main.swift): `Sources/PowerMateAgent/main.swift`
- [Keypress mode](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/KeypressMode.swift): `Sources/PowerMateAgent/KeypressMode.swift`
- [Input event posting](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/EventPosting.swift): `Sources/PowerMateAgent/EventPosting.swift`
- [Script actions](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/ScriptSupport.swift): `Sources/PowerMateAgent/ScriptSupport.swift`
- [Audio control](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/AudioControl.swift): `Sources/PowerMateAgent/AudioControl.swift`
- [App lifecycle](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/AppDelegate.swift): `Sources/PowerMateAgent/AppDelegate.swift`
- [Update check](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/UpdateCheck.swift): `Sources/PowerMateAgent/UpdateCheck.swift`
- [Self-test](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/SelfTest.swift): `Sources/PowerMateAgent/SelfTest.swift`

### Configuration

- [Settings and actions](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/Settings.swift): `Sources/PowerMateAgent/Settings.swift`
- [Menu controls](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/Menu.swift): `Sources/PowerMateAgent/Menu.swift`
- [Per-app settings UI](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/AppOverridesWindow.swift): `Sources/PowerMateAgent/AppOverridesWindow.swift`
- [Per-app overrides](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/AppOverrides.swift): `Sources/PowerMateAgent/AppOverrides.swift`

### System Feedback

- [System volume API](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/CAudioVolume/CAudioVolume.c): `Sources/CAudioVolume/CAudioVolume.c`
- [Audio VU meter](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/AudioMeter.swift): `Sources/PowerMateAgent/AudioMeter.swift`
- [LED control](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/LEDControl.swift): `Sources/PowerMateAgent/LEDControl.swift`
- [USB LED requests](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/CPowerMateLED/PowerMateLEDControl.c): `Sources/CPowerMateLED/PowerMateLEDControl.c`
- [Menu and Dock icons](https://github.com/jameslockman/griffin-powermate-driver/blob/main/Sources/PowerMateAgent/StatusIcon.swift): `Sources/PowerMateAgent/StatusIcon.swift`

### Other components

- **Mac user**
- **PowerMate**

## Connections

- Mac user → PowerMate: turns or presses (evidence: `README.md`)
- PowerMate → HID driver: sends HID reports (evidence: `Sources/PowerMateDriver/PowerMateDriver.swift`)
- HID driver → Button and rotation events: decodes reports (evidence: `Sources/PowerMateDriver/PowerMateDriver.swift`)
- Agent runtime → HID driver: starts driver (evidence: `Sources/PowerMateAgent/main.swift`)
- Button and rotation events → Agent runtime: invokes callbacks (evidence: `Sources/PowerMateDriver/PowerMateDriver.swift`)
- Mac user → Menu controls: configures behavior (evidence: `README.md`)
- Menu controls → Settings and actions: saves defaults (evidence: `Sources/PowerMateAgent/Menu.swift`)
- Mac user → Per-app settings UI: sets app options (evidence: `README.md`)
- Per-app settings UI → Per-app overrides: edits overrides (evidence: `Sources/PowerMateAgent/AppOverridesWindow.swift`)
- Agent runtime → Settings and actions: reads active settings (evidence: `Sources/PowerMateAgent/main.swift`)
- Agent runtime → App lifecycle: creates delegate (evidence: `Sources/PowerMateAgent/main.swift`)
- Agent runtime → Input event posting: posts input actions
- Agent runtime → Keypress mode: handles keypress mode
- Agent runtime → Audio control: adjusts volume
- Audio control → System volume API: sets system volume
- Agent runtime → Audio VU meter: drives VU display
- Agent runtime → LED control: updates device LED
- LED control → USB LED requests: sends LED requests
- Agent runtime → Script actions: runs configured scripts
- Menu controls → Menu and Dock icons: reflects mode state
- HID driver → Driver demo: used by demo (evidence: `Sources/PowerMateDemo/main.swift`)
- Mac user → Menu and Dock icons: views status (evidence: `README.md`)
