# tascvh/trackpad-is-too-damn-big architecture

> Architecture diagram of the GitHub repository tascvh/trackpad-is-too-damn-big, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tascvh/trackpad-is-too-damn-big
- Repository: https://github.com/tascvh/trackpad-is-too-damn-big

## Overview

##### Project’s Purpose and Scope
- Project Type: A native Linux utility designed to customize and modify trackpad behavior. It works at a low level, intercepting events from the trackpad device and applying custom filters and handling logic.
- Key Features: Cropping out specific areas of the trackpad and controlling how the device responds in those areas, including multitouch gesture recognition.

##### File Structure
- Top-Level Files:
- .gitignore, LICENSE, CMakeLists.txt, README.md: Standard project management files useful for build configuration and licensing.
- Source Files (in the “src” directory):
- main.cpp: Likely the entry point that initializes the application.
- devices.hpp: Provides abstractions or definitions for the trackpad or related hardware.
- evdev_helper.c: Contains low-level functions to interact with the Linux evdev (event device) API, handling input devices.
- event_filters.hpp & event_handlers.hpp: Define functions or classes that implement the logic for filtering trackpad events and performing the necessary adjustments.
- simple_parser.hpp: Likely a lightweight parser for configuration or specifying the exact domains (percentages) that need to be cropped/disabled.

##### Essential Components
a. Main Application Engine:
- Represented by main.cpp. It orchestrates initialization, configuration parsing, and module integration.

b. Configuration & Parsing:
- simple_parser.hpp: Handles input configurations (likely from user parameters or configuration files) that specify how and where the trackpad behavior should be modified.

c. Device Interaction Layer:
- devices.hpp: Abstraction layer for representing the trackpad device.
- evdev_helper.c: Directly interfaces with the Linux evdev subsystem. Illustrate how this component reads raw input events from the trackpad.

d. Event Processing Pipeline:
- event_filters.hpp: Applies custom filters to determine if an event should be modified or dropped based on the restricted areas indicated.
- event_handlers.hpp: Processes the filtered events, then dispatches them in a form that ensures proper multitouch and gesture recognition.

- The Main Application (main.cpp) initializes the system and loads the configuration using the configuration parser.
- It then integrates the Device Interaction Layer, which pulls data directly from the trackpad through evdev_helper.c.
- The raw input events are sent into the Event Processing Pipeline where event_filters and event_handlers are applied sequentially.
- Finally, the processed events are output (or injected back into the system) in way that modifies the trackpad behavior.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Each module (device interface, parser, event filtering, and handling) is handled by dedicated components.
- Pipeline/Flow Architecture: Emphasize a sequential flow where raw events are progressively refined by filters and handlers.
- Modular Design: The structure suggests ease of replacement or modification (e.g., switching out how events are handled without changing device interaction).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Initialization Layer"
        MA["Main Application"]:::init
        CP["Configuration Parser"]:::init
    end

    subgraph "Device Interaction Layer"
        DA["Device Abstraction"]:::device
        EI["evdev Interface"]:::device
    end

    subgraph "Event Processing Pipeline"
        EF["Event Filters"]:::processing
        EH["Event Handlers"]:::processing
    end

    MA -->|"loads"| CP
    MA -->|"initializes"| DA
    DA -->|"invokes"| EI
    EI -->|"sends_raw_events_to"| EF
    EF -->|"passes_filtered_events_to"| EH

    click MA "https://github.com/tascvh/trackpad-is-too-damn-big/blob/main/src/main.cpp"
    click CP "https://github.com/tascvh/trackpad-is-too-damn-big/blob/main/src/simple_parser.hpp"
    click DA "https://github.com/tascvh/trackpad-is-too-damn-big/blob/main/src/devices.hpp"
    click EI "https://github.com/tascvh/trackpad-is-too-damn-big/blob/main/src/evdev_helper.c"
    click EF "https://github.com/tascvh/trackpad-is-too-damn-big/blob/main/src/event_filters.hpp"
    click EH "https://github.com/tascvh/trackpad-is-too-damn-big/blob/main/src/event_handlers.hpp"

    classDef init fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef device fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef processing fill:#FFFFE0,stroke:#000,stroke-width:2px;
```
