refactor menu_toggle

This commit is contained in:
galister
2026-10-27 22:08:23 +01:00
committed by xytovl
parent 1f8e5afcf0
commit f91b68491d
2 changed files with 16 additions and 31 deletions
+15 -29
View File
@@ -563,8 +563,8 @@ void scenes::stream::on_focused()
}
}
plots_toggle_1 = get_action("plots_toggle_1").first;
plots_toggle_2 = get_action("plots_toggle_2").first;
menu_chord.a = get_action("menu_toggle_1").first;
menu_chord.b = get_action("menu_toggle_2").first;
gamepad_chord.a = get_action("gamepad_mode_1").first;
gamepad_chord.b = get_action("gamepad_mode_2").first;
recenter_left = get_action("recenter_left").first;
@@ -1277,30 +1277,16 @@ void scenes::stream::render(const XrFrameState & frame_state)
read_actions();
if (application::get_config().enable_stream_gui)
if (application::get_config().enable_stream_gui and menu_chord.check(instance.now()))
{
XrActionStateGetInfo get_info{
.type = XR_TYPE_ACTION_STATE_GET_INFO,
.action = plots_toggle_1,
};
XrActionStateBoolean state_1{XR_TYPE_ACTION_STATE_BOOLEAN};
CHECK_XR(xrGetActionStateBoolean(session, &get_info, &state_1));
get_info.action = plots_toggle_2;
XrActionStateBoolean state_2{XR_TYPE_ACTION_STATE_BOOLEAN};
CHECK_XR(xrGetActionStateBoolean(session, &get_info, &state_2));
if (state_1.currentState and state_2.currentState and (state_1.changedSinceLastSync or state_2.changedSinceLastSync))
{
// Arbitrary transitions can happen from network commands
// Ensure we can't have a set of 2 non interactable states
if (is_gui_interactable())
next_gui_status = stream_tab::hidden;
else if (is_interactable(stored_gui_status))
next_gui_status = stored_gui_status;
else
next_gui_status = stream_tab::applications;
}
// Arbitrary transitions can happen from network commands
// Ensure we can't have a set of 2 non interactable states
if (is_gui_interactable())
next_gui_status = stream_tab::hidden;
else if (is_interactable(stored_gui_status))
next_gui_status = stored_gui_status;
else
next_gui_status = stream_tab::applications;
}
query_pool_filled = true;
@@ -1404,8 +1390,8 @@ scene::meta & scenes::stream::get_meta_scene()
{"right_scroll", XR_ACTION_TYPE_VECTOR2F_INPUT},
{"right_haptic", XR_ACTION_TYPE_VIBRATION_OUTPUT},
{"plots_toggle_1", XR_ACTION_TYPE_BOOLEAN_INPUT},
{"plots_toggle_2", XR_ACTION_TYPE_BOOLEAN_INPUT},
{"menu_toggle_1", XR_ACTION_TYPE_BOOLEAN_INPUT},
{"menu_toggle_2", XR_ACTION_TYPE_BOOLEAN_INPUT},
{"gamepad_mode_1", XR_ACTION_TYPE_BOOLEAN_INPUT},
{"gamepad_mode_2", XR_ACTION_TYPE_BOOLEAN_INPUT},
@@ -1455,8 +1441,8 @@ scene::meta & scenes::stream::get_meta_scene()
{"foveation_ok", "/user/hand/right/input/a/click"},
{"foveation_cancel", "/user/hand/right/input/b/click"},
{"plots_toggle_1", "/user/hand/left/input/thumbstick/click"},
{"plots_toggle_2", "/user/hand/right/input/thumbstick/click"},
{"menu_toggle_1", "/user/hand/left/input/thumbstick/click"},
{"menu_toggle_2", "/user/hand/right/input/thumbstick/click"},
},
},
suggested_binding{