# krisgfx9/wireless-device-battery-monitor architecture

> Architecture diagram of the GitHub repository krisgfx9/wireless-device-battery-monitor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/krisgfx9/wireless-device-battery-monitor
- Repository: https://github.com/krisgfx9/wireless-device-battery-monitor

## Overview

Wireless Battery polls supported wireless devices and presents their battery state in a taskbar widget or system tray, with refresh and device-change handling. Its shared polling layer dispatches to vendor-specific HID drivers and produces a common device-status model; platform entry points provide Windows and Linux presentation. Other documented capabilities include translations, brand-colored display, diagnostic output, and an opt-in device-support request. Driver and UI details are represented at subsystem level where the excerpts do not show individual dispatches; edges are limited to documented or indexed relationships.

Main entry points: [`src/main.cpp`](https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/main.cpp) (Windows app), [`src/devices.cpp`](https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/devices.cpp) (Poll coordinator), [`src/drivers`](https://github.com/krisgfx9/wireless-device-battery-monitor/tree/main/src/drivers) (Vendor drivers), [`src/linux/main_linux.cpp`](https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/linux/main_linux.cpp) (Linux app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_win["Windows app<br/>[main.cpp]"]
  node_linux["Linux app<br/>[main_linux.cpp]"]
end

subgraph group_polling["Device polling"]
  node_status["Device status<br/>[devices.h]"]
  node_poller["Poll coordinator<br/>[devices.cpp]"]
  node_drivers["Vendor drivers"]
  node_hid["HID access<br/>[hid.cpp]"]
  node_linuxhid["Linux HID<br/>[hid_linux.cpp]"]
  node_linuxdev["Linux device scan<br/>[devices_linux.cpp]"]
  node_headset["HeadsetControl driver<br/>[headsetcontrol.cpp]"]
  node_generic["Generic drivers<br/>[generic.cpp]"]
  node_mouse["Mouse drivers<br/>[misc_mice.cpp]"]
  node_steam["Steam controller"]
end

subgraph group_presentation["Presentation"]
  node_widget["Taskbar widget<br/>[widget.cpp]"]
  node_tray["Tray display<br/>[main.cpp]"]
  node_brands["Brand colors<br/>[brands.cpp]"]
  node_labels["Device labels<br/>[labels.cpp]"]
  node_translations["Translations<br/>[i18n.cpp]"]
end

subgraph group_support["Device support"]
  node_report["Support report<br/>[report.cpp]"]
  node_request_service["Request service"]
end

node_user(("User"))

node_user -->|"uses"| node_win
node_user -->|"uses"| node_linux
node_win -->|"polls devices"| node_poller
node_linux -->|"polls devices"| node_poller
node_poller -->|"returns statuses"| node_status
node_poller -->|"dispatches polling"| node_drivers
node_poller -->|"enumerates HID"| node_hid
node_linux -->|"uses device scan"| node_linuxdev
node_linuxdev -->|"uses HID"| node_linuxhid
node_steam -->|"opens and reads"| node_hid
node_win -->|"updates widget"| node_widget
node_win -->|"manages tray"| node_tray
node_win -->|"opens support"| node_report
node_win -->|"uses labels"| node_labels
node_win -->|"uses translations"| node_translations
node_widget -->|"uses colors"| node_brands
node_report -->|"posts request"| node_request_service
node_report -->|"scans collections"| node_hid
node_drivers -.->|"includes support"| node_headset
node_drivers -.->|"includes fallback"| node_generic
node_drivers -.->|"includes protocols"| node_mouse

click node_win "https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/main.cpp"
click node_linux "https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/linux/main_linux.cpp"
click node_status "https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/devices.h"
click node_poller "https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/devices.cpp"
click node_drivers "https://github.com/krisgfx9/wireless-device-battery-monitor/tree/main/src/drivers"
click node_hid "https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/hid.cpp"
click node_linuxhid "https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/linux/hid_linux.cpp"
click node_linuxdev "https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/linux/devices_linux.cpp"
click node_widget "https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/widget.cpp"
click node_tray "https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/main.cpp"
click node_brands "https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/brands.cpp"
click node_labels "https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/labels.cpp"
click node_translations "https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/i18n.cpp"
click node_report "https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/report.cpp"
click node_headset "https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/drivers/headsetcontrol.cpp"
click node_generic "https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/drivers/generic.cpp"
click node_mouse "https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/drivers/misc_mice.cpp"
click node_steam "https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/drivers/steam_controller.cpp"

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_win,node_linux,node_user toneBlue
class node_status,node_poller,node_drivers,node_hid,node_linuxhid,node_linuxdev,node_headset,node_generic,node_mouse,node_steam toneAmber
class node_widget,node_tray,node_brands,node_labels,node_translations toneMint
class node_report,node_request_service toneRose
```

## Components

### Application

- [Windows app](https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/main.cpp): `src/main.cpp`
- [Linux app](https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/linux/main_linux.cpp): `src/linux/main_linux.cpp`

### Device polling

- [Device status](https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/devices.h): `src/devices.h`
- [Poll coordinator](https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/devices.cpp): `src/devices.cpp`
- [Vendor drivers](https://github.com/krisgfx9/wireless-device-battery-monitor/tree/main/src/drivers): `src/drivers`
- [HID access](https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/hid.cpp): `src/hid.cpp`
- [Linux HID](https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/linux/hid_linux.cpp): `src/linux/hid_linux.cpp`
- [Linux device scan](https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/linux/devices_linux.cpp): `src/linux/devices_linux.cpp`
- [HeadsetControl driver](https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/drivers/headsetcontrol.cpp): `src/drivers/headsetcontrol.cpp`
- [Generic drivers](https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/drivers/generic.cpp): `src/drivers/generic.cpp`
- [Mouse drivers](https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/drivers/misc_mice.cpp): `src/drivers/misc_mice.cpp`
- [Steam controller](https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/drivers/steam_controller.cpp): `src/drivers/steam_controller.cpp`

### Presentation

- [Taskbar widget](https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/widget.cpp): `src/widget.cpp`
- [Tray display](https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/main.cpp): `src/main.cpp`
- [Brand colors](https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/brands.cpp): `src/brands.cpp`
- [Device labels](https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/labels.cpp): `src/labels.cpp`
- [Translations](https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/i18n.cpp): `src/i18n.cpp`

### Device support

- [Support report](https://github.com/krisgfx9/wireless-device-battery-monitor/blob/main/src/report.cpp): `src/report.cpp`
- **Request service**

### Other components

- **User**

## Connections

- User → Windows app: uses
- User → Linux app: uses
- Windows app → Poll coordinator: polls devices (evidence: `src/main.cpp`)
- Linux app → Poll coordinator: polls devices (evidence: `src/linux/main_linux.cpp`)
- Poll coordinator → Device status: returns statuses (evidence: `src/devices.cpp`)
- Poll coordinator → Vendor drivers: dispatches polling (evidence: `src/devices.cpp`)
- Poll coordinator → HID access: enumerates HID (evidence: `src/devices.cpp`)
- Linux app → Linux device scan: uses device scan (evidence: `src/linux/main_linux.cpp`)
- Linux device scan → Linux HID: uses HID (evidence: `src/linux/devices_linux.cpp`)
- Steam controller → HID access: opens and reads (evidence: `src/drivers/steam_controller.cpp`)
- Windows app → Taskbar widget: updates widget (evidence: `src/main.cpp`)
- Windows app → Tray display: manages tray (evidence: `src/main.cpp`)
- Windows app → Support report: opens support (evidence: `src/main.cpp`)
- Windows app → Device labels: uses labels (evidence: `src/main.cpp`)
- Windows app → Translations: uses translations (evidence: `src/main.cpp`)
- Taskbar widget → Brand colors: uses colors
- Support report → Request service: posts request (evidence: `src/report.cpp`)
- Support report → HID access: scans collections (evidence: `src/report.cpp`)
- Vendor drivers → HeadsetControl driver: includes support (evidence: `src/drivers/headsetcontrol.cpp`)
- Vendor drivers → Generic drivers: includes fallback (evidence: `src/drivers/generic.cpp`)
- Vendor drivers → Mouse drivers: includes protocols (evidence: `src/drivers/misc_mice.cpp`)
