diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6a0b10a4..fe2d38d6 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -3,8 +3,6 @@
xmlns:tools="http://schemas.android.com/tools"
package="org.meumeu.wivrn"
android:installLocation="auto">
-
-
diff --git a/client/application.cpp b/client/application.cpp
index 024fe4ac..435ed765 100644
--- a/client/application.cpp
+++ b/client/application.cpp
@@ -36,6 +36,7 @@
#include
#include
#include
+#include
#ifndef NDEBUG
#include "utils/backtrace.h"
@@ -408,36 +409,67 @@ void application::initialize()
// TODO get it from application info
xr_actionset = xr::actionset(xr_instance, "actions", "Actions");
- std::vector bindings;
- for (const auto & [name, type]: oculus_touch)
- {
- std::string name_without_slashes = std::string(name).substr(1);
+ // TODO better way to handle bindings for different vendors/flavors of vendor
+ char model_chararr[PROP_VALUE_MAX+1];
+ __system_property_get("ro.product.model", model_chararr);
+ std::string model_string(model_chararr);
- for (char & i: name_without_slashes)
+ if (model_string == "Oculus Quest 2") {
+ spdlog::info("Suggesting Oculus Quest 2 bindings");
+ std::vector touch_controller_bindings;
+ for (const auto & [name, type]: oculus_touch)
{
- if (i == '/')
- i = '_';
+ process_binding_action(touch_controller_bindings, name, type);
}
-
- auto a = xr_actionset.create_action(type, name_without_slashes);
- actions.emplace_back(a, type, name);
-
- if (type == XR_ACTION_TYPE_POSE_INPUT)
+ xr_instance.suggest_bindings("/interaction_profiles/oculus/touch_controller", touch_controller_bindings);
+ } else if (model_string == "Pico Neo 3") {
+ spdlog::info("Suggesting Pico Neo 3 bindings");
+ std::vector pico_neo_3_bindings;
+ for (const auto & [name, type]: pico_neo_3)
{
- action_spaces.push_back(xr_session.create_action_space(a));
+ process_binding_action(pico_neo_3_bindings, name, type);
}
-
- bindings.push_back({a, xr_instance.string_to_path(name)});
+ xr_instance.suggest_bindings("/interaction_profiles/bytedance/pico_neo3_controller", pico_neo_3_bindings);
+ } else if (model_string == "Pico 4") {
+ spdlog::info("Suggesting Pico 4 bindings");
+ std::vector pico_4_bindings;
+ for (const auto & [name, type]: pico_4)
+ {
+ process_binding_action(pico_4_bindings, name, type);
+ }
+ xr_instance.suggest_bindings("/interaction_profiles/bytedance/pico4_controller", pico_4_bindings);
+ } else {
+ spdlog::error("Couldn't find any compatible suggested bindings");
}
- xr_instance.suggest_bindings("/interaction_profiles/oculus/touch_controller", bindings);
-
xr_session.attach_actionsets({xr_actionset});
interaction_profile_changed();
}
+void application::process_binding_action(std::vector & bindings,
+ const char *name,
+ const XrActionType &type) {
+ std::string name_without_slashes = std::string(name).substr(1);
+
+ for (char & i: name_without_slashes)
+ {
+ if (i == '/')
+ i = '_';
+ }
+
+ auto a = xr_actionset.create_action(type, name_without_slashes);
+ actions.emplace_back(a, type, name);
+
+ if (type == XR_ACTION_TYPE_POSE_INPUT)
+ {
+ action_spaces.push_back(xr_session.create_action_space(a));
+ }
+
+ bindings.push_back({a, xr_instance.string_to_path(name)});
+}
+
std::pair application::get_action(const std::string & requested_name)
{
for (const auto & [action, type, name]: instance_->actions)
diff --git a/client/application.h b/client/application.h
index c39d77c3..2b637b16 100644
--- a/client/application.h
+++ b/client/application.h
@@ -171,6 +171,83 @@ class application
{"/user/hand/right/input/thumbstick/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
{"/user/hand/right/input/thumbstick/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
{"/user/hand/right/input/thumbrest/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ };
+ static inline const std::pair pico_neo_3[] = {
+ {"/user/hand/left/output/haptic", XR_ACTION_TYPE_VIBRATION_OUTPUT},
+ {"/user/hand/right/output/haptic", XR_ACTION_TYPE_VIBRATION_OUTPUT},
+
+ {"/user/hand/left/input/grip/pose", XR_ACTION_TYPE_POSE_INPUT},
+ {"/user/hand/left/input/aim/pose", XR_ACTION_TYPE_POSE_INPUT},
+
+ {"/user/hand/right/input/grip/pose", XR_ACTION_TYPE_POSE_INPUT},
+ {"/user/hand/right/input/aim/pose", XR_ACTION_TYPE_POSE_INPUT},
+
+ {"/user/hand/left/input/x/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/left/input/x/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/left/input/y/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/left/input/y/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/left/input/squeeze/value", XR_ACTION_TYPE_FLOAT_INPUT},
+ {"/user/hand/left/input/trigger/value", XR_ACTION_TYPE_FLOAT_INPUT},
+ {"/user/hand/left/input/trigger/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/left/input/thumbstick", XR_ACTION_TYPE_VECTOR2F_INPUT},
+ {"/user/hand/left/input/thumbstick/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/left/input/thumbstick/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/left/input/thumbrest/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
+
+ {"/user/hand/right/input/a/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/right/input/a/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/right/input/b/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/right/input/b/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/right/input/squeeze/value", XR_ACTION_TYPE_FLOAT_INPUT},
+ {"/user/hand/right/input/trigger/value", XR_ACTION_TYPE_FLOAT_INPUT},
+ {"/user/hand/right/input/trigger/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/right/input/thumbstick", XR_ACTION_TYPE_VECTOR2F_INPUT},
+ {"/user/hand/right/input/thumbstick/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/right/input/thumbstick/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/right/input/thumbrest/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
+
+ {"/user/hand/left/input/menu/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/left/input/system/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/right/input/menu/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/right/input/system/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ };
+ static inline const std::pair pico_4[] = {
+ {"/user/hand/left/output/haptic", XR_ACTION_TYPE_VIBRATION_OUTPUT},
+ {"/user/hand/right/output/haptic", XR_ACTION_TYPE_VIBRATION_OUTPUT},
+
+ {"/user/hand/left/input/grip/pose", XR_ACTION_TYPE_POSE_INPUT},
+ {"/user/hand/left/input/aim/pose", XR_ACTION_TYPE_POSE_INPUT},
+
+ {"/user/hand/right/input/grip/pose", XR_ACTION_TYPE_POSE_INPUT},
+ {"/user/hand/right/input/aim/pose", XR_ACTION_TYPE_POSE_INPUT},
+
+ {"/user/hand/left/input/x/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/left/input/x/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/left/input/y/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/left/input/y/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/left/input/squeeze/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/left/input/squeeze/value", XR_ACTION_TYPE_FLOAT_INPUT},
+ {"/user/hand/left/input/trigger/value", XR_ACTION_TYPE_FLOAT_INPUT},
+ {"/user/hand/left/input/trigger/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/left/input/thumbstick", XR_ACTION_TYPE_VECTOR2F_INPUT},
+ {"/user/hand/left/input/thumbstick/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/left/input/thumbstick/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/left/input/thumbrest/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
+
+ {"/user/hand/right/input/a/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/right/input/a/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/right/input/b/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/right/input/b/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/right/input/squeeze/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/right/input/squeeze/value", XR_ACTION_TYPE_FLOAT_INPUT},
+ {"/user/hand/right/input/trigger/value", XR_ACTION_TYPE_FLOAT_INPUT},
+ {"/user/hand/right/input/trigger/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/right/input/thumbstick", XR_ACTION_TYPE_VECTOR2F_INPUT},
+ {"/user/hand/right/input/thumbstick/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/right/input/thumbstick/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
+ {"/user/hand/right/input/thumbrest/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
+
+ {"/user/hand/left/input/menu/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
};
bool session_running = false;
@@ -247,6 +324,10 @@ public:
void run();
+ void process_binding_action(std::vector & bindings,
+ const char * name,
+ const XrActionType & type);
+
static void push_scene(std::shared_ptr);
template
diff --git a/server/driver/ffmpeg/VideoEncoderVA.cpp b/server/driver/ffmpeg/VideoEncoderVA.cpp
index 7e238cf2..92c2b858 100644
--- a/server/driver/ffmpeg/VideoEncoderVA.cpp
+++ b/server/driver/ffmpeg/VideoEncoderVA.cpp
@@ -303,19 +303,22 @@ void VideoEncoderVA::InitFilterGraph()
AVFilterInOut * outputs = avfilter_inout_alloc();
AVFilterInOut * inputs = avfilter_inout_alloc();
- filter_in = avfilter_graph_alloc_filter(filter_graph.get(), avfilter_get_by_name("buffer"), "in");
+ std::stringstream buffer_filter_args;
+ buffer_filter_args << "video_size=" << mapped_frames[0]->width << "x" << mapped_frames[0]->height;
+ buffer_filter_args << ":pix_fmt=" << mapped_frames[0]->format;
+ buffer_filter_args << ":time_base=" << encoder_ctx->time_base.num << "/" << encoder_ctx->time_base.den;
+ int err;
+ if ((err = avfilter_graph_create_filter(&filter_in, avfilter_get_by_name("buffer"), "in", buffer_filter_args.str().c_str(), NULL, filter_graph.get())))
+ {
+ throw std::system_error(err, av_error_category(), "filter_in creation failed");
+ }
+ AVBufferSrcParameters *par = av_buffersrc_parameters_alloc();
+ memset(par, 0, sizeof(*par));
+ par->format = AV_PIX_FMT_NONE;
+ par->hw_frames_ctx = av_buffer_ref(mapped_frames[0]->hw_frames_ctx);
+ av_buffersrc_parameters_set(filter_in, par);
+ av_free(par);
- AVBufferSrcParameters * par = av_buffersrc_parameters_alloc();
- memset(par, 0, sizeof(*par));
- par->width = mapped_frames[0]->width;
- par->height = mapped_frames[0]->height;
- par->time_base = encoder_ctx->time_base;
- par->format = mapped_frames[0]->format;
- par->hw_frames_ctx = av_buffer_ref(mapped_frames[0]->hw_frames_ctx);
- av_buffersrc_parameters_set(filter_in, par);
- av_free(par);
-
- int err;
if ((err = avfilter_graph_create_filter(&filter_out, avfilter_get_by_name("buffersink"), "out", NULL, NULL, filter_graph.get())))
{
throw std::system_error(err, av_error_category(), "filter_out creation failed");
@@ -338,7 +341,7 @@ void VideoEncoderVA::InitFilterGraph()
avfilter_inout_free(&inputs);
if (err < 0)
{
- throw std::system_error(err, av_error_category(), "avfilter_graph_parse_ptr failed");
+ throw std::system_error(err, av_error_category(), "code "+ std::to_string(err) + "avfilter_graph_parse_ptr failed");
}
if ((err = avfilter_graph_config(filter_graph.get(), NULL)))