# Pedals & Gamepad Setup

> Connect and calibrate your racing pedals or gamepad for accurate brake training in Braking Lab.

Braking Lab works with any racing pedals or gamepad that supports the browser's Gamepad API. This guide covers how to connect, calibrate, and configure your hardware for the best training experience.

## Connecting Your Hardware

### Supported Devices

Braking Lab supports any controller compatible with the Gamepad API:

**Racing Pedals**
- Logitech (G29, G923, G Pro pedals, etc.)
- Thrustmaster (T-LCM, T3PA, etc.)
- Fanatec (CSL, ClubSport pedals)
- Heusinkveld
- Simucube
- And many more

**Gamepads**
- PlayStation controllers (DualShock, DualSense)
- Xbox controllers
- Generic USB controllers

### Initial Connection

Connect your hardware:

1. Plug in your racing pedals or gamepad
2. Open Braking Lab
3. Go to **Settings > Hardware**
4. Click **Connect Device**
5. Your browser will request permission
6. Press any button on your device to activate it
7. Device should appear in the connected list

### Permission Requirements

The Gamepad API requires:

- **HTTPS connection** - Braking Lab uses secure connections
- **User interaction** - Press a button to activate the device
- **Browser focus** - Window must be in focus to read input

## Calibration

### Why Calibrate?

Calibration ensures accurate input readings:

- Correct for dead zones in your pedals
- Set proper minimum and maximum ranges
- Account for pedal travel differences
- Compensate for sensor variations

### Calibration Process

**Step 1: Access Calibration**

1. Go to **Settings > Hardware**
2. Select your device
3. Click **Calibrate**

**Step 2: Release Position**

1. Ensure pedals are fully released
2. Click **Set Minimum**
3. The app records your zero position

**Step 3: Full Press**

1. Press the brake pedal fully
2. Hold at maximum pressure
3. Click **Set Maximum**
4. The app records your full range

**Step 4: Test**

1. Press brake pedal gradually
2. Watch the visualization respond
3. Ensure 0% shows when released
4. Ensure 100% shows at full press

### Fine-Tuning

Adjust calibration settings:

| Setting | Description |
|---------|-------------|
| Dead Zone (Min) | Ignore input below this threshold (0-20%) |
| Dead Zone (Max) | Treat as 100% above this threshold (80-100%) |
| Sensitivity Curve | Linear, Progressive, or Custom |
| Invert Axis | Flip input direction if pedal reads reversed |

### Sensitivity Curves

Choose how input is mapped:

**Linear**
- 1:1 mapping of pedal position to brake value
- Best for load cell pedals

**Progressive**
- Softer response at low pressure
- More resolution at high pressure
- Good for potentiometer pedals

**Custom**
- Draw your own response curve
- Fine-tune to your preference

## Real-Time Visualization

### Pedal Indicator

View real-time input during exercises:

- **Brake gauge** - Shows current brake pressure
- **Throttle gauge** - Shows throttle position (if enabled)
- **Numerical value** - Exact percentage display
- **History trace** - Recent input shown as a trail

### Visualization Options

Customize the display:

- Show/hide specific gauges
- Choose bar or circular visualization
- Adjust size and position
- Set colors for different input levels

## Multiple Devices

### Using Multiple Controllers

If you have multiple devices connected:

1. Connect all devices
2. Go to **Settings > Hardware**
3. Select which device to use for brake input
4. Configure each device independently

### Device Priority

Set which device to use:

1. Click **Set as Primary** on preferred device
2. Braking Lab will use this device for exercises
3. Switch devices anytime from Settings

## Troubleshooting

### Device Not Detected

**Check connections:**
- Ensure USB cable is securely connected
- Try a different USB port
- Test device in other applications

**Browser issues:**
- Use Chrome, Edge, or Firefox (Safari has limited support)
- Ensure browser is up to date
- Try a private/incognito window

**Permission issues:**
- Click inside the Braking Lab window
- Press a button on your device
- Check browser permissions in settings

### Incorrect Readings

**Input seems reversed:**
- Enable **Invert Axis** in calibration settings

**Values don't reach 0% or 100%:**
- Recalibrate with full pedal travel
- Adjust dead zone settings

**Jumpy or unstable readings:**
- Increase dead zone slightly
- Check for hardware issues
- Update device drivers

### Input Stops Working

**Window loses focus:**
- Gamepad API only works when browser is focused
- Click back into the Braking Lab window

**Device disconnected:**
- Check USB connection
- Reconnect and re-enable in Settings

### Browser-Specific Issues

**Chrome:**
- Generally best Gamepad API support
- Ensure site permissions allow gamepad access

**Firefox:**
- Good support, may need `dom.gamepad.enabled` in about:config

**Safari:**
- Limited Gamepad API support
- Use Chrome or Firefox for best experience

**Edge:**
- Same support as Chrome (Chromium-based)

## Tips for Best Results

### Hardware Setup

- Use dedicated racing pedals for best accuracy
- Load cell pedals provide most realistic feedback
- Ensure stable mounting for consistent input
- Calibrate periodically as hardware wears

### During Exercises

- Maintain consistent seating position
- Apply pressure smoothly
- Use the real-time visualization to verify input
- If readings seem off, recalibrate

### Maintenance

- Clean pedal sensors periodically
- Update device firmware when available
- Recalibrate after hardware adjustments
- Test calibration before important practice sessions
