mirror of
https://github.com/mitch030504/Wiicompiled_VR_Frame.git
synced 2026-10-06 09:00:28 +02:00
Refactor OpenXR controller input handling and update settings panel interactions
This commit is contained in:
1 parent
60c443654f
commit
e681294709
11 files changed
+163
-95
No files matched your search
@@ -1240,7 +1240,8 @@ void DrawVrSettings() {
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) {
|
||||
ImGui::SetTooltip(
|
||||
"Opens these settings on a panel in front of you, in menus and races alike.\n"
|
||||
"In the headset, clicking both thumbsticks together opens and closes it too.\n"
|
||||
"In the headset, left Y opens and closes it too (with Gamepad VR controllers,\n"
|
||||
"click both thumbsticks together instead).\n"
|
||||
"Aim at it and pull a trigger to change a setting; push a thumbstick to scroll.\n"
|
||||
"While it is open the game does not see the VR controllers.");
|
||||
}
|
||||
@@ -1253,8 +1254,8 @@ void DrawVrSettings() {
|
||||
ImGui::SetTooltip(
|
||||
"Wii Remote + Nunchuk: the right controller is a Wii Remote, with motion and a pointer "
|
||||
"that lands where you aim on the virtual screen; the left one is the Nunchuk.\n"
|
||||
" Right: A = A, trigger = B, stick up/down = 1/2, stick left/right = -/+\n"
|
||||
" Left: stick = Nunchuk stick, trigger = Z, grip = C, menu = HOME\n"
|
||||
" Right: A = A, trigger = B, stick up/down = 1/2\n"
|
||||
" Left: stick = Nunchuk stick, trigger = Z, grip = C, X = -, menu = +, Y = settings panel\n"
|
||||
"Gamepad: both controllers are one ordinary controller, read as a GameCube pad.\n"
|
||||
"Applies immediately; the game sees the controller change as a reconnection.");
|
||||
}
|
||||
@@ -1967,7 +1968,10 @@ void DrawVrSettingsPanelWindow() {
|
||||
mkw::vr::OpenXRSetSettingsPanelOpen(false);
|
||||
}
|
||||
ImGui::TextDisabled("Aim and pull a trigger to change a setting, push a thumbstick to scroll.");
|
||||
ImGui::TextDisabled("Click both thumbsticks or press Menu to close. The game does not see the controllers meanwhile.");
|
||||
ImGui::TextDisabled("%s to close. The game does not see the controllers meanwhile.",
|
||||
mkw::vr::OpenXRGetControllerMode() == mkw::vr::OpenXRControllerMode::WiiRemote
|
||||
? "Press left Y or Menu"
|
||||
: "Click both thumbsticks or press Menu");
|
||||
ImGui::Separator();
|
||||
if (ImGui::BeginTabBar("Settings")) {
|
||||
const auto tab = [](const char* label, void (*draw)()) {
|
||||
|
||||
@@ -40,9 +40,10 @@ namespace {
|
||||
// A new sequence number holds the button for kInjectHoldFrames XR frames.
|
||||
// Buttons: a, b, x, y, start, up, down, left, right, and for the Wii Remote
|
||||
// presentation also home, c and z (x/y/start press 1/2/+ there, and the
|
||||
// directions push the Nunchuk stick). `panel` clicks both thumbsticks, opening
|
||||
// or closing the settings panel, where `a` then selects. The property is unset
|
||||
// in normal use, so this costs one property read every few frames.
|
||||
// directions push the Nunchuk stick). `panel` presses the settings panel's
|
||||
// button (left Y, or both thumbsticks for a gamepad), opening or closing it,
|
||||
// where `a` then selects. The property is unset in normal use, so this costs
|
||||
// one property read every few frames.
|
||||
constexpr uint32_t kInjectHoldFrames = 12;
|
||||
constexpr uint32_t kInjectPollFrames = 4;
|
||||
|
||||
@@ -594,6 +595,8 @@ void OpenXRInput::Sync(XrTime predicted_display_time, const OpenXRPointerScreen&
|
||||
m_last_input_time = input_time;
|
||||
std::array<wii_remote::HandInputs, kHands> panel_hands = hands;
|
||||
if (Injected("panel")) {
|
||||
// The panel button in either controller mode.
|
||||
panel_hands[0].secondary = true;
|
||||
panel_hands[0].thumbstick_click = true;
|
||||
panel_hands[1].thumbstick_click = true;
|
||||
}
|
||||
@@ -604,7 +607,8 @@ void OpenXRInput::Sync(XrTime predicted_display_time, const OpenXRPointerScreen&
|
||||
// is written back.
|
||||
const bool was_open = OpenXRSettingsPanelOpen();
|
||||
bool open = was_open;
|
||||
const settings_panel::Frame panel = m_panel_controls.Update(panel_hands, open, dt_seconds);
|
||||
const settings_panel::Frame panel =
|
||||
m_panel_controls.Update(panel_hands, open, dt_seconds, OpenXRGetControllerMode());
|
||||
// Pointer first: the game thread reads it as soon as it sees the panel open.
|
||||
PublishSettingsPanel(input_time, settings_panel, panel);
|
||||
if (open != was_open) {
|
||||
|
||||
Reference in new issue
Block a user