# ediporeboucas/ahkxbox360lib architecture

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

- Interactive diagram: https://gitdiagram.com/ediporeboucas/ahkxbox360lib
- Repository: https://github.com/ediporeboucas/ahkxbox360lib

## Overview

##### Project type and purpose
- This is an open-source AutoHotkey (AHK) library (“XBOX360.ahk”) that exposes an object-oriented API for Xbox 360 controllers.
- Its goal is to let any AHK script easily initialize up to four controllers, read button/axis states, and drive vibration motors.

##### File structure
- Root
- XBOX360.ahk – the single-file library containing all classes (ControllerManager, Controller, etc.)
- README.md – high-level usage examples
- docs
- api.md – detailed API reference for every method/property
- examples
- debug.ahk, poweroff.ahk, readme.ahk – sample scripts showing typical integrations

##### README for additional insights
- Shows how to #Include XBOX360.ahk, instantiate the manager, InitializeController(n), call Update(), and read properties (buttons, sticks, triggers, vibration).
- Implies the library wraps native XInput DLL calls via AHK’s DllCall.

##### Elements
- /Import flow from script → library
- Method calls: script → ControllerManager/Controller → XInput DLL
- Data flow: controller hardware → XInput DLL → Controller.Update() → script
- User script in another (e.g., green)
- OS/driver in gray
- Hardware in orange

##### Final advice
- Be comprehensive: represent every piece of the call chain from AHK script down to native driver and back.
- OOP layering (Manager vs. Controller instances).
- Don’t overcomplicate: focus on the simplest clear separation—script vs. library vs. OS vs. hardware.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% AHK Scripts Layer
    subgraph "AHK Scripts" 
        direction TB
        Debug["debug.ahk (AHK Script)"]:::scripts
        Poweroff["poweroff.ahk (AHK Script)"]:::scripts
        ReadmeScript["readme.ahk (AHK Script)"]:::scripts
    end

    %% Library Layer
    subgraph "XBOX360.ahk Library"
        direction TB
        XBOX360["XBOX360.ahk Library"]:::library
        CM["ControllerManager"]:::library
        C["Controller Instances (0–3)"]:::library
    end

    %% Documentation Layer
    subgraph "Documentation"
        direction TB
        API["API Reference"]:::docs
        README["Usage Overview"]:::docs
    end

    %% OS/Driver Layer
    subgraph "OS / Driver"
        direction TB
        OS["XInput DLL (XINPUT1_4.dll)"]:::os
    end

    %% Hardware Layer
    HW["Xbox 360 Controller"]:::hardware

    %% Relationships
    Debug -->|"#Include"| XBOX360
    Poweroff -->|"#Include"| XBOX360
    ReadmeScript -->|"#Include"| XBOX360

    Debug -->|"InitializeController()/Update()"| CM
    CM -->|"returns Controller object"| C
    C -->|"DllCall XInputGetState/SetState"| OS
    OS -->|"state data / acknowledgments"| C
    C -->|"properties (A, B, X, Y, LT, RT...) "| Debug

    XBOX360 -->|"Documents API"| API
    XBOX360 -->|"Usage examples"| README

    OS -->|"communicates via driver"| HW
    HW -->|"controller input"| OS

    %% Click Events
    click Debug "https://github.com/ediporeboucas/ahkxbox360lib/blob/master/examples/debug.ahk"
    click Poweroff "https://github.com/ediporeboucas/ahkxbox360lib/blob/master/examples/poweroff.ahk"
    click ReadmeScript "https://github.com/ediporeboucas/ahkxbox360lib/blob/master/examples/readme.ahk"
    click XBOX360 "https://github.com/ediporeboucas/ahkxbox360lib/blob/master/XBOX360.ahk"
    click API "https://github.com/ediporeboucas/ahkxbox360lib/blob/master/docs/api.md"
    click README "https://github.com/ediporeboucas/ahkxbox360lib/blob/master/README.md"

    %% Styles
    classDef scripts fill:#e0ffe0,stroke:#2d7,stroke-width:1px
    classDef library fill:#e0f0ff,stroke:#07f,stroke-width:1px
    classDef docs fill:#f9f0ff,stroke:#a0f,stroke-width:1px
    classDef os fill:#f0f0f0,stroke:#999,stroke-width:1px
    classDef hardware fill:#ffe0b3,stroke:#e85,stroke-width:1px
```
