# ihatecsv/controlstadia architecture

> Architecture diagram of the GitHub repository ihatecsv/controlstadia, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ihatecsv/controlstadia
- Repository: https://github.com/ihatecsv/controlstadia

## Overview

##### Main Components

a) Browser Components:
- Chrome Extension Interface
- Content Scripts
- Background Scripts
- Storage System

b) External Components:
- Physical Input Devices (Gamepads, Wheels, etc.)
- Stadia Platform
- Xbox Cloud Platform (secondary support)
- Gamepad Testing Website

##### Key Flows

- Raw input data flow (physical devices → extension)
- Configuration data flow (settings → mapping system)
- Processed input data flow (virtual controller → gaming platforms)
- User interface interactions (settings panel ↔ background processes)

##### Technical Details to Highlight

- Input value ranges ([-1, 1] for axes)
- Transformation calculations (scaling and offset)
- Latency consideration points
- Multiple gamepad support (up to 4 devices)

##### Additional Notes

- The real-time nature of the system
- The transformation pipeline from physical to virtual controls
- The extension's integration with browser APIs
- The configuration flexibility for different input devices

## Diagram (Mermaid)

```mermaid
graph TB
    %% Input Layer
    subgraph InputDevices
        GP["Physical Gamepads"]:::input
        SW["Steering Wheels"]:::input
        FC["Flight Controls"]:::input
    end

    %% Extension Layer
    subgraph ExtensionCore
        BS["Background Script"]:::core
        CM["Control Management"]:::core
        SI["Settings Interface"]:::core
        SL["Settings Logic"]:::core
        CS["Configuration Storage"]:::storage
        MC["Manifest Config"]:::config
    end

    %% Processing Layer
    subgraph TransformationLayer
        IM["Input Mapping System"]:::process
        AS["Axis Scaling/Offset"]:::process
        VG["Virtual Gamepad Creation"]:::process
    end

    %% Output Layer
    subgraph OutputPlatforms
        SP["Stadia Platform"]:::platform
        XC["Xbox Cloud Gaming"]:::platform
        GT["Gamepad Testing Site"]:::platform
    end

    %% Connections
    GP --> BS
    SW --> BS
    FC --> BS
    
    BS --> CM
    CM --> IM
    SI --> SL
    SL --> CS
    CS --> IM
    MC --> BS
    
    IM --> AS
    AS --> VG
    
    VG --> SP
    VG -.-> XC
    VG -.-> GT

    %% Click Events
    click BS "https://github.com/ihatecsv/ControlStadia/blob/master/background.js"
    click CM "https://github.com/ihatecsv/ControlStadia/blob/master/controlstadia.js"
    click SI "https://github.com/ihatecsv/ControlStadia/blob/master/settings.html"
    click SL "https://github.com/ihatecsv/ControlStadia/blob/master/settings.js"
    click MC "https://github.com/ihatecsv/ControlStadia/blob/master/manifest.json"

    %% Styles
    classDef input fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef process fill:#FFD700,stroke:#333,stroke-width:2px
    classDef platform fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef storage fill:#B8860B,stroke:#333,stroke-width:2px
    classDef config fill:#F0E68C,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1["Input Devices"]:::input
        L2["Core Components"]:::core
        L3["Processing"]:::process
        L4["Platforms"]:::platform
        L5["Storage"]:::storage
        L6["Configuration"]:::config
    end
```
