Skip to content

feat: 添加调试选项和虚拟手柄监视器功能#5

Open
w1010tdev wants to merge 9 commits into
mainfrom
copilot/unify-axis-mapping-frontend
Open

feat: 添加调试选项和虚拟手柄监视器功能#5
w1010tdev wants to merge 9 commits into
mainfrom
copilot/unify-axis-mapping-frontend

Conversation

@w1010tdev
Copy link
Copy Markdown
Owner

No description provided.

- Implemented a new joystick type selection in the UI allowing users to choose between Xbox 360 and custom multi-axis joystick modes.
- Added functionality to configure up to 32 custom axes, each with independent source types (gyro or slider), peak values, deadzones, gyro ranges, and inversion options.
- Enhanced the backend to handle custom joystick configurations, including saving and loading settings.
- Updated the frontend to display custom axis configurations and provide real-time feedback on available sliders.
- Created comprehensive documentation for the new custom joystick feature, including setup guides and troubleshooting tips.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds comprehensive custom virtual joystick functionality to the wtxrc project, allowing users to choose between Xbox 360 controller mode and a configurable multi-axis joystick mode (1-32 axes) for use in flight simulation and other scenarios requiring multiple control axes.

Changes:

  • Implemented custom multi-axis virtual joystick support with Windows (vJoy) and Linux (uinput) backends
  • Added Web UI for configuring joystick type, axis count, and per-axis settings (input source, peak value, deadzone, gyro range, invert)
  • Updated configuration system to support both Xbox 360 and custom joystick modes with backward compatibility

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
server/joystick_manager.py Added CustomVirtualJoystick class and extended VirtualJoystick to support custom multi-axis mode
server/app.py Updated API endpoints and gyro/slider handlers to support custom joystick configuration
static/js/main.js Added reactive state management and UI logic for custom joystick configuration
templates/index.html Added UI components for joystick type selection and custom axis configuration table
config/config.py Extended JOYSTICK_CONFIG with custom joystick settings and changed monitor default to False
config/buttons.json Added example custom joystick configuration with 5 axes
requirements.txt Updated with clarified dependencies for Xbox 360 and custom joystick modes
README.md Added documentation for virtual joystick configuration options
CUSTOM_JOYSTICK_GUIDE.md New comprehensive guide for custom joystick feature
QUICK_START_CUSTOM_JOYSTICK.md New quick start examples for custom joystick setup
IMPLEMENTATION_SUMMARY.md New technical implementation summary document
Comments suppressed due to low confidence (1)

server/app.py:179

  • Duplicate exception handlers detected. Lines 168-173 and 175-179 both handle exceptions for the same try block, but the second one is unreachable because the first one will always catch exceptions first. Remove the duplicate exception handler at lines 175-179.
    except Exception as e:
        print(f"[CONFIG] 错误: {e}")
        import traceback
        traceback.print_exc()
        return jsonify({'status': 'error', 'message': str(e)}), 500

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread server/joystick_manager.py Outdated
Comment thread static/js/main.js
Comment on lines +162 to +180
const customAxisConfigList = computed(() => {
const list = [];
for (let i = 0; i < customJoystickAxisCount.value; i++) {
if (!customAxisMapping[i]) {
customAxisMapping[i] = {
source_type: 'none',
source_id: null,
peak_value: 1.0,
deadzone: 0.05,
gyro_range: 90.0,
invert: false
};
}
const cfg = customAxisMapping[i];
cfg.axisIndex = i;
list.push(cfg);
}
return list;
});
Copy link

Copilot AI Jan 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The computed property customAxisConfigList is mutating the reactive object customAxisMapping during computation by initializing missing entries and setting the axisIndex property. This violates Vue's best practices for computed properties, which should be pure and not cause side effects. Consider initializing the axis mappings in a separate initialization function or using a watcher to ensure the mappings exist, rather than doing it in the computed property.

Copilot uses AI. Check for mistakes.
Comment thread server/joystick_manager.py Outdated
Comment on lines +139 to +147
axis_codes = [
uinput.ABS_X, uinput.ABS_Y, uinput.ABS_Z,
uinput.ABS_RX, uinput.ABS_RY, uinput.ABS_RZ,
uinput.ABS_THROTTLE, uinput.ABS_RUDDER,
uinput.ABS_WHEEL, uinput.ABS_GAS, uinput.ABS_BRAKE,
uinput.ABS_HAT0X, uinput.ABS_HAT0Y, uinput.ABS_HAT1X,
uinput.ABS_HAT1Y, uinput.ABS_HAT2X, uinput.ABS_HAT2Y,
uinput.ABS_HAT3X, uinput.ABS_HAT3Y, uinput.ABS_PRESSURE,
]
Copy link

Copilot AI Jan 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The axis_codes list is duplicated in both _init_gamepad() (lines 74-82) and set_axis() (lines 139-147) methods. This duplication violates the DRY principle and makes the code harder to maintain. If the axis mapping needs to be updated, it must be changed in two places. Consider extracting this list as a class constant or a class method to avoid duplication.

Copilot uses AI. Check for mistakes.
Comment thread server/joystick_manager.py Outdated
Comment on lines +180 to +183
# 从配置中读取摇杆类型
if HAS_CONFIG and hasattr(config, 'JOYSTICK_CONFIG'):
self.joystick_type = config.JOYSTICK_CONFIG.get('type', 'xbox360')

Copy link

Copilot AI Jan 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Configuration inconsistency: The VirtualJoystick class reads joystick_type from config.py at initialization (line 182), but the runtime logic in app.py determines the type from buttons.json first, falling back to config.py (line 251 in app.py). This means if a user changes the joystick type in the Web UI and saves it to buttons.json, the change won't take effect until the server is restarted, and the wrong joystick type might be initialized. Consider either: 1) Documenting that server restart is required for joystick type changes, or 2) Making the joystick type hot-swappable by re-initializing the VirtualJoystick when the type changes.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use configs from buttons.json, config.py is jsut a fall back. And pls write the logic of fallback to config.py into READme

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@w1010tdev
Copy link
Copy Markdown
Owner Author

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 18, 2026

@w1010tdev I've opened a new pull request, #6, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 6 commits January 18, 2026 07:08
…d mutation, use buttons.json config priority

Co-authored-by: w1010tdev <246258262+w1010tdev@users.noreply.github.com>
Co-authored-by: w1010tdev <246258262+w1010tdev@users.noreply.github.com>
Co-authored-by: w1010tdev <246258262+w1010tdev@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Address PR review feedback: extract duplicated code, fix Vue reactivity violation, prioritize user config
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.

3 participants