portfolio/GhostHIDe

GhostHIDe

Multi-platform USB HID proxy system with custom 9-bit UART implementation, universal descriptor parsing, and transparent composite device operation.

Zephyr RTOSSTM32Raspberry PiUSB HIDC

Demo Media

Overview

GhostHIDe is a transparent USB HID proxy that intercepts and modifies input device data in real-time. The system sits between USB peripherals (mouse/keyboard) and the host computer, appearing as a standard composite HID device requiring no driver installation.

Built on Zephyr RTOS for embedded platforms, the system uses two CH375 USB controller modules-both operating as USB hosts. One module handles mouse enumeration and data processing, while the other manages keyboard input for hotkey detection and control. This dual-controller architecture enables simultaneous processing of both mouse and keyboard.

Project Goal: Implement custom 9-bit UART protocol implementation on platforms without native 9-bit UART support, enabling reliable command/data differentiation. Create recoil compensation patterns and implement algorithm to apply compensation values to input data.

The universal HID parser dynamically adapts to diverse device formats-validated against real hardware HID descriptors from Zowie, Razer, Logitech, and Raspberry Pi. It handles variable button counts (3-16), axis resolutions (8-bit/16-bit), Report ID detection, and both boot protocol and descriptor-based devices.

Key Achievements

  • Customized Hardware Protocol - Implemented 9-bit UART on STM32F4 via manual register configuration and RP2350 via PIO programs, bypassing Zephyr's limitations
  • Universal Device Support - Parser validated across 5+ manufacturers with diverse descriptor formats, handling edge cases like missing Report IDs and non-standard layouts
  • Unit Testing - 100+ unit tests with mock hardware layer, enabling isolated validation of USB protocol correctness without physical devices
  • Cross-Platform Zephyr HAL - Clean hardware abstraction enabling seamless deployment across STM32F4 and RP2350 with about 600 lines of platform-specific code per target
  • Real-Time Processing - Maintains standard USB HID polling while applying pattern-based compensation algorithms
  • Zero Configuration - Operates as standard composite HID device, transparent to host OS, no custom drivers required

System Architecture

The system operates as a USB man-in-the-middle, with two CH375 modules handling parallel USB host operations. The microcontroller acts as the central processing hub, communicating with both modules via custom 9-bit UART protocol.

Loading graph...

Data Flow

Mouse data undergoes real-time modification-HID reports are parsed, pattern-based compensation is applied when left mouse button is pressed, and modified data is forwarded through the composite device interface. Keyboard data is monitored for hotkey bindings (profile selection, sensitivity adjustment) without modification, maintaining original input for the host system.

Technical Implementation

9-bit UART Protocol

  • STM32F4 - Manual register manipulation
  • RP2350 - Custom PIOASM programs
  • 115200 baud with 9th bit framing
  • Command/Data differentiation (bit 8)
  • Frame sync without overhead

HID Descriptor Parser

  • Collection depth tracking
  • Report ID detection & handling
  • Variable formats - 8/16-bit axes
  • Real device validation

USB Host Stack

  • Device enumeration & reset
  • Multi-packet descriptor retrieval
  • Control transfers with SETUP/DATA/STATUS
  • NAK retry logic with timeouts