Give each scene its XrActionSet

This commit is contained in:
Guillaume Meunier
2024-01-28 11:33:35 +01:00
parent 705d16cd4e
commit 6de91ad837
12 changed files with 345 additions and 107 deletions
+53 -8
View File
@@ -100,16 +100,16 @@ scenes::lobby::lobby() :
std::array imgui_inputs{
imgui_context::controller{
.aim = application::left_aim(),
.trigger = application::get_action("/user/hand/left/input/select/click"),
.squeeze = application::get_action("/user/hand/left/input/squeeze/value"),
.scroll = application::get_action("/user/hand/left/input/thumbstick"),
.aim = get_action_space("left_aim"),
.trigger = get_action("left_trigger"),
.squeeze = get_action("left_squeeze"),
.scroll = get_action("left_scroll"),
},
imgui_context::controller{
.aim = application::right_aim(),
.trigger = application::get_action("/user/hand/right/input/select/click"),
.squeeze = application::get_action("/user/hand/right/input/squeeze/value"),
.scroll = application::get_action("/user/hand/right/input/thumbstick"),
.aim = get_action_space("right_aim"),
.trigger = get_action("right_trigger"),
.squeeze = get_action("right_squeeze"),
.scroll = get_action("right_scroll"),
},
};
@@ -347,3 +347,48 @@ void scenes::lobby::on_unfocused()
{
discover.reset();
}
scene::meta& scenes::lobby::get_meta_scene()
{
static meta m{
.name = "Lobby",
.actions = {
{"left_aim", XR_ACTION_TYPE_POSE_INPUT},
{"left_trigger", XR_ACTION_TYPE_FLOAT_INPUT},
{"left_squeeze", XR_ACTION_TYPE_FLOAT_INPUT},
{"left_scroll", XR_ACTION_TYPE_VECTOR2F_INPUT},
{"right_aim", XR_ACTION_TYPE_POSE_INPUT},
{"right_trigger", XR_ACTION_TYPE_FLOAT_INPUT},
{"right_squeeze", XR_ACTION_TYPE_FLOAT_INPUT},
{"right_scroll", XR_ACTION_TYPE_VECTOR2F_INPUT},
},
.bindings = {
suggested_binding{
"/interaction_profiles/oculus/touch_controller",
{
{"left_aim", "/user/hand/left/input/aim/pose"},
{"left_trigger", "/user/hand/left/input/trigger/value"},
{"left_squeeze", "/user/hand/left/input/squeeze/value"},
{"left_scroll", "/user/hand/left/input/thumbstick"},
{"right_aim", "/user/hand/right/input/aim/pose"},
{"right_trigger", "/user/hand/right/input/trigger/value"},
{"right_squeeze", "/user/hand/right/input/squeeze/value"},
{"right_scroll", "/user/hand/right/input/thumbstick"},
}
},
suggested_binding{
"/interaction_profiles/khr/simple_controller",
{
{"left_aim", "/user/hand/left/input/aim/pose"},
{"left_trigger", "/user/hand/left/input/select/click"},
{"left_squeeze", "/user/hand/left/input/menu/click"},
{"right_aim", "/user/hand/right/input/aim/pose"},
{"right_trigger", "/user/hand/right/input/select/click"},
{"right_squeeze", "/user/hand/right/input/menu/click"},
}
},
}
};
return m;
}
+3 -1
View File
@@ -35,7 +35,7 @@ namespace scenes
{
class stream;
class lobby : public scene
class lobby : public scene_impl<lobby>
{
std::string status_string;
std::string last_status_string;
@@ -70,5 +70,7 @@ public:
void on_unfocused() override;
void on_focused() override;
static meta& get_meta_scene();
};
} // namespace scenes
+10
View File
@@ -555,3 +555,13 @@ void scenes::stream::video()
}
}
}
scene::meta& scenes::stream::get_meta_scene()
{
static meta m{
"Stream",
{}
};
return m;
}
+3 -1
View File
@@ -32,7 +32,7 @@
namespace scenes
{
class stream : public scene, public std::enable_shared_from_this<stream>
class stream : public scene_impl<stream>, public std::enable_shared_from_this<stream>
{
static const size_t view_count = 2;
@@ -121,6 +121,8 @@ public:
return !exiting;
}
static meta& get_meta_scene();
private:
void process_packets();
void tracking();
+1
View File
@@ -19,6 +19,7 @@
#include "stream.h"
#include "application.h"
#include <spdlog/spdlog.h>
void scenes::stream::read_actions()
{
+1
View File
@@ -21,6 +21,7 @@
#include "utils/ranges.h"
#include "application.h"
#include <thread>
#include <spdlog/spdlog.h>
static from_headset::tracking::pose locate_space(device_id device, XrSpace space, XrSpace reference, XrTime time)
{