Files
novafarma/docs/guides/INPUT_REMAPPING_TESTING.md
2025-12-12 22:46:38 +01:00

10 KiB

🎮 Input Remapping System Testing Guide

📋 Overview

Complete input customization system with:

  • Full keyboard remapping
  • Controller button remapping
  • Multiple control profiles
  • One-handed layouts (left/right)
  • Custom profile saving
  • Import/Export bindings

🎯 Features to Test

1. Basic Input Detection

Test Cases:

  • Keyboard keys are detected correctly
  • Mouse buttons are detected (left, right, middle)
  • Mouse wheel is detected (up/down)
  • Controller buttons are detected (if connected)
  • All input types can be bound to actions

How to Test:

// In browser console (F12):
const inputSystem = game.scene.scenes[1].inputRemapping;

// Check if action is pressed
console.log('Move Up pressed:', inputSystem.isActionPressed('move_up'));
console.log('Attack pressed:', inputSystem.isActionPressed('attack'));
console.log('Interact pressed:', inputSystem.isActionPressed('interact'));

// Check if action was just pressed (single frame)
console.log('Inventory just pressed:', inputSystem.isActionJustPressed('inventory'));

2. Action Rebinding

Test Cases:

  • Can rebind any action to a new key
  • Rebinding shows "Press any key..." prompt
  • ESC cancels rebinding
  • New binding is saved to localStorage
  • Binding persists after page reload

How to Test:

const inputSystem = game.scene.scenes[1].inputRemapping;

// Rebind "interact" action
inputSystem.startRebinding('interact', (action, newKey) => {
    console.log(`Action "${action}" rebound to: ${newKey}`);
});

// Now press any key to rebind
// Press ESC to cancel

// Check new binding
console.log('Interact binding:', inputSystem.getBindingDisplay('interact'));

// Reset to default
inputSystem.resetAction('interact');
console.log('Interact reset:', inputSystem.getBindingDisplay('interact'));

3. Control Profiles

Available Profiles:

  • default: Standard WASD + mouse
  • wasd: WASD movement (same as default)
  • arrows: Arrow keys for movement
  • left-handed: Numpad movement, left-side actions
  • right-handed: Standard WASD (same as default)
  • custom-1: User-defined profile 1
  • custom-2: User-defined profile 2
  • custom-3: User-defined profile 3

Test Cases:

  • Can switch between profiles
  • Profile changes are applied immediately
  • Profile selection is saved
  • Custom profiles can be created
  • Custom profiles persist after reload

How to Test:

const inputSystem = game.scene.scenes[1].inputRemapping;

// List all profiles
console.log('Available profiles:', inputSystem.getProfiles());

// Switch to left-handed profile
inputSystem.switchProfile('left-handed');
console.log('Move Up binding:', inputSystem.getBindingDisplay('move_up'));

// Switch to arrows profile
inputSystem.switchProfile('arrows');
console.log('Move Up binding:', inputSystem.getBindingDisplay('move_up'));

// Switch back to default
inputSystem.switchProfile('default');

// Get current profile
console.log('Current profile:', inputSystem.getCurrentProfile());

4. One-Handed Layouts

Left-Handed Layout:

  • Movement: Numpad (8/5/4/6) or IJKL
  • Actions: Q, W, E, R, T, Y (left side of keyboard)
  • Tools: 7, 8, 9, 0, - (top row)
  • Quick actions: A, S (easy reach)

Right-Handed Layout:

  • Movement: WASD (standard)
  • Actions: E, Space, J (right side)
  • Tools: 1-5 (number row)
  • Quick actions: H, F (right hand)

Test Cases:

  • Left-handed layout uses numpad for movement
  • Right-handed layout uses WASD
  • All actions are reachable with one hand
  • Layouts are comfortable for extended play

How to Test:

const inputSystem = game.scene.scenes[1].inputRemapping;

// Test left-handed layout
inputSystem.switchProfile('left-handed');
console.log('=== LEFT-HANDED LAYOUT ===');
console.log('Move Up:', inputSystem.getBindingDisplay('move_up'));
console.log('Move Down:', inputSystem.getBindingDisplay('move_down'));
console.log('Move Left:', inputSystem.getBindingDisplay('move_left'));
console.log('Move Right:', inputSystem.getBindingDisplay('move_right'));
console.log('Interact:', inputSystem.getBindingDisplay('interact'));
console.log('Attack:', inputSystem.getBindingDisplay('attack'));

// Test right-handed layout
inputSystem.switchProfile('right-handed');
console.log('=== RIGHT-HANDED LAYOUT ===');
console.log('Move Up:', inputSystem.getBindingDisplay('move_up'));
console.log('Interact:', inputSystem.getBindingDisplay('interact'));

5. Custom Profiles

Test Cases:

  • Can save current bindings to custom profile
  • Can load custom profile
  • Custom profiles persist after reload
  • Can have up to 3 custom profiles

How to Test:

const inputSystem = game.scene.scenes[1].inputRemapping;

// Customize some bindings
inputSystem.startRebinding('move_up', () => {});
// Press 'I' key

inputSystem.startRebinding('move_down', () => {});
// Press 'K' key

// Save to custom profile
inputSystem.saveToProfile('custom-1');
console.log('✅ Saved to custom-1');

// Switch to another profile
inputSystem.switchProfile('default');

