Skip to content

Add runtime deadzone configuration API#86

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-per-axis-deadzone-api
Draft

Add runtime deadzone configuration API#86
Copilot wants to merge 2 commits intomainfrom
copilot/add-per-axis-deadzone-api

Conversation

Copy link
Contributor

Copilot AI commented Feb 18, 2026

Describe your changes

Deadzones were previously baked into AxisAsButton model definitions. This PR adds runtime deadzone configuration per player/axis.

New API on GameInputPlayer:

  • setDeadzone(path, value) - Configure deadzone at runtime (value: 0.0-1.0)
    • Stick-level: 'leftStick', 'rightStick', 'trigger'
    • Axis-level: 'leftStick.x', 'leftStick.y', 'trigger.left', etc.
  • getDeadzone(path) - Query current deadzone
  • resetDeadzone(path?) - Clear overrides

Implementation:

  • Runtime overrides stored in private Map<string, number>
  • Modified getStickVector(), getNormalizedStickVector(), getNormalizedTriggerValue() to check for overrides before using model defaults
  • Runtime values take precedence; falls back to model-defined deadzones when unset

Example:

const player = gameInput.getPlayer(0);

// Per-stick configuration
player.setDeadzone('leftStick', 0.15);

// Per-axis fine-tuning
player.setDeadzone('leftStick.x', 0.2);
player.setDeadzone('trigger.left', 0.25);

// Query and reset
const dz = player.getDeadzone('leftStick.x');  // 0.2
player.resetDeadzone('leftStick');

Use cases: Accessibility settings, worn controller compensation, precision gaming, per-game preferences.

Describe your testing

Added 23 test cases covering:

  • API validation (bounds checking, invalid paths)
  • Stick/axis-level configuration
  • Integration with getStickVector() and getNormalizedStickVector()
  • Backward compatibility (no runtime overrides)
  • Override priority

All 2177 tests passing. CodeQL scan clean.

Issue ticket number and link

#[issue number]

Checklist before requesting a review

  • I have performed a self-review of my code
  • The code passes lint checks.
  • The code has been tested for regressions of existing features.
  • I have considered adding unit tests for any new code.
Original prompt

This section details on the original issue you should resolve

<issue_title>Add per-axis deadzone configuration API</issue_title>
<issue_description>## Feature Request
Allow developers to set deadzone values for each player/axis at runtime, rather than baking them into AxisAsButton definitions.

Current Limitation

Deadzones are hardcoded in axis definitions:

// src/axis-as-button.js
constructor (direction, axisNum, max = 1, deadZone = 0.25) {
    // ❌ Deadzone is set at model definition time
    this.deadZone = direction === '+' ? deadZone : -deadZone
}

Users cannot adjust sensitivity per-player or at runtime.

Proposed API

// Get player
const player = gameInput.getPlayer(0)

// Set deadzone for entire stick
player.setDeadzone('leftStick', 0.15)

// Set deadzone for individual axis
player.setDeadzone('leftStick.x', 0.2)
player.setDeadzone('leftStick.y', 0.1)

// Get current deadzone
const dz = player.getDeadzone('leftStick')  // Returns 0.15

// Reset to default
player.resetDeadzone('leftStick')

Advanced Options

// Different deadzone shapes
player.setDeadzone('leftStick', {
    threshold: 0.15,
    shape: 'radial'  // or 'axial', 'cross'
})

// Per-player defaults
gameInput.setDefaultDeadzone(0.2)  // All players, all axes

// Save/load user preferences
const prefs = player.getDeadzonePreferences()
localStorage.setItem('deadzones', JSON.stringify(prefs))

Implementation Approach

  1. Add deadzone property to GameInputPlayer
  2. Store per-axis overrides in player state
  3. Apply runtime deadzones in update loop
  4. Maintain backward compatibility with model-defined deadzones

Use Cases

  • Accessibility: Users with motor impairments need custom deadzones
  • Worn controllers: Older controllers with stick drift need larger deadzones
  • Precision gaming: Competitive players want minimal deadzones
  • Per-game settings: Different games need different sensitivities

Example: Settings Menu

// In-game deadzone calibration
function showDeadzoneSettings(playerIndex) {
    const player = gameInput.getPlayer(playerIndex)
    
    slider.oninput = (e) => {
        const value = e.target.value / 100  // 0.0 to 1.0
        player.setDeadzone('leftStick', value)
        updatePreview()
    }
}

Backward Compatibility

  • Default to model-defined deadzones if not overridden
  • Runtime overrides are optional
  • No breaking changes to existing API
    </issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Added setDeadzone(), getDeadzone(), and resetDeadzone() methods to GameInputPlayer
- Support for stick-level (e.g., 'leftStick') and axis-level (e.g., 'leftStick.x') configuration
- Runtime deadzones override model-defined deadzones
- Backward compatible - uses model deadzones when no runtime override set
- Added comprehensive tests with 23 test cases covering all functionality

Co-authored-by: lunarcloud <1565970+lunarcloud@users.noreply.github.com>
Copilot AI changed the title [WIP] Add per-axis deadzone configuration API Add runtime deadzone configuration API Feb 18, 2026
Copilot AI requested a review from lunarcloud February 18, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add per-axis deadzone configuration API

2 participants