refactor menu_toggle
This commit is contained in:
+15
-29
@@ -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{
|
||||
|
||||
@@ -103,6 +103,7 @@ private:
|
||||
// Read actions a and b and determine if they were activated together clicks_needed times in a row
|
||||
bool check(XrTime now);
|
||||
};
|
||||
chord_state menu_chord = {};
|
||||
chord_state gamepad_chord = {.clicks_needed = 2};
|
||||
|
||||
bool using_frame_gamepad() const
|
||||
@@ -203,8 +204,6 @@ private:
|
||||
|
||||
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_right = XR_NULL_HANDLE;
|
||||
XrAction gui_distance_left = XR_NULL_HANDLE;
|
||||
|
||||
Reference in New Issue
Block a user