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; menu_chord.a = get_action("menu_toggle_1").first;
plots_toggle_2 = get_action("plots_toggle_2").first; menu_chord.b = get_action("menu_toggle_2").first;
gamepad_chord.a = get_action("gamepad_mode_1").first; gamepad_chord.a = get_action("gamepad_mode_1").first;
gamepad_chord.b = get_action("gamepad_mode_2").first; gamepad_chord.b = get_action("gamepad_mode_2").first;
recenter_left = get_action("recenter_left").first; recenter_left = get_action("recenter_left").first;
@@ -1277,30 +1277,16 @@ void scenes::stream::render(const XrFrameState & frame_state)
read_actions(); 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{ // Arbitrary transitions can happen from network commands
.type = XR_TYPE_ACTION_STATE_GET_INFO, // Ensure we can't have a set of 2 non interactable states
.action = plots_toggle_1, if (is_gui_interactable())
}; next_gui_status = stream_tab::hidden;
else if (is_interactable(stored_gui_status))
XrActionStateBoolean state_1{XR_TYPE_ACTION_STATE_BOOLEAN}; next_gui_status = stored_gui_status;
CHECK_XR(xrGetActionStateBoolean(session, &get_info, &state_1)); else
get_info.action = plots_toggle_2; next_gui_status = stream_tab::applications;
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;
}
} }
query_pool_filled = true; query_pool_filled = true;
@@ -1404,8 +1390,8 @@ scene::meta & scenes::stream::get_meta_scene()
{"right_scroll", XR_ACTION_TYPE_VECTOR2F_INPUT}, {"right_scroll", XR_ACTION_TYPE_VECTOR2F_INPUT},
{"right_haptic", XR_ACTION_TYPE_VIBRATION_OUTPUT}, {"right_haptic", XR_ACTION_TYPE_VIBRATION_OUTPUT},
{"plots_toggle_1", XR_ACTION_TYPE_BOOLEAN_INPUT}, {"menu_toggle_1", XR_ACTION_TYPE_BOOLEAN_INPUT},
{"plots_toggle_2", XR_ACTION_TYPE_BOOLEAN_INPUT}, {"menu_toggle_2", XR_ACTION_TYPE_BOOLEAN_INPUT},
{"gamepad_mode_1", XR_ACTION_TYPE_BOOLEAN_INPUT}, {"gamepad_mode_1", XR_ACTION_TYPE_BOOLEAN_INPUT},
{"gamepad_mode_2", 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_ok", "/user/hand/right/input/a/click"},
{"foveation_cancel", "/user/hand/right/input/b/click"}, {"foveation_cancel", "/user/hand/right/input/b/click"},
{"plots_toggle_1", "/user/hand/left/input/thumbstick/click"}, {"menu_toggle_1", "/user/hand/left/input/thumbstick/click"},
{"plots_toggle_2", "/user/hand/right/input/thumbstick/click"}, {"menu_toggle_2", "/user/hand/right/input/thumbstick/click"},
}, },
}, },
suggested_binding{ suggested_binding{
+1 -2
View File
@@ -103,6 +103,7 @@ private:
// Read actions a and b and determine if they were activated together clicks_needed times in a row // Read actions a and b and determine if they were activated together clicks_needed times in a row
bool check(XrTime now); bool check(XrTime now);
}; };
chord_state menu_chord = {};
chord_state gamepad_chord = {.clicks_needed = 2}; chord_state gamepad_chord = {.clicks_needed = 2};
bool using_frame_gamepad() const bool using_frame_gamepad() const
@@ -203,8 +204,6 @@ private:
thread_safe<std::queue<std::string>> stream_error_queue; thread_safe<std::queue<std::string>> stream_error_queue;
XrAction plots_toggle_1 = XR_NULL_HANDLE;
XrAction plots_toggle_2 = XR_NULL_HANDLE;
XrAction recenter_left = XR_NULL_HANDLE; XrAction recenter_left = XR_NULL_HANDLE;
XrAction recenter_right = XR_NULL_HANDLE; XrAction recenter_right = XR_NULL_HANDLE;
XrAction gui_distance_left = XR_NULL_HANDLE; XrAction gui_distance_left = XR_NULL_HANDLE;