diff --git a/alvr/client_core/cpp/bindings.h b/alvr/client_core/cpp/bindings.h index 9060f22ee5..6d6ce9b854 100644 --- a/alvr/client_core/cpp/bindings.h +++ b/alvr/client_core/cpp/bindings.h @@ -1,6 +1,6 @@ #pragma once -struct EyeInput { +struct FfiViewInput { float orientation[4]; // x, y, z, w float position[3]; float fovLeft; @@ -10,12 +10,7 @@ struct EyeInput { unsigned int swapchainIndex; }; -struct OnCreateResult { - int streamSurfaceHandle; - int loadingSurfaceHandle; -}; - -struct StreamConfigInput { +struct FfiStreamConfig { unsigned int viewWidth; unsigned int viewHeight; const unsigned int *swapchainTextures[2]; @@ -43,8 +38,8 @@ extern "C" void prepareLobbyRoom(int viewWidth, const unsigned int *swapchainTextures[2], int swapchainLength); extern "C" void destroyRenderers(); -extern "C" void streamStartNative(StreamConfigInput config); +extern "C" void streamStartNative(FfiStreamConfig config); extern "C" void updateLobbyHudTexture(const unsigned char *data); -extern "C" void renderLobbyNative(const EyeInput eyeInputs[2]); +extern "C" void renderLobbyNative(const FfiViewInput eyeInputs[2]); extern "C" void renderStreamNative(void *streamHardwareBuffer, const unsigned int swapchainIndices[2]); diff --git a/alvr/client_core/cpp/graphics.cpp b/alvr/client_core/cpp/graphics.cpp index dfa9465853..e39f3eff55 100644 --- a/alvr/client_core/cpp/graphics.cpp +++ b/alvr/client_core/cpp/graphics.cpp @@ -660,7 +660,7 @@ void renderEye( GL(glUseProgram(0)); } -void ovrRenderer_RenderFrame(ovrRenderer *renderer, const EyeInput input[2], bool isLobby) { +void ovrRenderer_RenderFrame(ovrRenderer *renderer, const FfiViewInput input[2], bool isLobby) { if (renderer->enableFFR) { renderer->ffr->Render(); } @@ -760,7 +760,7 @@ void destroyRenderers() { } } -void streamStartNative(StreamConfigInput config) { +void streamStartNative(FfiStreamConfig config) { if (g_ctx.streamRenderer) { ovrRenderer_Destroy(g_ctx.streamRenderer.get()); g_ctx.streamRenderer.release(); @@ -800,7 +800,7 @@ void updateLobbyHudTexture(const unsigned char *data) { memcpy(&g_ctx.hudTextureBitmap[0], data, HUD_TEXTURE_WIDTH * HUD_TEXTURE_HEIGHT * 4); } -void renderLobbyNative(const EyeInput eyeInputs[2]) { +void renderLobbyNative(const FfiViewInput eyeInputs[2]) { // update text image { std::lock_guard lock(g_ctx.hudTextureMutex); @@ -832,7 +832,7 @@ void renderStreamNative(void *streamHardwareBuffer, const unsigned int swapchain GL(glBindTexture(GL_TEXTURE_EXTERNAL_OES, g_ctx.streamTexture->GetGLTexture())); GL(glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, (GLeglImageOES)image)); - EyeInput eyeInputs[2] = {}; + FfiViewInput eyeInputs[2] = {}; eyeInputs[0].swapchainIndex = swapchainIndices[0]; eyeInputs[1].swapchainIndex = swapchainIndices[1]; ovrRenderer_RenderFrame(g_ctx.streamRenderer.get(), eyeInputs, false); diff --git a/alvr/client_core/src/opengl.rs b/alvr/client_core/src/opengl.rs index a2179c6982..3b878e1f98 100644 --- a/alvr/client_core/src/opengl.rs +++ b/alvr/client_core/src/opengl.rs @@ -78,7 +78,7 @@ pub fn start_stream( ) { #[cfg(target_os = "android")] unsafe { - let config = StreamConfigInput { + let config = FfiStreamConfig { viewWidth: view_resolution.x, viewHeight: view_resolution.y, swapchainTextures: [ @@ -165,7 +165,7 @@ pub fn render_lobby(view_inputs: [RenderViewInput; 2]) { #[cfg(target_os = "android")] unsafe { let eye_inputs = [ - EyeInput { + FfiViewInput { position: view_inputs[0].position.to_array(), orientation: view_inputs[0].orientation.to_array(), fovLeft: view_inputs[0].fov.left, @@ -174,7 +174,7 @@ pub fn render_lobby(view_inputs: [RenderViewInput; 2]) { fovDown: view_inputs[0].fov.down, swapchainIndex: view_inputs[0].swapchain_index as _, }, - EyeInput { + FfiViewInput { position: view_inputs[1].position.to_array(), orientation: view_inputs[1].orientation.to_array(), fovLeft: view_inputs[1].fov.left, diff --git a/alvr/server/cpp/alvr_server/OvrController.cpp b/alvr/server/cpp/alvr_server/OvrController.cpp index e3230f012f..758461d66a 100644 --- a/alvr/server/cpp/alvr_server/OvrController.cpp +++ b/alvr/server/cpp/alvr_server/OvrController.cpp @@ -69,10 +69,9 @@ vr::EVRInitError OvrController::Activate(vr::TrackedDeviceIndex_t unObjectId) { Settings::Instance().m_useHeadsetTrackingSystem ? Settings::Instance().mTrackingSystemName.c_str() : Settings::Instance().m_controllerTrackingSystemName.c_str()); - vr_properties->SetStringProperty( - this->prop_container, - vr::Prop_ManufacturerName_String, - Settings::Instance().m_controllerManufacturerName.c_str()); + vr_properties->SetStringProperty(this->prop_container, + vr::Prop_ManufacturerName_String, + Settings::Instance().m_controllerManufacturerName.c_str()); vr_properties->SetStringProperty( this->prop_container, vr::Prop_ModelNumber_String, @@ -123,22 +122,21 @@ vr::EVRInitError OvrController::Activate(vr::TrackedDeviceIndex_t unObjectId) { vr_properties->SetInt32Property( this->prop_container, vr::Prop_Axis0Type_Int32, vr::k_eControllerAxis_Joystick); - vr_properties->SetInt32Property( - this->prop_container, - vr::Prop_ControllerRoleHint_Int32, - isViveTracker ? vr::TrackedControllerRole_Invalid - : (this->device_id == LEFT_HAND_ID ? vr::TrackedControllerRole_LeftHand + vr_properties->SetInt32Property(this->prop_container, + vr::Prop_ControllerRoleHint_Int32, + isViveTracker ? vr::TrackedControllerRole_Invalid + : (this->device_id == LEFT_HAND_ID + ? vr::TrackedControllerRole_LeftHand : vr::TrackedControllerRole_RightHand)); vr_properties->SetStringProperty(this->prop_container, - vr::Prop_ControllerType_String, - this->device_id == LEFT_HAND_ID - ? Settings::Instance().m_controllerTypeLeft.c_str() - : Settings::Instance().m_controllerTypeRight.c_str()); - vr_properties->SetStringProperty( - this->prop_container, - vr::Prop_InputProfilePath_String, - Settings::Instance().m_controllerInputProfilePath.c_str()); + vr::Prop_ControllerType_String, + this->device_id == LEFT_HAND_ID + ? Settings::Instance().m_controllerTypeLeft.c_str() + : Settings::Instance().m_controllerTypeRight.c_str()); + vr_properties->SetStringProperty(this->prop_container, + vr::Prop_InputProfilePath_String, + Settings::Instance().m_controllerInputProfilePath.c_str()); switch (Settings::Instance().m_controllerMode) { case 1: // Oculus Rift @@ -149,15 +147,15 @@ vr::EVRInitError OvrController::Activate(vr::TrackedDeviceIndex_t unObjectId) { vr_driver_input->CreateBooleanComponent( this->prop_container, "/input/system/touch", &m_handles[ALVR_INPUT_THUMB_REST_TOUCH]); vr_driver_input->CreateBooleanComponent(this->prop_container, - "/input/application_menu/click", - &m_handles[ALVR_INPUT_APPLICATION_MENU_CLICK]); + "/input/application_menu/click", + &m_handles[ALVR_INPUT_APPLICATION_MENU_CLICK]); vr_driver_input->CreateBooleanComponent( this->prop_container, "/input/grip/click", &m_handles[ALVR_INPUT_GRIP_CLICK]); vr_driver_input->CreateScalarComponent(this->prop_container, - "/input/grip/value", - &m_handles[ALVR_INPUT_GRIP_VALUE], - vr::VRScalarType_Absolute, - vr::VRScalarUnits_NormalizedOneSided); + "/input/grip/value", + &m_handles[ALVR_INPUT_GRIP_VALUE], + vr::VRScalarType_Absolute, + vr::VRScalarUnits_NormalizedOneSided); vr_driver_input->CreateBooleanComponent( this->prop_container, "/input/grip/touch", &m_handles[ALVR_INPUT_GRIP_TOUCH]); @@ -184,28 +182,25 @@ vr::EVRInitError OvrController::Activate(vr::TrackedDeviceIndex_t unObjectId) { // icons vr_properties->SetStringProperty(this->prop_container, - vr::Prop_NamedIconPathDeviceOff_String, - "{oculus}/icons/rifts_right_controller_off.png"); - vr_properties->SetStringProperty( - this->prop_container, - vr::Prop_NamedIconPathDeviceSearching_String, - "{oculus}/icons/rifts_right_controller_searching.gif"); + vr::Prop_NamedIconPathDeviceOff_String, + "{oculus}/icons/rifts_right_controller_off.png"); + vr_properties->SetStringProperty(this->prop_container, + vr::Prop_NamedIconPathDeviceSearching_String, + "{oculus}/icons/rifts_right_controller_searching.gif"); vr_properties->SetStringProperty( this->prop_container, vr::Prop_NamedIconPathDeviceSearchingAlert_String, "{oculus}/icons/rifts_right_controller_searching_alert.gif"); - vr_properties->SetStringProperty( - this->prop_container, - vr::Prop_NamedIconPathDeviceReady_String, - "{oculus}/icons/rifts_right_controller_ready.png"); + vr_properties->SetStringProperty(this->prop_container, + vr::Prop_NamedIconPathDeviceReady_String, + "{oculus}/icons/rifts_right_controller_ready.png"); vr_properties->SetStringProperty( this->prop_container, vr::Prop_NamedIconPathDeviceReadyAlert_String, "{oculus}/icons/rifts_right_controller_ready_alert.png"); - vr_properties->SetStringProperty( - this->prop_container, - vr::Prop_NamedIconPathDeviceAlertLow_String, - "{oculus}/icons/rifts_right_controller_ready_low.png"); + vr_properties->SetStringProperty(this->prop_container, + vr::Prop_NamedIconPathDeviceAlertLow_String, + "{oculus}/icons/rifts_right_controller_ready_low.png"); } else { // X,Y for left hand. @@ -230,41 +225,39 @@ vr::EVRInitError OvrController::Activate(vr::TrackedDeviceIndex_t unObjectId) { // icons vr_properties->SetStringProperty(this->prop_container, - vr::Prop_NamedIconPathDeviceOff_String, - "{oculus}/icons/rifts_left_controller_off.png"); - vr_properties->SetStringProperty( - this->prop_container, - vr::Prop_NamedIconPathDeviceSearching_String, - "{oculus}/icons/rifts_left_controller_searching.gif"); + vr::Prop_NamedIconPathDeviceOff_String, + "{oculus}/icons/rifts_left_controller_off.png"); + vr_properties->SetStringProperty(this->prop_container, + vr::Prop_NamedIconPathDeviceSearching_String, + "{oculus}/icons/rifts_left_controller_searching.gif"); vr_properties->SetStringProperty( this->prop_container, vr::Prop_NamedIconPathDeviceSearchingAlert_String, "{oculus}/icons/rifts_left_controller_searching_alert.gif"); vr_properties->SetStringProperty(this->prop_container, - vr::Prop_NamedIconPathDeviceReady_String, - "{oculus}/icons/rifts_left_controller_ready.png"); + vr::Prop_NamedIconPathDeviceReady_String, + "{oculus}/icons/rifts_left_controller_ready.png"); vr_properties->SetStringProperty( this->prop_container, vr::Prop_NamedIconPathDeviceReadyAlert_String, "{oculus}/icons/rifts_left_controller_ready_alert.png"); - vr_properties->SetStringProperty( - this->prop_container, - vr::Prop_NamedIconPathDeviceAlertLow_String, - "{oculus}/icons/rifts_left_controller_ready_low.png"); + vr_properties->SetStringProperty(this->prop_container, + vr::Prop_NamedIconPathDeviceAlertLow_String, + "{oculus}/icons/rifts_left_controller_ready_low.png"); } vr_driver_input->CreateBooleanComponent( this->prop_container, "/input/joystick/click", &m_handles[ALVR_INPUT_JOYSTICK_CLICK]); vr_driver_input->CreateScalarComponent(this->prop_container, - "/input/joystick/x", - &m_handles[ALVR_INPUT_JOYSTICK_X], - vr::VRScalarType_Absolute, - vr::VRScalarUnits_NormalizedTwoSided); + "/input/joystick/x", + &m_handles[ALVR_INPUT_JOYSTICK_X], + vr::VRScalarType_Absolute, + vr::VRScalarUnits_NormalizedTwoSided); vr_driver_input->CreateScalarComponent(this->prop_container, - "/input/joystick/y", - &m_handles[ALVR_INPUT_JOYSTICK_Y], - vr::VRScalarType_Absolute, - vr::VRScalarUnits_NormalizedTwoSided); + "/input/joystick/y", + &m_handles[ALVR_INPUT_JOYSTICK_Y], + vr::VRScalarType_Absolute, + vr::VRScalarUnits_NormalizedTwoSided); vr_driver_input->CreateBooleanComponent( this->prop_container, "/input/joystick/touch", &m_handles[ALVR_INPUT_JOYSTICK_TOUCH]); @@ -278,10 +271,10 @@ vr::EVRInitError OvrController::Activate(vr::TrackedDeviceIndex_t unObjectId) { vr_driver_input->CreateBooleanComponent( this->prop_container, "/input/trigger/click", &m_handles[ALVR_INPUT_TRIGGER_CLICK]); vr_driver_input->CreateScalarComponent(this->prop_container, - "/input/trigger/value", - &m_handles[ALVR_INPUT_TRIGGER_VALUE], - vr::VRScalarType_Absolute, - vr::VRScalarUnits_NormalizedOneSided); + "/input/trigger/value", + &m_handles[ALVR_INPUT_TRIGGER_VALUE], + vr::VRScalarType_Absolute, + vr::VRScalarUnits_NormalizedOneSided); vr_driver_input->CreateBooleanComponent( this->prop_container, "/input/trigger/touch", &m_handles[ALVR_INPUT_TRIGGER_TOUCH]); @@ -304,73 +297,73 @@ vr::EVRInitError OvrController::Activate(vr::TrackedDeviceIndex_t unObjectId) { vr_driver_input->CreateBooleanComponent( this->prop_container, "/input/trigger/touch", &m_handles[ALVR_INPUT_TRIGGER_TOUCH]); vr_driver_input->CreateScalarComponent(this->prop_container, - "/input/trigger/value", - &m_handles[ALVR_INPUT_TRIGGER_VALUE], - vr::VRScalarType_Absolute, - vr::VRScalarUnits_NormalizedOneSided); + "/input/trigger/value", + &m_handles[ALVR_INPUT_TRIGGER_VALUE], + vr::VRScalarType_Absolute, + vr::VRScalarUnits_NormalizedOneSided); vr_driver_input->CreateScalarComponent(this->prop_container, - "/input/trackpad/x", - &m_handles[ALVR_INPUT_TRACKPAD_X], - vr::VRScalarType_Absolute, - vr::VRScalarUnits_NormalizedTwoSided); + "/input/trackpad/x", + &m_handles[ALVR_INPUT_TRACKPAD_X], + vr::VRScalarType_Absolute, + vr::VRScalarUnits_NormalizedTwoSided); vr_driver_input->CreateScalarComponent(this->prop_container, - "/input/trackpad/y", - &m_handles[ALVR_INPUT_TRACKPAD_Y], - vr::VRScalarType_Absolute, - vr::VRScalarUnits_NormalizedTwoSided); + "/input/trackpad/y", + &m_handles[ALVR_INPUT_TRACKPAD_Y], + vr::VRScalarType_Absolute, + vr::VRScalarUnits_NormalizedTwoSided); vr_driver_input->CreateScalarComponent(this->prop_container, - "/input/trackpad/force", - &m_handles[ALVR_INPUT_TRACKPAD_FORCE], - vr::VRScalarType_Absolute, - vr::VRScalarUnits_NormalizedOneSided); + "/input/trackpad/force", + &m_handles[ALVR_INPUT_TRACKPAD_FORCE], + vr::VRScalarType_Absolute, + vr::VRScalarUnits_NormalizedOneSided); vr_driver_input->CreateBooleanComponent( this->prop_container, "/input/trackpad/touch", &m_handles[ALVR_INPUT_TRACKPAD_TOUCH]); vr_driver_input->CreateScalarComponent(this->prop_container, - "/input/grip/force", - &m_handles[ALVR_INPUT_GRIP_FORCE], - vr::VRScalarType_Absolute, - vr::VRScalarUnits_NormalizedOneSided); + "/input/grip/force", + &m_handles[ALVR_INPUT_GRIP_FORCE], + vr::VRScalarType_Absolute, + vr::VRScalarUnits_NormalizedOneSided); vr_driver_input->CreateScalarComponent(this->prop_container, - "/input/grip/value", - &m_handles[ALVR_INPUT_GRIP_VALUE], - vr::VRScalarType_Absolute, - vr::VRScalarUnits_NormalizedOneSided); + "/input/grip/value", + &m_handles[ALVR_INPUT_GRIP_VALUE], + vr::VRScalarType_Absolute, + vr::VRScalarUnits_NormalizedOneSided); vr_driver_input->CreateBooleanComponent( this->prop_container, "/input/grip/touch", &m_handles[ALVR_INPUT_GRIP_TOUCH]); vr_driver_input->CreateScalarComponent(this->prop_container, - "/input/thumbstick/x", - &m_handles[ALVR_INPUT_JOYSTICK_X], - vr::VRScalarType_Absolute, - vr::VRScalarUnits_NormalizedTwoSided); + "/input/thumbstick/x", + &m_handles[ALVR_INPUT_JOYSTICK_X], + vr::VRScalarType_Absolute, + vr::VRScalarUnits_NormalizedTwoSided); vr_driver_input->CreateScalarComponent(this->prop_container, - "/input/thumbstick/y", - &m_handles[ALVR_INPUT_JOYSTICK_Y], - vr::VRScalarType_Absolute, - vr::VRScalarUnits_NormalizedTwoSided); + "/input/thumbstick/y", + &m_handles[ALVR_INPUT_JOYSTICK_Y], + vr::VRScalarType_Absolute, + vr::VRScalarUnits_NormalizedTwoSided); vr_driver_input->CreateBooleanComponent( this->prop_container, "/input/thumbstick/click", &m_handles[ALVR_INPUT_JOYSTICK_CLICK]); vr_driver_input->CreateBooleanComponent( this->prop_container, "/input/thumbstick/touch", &m_handles[ALVR_INPUT_JOYSTICK_TOUCH]); vr_driver_input->CreateScalarComponent(this->prop_container, - "/input/finger/index", - &m_handles[ALVR_INPUT_FINGER_INDEX], - vr::VRScalarType_Absolute, - vr::VRScalarUnits_NormalizedOneSided); + "/input/finger/index", + &m_handles[ALVR_INPUT_FINGER_INDEX], + vr::VRScalarType_Absolute, + vr::VRScalarUnits_NormalizedOneSided); vr_driver_input->CreateScalarComponent(this->prop_container, - "/input/finger/middle", - &m_handles[ALVR_INPUT_FINGER_MIDDLE], - vr::VRScalarType_Absolute, - vr::VRScalarUnits_NormalizedOneSided); + "/input/finger/middle", + &m_handles[ALVR_INPUT_FINGER_MIDDLE], + vr::VRScalarType_Absolute, + vr::VRScalarUnits_NormalizedOneSided); vr_driver_input->CreateScalarComponent(this->prop_container, - "/input/finger/ring", - &m_handles[ALVR_INPUT_FINGER_RING], - vr::VRScalarType_Absolute, - vr::VRScalarUnits_NormalizedOneSided); + "/input/finger/ring", + &m_handles[ALVR_INPUT_FINGER_RING], + vr::VRScalarType_Absolute, + vr::VRScalarUnits_NormalizedOneSided); vr_driver_input->CreateScalarComponent(this->prop_container, - "/input/finger/pinky", - &m_handles[ALVR_INPUT_FINGER_PINKY], - vr::VRScalarType_Absolute, - vr::VRScalarUnits_NormalizedOneSided); + "/input/finger/pinky", + &m_handles[ALVR_INPUT_FINGER_PINKY], + vr::VRScalarType_Absolute, + vr::VRScalarUnits_NormalizedOneSided); if (this->device_id == LEFT_HAND_ID) { vr_driver_input->CreateSkeletonComponent( this->prop_container, @@ -399,33 +392,29 @@ vr::EVRInitError OvrController::Activate(vr::TrackedDeviceIndex_t unObjectId) { // All of these property values were dumped from real a vive tracker via // https://github.com/SDraw/openvr_dumper and were copied from // https://github.com/SDraw/driver_kinectV2 - vr_properties->SetStringProperty( - this->prop_container, vr::Prop_ResourceRoot_String, "htc"); - vr_properties->SetBoolProperty( - this->prop_container, vr::Prop_WillDriftInYaw_Bool, false); + vr_properties->SetStringProperty(this->prop_container, vr::Prop_ResourceRoot_String, "htc"); + vr_properties->SetBoolProperty(this->prop_container, vr::Prop_WillDriftInYaw_Bool, false); vr_properties->SetStringProperty( this->prop_container, vr::Prop_TrackingFirmwareVersion_String, "1541800000 RUNNER-WATCHMAN$runner-watchman@runner-watchman 2018-01-01 FPGA " "512(2.56/0/0) BL 0 VRC 1541800000 Radio 1518800000"); // Changed vr_properties->SetStringProperty(this->prop_container, - vr::Prop_HardwareRevision_String, - "product 128 rev 2.5.6 lot 2000/0/0 0"); + vr::Prop_HardwareRevision_String, + "product 128 rev 2.5.6 lot 2000/0/0 0"); vr_properties->SetStringProperty( this->prop_container, vr::Prop_ConnectedWirelessDongle_String, "D0000BE000"); - vr_properties->SetBoolProperty( - this->prop_container, vr::Prop_DeviceIsWireless_Bool, true); - vr_properties->SetBoolProperty( - this->prop_container, vr::Prop_DeviceIsCharging_Bool, false); + vr_properties->SetBoolProperty(this->prop_container, vr::Prop_DeviceIsWireless_Bool, true); + vr_properties->SetBoolProperty(this->prop_container, vr::Prop_DeviceIsCharging_Bool, false); vr_properties->SetInt32Property( this->prop_container, vr::Prop_ControllerHandSelectionPriority_Int32, -1); vr::HmdMatrix34_t l_transform = { {{-1.f, 0.f, 0.f, 0.f}, {0.f, 0.f, -1.f, 0.f}, {0.f, -1.f, 0.f, 0.f}}}; vr_properties->SetProperty(this->prop_container, - vr::Prop_StatusDisplayTransform_Matrix34, - &l_transform, - sizeof(vr::HmdMatrix34_t), - vr::k_unHmdMatrix34PropertyTag); + vr::Prop_StatusDisplayTransform_Matrix34, + &l_transform, + sizeof(vr::HmdMatrix34_t), + vr::k_unHmdMatrix34PropertyTag); vr_properties->SetBoolProperty( this->prop_container, vr::Prop_Firmware_UpdateAvailable_Bool, false); vr_properties->SetBoolProperty( @@ -438,23 +427,20 @@ vr::EVRInitError OvrController::Activate(vr::TrackedDeviceIndex_t unObjectId) { this->prop_container, vr::Prop_HardwareRevision_Uint64, 2214720000); vr_properties->SetUint64Property( this->prop_container, vr::Prop_FirmwareVersion_Uint64, 1541800000); - vr_properties->SetUint64Property( - this->prop_container, vr::Prop_FPGAVersion_Uint64, 512); + vr_properties->SetUint64Property(this->prop_container, vr::Prop_FPGAVersion_Uint64, 512); vr_properties->SetUint64Property( this->prop_container, vr::Prop_VRCVersion_Uint64, 1514800000); vr_properties->SetUint64Property( this->prop_container, vr::Prop_RadioVersion_Uint64, 1518800000); vr_properties->SetUint64Property( this->prop_container, vr::Prop_DongleVersion_Uint64, 8933539758); - vr_properties->SetBoolProperty( - this->prop_container, vr::Prop_DeviceCanPowerOff_Bool, true); + vr_properties->SetBoolProperty(this->prop_container, vr::Prop_DeviceCanPowerOff_Bool, true); vr_properties->SetStringProperty(this->prop_container, - vr::Prop_Firmware_ProgrammingTarget_String, - GetSerialNumber().c_str()); + vr::Prop_Firmware_ProgrammingTarget_String, + GetSerialNumber().c_str()); vr_properties->SetBoolProperty( this->prop_container, vr::Prop_Firmware_ForceUpdateRequired_Bool, false); - vr_properties->SetBoolProperty( - this->prop_container, vr::Prop_Identifiable_Bool, false); + vr_properties->SetBoolProperty(this->prop_container, vr::Prop_Identifiable_Bool, false); vr_properties->SetBoolProperty( this->prop_container, vr::Prop_Firmware_RemindUpdate_Bool, false); vr_properties->SetBoolProperty( @@ -468,29 +454,29 @@ vr::EVRInitError OvrController::Activate(vr::TrackedDeviceIndex_t unObjectId) { // icons vr_properties->SetStringProperty(this->prop_container, - vr::Prop_NamedIconPathDeviceOff_String, - "{htc}/icons/tracker_status_off.png"); + vr::Prop_NamedIconPathDeviceOff_String, + "{htc}/icons/tracker_status_off.png"); vr_properties->SetStringProperty(this->prop_container, - vr::Prop_NamedIconPathDeviceSearching_String, - "{htc}/icons/tracker_status_searching.gif"); + vr::Prop_NamedIconPathDeviceSearching_String, + "{htc}/icons/tracker_status_searching.gif"); vr_properties->SetStringProperty(this->prop_container, - vr::Prop_NamedIconPathDeviceSearchingAlert_String, - "{htc}/icons/tracker_status_searching_alert.gif"); + vr::Prop_NamedIconPathDeviceSearchingAlert_String, + "{htc}/icons/tracker_status_searching_alert.gif"); vr_properties->SetStringProperty(this->prop_container, - vr::Prop_NamedIconPathDeviceReady_String, - "{htc}/icons/tracker_status_ready.png"); + vr::Prop_NamedIconPathDeviceReady_String, + "{htc}/icons/tracker_status_ready.png"); vr_properties->SetStringProperty(this->prop_container, - vr::Prop_NamedIconPathDeviceReadyAlert_String, - "{htc}/icons/tracker_status_ready_alert.png"); + vr::Prop_NamedIconPathDeviceReadyAlert_String, + "{htc}/icons/tracker_status_ready_alert.png"); vr_properties->SetStringProperty(this->prop_container, - vr::Prop_NamedIconPathDeviceNotReady_String, - "{htc}/icons/tracker_status_error.png"); + vr::Prop_NamedIconPathDeviceNotReady_String, + "{htc}/icons/tracker_status_error.png"); vr_properties->SetStringProperty(this->prop_container, - vr::Prop_NamedIconPathDeviceStandby_String, - "{htc}/icons/tracker_status_standby.png"); + vr::Prop_NamedIconPathDeviceStandby_String, + "{htc}/icons/tracker_status_standby.png"); vr_properties->SetStringProperty(this->prop_container, - vr::Prop_NamedIconPathDeviceAlertLow_String, - "{htc}/icons/tracker_status_ready_low.png"); + vr::Prop_NamedIconPathDeviceAlertLow_String, + "{htc}/icons/tracker_status_ready_low.png"); // yes we want to explicitly fallthrough to vive case!, vive trackers can have input when // POGO pins are connected to a peripheral. the input bindings are only active when the // tracker role is set to "vive_tracker_handed"/held_in_hand roles. @@ -502,27 +488,27 @@ vr::EVRInitError OvrController::Activate(vr::TrackedDeviceIndex_t unObjectId) { vr_driver_input->CreateBooleanComponent( this->prop_container, "/input/trackpad/click", &m_handles[ALVR_INPUT_TRACKPAD_CLICK]); vr_driver_input->CreateScalarComponent(this->prop_container, - "/input/trackpad/x", - &m_handles[ALVR_INPUT_TRACKPAD_X], - vr::VRScalarType_Absolute, - vr::VRScalarUnits_NormalizedTwoSided); + "/input/trackpad/x", + &m_handles[ALVR_INPUT_TRACKPAD_X], + vr::VRScalarType_Absolute, + vr::VRScalarUnits_NormalizedTwoSided); vr_driver_input->CreateScalarComponent(this->prop_container, - "/input/trackpad/y", - &m_handles[ALVR_INPUT_TRACKPAD_Y], - vr::VRScalarType_Absolute, - vr::VRScalarUnits_NormalizedTwoSided); + "/input/trackpad/y", + &m_handles[ALVR_INPUT_TRACKPAD_Y], + vr::VRScalarType_Absolute, + vr::VRScalarUnits_NormalizedTwoSided); vr_driver_input->CreateBooleanComponent( this->prop_container, "/input/trigger/click", &m_handles[ALVR_INPUT_TRIGGER_CLICK]); vr_driver_input->CreateScalarComponent(this->prop_container, - "/input/trigger/value", - &m_handles[ALVR_INPUT_TRIGGER_VALUE], - vr::VRScalarType_Absolute, - vr::VRScalarUnits_NormalizedOneSided); + "/input/trigger/value", + &m_handles[ALVR_INPUT_TRIGGER_VALUE], + vr::VRScalarType_Absolute, + vr::VRScalarUnits_NormalizedOneSided); vr_driver_input->CreateBooleanComponent( this->prop_container, "/input/grip/click", &m_handles[ALVR_INPUT_GRIP_CLICK]); vr_driver_input->CreateBooleanComponent(this->prop_container, - "/input/application_menu/click", - &m_handles[ALVR_INPUT_APPLICATION_MENU_CLICK]); + "/input/application_menu/click", + &m_handles[ALVR_INPUT_APPLICATION_MENU_CLICK]); vr_driver_input->CreateBooleanComponent( this->prop_container, "/input/system/click", &m_handles[ALVR_INPUT_SYSTEM_CLICK]); if (this->device_id == LEFT_HAND_ID) { @@ -614,7 +600,7 @@ vr::HmdQuaternionf_t QuatMultiply(const vr::HmdQuaternionf_t *q1, const vr::HmdQ return result; } -void OvrController::SetButton(uint64_t id, AlvrButtonValue value) { +void OvrController::SetButton(uint64_t id, FfiButtonValue value) { if (value.type == BUTTON_TYPE_BINARY) { uint32_t flag; if (id == MENU_CLICK_ID) { @@ -665,8 +651,8 @@ inline float Magnitude(const float v[3]) { return v[0] * v[0] + v[1] * v[1] + v[ inline float Shape(float x, float a) { return (x > a * a ? 1 - (a * a / x) : 0.); } bool OvrController::onPoseUpdate(float predictionS, - AlvrDeviceMotion motion, - const OculusHand &hand) { + FfiDeviceMotion motion, + const FfiHandSkeleton &hand) { if (this->object_id == vr::k_unTrackedDeviceIndexInvalid) { return false; } @@ -795,8 +781,7 @@ bool OvrController::onPoseUpdate(float predictionS, switch (Settings::Instance().m_controllerMode) { case 1: // Oculus Rift case 7: // Oculus Quest - vr_driver_input->UpdateBooleanComponent( - m_handles[ALVR_INPUT_SYSTEM_CLICK], false, 0.0); + vr_driver_input->UpdateBooleanComponent(m_handles[ALVR_INPUT_SYSTEM_CLICK], false, 0.0); vr_driver_input->UpdateBooleanComponent( m_handles[ALVR_INPUT_APPLICATION_MENU_CLICK], false, 0.0); vr_driver_input->UpdateBooleanComponent( @@ -807,23 +792,15 @@ bool OvrController::onPoseUpdate(float predictionS, vr_driver_input->UpdateBooleanComponent( m_handles[ALVR_INPUT_THUMB_REST_TOUCH], false, 0.0); if (this->device_id == RIGHT_HAND_ID) { - vr_driver_input->UpdateBooleanComponent( - m_handles[ALVR_INPUT_A_CLICK], false, 0.0); - vr_driver_input->UpdateBooleanComponent( - m_handles[ALVR_INPUT_A_TOUCH], false, 0.0); - vr_driver_input->UpdateBooleanComponent( - m_handles[ALVR_INPUT_B_CLICK], false, 0.0); - vr_driver_input->UpdateBooleanComponent( - m_handles[ALVR_INPUT_B_TOUCH], false, 0.0); + vr_driver_input->UpdateBooleanComponent(m_handles[ALVR_INPUT_A_CLICK], false, 0.0); + vr_driver_input->UpdateBooleanComponent(m_handles[ALVR_INPUT_A_TOUCH], false, 0.0); + vr_driver_input->UpdateBooleanComponent(m_handles[ALVR_INPUT_B_CLICK], false, 0.0); + vr_driver_input->UpdateBooleanComponent(m_handles[ALVR_INPUT_B_TOUCH], false, 0.0); } else { - vr_driver_input->UpdateBooleanComponent( - m_handles[ALVR_INPUT_X_CLICK], false, 0.0); - vr_driver_input->UpdateBooleanComponent( - m_handles[ALVR_INPUT_X_TOUCH], false, 0.0); - vr_driver_input->UpdateBooleanComponent( - m_handles[ALVR_INPUT_Y_CLICK], false, 0.0); - vr_driver_input->UpdateBooleanComponent( - m_handles[ALVR_INPUT_Y_TOUCH], false, 0.0); + vr_driver_input->UpdateBooleanComponent(m_handles[ALVR_INPUT_X_CLICK], false, 0.0); + vr_driver_input->UpdateBooleanComponent(m_handles[ALVR_INPUT_X_TOUCH], false, 0.0); + vr_driver_input->UpdateBooleanComponent(m_handles[ALVR_INPUT_Y_CLICK], false, 0.0); + vr_driver_input->UpdateBooleanComponent(m_handles[ALVR_INPUT_Y_TOUCH], false, 0.0); } vr_driver_input->UpdateBooleanComponent( m_handles[ALVR_INPUT_JOYSTICK_CLICK], false, 0.0); @@ -831,12 +808,9 @@ bool OvrController::onPoseUpdate(float predictionS, vr_driver_input->UpdateScalarComponent(m_handles[ALVR_INPUT_JOYSTICK_Y], 0.0f, 0.0); vr_driver_input->UpdateBooleanComponent( m_handles[ALVR_INPUT_JOYSTICK_TOUCH], rotThumb > 0.7f, 0.0); - vr_driver_input->UpdateBooleanComponent( - m_handles[ALVR_INPUT_BACK_CLICK], false, 0.0); - vr_driver_input->UpdateBooleanComponent( - m_handles[ALVR_INPUT_GUIDE_CLICK], false, 0.0); - vr_driver_input->UpdateBooleanComponent( - m_handles[ALVR_INPUT_START_CLICK], false, 0.0); + vr_driver_input->UpdateBooleanComponent(m_handles[ALVR_INPUT_BACK_CLICK], false, 0.0); + vr_driver_input->UpdateBooleanComponent(m_handles[ALVR_INPUT_GUIDE_CLICK], false, 0.0); + vr_driver_input->UpdateBooleanComponent(m_handles[ALVR_INPUT_START_CLICK], false, 0.0); vr_driver_input->UpdateBooleanComponent( m_handles[ALVR_INPUT_TRIGGER_CLICK], rotIndex > 0.9f, 0.0); vr_driver_input->UpdateScalarComponent( @@ -845,8 +819,7 @@ bool OvrController::onPoseUpdate(float predictionS, m_handles[ALVR_INPUT_TRIGGER_TOUCH], rotIndex > 0.7f, 0.0); break; case 3: - vr_driver_input->UpdateBooleanComponent( - m_handles[ALVR_INPUT_SYSTEM_CLICK], false, 0.0); + vr_driver_input->UpdateBooleanComponent(m_handles[ALVR_INPUT_SYSTEM_CLICK], false, 0.0); vr_driver_input->UpdateBooleanComponent( m_handles[ALVR_INPUT_GRIP_TOUCH], grip > 0.7f, 0.0); vr_driver_input->UpdateScalarComponent( @@ -890,8 +863,7 @@ bool OvrController::onPoseUpdate(float predictionS, m_handles[ALVR_INPUT_GRIP_CLICK], grip > 0.9f, 0.0); vr_driver_input->UpdateBooleanComponent( m_handles[ALVR_INPUT_APPLICATION_MENU_CLICK], false, 0.0); - vr_driver_input->UpdateBooleanComponent( - m_handles[ALVR_INPUT_SYSTEM_CLICK], false, 0.0); + vr_driver_input->UpdateBooleanComponent(m_handles[ALVR_INPUT_SYSTEM_CLICK], false, 0.0); break; } // Hand @@ -1062,17 +1034,14 @@ bool OvrController::onPoseUpdate(float predictionS, vr_driver_input->UpdateSkeletonComponent( m_compSkeleton, vr::VRSkeletalMotionRange_WithController, m_boneTransform, HSB_Count); vr_driver_input->UpdateSkeletonComponent(m_compSkeleton, - vr::VRSkeletalMotionRange_WithoutController, - m_boneTransform, - HSB_Count); - - vr_driver_input->UpdateScalarComponent( - m_handles[ALVR_INPUT_FINGER_INDEX], rotIndex, 0.0); - vr_driver_input->UpdateScalarComponent( - m_handles[ALVR_INPUT_FINGER_MIDDLE], rotMiddle, 0.0); + vr::VRSkeletalMotionRange_WithoutController, + m_boneTransform, + HSB_Count); + + vr_driver_input->UpdateScalarComponent(m_handles[ALVR_INPUT_FINGER_INDEX], rotIndex, 0.0); + vr_driver_input->UpdateScalarComponent(m_handles[ALVR_INPUT_FINGER_MIDDLE], rotMiddle, 0.0); vr_driver_input->UpdateScalarComponent(m_handles[ALVR_INPUT_FINGER_RING], rotRing, 0.0); - vr_driver_input->UpdateScalarComponent( - m_handles[ALVR_INPUT_FINGER_PINKY], rotPinky, 0.0); + vr_driver_input->UpdateScalarComponent(m_handles[ALVR_INPUT_FINGER_PINKY], rotPinky, 0.0); vr::VRServerDriverHost()->TrackedDevicePoseUpdated( this->object_id, pose, sizeof(vr::DriverPose_t)); @@ -1146,9 +1115,9 @@ bool OvrController::onPoseUpdate(float predictionS, } vr_driver_input->UpdateBooleanComponent( m_handles[ALVR_INPUT_TRIGGER_CLICK], - Settings::Instance().m_overrideTriggerThreshold ? - m_triggerValue >= Settings::Instance().m_triggerThreshold : - (m_buttons & ALVR_BUTTON_FLAG(ALVR_INPUT_TRIGGER_CLICK)) != 0, + Settings::Instance().m_overrideTriggerThreshold + ? m_triggerValue >= Settings::Instance().m_triggerThreshold + : (m_buttons & ALVR_BUTTON_FLAG(ALVR_INPUT_TRIGGER_CLICK)) != 0, 0.0); vr_driver_input->UpdateBooleanComponent( m_handles[ALVR_INPUT_TRIGGER_TOUCH], @@ -1195,17 +1164,17 @@ bool OvrController::onPoseUpdate(float predictionS, m_handles[ALVR_INPUT_TRACKPAD_Y], m_joystickY, 0.0); vr_driver_input->UpdateBooleanComponent( m_handles[ALVR_INPUT_TRIGGER_CLICK], - Settings::Instance().m_overrideTriggerThreshold ? - m_triggerValue >= Settings::Instance().m_triggerThreshold : - (m_buttons & ALVR_BUTTON_FLAG(ALVR_INPUT_TRIGGER_CLICK)) != 0, + Settings::Instance().m_overrideTriggerThreshold + ? m_triggerValue >= Settings::Instance().m_triggerThreshold + : (m_buttons & ALVR_BUTTON_FLAG(ALVR_INPUT_TRIGGER_CLICK)) != 0, 0.0); vr_driver_input->UpdateScalarComponent( m_handles[ALVR_INPUT_TRIGGER_VALUE], m_triggerValue, 0.0); vr_driver_input->UpdateBooleanComponent( m_handles[ALVR_INPUT_GRIP_CLICK], - Settings::Instance().m_overrideGripThreshold ? - m_gripValue >= Settings::Instance().m_gripThreshold : - (m_buttons & ALVR_BUTTON_FLAG(ALVR_INPUT_GRIP_CLICK)) != 0, + Settings::Instance().m_overrideGripThreshold + ? m_gripValue >= Settings::Instance().m_gripThreshold + : (m_buttons & ALVR_BUTTON_FLAG(ALVR_INPUT_GRIP_CLICK)) != 0, 0.0); vr_driver_input->UpdateBooleanComponent( m_handles[ALVR_INPUT_SYSTEM_CLICK], @@ -1236,9 +1205,9 @@ bool OvrController::onPoseUpdate(float predictionS, 0.0); vr_driver_input->UpdateBooleanComponent( m_handles[ALVR_INPUT_GRIP_CLICK], - Settings::Instance().m_overrideGripThreshold ? - m_gripValue >= Settings::Instance().m_gripThreshold : - (m_buttons & ALVR_BUTTON_FLAG(ALVR_INPUT_GRIP_CLICK)) != 0, + Settings::Instance().m_overrideGripThreshold + ? m_gripValue >= Settings::Instance().m_gripThreshold + : (m_buttons & ALVR_BUTTON_FLAG(ALVR_INPUT_GRIP_CLICK)) != 0, 0.0); vr_driver_input->UpdateScalarComponent( m_handles[ALVR_INPUT_GRIP_VALUE], m_gripValue, 0.0); @@ -1318,9 +1287,9 @@ bool OvrController::onPoseUpdate(float predictionS, vr_driver_input->UpdateBooleanComponent( m_handles[ALVR_INPUT_TRIGGER_CLICK], - Settings::Instance().m_overrideTriggerThreshold ? - m_triggerValue >= Settings::Instance().m_triggerThreshold : - (m_buttons & ALVR_BUTTON_FLAG(ALVR_INPUT_TRIGGER_CLICK)) != 0, + Settings::Instance().m_overrideTriggerThreshold + ? m_triggerValue >= Settings::Instance().m_triggerThreshold + : (m_buttons & ALVR_BUTTON_FLAG(ALVR_INPUT_TRIGGER_CLICK)) != 0, 0.0); vr_driver_input->UpdateScalarComponent( m_handles[ALVR_INPUT_TRIGGER_VALUE], m_triggerValue, 0.0); @@ -1370,11 +1339,11 @@ bool OvrController::onPoseUpdate(float predictionS, boneTransforms); // Then update the WithController pose on the component with those transforms - vr::EVRInputError err = vr_driver_input->UpdateSkeletonComponent( - m_compSkeleton, - vr::VRSkeletalMotionRange_WithController, - boneTransforms, - SKELETON_BONE_COUNT); + vr::EVRInputError err = + vr_driver_input->UpdateSkeletonComponent(m_compSkeleton, + vr::VRSkeletalMotionRange_WithController, + boneTransforms, + SKELETON_BONE_COUNT); if (err != vr::VRInputError_None) { // Handle failure case Debug("UpdateSkeletonComponentfailed. Error: %i\n", err); diff --git a/alvr/server/cpp/alvr_server/OvrController.h b/alvr/server/cpp/alvr_server/OvrController.h index 351a10b985..1b92fce78a 100644 --- a/alvr/server/cpp/alvr_server/OvrController.h +++ b/alvr/server/cpp/alvr_server/OvrController.h @@ -35,9 +35,9 @@ class OvrController : public TrackedDevice, public vr::ITrackedDeviceServerDrive vr::VRInputComponentHandle_t getHapticComponent(); - void SetButton(uint64_t id, AlvrButtonValue value); + void SetButton(uint64_t id, FfiButtonValue value); - bool onPoseUpdate(float predictionS, AlvrDeviceMotion motion, const OculusHand &hand); + bool onPoseUpdate(float predictionS, FfiDeviceMotion motion, const FfiHandSkeleton &hand); std::string GetSerialNumber(); void GetBoneTransform(bool withController, diff --git a/alvr/server/cpp/alvr_server/OvrHMD.cpp b/alvr/server/cpp/alvr_server/OvrHMD.cpp index 23b479d30b..0935e9d62e 100644 --- a/alvr/server/cpp/alvr_server/OvrHMD.cpp +++ b/alvr/server/cpp/alvr_server/OvrHMD.cpp @@ -22,7 +22,7 @@ const vr::HmdMatrix34_t MATRIX_IDENTITY = { {{1.0, 0.0, 0.0, 0.0}, {0.0, 1.0, 0.0, 0.0}, {0.0, 0.0, 1.0, 0.0}}}; -vr::HmdRect2_t fov_to_projection(EyeFov fov) { +vr::HmdRect2_t fov_to_projection(FfiFov fov) { auto proj_bounds = vr::HmdRect2_t{}; proj_bounds.vTopLeft.v[0] = tanf(fov.left); proj_bounds.vBottomRight.v[0] = tanf(fov.right); @@ -50,9 +50,9 @@ inline vr::ETrackedDeviceClass getControllerDeviceClass() { OvrHmd::OvrHmd() : TrackedDevice(HEAD_ID), m_baseComponentsInitialized(false), m_streamComponentsInitialized(false) { - auto dummy_fov = EyeFov{-1.0, 1.0, 1.0, -1.0}; + auto dummy_fov = FfiFov{-1.0, 1.0, 1.0, -1.0}; - this->views_config = ViewsConfigData{}; + this->views_config = FfiViewsConfig{}; this->views_config.ipd_m = 0.063; this->views_config.fov[0] = dummy_fov; this->views_config.fov[1] = dummy_fov; @@ -309,7 +309,7 @@ void *OvrHmd::GetComponent(const char *component_name_and_version) { vr::DriverPose_t OvrHmd::GetPose() { return m_pose; } -void OvrHmd::OnPoseUpdated(uint64_t targetTimestampNs, AlvrDeviceMotion motion) { +void OvrHmd::OnPoseUpdated(uint64_t targetTimestampNs, FfiDeviceMotion motion) { if (this->object_id != vr::k_unTrackedDeviceIndexInvalid) { auto pose = vr::DriverPose_t{}; pose.poseIsValid = true; @@ -393,7 +393,7 @@ void OvrHmd::StopStreaming() { vr::VRDriverInput()->UpdateBooleanComponent(m_proximity, false, 0.0); } -void OvrHmd::SetViewsConfig(ViewsConfigData config) { +void OvrHmd::SetViewsConfig(FfiViewsConfig config) { this->views_config = config; auto left_transform = MATRIX_IDENTITY; diff --git a/alvr/server/cpp/alvr_server/OvrHMD.h b/alvr/server/cpp/alvr_server/OvrHMD.h index a70e57f2f5..e5ce062dba 100644 --- a/alvr/server/cpp/alvr_server/OvrHMD.h +++ b/alvr/server/cpp/alvr_server/OvrHMD.h @@ -37,13 +37,13 @@ class OvrHmd : public TrackedDevice, virtual void DebugRequest(const char *, char *, uint32_t) {} virtual vr::DriverPose_t GetPose(); - void OnPoseUpdated(uint64_t targetTimestampNs, AlvrDeviceMotion motion); + void OnPoseUpdated(uint64_t targetTimestampNs, FfiDeviceMotion motion); void StartStreaming(); void StopStreaming(); - void SetViewsConfig(ViewsConfigData config); + void SetViewsConfig(FfiViewsConfig config); bool IsTrackingRef() const { return m_deviceClass == vr::TrackedDeviceClass_TrackingReference; } bool IsHMD() const { return m_deviceClass == vr::TrackedDeviceClass_HMD; } @@ -71,7 +71,7 @@ class OvrHmd : public TrackedDevice, std::shared_ptr m_poseHistory; private: - ViewsConfigData views_config; + FfiViewsConfig views_config; bool m_baseComponentsInitialized; bool m_streamComponentsInitialized; diff --git a/alvr/server/cpp/alvr_server/PoseHistory.cpp b/alvr/server/cpp/alvr_server/PoseHistory.cpp index 4677bb3c14..fe639a930f 100644 --- a/alvr/server/cpp/alvr_server/PoseHistory.cpp +++ b/alvr/server/cpp/alvr_server/PoseHistory.cpp @@ -4,7 +4,7 @@ #include #include -void PoseHistory::OnPoseUpdated(uint64_t targetTimestampNs, AlvrDeviceMotion motion) { +void PoseHistory::OnPoseUpdated(uint64_t targetTimestampNs, FfiDeviceMotion motion) { // Put pose history buffer TrackingHistoryFrame history; history.targetTimestampNs = targetTimestampNs; diff --git a/alvr/server/cpp/alvr_server/PoseHistory.h b/alvr/server/cpp/alvr_server/PoseHistory.h index f2a425ade7..c878f8f5c8 100644 --- a/alvr/server/cpp/alvr_server/PoseHistory.h +++ b/alvr/server/cpp/alvr_server/PoseHistory.h @@ -11,11 +11,11 @@ class PoseHistory public: struct TrackingHistoryFrame { uint64_t targetTimestampNs; - AlvrDeviceMotion motion; + FfiDeviceMotion motion; vr::HmdMatrix34_t rotationMatrix; }; - void OnPoseUpdated(uint64_t targetTimestampNs, AlvrDeviceMotion motion); + void OnPoseUpdated(uint64_t targetTimestampNs, FfiDeviceMotion motion); std::optional GetBestPoseMatch(const vr::HmdMatrix34_t &pose) const; // Return the most recent pose known at the given timestamp diff --git a/alvr/server/cpp/alvr_server/TrackedDevice.cpp b/alvr/server/cpp/alvr_server/TrackedDevice.cpp index 4a2fb9e505..58cae89dbf 100644 --- a/alvr/server/cpp/alvr_server/TrackedDevice.cpp +++ b/alvr/server/cpp/alvr_server/TrackedDevice.cpp @@ -1,32 +1,32 @@ #include "TrackedDevice.h" #include "Logger.h" -void TrackedDevice::set_prop(OpenvrProperty prop) { +void TrackedDevice::set_prop(FfiOpenvrProperty prop) { auto key = (vr::ETrackedDeviceProperty)prop.key; auto vr_properties = vr::VRProperties(); vr::ETrackedPropertyError result; - if (prop.type == OpenvrPropertyType::Bool) { + if (prop.type == FfiOpenvrPropertyType::Bool) { result = vr_properties->SetBoolProperty(this->prop_container, key, prop.value.bool_); - } else if (prop.type == OpenvrPropertyType::Float) { + } else if (prop.type == FfiOpenvrPropertyType::Float) { result = vr_properties->SetFloatProperty(this->prop_container, key, prop.value.float_); - } else if (prop.type == OpenvrPropertyType::Int32) { + } else if (prop.type == FfiOpenvrPropertyType::Int32) { result = vr_properties->SetInt32Property(this->prop_container, key, prop.value.int32); - } else if (prop.type == OpenvrPropertyType::Uint64) { + } else if (prop.type == FfiOpenvrPropertyType::Uint64) { result = vr_properties->SetUint64Property(this->prop_container, key, prop.value.uint64); - } else if (prop.type == OpenvrPropertyType::Vector3) { + } else if (prop.type == FfiOpenvrPropertyType::Vector3) { auto vec3 = vr::HmdVector3_t{}; vec3.v[0] = prop.value.vector3[0]; vec3.v[1] = prop.value.vector3[1]; vec3.v[2] = prop.value.vector3[2]; result = vr_properties->SetVec3Property(this->prop_container, key, vec3); - } else if (prop.type == OpenvrPropertyType::Double) { + } else if (prop.type == FfiOpenvrPropertyType::Double) { result = vr_properties->SetDoubleProperty(this->prop_container, key, prop.value.double_); - } else if (prop.type == OpenvrPropertyType::String) { + } else if (prop.type == FfiOpenvrPropertyType::String) { result = vr_properties->SetStringProperty(this->prop_container, key, prop.value.string); } else { diff --git a/alvr/server/cpp/alvr_server/TrackedDevice.h b/alvr/server/cpp/alvr_server/TrackedDevice.h index f986e9483c..89751196bb 100644 --- a/alvr/server/cpp/alvr_server/TrackedDevice.h +++ b/alvr/server/cpp/alvr_server/TrackedDevice.h @@ -10,7 +10,7 @@ class TrackedDevice { vr::TrackedDeviceIndex_t object_id = vr::k_unTrackedDeviceIndexInvalid; vr::PropertyContainerHandle_t prop_container = vr::k_ulInvalidPropertyContainer; - void set_prop(OpenvrProperty prop); + void set_prop(FfiOpenvrProperty prop); TrackedDevice(uint64_t device_id) : device_id(device_id) {} }; \ No newline at end of file diff --git a/alvr/server/cpp/alvr_server/alvr_server.cpp b/alvr/server/cpp/alvr_server/alvr_server.cpp index 733407ff7d..de84aebbc5 100644 --- a/alvr/server/cpp/alvr_server/alvr_server.cpp +++ b/alvr/server/cpp/alvr_server/alvr_server.cpp @@ -243,10 +243,10 @@ void RequestIDR() { void SetTracking(unsigned long long targetTimestampNs, float controllerPoseTimeOffsetS, - const AlvrDeviceMotion *deviceMotions, + const FfiDeviceMotion *deviceMotions, int motionsCount, - OculusHand leftHand, - OculusHand rightHand) { + FfiHandSkeleton leftHand, + FfiHandSkeleton rightHand) { for (int i = 0; i < motionsCount; i++) { if (deviceMotions[i].deviceID == HEAD_ID && g_driver_provider.hmd) { g_driver_provider.hmd->OnPoseUpdated(targetTimestampNs, deviceMotions[i]); @@ -281,7 +281,7 @@ void ShutdownSteamvr() { } } -void SetOpenvrProperty(unsigned long long top_level_path, OpenvrProperty prop) { +void SetOpenvrProperty(unsigned long long top_level_path, FfiOpenvrProperty prop) { auto device_it = g_driver_provider.tracked_devices.find(top_level_path); if (device_it != g_driver_provider.tracked_devices.end()) { @@ -289,7 +289,7 @@ void SetOpenvrProperty(unsigned long long top_level_path, OpenvrProperty prop) { } } -void SetViewsConfig(ViewsConfigData config) { +void SetViewsConfig(FfiViewsConfig config) { if (g_driver_provider.hmd) { g_driver_provider.hmd->SetViewsConfig(config); } @@ -306,7 +306,7 @@ void SetBattery(unsigned long long top_level_path, float gauge_value, bool is_pl } } -void SetButton(unsigned long long path, AlvrButtonValue value) { +void SetButton(unsigned long long path, FfiButtonValue value) { if (std::find(LEFT_CONTROLLER_BUTTON_IDS.begin(), LEFT_CONTROLLER_BUTTON_IDS.end(), path) != LEFT_CONTROLLER_BUTTON_IDS.end()) { g_driver_provider.left_controller->SetButton(path, value); diff --git a/alvr/server/cpp/alvr_server/bindings.h b/alvr/server/cpp/alvr_server/bindings.h index e5bc4aa58c..f50f79c40e 100644 --- a/alvr/server/cpp/alvr_server/bindings.h +++ b/alvr/server/cpp/alvr_server/bindings.h @@ -1,33 +1,33 @@ #pragma once -struct EyeFov { +struct FfiFov { float left; float right; float up; float down; }; -struct AlvrQuat { +struct FfiQuat { float x; float y; float z; float w; }; -struct OculusHand { +struct FfiHandSkeleton { bool enabled; - AlvrQuat boneRotations[19]; + FfiQuat boneRotations[19]; }; -struct AlvrDeviceMotion { +struct FfiDeviceMotion { unsigned long long deviceID; - AlvrQuat orientation; + FfiQuat orientation; float position[3]; float linearVelocity[3]; float angularVelocity[3]; }; -enum OpenvrPropertyType { +enum FfiOpenvrPropertyType { Bool, Float, Int32, @@ -37,7 +37,7 @@ enum OpenvrPropertyType { String, }; -union OpenvrPropertyValue { +union FfiOpenvrPropertyValue { bool bool_; float float_; int int32; @@ -47,24 +47,24 @@ union OpenvrPropertyValue { char string[64]; }; -struct OpenvrProperty { +struct FfiOpenvrProperty { unsigned int key; - OpenvrPropertyType type; - OpenvrPropertyValue value; + FfiOpenvrPropertyType type; + FfiOpenvrPropertyValue value; }; -struct ViewsConfigData { - EyeFov fov[2]; +struct FfiViewsConfig { + FfiFov fov[2]; float ipd_m; }; -enum AlvrButtonType { +enum FfiButtonType { BUTTON_TYPE_BINARY, BUTTON_TYPE_SCALAR, }; -struct AlvrButtonValue { - AlvrButtonType type; +struct FfiButtonValue { + FfiButtonType type; union { bool binary; float scalar; @@ -121,19 +121,19 @@ extern "C" void SendVSync(float frameIntervalS); extern "C" void RequestIDR(); extern "C" void SetTracking(unsigned long long targetTimestampNs, float controllerPoseTimeOffsetS, - const AlvrDeviceMotion *deviceMotions, + const FfiDeviceMotion *deviceMotions, int motionsCount, - OculusHand leftHand, - OculusHand rightHand); + FfiHandSkeleton leftHand, + FfiHandSkeleton rightHand); extern "C" void ReportNetworkLatency(unsigned long long latencyUs); extern "C" void VideoErrorReportReceive(); extern "C" void ShutdownSteamvr(); -extern "C" void SetOpenvrProperty(unsigned long long topLevelPath, OpenvrProperty prop); +extern "C" void SetOpenvrProperty(unsigned long long topLevelPath, FfiOpenvrProperty prop); extern "C" void SetChaperone(float areaWidth, float areaHeight); -extern "C" void SetViewsConfig(ViewsConfigData config); +extern "C" void SetViewsConfig(FfiViewsConfig config); extern "C" void SetBattery(unsigned long long topLevelPath, float gauge_value, bool is_plugged); -extern "C" void SetButton(unsigned long long path, AlvrButtonValue value); +extern "C" void SetButton(unsigned long long path, FfiButtonValue value); extern "C" void SetBitrateParameters(unsigned long long bitrate_mbs, bool adaptive_bitrate_enabled, diff --git a/alvr/server/src/connection.rs b/alvr/server/src/connection.rs index 2548230eb6..8a672d26eb 100644 --- a/alvr/server/src/connection.rs +++ b/alvr/server/src/connection.rs @@ -1,10 +1,9 @@ use crate::{ buttons::BUTTON_PATH_FROM_ID, sockets::WelcomeSocket, statistics::StatisticsManager, - tracking::TrackingManager, AlvrButtonType_BUTTON_TYPE_BINARY, - AlvrButtonType_BUTTON_TYPE_SCALAR, AlvrButtonValue, AlvrButtonValue__bindgen_ty_1, - AlvrDeviceMotion, AlvrQuat, EyeFov, OculusHand, VideoPacket, CONTROL_CHANNEL_SENDER, - DECODER_CONFIG, DISCONNECT_CLIENT_NOTIFIER, HAPTICS_SENDER, IS_ALIVE, RESTART_NOTIFIER, - SERVER_DATA_MANAGER, STATISTICS_MANAGER, VIDEO_SENDER, + tracking::TrackingManager, FfiButtonValue, FfiDeviceMotion, FfiFov, FfiHandSkeleton, FfiQuat, + FfiViewsConfig, VideoPacket, CONTROL_CHANNEL_SENDER, DECODER_CONFIG, + DISCONNECT_CLIENT_NOTIFIER, HAPTICS_SENDER, IS_ALIVE, RESTART_NOTIFIER, SERVER_DATA_MANAGER, + STATISTICS_MANAGER, VIDEO_SENDER, }; use alvr_audio::{AudioDevice, AudioDeviceType}; use alvr_common::{ @@ -679,7 +678,7 @@ async fn connection_pipeline( }; crate::SetOpenvrProperty( *HEAD_ID, - crate::to_cpp_openvr_prop( + crate::to_ffi_openvr_prop( alvr_session::OpenvrPropertyKey::AudioDefaultPlaybackDeviceId, alvr_session::OpenvrPropValue::String(device_id), ), @@ -711,7 +710,7 @@ async fn connection_pipeline( unsafe { crate::SetOpenvrProperty( *HEAD_ID, - crate::to_cpp_openvr_prop( + crate::to_ffi_openvr_prop( alvr_session::OpenvrPropertyKey::AudioDefaultPlaybackDeviceId, alvr_session::OpenvrPropValue::String(default_device_id), ), @@ -744,7 +743,7 @@ async fn connection_pipeline( unsafe { crate::SetOpenvrProperty( *HEAD_ID, - crate::to_cpp_openvr_prop( + crate::to_ffi_openvr_prop( alvr_session::OpenvrPropertyKey::AudioDefaultRecordingDeviceId, alvr_session::OpenvrPropValue::String(microphone_device_id), ), @@ -820,8 +819,8 @@ async fn connection_pipeline( }); } - fn to_tracking_quat(quat: Quat) -> AlvrQuat { - AlvrQuat { + fn to_ffi_quat(quat: Quat) -> FfiQuat { + FfiQuat { x: quat.x, y: quat.y, z: quat.z, @@ -860,79 +859,77 @@ async fn connection_pipeline( device_motions.push((id, motion)); } - let raw_motions = device_motions + let ffi_motions = device_motions .into_iter() - .map(|(id, motion)| AlvrDeviceMotion { + .map(|(id, motion)| FfiDeviceMotion { deviceID: id, - orientation: to_tracking_quat(motion.orientation), + orientation: to_ffi_quat(motion.orientation), position: motion.position.to_array(), linearVelocity: motion.linear_velocity.to_array(), angularVelocity: motion.angular_velocity.to_array(), }) .collect::>(); - let left_oculus_hand = if let Some(arr) = tracking.left_hand_skeleton { - let vec = arr.into_iter().map(to_tracking_quat).collect::>(); - let mut array = [AlvrQuat::default(); 19]; + let left_hand_skeleton = if let Some(arr) = tracking.left_hand_skeleton { + let vec = arr.into_iter().map(to_ffi_quat).collect::>(); + let mut array = [FfiQuat::default(); 19]; array.copy_from_slice(&vec); - OculusHand { + FfiHandSkeleton { enabled: true, boneRotations: array, } } else { - OculusHand { + FfiHandSkeleton { enabled: false, ..Default::default() } }; - let right_oculus_hand = if let Some(arr) = tracking.right_hand_skeleton { - let vec = arr.into_iter().map(to_tracking_quat).collect::>(); - let mut array = [AlvrQuat::default(); 19]; + let right_hand_skeleton = if let Some(arr) = tracking.right_hand_skeleton { + let vec = arr.into_iter().map(to_ffi_quat).collect::>(); + let mut array = [FfiQuat::default(); 19]; array.copy_from_slice(&vec); - OculusHand { + FfiHandSkeleton { enabled: true, boneRotations: array, } } else { - OculusHand { + FfiHandSkeleton { enabled: false, ..Default::default() } }; - let maybe_server_prediction_average = - if let Some(stats) = &mut *STATISTICS_MANAGER.lock() { - stats.report_tracking_received(tracking.target_timestamp); - - unsafe { - crate::SetTracking( - tracking.target_timestamp.as_nanos() as _, - tracking_latency_offset_s, - raw_motions.as_ptr(), - raw_motions.len() as _, - left_oculus_hand, - right_oculus_hand, - ) - }; - - Some(stats.get_server_prediction_average()) - } else { - None + let server_prediction_average = if let Some(stats) = &mut *STATISTICS_MANAGER.lock() + { + stats.report_tracking_received(tracking.target_timestamp); + + unsafe { + crate::SetTracking( + tracking.target_timestamp.as_nanos() as _, + tracking_latency_offset_s, + ffi_motions.as_ptr(), + ffi_motions.len() as _, + left_hand_skeleton, + right_hand_skeleton, + ) }; - if let Some(server_prediction_average) = maybe_server_prediction_average { - control_sender - .lock() - .await - .send(&ServerControlPacket::ServerPredictionAverage( - server_prediction_average, - )) - .await - .ok(); - } + stats.get_server_prediction_average() + } else { + Duration::ZERO + }; + + control_sender + .lock() + .await + .send(&ServerControlPacket::ServerPredictionAverage( + server_prediction_average, + )) + .await + .ok(); } } }; @@ -1036,15 +1033,15 @@ async fn connection_pipeline( unsafe { crate::VideoErrorReportReceive() }; } Ok(ClientControlPacket::ViewsConfig(config)) => unsafe { - crate::SetViewsConfig(crate::ViewsConfigData { + crate::SetViewsConfig(FfiViewsConfig { fov: [ - EyeFov { + FfiFov { left: config.fov[0].left, right: config.fov[0].right, up: config.fov[0].up, down: config.fov[0].down, }, - EyeFov { + FfiFov { left: config.fov[1].left, right: config.fov[1].right, up: config.fov[1].up, @@ -1073,14 +1070,14 @@ async fn connection_pipeline( } let value = match value { - ButtonValue::Binary(value) => AlvrButtonValue { - type_: AlvrButtonType_BUTTON_TYPE_BINARY, - __bindgen_anon_1: AlvrButtonValue__bindgen_ty_1 { binary: value }, + ButtonValue::Binary(value) => FfiButtonValue { + type_: crate::FfiButtonType_BUTTON_TYPE_BINARY, + __bindgen_anon_1: crate::FfiButtonValue__bindgen_ty_1 { binary: value }, }, - ButtonValue::Scalar(value) => AlvrButtonValue { - type_: AlvrButtonType_BUTTON_TYPE_SCALAR, - __bindgen_anon_1: AlvrButtonValue__bindgen_ty_1 { scalar: value }, + ButtonValue::Scalar(value) => FfiButtonValue { + type_: crate::FfiButtonType_BUTTON_TYPE_SCALAR, + __bindgen_anon_1: crate::FfiButtonValue__bindgen_ty_1 { scalar: value }, }, }; diff --git a/alvr/server/src/lib.rs b/alvr/server/src/lib.rs index b17bb7e66a..d2fc0ea57f 100644 --- a/alvr/server/src/lib.rs +++ b/alvr/server/src/lib.rs @@ -100,24 +100,24 @@ pub enum WindowType { Browser, } -pub fn to_cpp_openvr_prop(key: OpenvrPropertyKey, value: OpenvrPropValue) -> OpenvrProperty { +pub fn to_ffi_openvr_prop(key: OpenvrPropertyKey, value: OpenvrPropValue) -> FfiOpenvrProperty { let type_ = match value { - OpenvrPropValue::Bool(_) => OpenvrPropertyType_Bool, - OpenvrPropValue::Float(_) => OpenvrPropertyType_Float, - OpenvrPropValue::Int32(_) => OpenvrPropertyType_Int32, - OpenvrPropValue::Uint64(_) => OpenvrPropertyType_Uint64, - OpenvrPropValue::Vector3(_) => OpenvrPropertyType_Vector3, - OpenvrPropValue::Double(_) => OpenvrPropertyType_Double, - OpenvrPropValue::String(_) => OpenvrPropertyType_String, + OpenvrPropValue::Bool(_) => FfiOpenvrPropertyType_Bool, + OpenvrPropValue::Float(_) => FfiOpenvrPropertyType_Float, + OpenvrPropValue::Int32(_) => FfiOpenvrPropertyType_Int32, + OpenvrPropValue::Uint64(_) => FfiOpenvrPropertyType_Uint64, + OpenvrPropValue::Vector3(_) => FfiOpenvrPropertyType_Vector3, + OpenvrPropValue::Double(_) => FfiOpenvrPropertyType_Double, + OpenvrPropValue::String(_) => FfiOpenvrPropertyType_String, }; let value = match value { - OpenvrPropValue::Bool(bool_) => OpenvrPropertyValue { bool_ }, - OpenvrPropValue::Float(float_) => OpenvrPropertyValue { float_ }, - OpenvrPropValue::Int32(int32) => OpenvrPropertyValue { int32 }, - OpenvrPropValue::Uint64(uint64) => OpenvrPropertyValue { uint64 }, - OpenvrPropValue::Vector3(vector3) => OpenvrPropertyValue { vector3 }, - OpenvrPropValue::Double(double_) => OpenvrPropertyValue { double_ }, + OpenvrPropValue::Bool(bool_) => FfiOpenvrPropertyValue { bool_ }, + OpenvrPropValue::Float(float_) => FfiOpenvrPropertyValue { float_ }, + OpenvrPropValue::Int32(int32) => FfiOpenvrPropertyValue { int32 }, + OpenvrPropValue::Uint64(uint64) => FfiOpenvrPropertyValue { uint64 }, + OpenvrPropValue::Vector3(vector3) => FfiOpenvrPropertyValue { vector3 }, + OpenvrPropValue::Double(double_) => FfiOpenvrPropertyValue { double_ }, OpenvrPropValue::String(value) => { let c_string = CString::new(value).unwrap(); let mut string = [0; 64]; @@ -130,11 +130,11 @@ pub fn to_cpp_openvr_prop(key: OpenvrPropertyKey, value: OpenvrPropValue) -> Ope ); } - OpenvrPropertyValue { string } + FfiOpenvrPropertyValue { string } } }; - OpenvrProperty { + FfiOpenvrProperty { key: key as u32, type_, value,