// Load custom profile
inputSystem.switchProfile('custom-1');
console.log('Move Up:', inputSystem.getBindingDisplay('move_up'));
console.log('Move Down:', inputSystem.getBindingDisplay('move_down'));

6. Import/Export Bindings

Test Cases:

  • Can export bindings as JSON
  • Can import bindings from JSON
  • Import/export preserves all profiles
  • Import/export preserves active profile

How to Test:

const inputSystem = game.scene.scenes[1].inputRemapping;

// Export bindings
const exported = inputSystem.exportBindings();
console.log('Exported bindings:', exported);

// Copy to clipboard (manual step)
// Modify some bindings...

// Import bindings
const success = inputSystem.importBindings(exported);
console.log('Import success:', success);

// Verify bindings are restored
console.log('Current profile:', inputSystem.getCurrentProfile());

7. Controller Support

Test Cases:

  • Controller is detected when connected
  • Controller buttons are mapped correctly
  • Xbox and PlayStation layouts are supported
  • Controller info is displayed

How to Test:

const inputSystem = game.scene.scenes[1].inputRemapping;

// Check if controller is connected
console.log('Controller connected:', inputSystem.isControllerConnected());

// Get controller info
const info = inputSystem.getControllerInfo();
console.log('Controller info:', info);

// Get button names
console.log('A button:', inputSystem.getControllerButtonName('A'));
console.log('Start button:', inputSystem.getControllerButtonName('START'));

8. Binding Display

Test Cases:

  • Key names are formatted correctly
  • Mouse buttons show as "Left Click", etc.
  • Arrow keys show as ↑↓←→
  • Multiple bindings show as "W / ↑"

How to Test:

const inputSystem = game.scene.scenes[1].inputRemapping;

// Get all action bindings
const actions = [
    'move_up', 'move_down', 'move_left', 'move_right',
    'interact', 'attack', 'inventory', 'sprint',
    'zoom_in', 'zoom_out'
];

console.log('=== ALL BINDINGS ===');
actions.forEach(action => {
    console.log(`${action}: ${inputSystem.getBindingDisplay(action)}`);
});

9. Reset Functions

Test Cases:

  • Can reset single action to default
  • Can reset all bindings to default
  • Reset is saved to localStorage

How to Test:

const inputSystem = game.scene.scenes[1].inputRemapping;

// Rebind something
inputSystem.startRebinding('interact', () => {});
// Press 'G' key

console.log('Modified:', inputSystem.getBindingDisplay('interact'));

// Reset single action
inputSystem.resetAction('interact');
console.log('Reset:', inputSystem.getBindingDisplay('interact'));

// Rebind multiple actions...
// Then reset all
inputSystem.resetAllBindings();
console.log('All bindings reset to default');

🎮 Integration Testing

Test All Features Together:

const inputSystem = game.scene.scenes[1].inputRemapping;

// Scenario 1: Left-handed player setup
console.log('=== LEFT-HANDED PLAYER SETUP ===');
inputSystem.switchProfile('left-handed');
console.log('Movement:', inputSystem.getBindingDisplay('move_up'));
inputSystem.saveToProfile('custom-1');

// Scenario 2: Custom bindings
console.log('=== CUSTOM BINDINGS ===');
inputSystem.switchProfile('default');
inputSystem.startRebinding('sprint', (action, key) => {
    console.log(`Sprint rebound to: ${key}`);
});
// Press 'SPACE'

// Scenario 3: Export/Import
console.log('=== EXPORT/IMPORT ===');
const backup = inputSystem.exportBindings();
// Modify bindings...
inputSystem.importBindings(backup);
console.log('Bindings restored from backup');

// Scenario 4: Controller support
console.log('=== CONTROLLER ===');
if (inputSystem.isControllerConnected()) {
    console.log('Controller detected:', inputSystem.getControllerInfo());
} else {
    console.log('No controller connected');
}

📊 Expected Results

Success Criteria:

  1. All keyboard keys can be detected and bound
  2. Mouse buttons and wheel work correctly
  3. Profile switching works instantly
  4. One-handed layouts are comfortable
  5. Custom profiles save and load correctly
  6. Import/export preserves all data
  7. Controller detection works (if connected)
  8. Bindings persist after page reload
  9. Reset functions work correctly
  10. No console errors

Known Issues:

  • None currently

🐛 Bug Reporting

If you find any issues, please report:

  1. What you were testing
  2. What you expected to happen
  3. What actually happened
  4. Console errors (if any)
  5. Steps to reproduce

📝 Default Bindings Reference

Movement:

  • Move Up: W / ↑
  • Move Down: S / ↓
  • Move Left: A / ←
  • Move Right: D / →

Actions:

  • Interact: E / Space
  • Attack: Left Click / J
  • Cancel: Escape / X
  • Confirm: Enter / E

Inventory & UI:

  • Inventory: I / Tab
  • Crafting: C
  • Map: M
  • Quest Log: Q
  • Pause: Escape / P

Tools:

  • Tool 1-5: 1-5 (number keys)

Quick Actions:

  • Quick Heal: H
  • Quick Eat: F
  • Sprint: Shift
  • Crouch: Ctrl

Camera:

  • Zoom In: + / Scroll Up
  • Zoom Out: - / Scroll Down
  • Camera Reset: R

Last Updated: 2025-12-12
Version: 2.5.0
Status: Ready for Testing