# jays2kings/ds4windows architecture

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

- Interactive diagram: https://gitdiagram.com/jays2kings/ds4windows
- Repository: https://github.com/jays2kings/ds4windows

## Overview

DS4Windows turns DualShock 4 input into an emulated Xbox 360 controller, with configurable mappings and optional keyboard/mouse behavior. The main workflow starts the Windows application, discovers and reads controllers, processes their state and mappings, then sends output through the virtual-controller layer. The UI also manages profiles, controller settings, macros, and special actions. Relationships are limited to those visible in excerpts, the source index, or the README; unsampled implementation details are not inferred.

Main entry points: [`DS4Windows/DS4Control/ControlSerivce.cs`](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Control/ControlSerivce.cs) (Control service), [`DS4Windows/DS4Forms/DS4Form.cs`](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Forms/DS4Form.cs) (Main window), [`DS4Windows/DS4Control/Mapping.cs`](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Control/Mapping.cs) (Button mapping), [`DS4Windows/DS4Library/DS4Device.cs`](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Library/DS4Device.cs) (Controller device)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application and UI"]
  node_program["Application startup<br/>[Program.cs]"]
  node_form["Main window<br/>[DS4Form.cs]"]
  node_settings["Settings and profiles<br/>[Options.cs]"]
  node_macroeditor["Macro editor<br/>[RecordBox.cs]"]
  node_specialactions["Special actions<br/>[SpecActions.cs]"]
end

subgraph group_device["Controller I/O"]
  node_enumeration["Controller discovery<br/>[DS4Devices.cs]"]
  node_hid["HID access<br/>[HidDevice.cs]"]
  node_native["Windows HID APIs<br/>[NativeMethods.cs]"]
  node_controller["Controller device<br/>[DS4Device.cs]"]
  node_state["Controller state<br/>[DS4State.cs]"]
  node_touchpad["Touchpad handling<br/>[DS4Touchpad.cs]"]
end

subgraph group_mapping["Input mapping"]
  node_service["Control service<br/>[ControlSerivce.cs]"]
  node_mappingcore["Button mapping<br/>[Mapping.cs]"]
  node_inputmethods["Keyboard input<br/>[InputMethods.cs]"]
  node_mouse["Mouse behavior<br/>[Mouse.cs]"]
  node_lightbar["Light bar<br/>[DS4LightBar.cs]"]
end

subgraph group_output["Output and actions"]
  node_x360["Xbox 360 output<br/>[X360Device.cs]"]
  node_scp["Virtual bus device<br/>[ScpDevice.cs]"]
  node_scphub["Virtual bus hub<br/>[ScpHub.cs]"]
  node_actions["Input actions<br/>[SpecActions.cs]"]
end

node_user(("Controller user"))
node_windows["Windows"]
node_ds4["DualShock 4"]

node_user -->|"starts"| node_program
node_program -->|"creates"| node_service
node_program -->|"opens"| node_form
node_form -->|"configures"| node_settings
node_form -->|"opens"| node_macroeditor
node_macroeditor -->|"configures"| node_actions
node_form -->|"configures"| node_actions
node_ds4 -->|"is discovered"| node_enumeration
node_enumeration -->|"opens devices"| node_hid
node_hid -->|"calls APIs"| node_native
node_controller -->|"reads reports"| node_hid
node_controller -.->|"updates"| node_state
node_controller -->|"uses"| node_touchpad
node_service -->|"manages devices"| node_enumeration
node_service -->|"processes"| node_controller
node_service -->|"invokes"| node_mappingcore
node_mappingcore -->|"uses"| node_inputmethods
node_mappingcore -->|"uses"| node_mouse
node_mappingcore -->|"uses"| node_lightbar
node_service -->|"updates output"| node_x360
node_x360 -->|"uses device"| node_scp
node_scphub -->|"manages"| node_scp
node_service -->|"reads settings"| node_settings
node_settings -->|"edits actions"| node_actions
node_windows -.->|"provides APIs"| node_native

