diff --git a/CustomHMD/.vs/CustomHMD/v16/.suo b/CustomHMD/.vs/CustomHMD/v16/.suo index be25205..59a0ae1 100644 Binary files a/CustomHMD/.vs/CustomHMD/v16/.suo and b/CustomHMD/.vs/CustomHMD/v16/.suo differ diff --git a/CustomHMD/.vs/CustomHMD/v16/Browse.VC.db b/CustomHMD/.vs/CustomHMD/v16/Browse.VC.db index 7e0ea9b..6dcdad8 100644 Binary files a/CustomHMD/.vs/CustomHMD/v16/Browse.VC.db and b/CustomHMD/.vs/CustomHMD/v16/Browse.VC.db differ diff --git a/CustomHMD/Common.h b/CustomHMD/Common.h index 3ac791f..d626ff7 100644 --- a/CustomHMD/Common.h +++ b/CustomHMD/Common.h @@ -66,6 +66,7 @@ struct config_data { double world_translation[3]; vr::HmdQuaternion_t world_orientation_q; double world_orientation_euler[3]; + double skeleton_smoothing; }; struct shared_buffer { @@ -89,10 +90,13 @@ void log_to_buffer(std::string s) { if (!comm_buffer) return; WaitForSingleObject(comm_mutex, INFINITE); for (int i = 0; i < s.size(); i++) { - comm_buffer->logging_buffer[comm_buffer->logging_offset + i] = s.c_str()[i]; + if (comm_buffer->logging_offset < 1023) { + comm_buffer->logging_buffer[comm_buffer->logging_offset] = s.c_str()[i]; + comm_buffer->logging_offset++; + } } - comm_buffer->logging_buffer[comm_buffer->logging_offset + s.size()] = '\n'; - comm_buffer->logging_offset += s.size() + 1; + comm_buffer->logging_buffer[comm_buffer->logging_offset] = '\n'; + comm_buffer->logging_offset ++; ReleaseMutex(comm_mutex); return; } diff --git a/CustomHMD/Release/x64/driver_OculusTouchLink.dll b/CustomHMD/Release/x64/driver_OculusTouchLink.dll index d127681..2e03812 100644 Binary files a/CustomHMD/Release/x64/driver_OculusTouchLink.dll and b/CustomHMD/Release/x64/driver_OculusTouchLink.dll differ diff --git a/CustomHMD/TouchControllerDriver.h b/CustomHMD/TouchControllerDriver.h index 51560a6..b9299f2 100644 --- a/CustomHMD/TouchControllerDriver.h +++ b/CustomHMD/TouchControllerDriver.h @@ -614,7 +614,7 @@ class CTouchControllerDriver : public vr::ITrackedDeviceServerDriver vr::VRDriverInput()->UpdateBooleanComponent(m_compJoyt, inputState.Touches & ovrTouch_RThumb, 0); #if DO_SKELETON - VRBoneTransform_t active_hand_pose[HSB_Count]; + VRBoneTransform_t target_hand_pose[HSB_Count]; float hand_blend_fraction = inputState.HandTrigger[isRightHand]; float finger_bend_fraction = inputState.IndexTrigger[isRightHand]; if (!(inputState.Touches & ovrTouch_RThumbUp)) { @@ -624,17 +624,22 @@ class CTouchControllerDriver : public vr::ITrackedDeviceServerDriver } } - for (int i = 0; i < HSB_Count; i++) active_hand_pose[i] = blend_bones(right_open_hand_pose[i], right_fist_pose[i], hand_blend_fraction); + for (int i = 0; i < HSB_Count; i++) target_hand_pose[i] = blend_bones(right_open_hand_pose[i], right_fist_pose[i], hand_blend_fraction); - for (int i = HSB_IndexFinger0; i <= HSB_IndexFinger4; i++) active_hand_pose[i] = blend_bones(right_open_hand_pose[i], right_fist_pose[i], finger_bend_fraction); + for (int i = HSB_IndexFinger0; i <= HSB_IndexFinger4; i++) target_hand_pose[i] = blend_bones(right_open_hand_pose[i], right_fist_pose[i], finger_bend_fraction); if (finger_bend_fraction > hand_blend_fraction) - for (int i = HSB_Thumb0; i <= HSB_Thumb3; i++) active_hand_pose[i] = blend_bones(right_open_hand_pose[i], right_fist_pose[i], finger_bend_fraction); + for (int i = HSB_Thumb0; i <= HSB_Thumb3; i++) target_hand_pose[i] = blend_bones(right_open_hand_pose[i], right_fist_pose[i], finger_bend_fraction); if (inputState.Touches & ovrTouch_RThumbUp) { - for (int i = HSB_Thumb0; i <= HSB_Thumb3; i++) active_hand_pose[i] = right_open_hand_pose[i]; + for (int i = HSB_Thumb0; i <= HSB_Thumb3; i++) target_hand_pose[i] = right_open_hand_pose[i]; } + else { + for (int i = HSB_Thumb0; i <= HSB_Thumb3; i++) target_hand_pose[i] = blend_bones(right_open_hand_pose[i], right_fist_pose[i], max(0.5, finger_bend_fraction)); + } + + for (int i = 0; i < HSB_Count; i++) active_hand_pose[i] = blend_bones(active_hand_pose[i], target_hand_pose[i], comm_buffer->config.skeleton_smoothing); vr::VRDriverInput()->UpdateSkeletonComponent( m_compSkel, vr::VRSkeletalMotionRange_WithoutController, @@ -661,7 +666,7 @@ class CTouchControllerDriver : public vr::ITrackedDeviceServerDriver vr::VRDriverInput()->UpdateBooleanComponent(m_compSysc, inputState.Buttons & ovrButton_Enter, 0); #if DO_LSKELETON - VRBoneTransform_t active_hand_pose[HSB_Count]; + VRBoneTransform_t target_hand_pose[HSB_Count]; float hand_blend_fraction = inputState.HandTrigger[isRightHand]; float finger_bend_fraction = inputState.IndexTrigger[isRightHand]; @@ -672,17 +677,23 @@ class CTouchControllerDriver : public vr::ITrackedDeviceServerDriver } } - for (int i = 0; i < HSB_Count; i++) active_hand_pose[i] = blend_bones(left_open_hand_pose[i], left_fist_pose[i], hand_blend_fraction); + for (int i = 0; i < HSB_Count; i++) target_hand_pose[i] = blend_bones(left_open_hand_pose[i], left_fist_pose[i], hand_blend_fraction); - for (int i = HSB_IndexFinger0; i <= HSB_IndexFinger4; i++) active_hand_pose[i] = blend_bones(left_open_hand_pose[i], left_fist_pose[i], finger_bend_fraction); + for (int i = HSB_IndexFinger0; i <= HSB_IndexFinger4; i++) target_hand_pose[i] = blend_bones(left_open_hand_pose[i], left_fist_pose[i], finger_bend_fraction); if (finger_bend_fraction > hand_blend_fraction) - for (int i = HSB_Thumb0; i <= HSB_Thumb3; i++) active_hand_pose[i] = blend_bones(left_open_hand_pose[i], left_fist_pose[i], finger_bend_fraction); + for (int i = HSB_Thumb0; i <= HSB_Thumb3; i++) target_hand_pose[i] = blend_bones(left_open_hand_pose[i], left_fist_pose[i], finger_bend_fraction); if (inputState.Touches & ovrTouch_LThumbUp) { - for (int i = HSB_Thumb0; i <= HSB_Thumb3; i++) active_hand_pose[i] = left_open_hand_pose[i]; + for (int i = HSB_Thumb0; i <= HSB_Thumb3; i++) target_hand_pose[i] = left_open_hand_pose[i]; + } + else { + for (int i = HSB_Thumb0; i <= HSB_Thumb3; i++) target_hand_pose[i] = blend_bones(left_open_hand_pose[i], left_fist_pose[i], max(0.5, finger_bend_fraction)); } + + for (int i = 0; i < HSB_Count; i++) active_hand_pose[i] = blend_bones(active_hand_pose[i], target_hand_pose[i], comm_buffer->config.skeleton_smoothing); + vr::VRDriverInput()->UpdateSkeletonComponent( m_compSkel, vr::VRSkeletalMotionRange_WithoutController, @@ -819,6 +830,8 @@ class CTouchControllerDriver : public vr::ITrackedDeviceServerDriver float m_time_of_last_pose; + VRBoneTransform_t active_hand_pose[HSB_Count]; + /*std::chrono::time_point haptic_end; float haptic_strength; float haptic_frequency; */ diff --git a/ReleasePackage/OculusTouchLink.7z b/ReleasePackage/OculusTouchLink.7z index 639d761..e9709a9 100644 Binary files a/ReleasePackage/OculusTouchLink.7z and b/ReleasePackage/OculusTouchLink.7z differ diff --git a/ReleasePackage/OculusTouchLink/bin/win64/driver_OculusTouchLink.dll b/ReleasePackage/OculusTouchLink/bin/win64/driver_OculusTouchLink.dll index 8936a42..2e03812 100644 Binary files a/ReleasePackage/OculusTouchLink/bin/win64/driver_OculusTouchLink.dll and b/ReleasePackage/OculusTouchLink/bin/win64/driver_OculusTouchLink.dll differ diff --git a/ReleasePackage/OculusTouchLink/config.dat b/ReleasePackage/OculusTouchLink/config.dat index 553296a..f9da635 100644 --- a/ReleasePackage/OculusTouchLink/config.dat +++ b/ReleasePackage/OculusTouchLink/config.dat @@ -23,3 +23,4 @@ Oculus_link 0 0 0 +0.2 diff --git a/ReleasePackage/OculusTouchLink/ovr_test.exe b/ReleasePackage/OculusTouchLink/ovr_test.exe index d28e2e4..dd325a8 100644 Binary files a/ReleasePackage/OculusTouchLink/ovr_test.exe and b/ReleasePackage/OculusTouchLink/ovr_test.exe differ diff --git a/ovr_test/.vs/ovr_test/v16/.suo b/ovr_test/.vs/ovr_test/v16/.suo index f633bd5..cf14f6a 100644 Binary files a/ovr_test/.vs/ovr_test/v16/.suo and b/ovr_test/.vs/ovr_test/v16/.suo differ diff --git a/ovr_test/.vs/ovr_test/v16/Browse.VC.db b/ovr_test/.vs/ovr_test/v16/Browse.VC.db index d2d6aad..fc2e62b 100644 Binary files a/ovr_test/.vs/ovr_test/v16/Browse.VC.db and b/ovr_test/.vs/ovr_test/v16/Browse.VC.db differ diff --git a/ovr_test/definitions.h b/ovr_test/definitions.h index ed65d94..18bff4f 100644 --- a/ovr_test/definitions.h +++ b/ovr_test/definitions.h @@ -41,6 +41,7 @@ struct config_data { double world_translation[3]; vr::HmdQuaternion_t world_orientation_q; double world_orientation_euler[3]; + double skeleton_smoothing; }; struct shared_buffer { diff --git a/ovr_test/gui.cpp b/ovr_test/gui.cpp index 5c70981..93fe0e9 100644 --- a/ovr_test/gui.cpp +++ b/ovr_test/gui.cpp @@ -8,7 +8,7 @@ #define _USE_MATH_DEFINES #include -#define DEBUG_VIB 1 +//#define DEBUG_VIB 1 class unique_window_id { public: @@ -513,12 +513,44 @@ std::vector config_windows = { SetWindowText((HWND)self->wnd, CompBuffer); return; } } -, { L"Reset",L"BUTTON", WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_FLAT | BS_TEXT , + + , { L"skeleton smoothing",L"EDIT", WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_FLAT | BS_TEXT | ES_READONLY, + default_wm_command, default_init } + , { L"0.2",L"EDIT", WS_VISIBLE | WS_CHILD | ES_NUMBER, + [](HWND window, WPARAM wp, LPARAM lp, shared_buffer* comm_buffer) { + switch (HIWORD(wp)) + { + case EN_CHANGE: + { + const size_t len = 64; + WCHAR Buffer[len]; + double smoothing; + GetWindowText((HWND)lp, Buffer, len); + swscanf_s(Buffer, L"%lf", &smoothing); + std::wcout << L"control text is: " << Buffer << std::endl; + std::cout << "parsed smoothing " << smoothing << std::endl; + + comm_buffer->config.skeleton_smoothing = smoothing; + } + } + return; + }, [](config_window_object* self, HWND parent, shared_buffer* comm_buffer) { + self->parent = parent; + orient_q_wp = self; + const size_t len = 64; + WCHAR CompBuffer[len]; + swprintf_s(CompBuffer, len, L"%.2lf", comm_buffer->config.skeleton_smoothing); + SetWindowText((HWND)self->wnd, CompBuffer); + return; + } } + + , { L"Reset",L"BUTTON", WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_FLAT | BS_TEXT , [](HWND window, WPARAM wp, LPARAM lp, shared_buffer* comm_buffer) { reset_config_settings(comm_buffer->config); GUI_Manager::self->reset_settings_window(); return; }, default_init } + #ifdef DEBUG_VIB , { L"frequency amplitude duration",L"EDIT", WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_FLAT | BS_TEXT | ES_READONLY, default_wm_command, default_init } @@ -580,7 +612,7 @@ GUI_Manager::GUI_Manager(shared_buffer* comm_buffer) { window = CreateWindowEx(0, L"MyWindowsApp", L"OculusTouchlink Configuration", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, - 600, 630, 0, 0, GetModuleHandle(0), 0); + 600, 650, 0, 0, GetModuleHandle(0), 0); } diff --git a/ovr_test/ovr_test.cpp b/ovr_test/ovr_test.cpp index f95fb9f..17d5191 100644 --- a/ovr_test/ovr_test.cpp +++ b/ovr_test/ovr_test.cpp @@ -29,7 +29,7 @@ void main_loop(ovrSession mSession, HANDLE comm_mutex, shared_buffer* comm_buffe WaitForSingleObject(comm_mutex, INFINITE); if (comm_buffer->logging_offset) { - for (int i = 0; i < comm_buffer->logging_offset; i++) { + for (int i = 0; ((i < 1024) && (i < comm_buffer->logging_offset)); i++) { putc(comm_buffer->logging_buffer[i], stdout); } comm_buffer->logging_offset = 0; @@ -263,6 +263,7 @@ void reset_config_settings(config_data& config) { config.world_orientation_euler[0] = 0.0; config.world_orientation_euler[1] = 0.0; config.world_orientation_euler[2] = 0.0; + config.skeleton_smoothing = 0.2; } void save_config_to_file(config_data& config) { @@ -308,6 +309,7 @@ void save_config_to_file(config_data& config) { ofs << config.world_orientation_euler[1] << std::endl; ofs << config.world_orientation_euler[2] << std::endl; ofs << config.disable_controllers << std::endl; + ofs << config.skeleton_smoothing << std::endl; ofs.close(); } @@ -359,6 +361,7 @@ void load_config_from_file(config_data& config) { ifs >> config.world_orientation_euler[2]; ifs >> config.disable_controllers; + ifs >> config.skeleton_smoothing; ifs.close(); } } diff --git a/ovr_test/x64/Release/config.dat b/ovr_test/x64/Release/config.dat index 3d681b0..0917411 100644 --- a/ovr_test/x64/Release/config.dat +++ b/ovr_test/x64/Release/config.dat @@ -13,7 +13,7 @@ Oculus_link 0 0 0 --0.003 +0 0 1 0 @@ -23,3 +23,4 @@ Oculus_link 0 0 0 +0.2 diff --git a/ovr_test/x64/Release/ovr_test.exe b/ovr_test/x64/Release/ovr_test.exe index d28e2e4..dd325a8 100644 Binary files a/ovr_test/x64/Release/ovr_test.exe and b/ovr_test/x64/Release/ovr_test.exe differ