Skip to main content

Overview

Ryujinx’s input system provides a flexible abstraction layer for various input devices, mapping host controllers to emulated Switch controllers. The architecture separates device drivers from HLE (High-Level Emulation) services:
Abstraction benefits: Easy to add new input backends, consistent mapping across platforms, flexible configuration

Input Interfaces

Core abstractions from src/Ryujinx.Input/:

IGamepadDriver

IGamepad

GamepadStateSnapshot

Button Mapping

Button enumeration:

SDL3 Driver Implementation

Primary input driver from src/Ryujinx.Input.SDL3/SDL3Gamepad.cs:

State Polling

Face Button Auto-Detection

SDL3 provides button label information:
Smart mapping: Automatically adapts to Xbox (ABXY) vs PlayStation (Cross/Circle/Square/Triangle) layouts

Motion Controls

Gyroscope and accelerometer support:
Motion calibration:

Rumble/Haptics

HD Rumble emulation:

Controller Configuration

User-configurable button mapping:

HID Service Integration

Input data flows to the HID (Human Interface Device) shared memory:

Stick Processing

Deadzone and calibration:
Radial vs axial deadzone:
Pros: Natural feel, preserves all directions equally

Keyboard/Mouse Support

Keyboard input mapped to controller:

Controller Types

Supported controller emulation:

Performance Considerations

Polling Rate

Typical rates:
  • 60 Hz: Most games
  • 120 Hz: Fast-paced games
  • 1000 Hz: Hardware polling
Overhead: Less than 0.1ms per poll

Latency

Input-to-display:
  • USB: 1-4ms
  • Bluetooth: 3-10ms
  • Processing: Less than 1ms
Total: 4-15ms typical

Memory

Per controller:
  • Driver state: Less than 1 KB
  • Rumble queue: ~4 KB
  • Mapping config: Less than 1 KB
Total: ~65 KB per controller

Configuration Example

Debugging Tools

Input Viewer

Visual input overlay:

Input Logging

Log all input events:

Latency Monitor

Measure input latency:

Device Info

Controller capabilities:

HLE Services

HID service implementation

Configuration

Controller setup guide

Troubleshooting

Resolving input issues

Motion Controls

Using motion controls

Source Code Reference

  • src/Ryujinx.Input/IGamepadDriver.cs:9 - Driver interface
  • src/Ryujinx.Input/IGamepad.cs - Gamepad interface
  • src/Ryujinx.Input.SDL3/SDL3Gamepad.cs:14 - SDL3 implementation
  • src/Ryujinx.Input/Motion/ - Motion handling
  • src/Ryujinx.HLE/HOS/Services/Hid/ - HID service