click node_program "https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/Program.cs"
click node_form "https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Forms/DS4Form.cs"
click node_settings "https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Forms/Options.cs"
click node_macroeditor "https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Forms/RecordBox.cs"
click node_specialactions "https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Forms/SpecActions.cs"
click node_enumeration "https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Library/DS4Devices.cs"
click node_hid "https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/HidLibrary/HidDevice.cs"
click node_native "https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/HidLibrary/NativeMethods.cs"
click node_controller "https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Library/DS4Device.cs"
click node_state "https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Library/DS4State.cs"
click node_touchpad "https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Library/DS4Touchpad.cs"
click node_service "https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Control/ControlSerivce.cs"
click node_mappingcore "https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Control/Mapping.cs"
click node_inputmethods "https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Control/InputMethods.cs"
click node_mouse "https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Control/Mouse.cs"
click node_lightbar "https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Control/DS4LightBar.cs"
click node_x360 "https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Control/X360Device.cs"
click node_scp "https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Control/ScpDevice.cs"
click node_scphub "https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Control/ScpHub.cs"
click node_actions "https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Forms/SpecActions.cs"

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_program,node_form,node_settings,node_macroeditor,node_specialactions,node_user toneBlue
class node_enumeration,node_hid,node_native,node_controller,node_state,node_touchpad toneAmber
class node_service,node_mappingcore,node_inputmethods,node_mouse,node_lightbar toneMint
class node_x360,node_scp,node_scphub,node_actions toneRose
class node_windows,node_ds4 toneIndigo
```

## Components

### Application and UI

- [Application startup](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/Program.cs): `DS4Windows/Program.cs`
- [Main window](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Forms/DS4Form.cs): `DS4Windows/DS4Forms/DS4Form.cs`
- [Settings and profiles](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Forms/Options.cs): `DS4Windows/DS4Forms/Options.cs`
- [Macro editor](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Forms/RecordBox.cs): `DS4Windows/DS4Forms/RecordBox.cs`
- [Special actions](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Forms/SpecActions.cs): `DS4Windows/DS4Forms/SpecActions.cs`

### Controller I/O

- [Controller discovery](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Library/DS4Devices.cs): `DS4Windows/DS4Library/DS4Devices.cs`
- [HID access](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/HidLibrary/HidDevice.cs): `DS4Windows/HidLibrary/HidDevice.cs`
- [Windows HID APIs](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/HidLibrary/NativeMethods.cs): `DS4Windows/HidLibrary/NativeMethods.cs`
- [Controller device](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Library/DS4Device.cs): `DS4Windows/DS4Library/DS4Device.cs`
- [Controller state](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Library/DS4State.cs): `DS4Windows/DS4Library/DS4State.cs`
- [Touchpad handling](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Library/DS4Touchpad.cs): `DS4Windows/DS4Library/DS4Touchpad.cs`

### Input mapping

- [Control service](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Control/ControlSerivce.cs): `DS4Windows/DS4Control/ControlSerivce.cs`
- [Button mapping](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Control/Mapping.cs): `DS4Windows/DS4Control/Mapping.cs`
- [Keyboard input](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Control/InputMethods.cs): `DS4Windows/DS4Control/InputMethods.cs`
- [Mouse behavior](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Control/Mouse.cs): `DS4Windows/DS4Control/Mouse.cs`
- [Light bar](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Control/DS4LightBar.cs): `DS4Windows/DS4Control/DS4LightBar.cs`

### Output and actions

- [Xbox 360 output](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Control/X360Device.cs): `DS4Windows/DS4Control/X360Device.cs`
- [Virtual bus device](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Control/ScpDevice.cs): `DS4Windows/DS4Control/ScpDevice.cs`
- [Virtual bus hub](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Control/ScpHub.cs): `DS4Windows/DS4Control/ScpHub.cs`
- [Input actions](https://github.com/jays2kings/ds4windows/blob/jay/DS4Windows/DS4Forms/SpecActions.cs): `DS4Windows/DS4Forms/SpecActions.cs`

### Other components

- **Controller user**
- **Windows**
- **DualShock 4**

## Connections

- Controller user → Application startup: starts
- Application startup → Control service: creates (evidence: `DS4Windows/Program.cs`)
- Application startup → Main window: opens (evidence: `DS4Windows/Program.cs`)
- Main window → Settings and profiles: configures (evidence: `DS4Windows/DS4Forms/DS4Form.cs`)
- Main window → Macro editor: opens (evidence: `DS4Windows/DS4Forms/DS4Form.cs`)
- Macro editor → Input actions: configures (evidence: `DS4Windows/DS4Forms/RecordBox.cs`)
- Main window → Input actions: configures (evidence: `DS4Windows/DS4Forms/DS4Form.cs`)
- DualShock 4 → Controller discovery: is discovered (evidence: `DS4Windows/DS4Library/DS4Devices.cs`)
- Controller discovery → HID access: opens devices (evidence: `DS4Windows/DS4Library/DS4Devices.cs`)
- HID access → Windows HID APIs: calls APIs (evidence: `DS4Windows/HidLibrary/HidDevice.cs`)
- Controller device → HID access: reads reports (evidence: `DS4Windows/DS4Library/DS4Device.cs`)
- Controller device → Controller state: updates (evidence: `DS4Windows/DS4Library/DS4Device.cs`)
- Controller device → Touchpad handling: uses (evidence: `DS4Windows/DS4Library/DS4Device.cs`)
- Control service → Controller discovery: manages devices (evidence: `DS4Windows/DS4Control/ControlSerivce.cs`)
- Control service → Controller device: processes (evidence: `DS4Windows/DS4Control/ControlSerivce.cs`)
- Control service → Button mapping: invokes (evidence: `DS4Windows/DS4Control/ControlSerivce.cs`)
- Button mapping → Keyboard input: uses (evidence: `DS4Windows/DS4Control/Mapping.cs`)
- Button mapping → Mouse behavior: uses (evidence: `DS4Windows/DS4Control/Mapping.cs`)
- Button mapping → Light bar: uses (evidence: `DS4Windows/DS4Control/Mapping.cs`)
- Control service → Xbox 360 output: updates output (evidence: `DS4Windows/DS4Control/ControlSerivce.cs`)
- Xbox 360 output → Virtual bus device: uses device (evidence: `DS4Windows/DS4Control/X360Device.cs`)
- Virtual bus hub → Virtual bus device: manages (evidence: `DS4Windows/DS4Control/ScpHub.cs`)
- Control service → Settings and profiles: reads settings (evidence: `DS4Windows/DS4Control/ControlSerivce.cs`)
- Settings and profiles → Input actions: edits actions (evidence: `DS4Windows/DS4Forms/Options.cs`)
- Windows → Windows HID APIs: provides APIs
