Loading services/vr/vr_window_manager/Android.mk_disable +49 −1 Original line number Diff line number Diff line Loading @@ -14,6 +14,30 @@ LOCAL_PATH := $(call my-dir) binder_src := \ vr_window_manager_binder.cpp \ aidl/android/service/vr/IVrWindowManager.aidl static_libs := \ libcutils shared_libs := \ libbase \ libbinder \ libutils include $(CLEAR_VARS) LOCAL_SRC_FILES := $(binder_src) LOCAL_STATIC_LIBRARIES := $(static_libs) LOCAL_SHARED_LIBRARIES := $(shared_libs) LOCAL_CPPFLAGS += -std=c++11 LOCAL_CFLAGS += -DLOG_TAG=\"VrWindowManager\" LOCAL_LDLIBS := -llog LOCAL_MODULE := libvrwm_binder LOCAL_MODULE_TAGS := optional include $(BUILD_STATIC_LIBRARY) native_src := \ application.cpp \ controller_mesh.cpp \ Loading Loading @@ -94,7 +118,7 @@ include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_SRC_FILES := $(native_src) LOCAL_C_INCLUDES := hardware/qcom/display/msm8996/libgralloc LOCAL_STATIC_LIBRARIES := $(static_libs) LOCAL_STATIC_LIBRARIES := $(static_libs) libvrwm_binder LOCAL_SHARED_LIBRARIES := $(shared_libs) LOCAL_SHARED_LIBRARIES += libgvr LOCAL_STATIC_LIBRARIES += libgvr_ext Loading Loading @@ -126,3 +150,27 @@ LOCAL_AAPT_FLAGS += --auto-add-overlay LOCAL_AAPT_FLAGS += --extra-packages com.google.vr.cardboard LOCAL_PROGUARD_FLAG_FILES := proguard.flags include $(BUILD_PACKAGE) cmd_src := \ vr_wm_ctl.cpp \ aidl/android/service/vr/IVrWindowManager.aidl static_libs := \ libcutils shared_libs := \ libbase \ libbinder \ libutils include $(CLEAR_VARS) LOCAL_SRC_FILES := $(cmd_src) LOCAL_STATIC_LIBRARIES := $(static_libs) LOCAL_SHARED_LIBRARIES := $(shared_libs) LOCAL_CPPFLAGS += -std=c++11 LOCAL_CFLAGS += -DLOG_TAG=\"vrwmctl\" LOCAL_LDLIBS := -llog LOCAL_MODULE := vr_wm_ctl LOCAL_MODULE_TAGS := optional include $(BUILD_EXECUTABLE) services/vr/vr_window_manager/AndroidManifest.xml +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ <service android:name=".VrWindowManagerService" /> <receiver android:name="com.google.vr.windowmanager.BootCompletedReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <!-- action android:name="android.intent.action.BOOT_COMPLETED" / --> </intent-filter> </receiver> </application> Loading services/vr/vr_window_manager/aidl/android/service/vr/IVrWindowManager.aidl 0 → 100644 +28 −0 Original line number Diff line number Diff line /** * Copyright (c) 2017, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.service.vr; /** @hide */ interface IVrWindowManager { const String SERVICE_NAME = "vr_window_manager"; void connectController(in FileDescriptor fd) = 0; void disconnectController() = 1; void enterVrMode() = 2; void exitVrMode() = 3; void setDebugMode(int mode) = 4; } services/vr/vr_window_manager/application.cpp +62 −6 Original line number Diff line number Diff line Loading @@ -226,10 +226,8 @@ void Application::DrawFrame() { if (fade_value_ > 1.0f) fade_value_ = 1.0f; quat controller_quat(controller_orientation_.qw, controller_orientation_.qx, controller_orientation_.qy, controller_orientation_.qz); controller_position_ = elbow_model_.Update( delta, last_pose_.GetRotation(), controller_quat, false); controller_position_ = elbow_model_.Update(delta, last_pose_.GetRotation(), controller_orientation_, false); dvrBeginRenderFrameEds(graphics_context_, pose.orientation, pose.translation); Loading Loading @@ -257,6 +255,61 @@ void Application::DrawFrame() { } void Application::ProcessControllerInput() { if (controller_data_provider_) { shmem_controller_active_ = false; const void* data = controller_data_provider_->LockControllerData(); // TODO(kpschoedel): define wire format. if (data) { struct wire_format { uint32_t version; uint32_t timestamph; uint32_t timestampl; uint32_t quat_count; float q[4]; uint32_t buttonsh; uint32_t buttonsl; } __attribute__((__aligned__(32))); const wire_format* wire_data = static_cast<const wire_format*>(data); static uint64_t last_timestamp = 0; if (wire_data->version == 1) { shmem_controller_active_ = true; uint64_t timestamp = (((uint64_t)wire_data->timestamph) << 32) | wire_data->timestampl; if (timestamp == last_timestamp) { static uint64_t last_logged_timestamp = 0; if (last_logged_timestamp != last_timestamp) { last_logged_timestamp = last_timestamp; ALOGI("Controller shmem stale T=0x%" PRIX64, last_timestamp); } } else { last_timestamp = timestamp; controller_orientation_ = quat(wire_data->q[3], wire_data->q[0], wire_data->q[1], wire_data->q[2]); shmem_controller_buttons_ = (((uint64_t)wire_data->buttonsh) << 32) | wire_data->buttonsl; } } else if (wire_data->version == 0xFEEDFACE) { static bool logged_init = false; if (!logged_init) { logged_init = true; ALOGI("Controller shmem waiting for data"); } } } controller_data_provider_->UnlockControllerData(); if (shmem_controller_active_) { // TODO(kpschoedel): change to ALOGV or remove. ALOGI("Controller shmem orientation: %f %f %f %f", controller_orientation_.x(), controller_orientation_.y(), controller_orientation_.z(), controller_orientation_.w()); if (shmem_controller_buttons_) { ALOGI("Controller shmem buttons: %017" PRIX64, shmem_controller_buttons_); } return; } } if (!controller_) return; Loading Loading @@ -289,8 +342,11 @@ void Application::ProcessControllerInput() { controller_connection_state_logged_ = false; } if (new_api_status == gvr::kControllerApiOk) controller_orientation_ = controller_state_->GetOrientation(); if (new_api_status == gvr::kControllerApiOk) { gvr_quatf orientation = controller_state_->GetOrientation(); controller_orientation_ = quat(orientation.qw, orientation.qx, orientation.qy, orientation.qz); } controller_api_status_ = new_api_status; controller_connection_state_ = new_connection_state; Loading services/vr/vr_window_manager/application.h +11 −1 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ #include <chrono> #include <mutex> #include "controller_data_provider.h" #include "elbow_model.h" struct DvrGraphicsContext; Loading @@ -32,6 +33,10 @@ class Application { void DrawFrame(); void SetControllerDataProvider(ControllerDataProvider* provider) { controller_data_provider_ = provider; } protected: enum class MainThreadTask { EnteringVrMode, Loading Loading @@ -69,9 +74,11 @@ class Application { std::unique_ptr<gvr::ControllerState> controller_state_; gvr::ControllerApiStatus controller_api_status_; gvr::ControllerConnectionState controller_connection_state_; gvr_quatf controller_orientation_; quat controller_orientation_; bool shmem_controller_active_ = false; bool controller_api_status_logged_; bool controller_connection_state_logged_; uint64_t shmem_controller_buttons_; bool is_visible_ = false; std::chrono::time_point<std::chrono::system_clock> visibility_button_press_; Loading @@ -93,6 +100,9 @@ class Application { jobject app_context_; jobject class_loader_; // Controller data provider from shared memory buffer. ControllerDataProvider* controller_data_provider_ = nullptr; Application(const Application&) = delete; void operator=(const Application&) = delete; }; Loading Loading
services/vr/vr_window_manager/Android.mk_disable +49 −1 Original line number Diff line number Diff line Loading @@ -14,6 +14,30 @@ LOCAL_PATH := $(call my-dir) binder_src := \ vr_window_manager_binder.cpp \ aidl/android/service/vr/IVrWindowManager.aidl static_libs := \ libcutils shared_libs := \ libbase \ libbinder \ libutils include $(CLEAR_VARS) LOCAL_SRC_FILES := $(binder_src) LOCAL_STATIC_LIBRARIES := $(static_libs) LOCAL_SHARED_LIBRARIES := $(shared_libs) LOCAL_CPPFLAGS += -std=c++11 LOCAL_CFLAGS += -DLOG_TAG=\"VrWindowManager\" LOCAL_LDLIBS := -llog LOCAL_MODULE := libvrwm_binder LOCAL_MODULE_TAGS := optional include $(BUILD_STATIC_LIBRARY) native_src := \ application.cpp \ controller_mesh.cpp \ Loading Loading @@ -94,7 +118,7 @@ include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_SRC_FILES := $(native_src) LOCAL_C_INCLUDES := hardware/qcom/display/msm8996/libgralloc LOCAL_STATIC_LIBRARIES := $(static_libs) LOCAL_STATIC_LIBRARIES := $(static_libs) libvrwm_binder LOCAL_SHARED_LIBRARIES := $(shared_libs) LOCAL_SHARED_LIBRARIES += libgvr LOCAL_STATIC_LIBRARIES += libgvr_ext Loading Loading @@ -126,3 +150,27 @@ LOCAL_AAPT_FLAGS += --auto-add-overlay LOCAL_AAPT_FLAGS += --extra-packages com.google.vr.cardboard LOCAL_PROGUARD_FLAG_FILES := proguard.flags include $(BUILD_PACKAGE) cmd_src := \ vr_wm_ctl.cpp \ aidl/android/service/vr/IVrWindowManager.aidl static_libs := \ libcutils shared_libs := \ libbase \ libbinder \ libutils include $(CLEAR_VARS) LOCAL_SRC_FILES := $(cmd_src) LOCAL_STATIC_LIBRARIES := $(static_libs) LOCAL_SHARED_LIBRARIES := $(shared_libs) LOCAL_CPPFLAGS += -std=c++11 LOCAL_CFLAGS += -DLOG_TAG=\"vrwmctl\" LOCAL_LDLIBS := -llog LOCAL_MODULE := vr_wm_ctl LOCAL_MODULE_TAGS := optional include $(BUILD_EXECUTABLE)
services/vr/vr_window_manager/AndroidManifest.xml +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ <service android:name=".VrWindowManagerService" /> <receiver android:name="com.google.vr.windowmanager.BootCompletedReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <!-- action android:name="android.intent.action.BOOT_COMPLETED" / --> </intent-filter> </receiver> </application> Loading
services/vr/vr_window_manager/aidl/android/service/vr/IVrWindowManager.aidl 0 → 100644 +28 −0 Original line number Diff line number Diff line /** * Copyright (c) 2017, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.service.vr; /** @hide */ interface IVrWindowManager { const String SERVICE_NAME = "vr_window_manager"; void connectController(in FileDescriptor fd) = 0; void disconnectController() = 1; void enterVrMode() = 2; void exitVrMode() = 3; void setDebugMode(int mode) = 4; }
services/vr/vr_window_manager/application.cpp +62 −6 Original line number Diff line number Diff line Loading @@ -226,10 +226,8 @@ void Application::DrawFrame() { if (fade_value_ > 1.0f) fade_value_ = 1.0f; quat controller_quat(controller_orientation_.qw, controller_orientation_.qx, controller_orientation_.qy, controller_orientation_.qz); controller_position_ = elbow_model_.Update( delta, last_pose_.GetRotation(), controller_quat, false); controller_position_ = elbow_model_.Update(delta, last_pose_.GetRotation(), controller_orientation_, false); dvrBeginRenderFrameEds(graphics_context_, pose.orientation, pose.translation); Loading Loading @@ -257,6 +255,61 @@ void Application::DrawFrame() { } void Application::ProcessControllerInput() { if (controller_data_provider_) { shmem_controller_active_ = false; const void* data = controller_data_provider_->LockControllerData(); // TODO(kpschoedel): define wire format. if (data) { struct wire_format { uint32_t version; uint32_t timestamph; uint32_t timestampl; uint32_t quat_count; float q[4]; uint32_t buttonsh; uint32_t buttonsl; } __attribute__((__aligned__(32))); const wire_format* wire_data = static_cast<const wire_format*>(data); static uint64_t last_timestamp = 0; if (wire_data->version == 1) { shmem_controller_active_ = true; uint64_t timestamp = (((uint64_t)wire_data->timestamph) << 32) | wire_data->timestampl; if (timestamp == last_timestamp) { static uint64_t last_logged_timestamp = 0; if (last_logged_timestamp != last_timestamp) { last_logged_timestamp = last_timestamp; ALOGI("Controller shmem stale T=0x%" PRIX64, last_timestamp); } } else { last_timestamp = timestamp; controller_orientation_ = quat(wire_data->q[3], wire_data->q[0], wire_data->q[1], wire_data->q[2]); shmem_controller_buttons_ = (((uint64_t)wire_data->buttonsh) << 32) | wire_data->buttonsl; } } else if (wire_data->version == 0xFEEDFACE) { static bool logged_init = false; if (!logged_init) { logged_init = true; ALOGI("Controller shmem waiting for data"); } } } controller_data_provider_->UnlockControllerData(); if (shmem_controller_active_) { // TODO(kpschoedel): change to ALOGV or remove. ALOGI("Controller shmem orientation: %f %f %f %f", controller_orientation_.x(), controller_orientation_.y(), controller_orientation_.z(), controller_orientation_.w()); if (shmem_controller_buttons_) { ALOGI("Controller shmem buttons: %017" PRIX64, shmem_controller_buttons_); } return; } } if (!controller_) return; Loading Loading @@ -289,8 +342,11 @@ void Application::ProcessControllerInput() { controller_connection_state_logged_ = false; } if (new_api_status == gvr::kControllerApiOk) controller_orientation_ = controller_state_->GetOrientation(); if (new_api_status == gvr::kControllerApiOk) { gvr_quatf orientation = controller_state_->GetOrientation(); controller_orientation_ = quat(orientation.qw, orientation.qx, orientation.qy, orientation.qz); } controller_api_status_ = new_api_status; controller_connection_state_ = new_connection_state; Loading
services/vr/vr_window_manager/application.h +11 −1 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ #include <chrono> #include <mutex> #include "controller_data_provider.h" #include "elbow_model.h" struct DvrGraphicsContext; Loading @@ -32,6 +33,10 @@ class Application { void DrawFrame(); void SetControllerDataProvider(ControllerDataProvider* provider) { controller_data_provider_ = provider; } protected: enum class MainThreadTask { EnteringVrMode, Loading Loading @@ -69,9 +74,11 @@ class Application { std::unique_ptr<gvr::ControllerState> controller_state_; gvr::ControllerApiStatus controller_api_status_; gvr::ControllerConnectionState controller_connection_state_; gvr_quatf controller_orientation_; quat controller_orientation_; bool shmem_controller_active_ = false; bool controller_api_status_logged_; bool controller_connection_state_logged_; uint64_t shmem_controller_buttons_; bool is_visible_ = false; std::chrono::time_point<std::chrono::system_clock> visibility_button_press_; Loading @@ -93,6 +100,9 @@ class Application { jobject app_context_; jobject class_loader_; // Controller data provider from shared memory buffer. ControllerDataProvider* controller_data_provider_ = nullptr; Application(const Application&) = delete; void operator=(const Application&) = delete; }; Loading