mirror of
https://github.com/mitch030504/Wiicompiled_VR_Frame.git
synced 2026-10-06 12:00:29 +02:00
Add USB steering wheel and pedal support
Ported from heurazy's mario-kart-wii-VR-port. F10 > Controllers > USB wheel and pedals (also in the headset panel) picks and calibrates the steering axis and both pedals by moving them, and assigns buttons by pressing them, over raw SDL joysticks: no per-model table or gamepad mapping, and separate pedals, reversed axes and combined pedal axes all calibrate the same way. Settings live in PhysicalWheel.toml beside Config.toml; heurazy's five-button files load unchanged. The wheel is player 1's GameCube controller. In a race it owns port 0 (steering on the stick, the accelerator on A, the brake pedal braking then reversing over A and drift, the paddles on R and L), keeping only the other source's pause and item aim. In menus it adds only deliberate presses. It arms once every pedal and button is released, stays neutral in a race while its setup is incomplete, and nothing is opened until it is enabled. Optional light rumble follows the game's own, capped at 15 %. Added here: its confirm, a new back button and the steering device's first hat (D-pad) work the menus, since our VR controllers default to a Wii Remote and the wheel needs to navigate on its own. Devices SDL classifies as wheels are marked in the list. In the VR cockpit the wheel follows the hardware steering and hand steering steps aside while it drives. README documents setup and Logitech notes (G HUB, the G29's PS3 switch, shifter gears as buttons); not yet tried on a physical wheel. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
131da8a7a9
commit
c11a7c9a61
11 files changed
+923
-7
No files matched your search
@@ -10,6 +10,7 @@
|
||||
#endif
|
||||
|
||||
#include "vr/openxr_input.h"
|
||||
#include "physical_wheel.h"
|
||||
#include "runtime_config.h"
|
||||
#include "vr/mkw_vr_first_person.h"
|
||||
#include "vr/openxr_diagnostics.h"
|
||||
@@ -864,7 +865,11 @@ void OpenXRInput::UpdateDriving(XrTime display_time, const driving::SeatFrame& s
|
||||
wheel_hands[hand] = geometry.ToWheel(wheel_hands[hand]);
|
||||
}
|
||||
}
|
||||
const bool active = hand_steering && !withheld;
|
||||
// A USB wheel drives the race through the GameCube pad: it steers, the
|
||||
// cockpit's wheel shows its angle, and the hands cannot take hold.
|
||||
float hardware_steering = 0.0f;
|
||||
const bool hardware_wheel = physical_wheel::SteeringSnapshot(hardware_steering);
|
||||
const bool active = hand_steering && !withheld && !hardware_wheel;
|
||||
const WheelState wheel = m_wheel.Update(wheel_hands, active, dt,
|
||||
uses_geometry ? geometry.radius : SteeringWheel::Radius,
|
||||
anchor.bike, tuning);
|
||||
@@ -879,10 +884,16 @@ void OpenXRInput::UpdateDriving(XrTime display_time, const driving::SeatFrame& s
|
||||
m_wheel_held = wheel.held;
|
||||
snapshot.held = wheel.held;
|
||||
driving::ApplyHandSteering(hands, wheel);
|
||||
snapshot.steering_input = withheld ? 0.0f : hands[0].stick_x;
|
||||
snapshot.visual_angle =
|
||||
m_wheel_visual.Update(wheel.held[0] || wheel.held[1], wheel.visualAngle, snapshot.steering_input,
|
||||
driving::MaxWheelAngle(anchor.bike, tuning), dt);
|
||||
const float max_angle = driving::MaxWheelAngle(anchor.bike, tuning);
|
||||
if (hardware_wheel) {
|
||||
snapshot.steering_input = std::clamp(hardware_steering, -1.0f, 1.0f);
|
||||
// The hardware wheel is already smooth; follow it directly.
|
||||
snapshot.visual_angle = m_wheel_visual.Update(true, snapshot.steering_input * max_angle, 0.0f, max_angle, dt);
|
||||
} else {
|
||||
snapshot.steering_input = withheld ? 0.0f : hands[0].stick_x;
|
||||
snapshot.visual_angle = m_wheel_visual.Update(wheel.held[0] || wheel.held[1], wheel.visualAngle,
|
||||
snapshot.steering_input, max_angle, dt);
|
||||
}
|
||||
m_driving = snapshot;
|
||||
OpenXRPublishDriving(snapshot);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user