diff --git a/src/openvr_plugin/CMakeLists.txt b/src/openvr_plugin/CMakeLists.txt index cb7c068f..2546494c 100644 --- a/src/openvr_plugin/CMakeLists.txt +++ b/src/openvr_plugin/CMakeLists.txt @@ -25,15 +25,21 @@ file(GLOB OPENVR_PLUGIN_LIBRARY_SRC ) # Shared library -add_library(driver_psmoveservice SHARED ${OPENVR_PLUGIN_LIBRARY_SRC}) -target_include_directories(driver_psmoveservice PUBLIC ${OPENVR_PLUGIN_INCL_DIRS}) -target_link_libraries(driver_psmoveservice ${OPENVR_PLUGIN_REQ_LIBS}) +add_library(driver_psmove SHARED ${OPENVR_PLUGIN_LIBRARY_SRC}) +target_include_directories(driver_psmove PUBLIC ${OPENVR_PLUGIN_INCL_DIRS}) +target_link_libraries(driver_psmove ${OPENVR_PLUGIN_REQ_LIBS}) # Install IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows") -install(TARGETS driver_psmoveservice +install(TARGETS driver_psmove RUNTIME DESTINATION ${ROOT_DIR}/win32/bin LIBRARY DESTINATION ${ROOT_DIR}/win32/lib ARCHIVE DESTINATION ${ROOT_DIR}/win32/lib) +install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/ + DESTINATION ${ROOT_DIR}/win32/bin + FILES_MATCHING PATTERN "*.bat") +install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/resources + DESTINATION ${ROOT_DIR}/win32/bin + FILES_MATCHING PATTERN "*.png" PATTERN "*.json" PATTERN "*.obj" PATTERN "*.mtl") ELSE() #Linux/Darwin ENDIF() diff --git a/src/openvr_plugin/InitialSetup.bat b/src/openvr_plugin/SteamVR_InitialSetup.bat similarity index 76% rename from src/openvr_plugin/InitialSetup.bat rename to src/openvr_plugin/SteamVR_InitialSetup.bat index ace06ddd..504bc1ec 100644 --- a/src/openvr_plugin/InitialSetup.bat +++ b/src/openvr_plugin/SteamVR_InitialSetup.bat @@ -27,15 +27,14 @@ goto write_set_drivers_script echo "Found SteamVR Runtime Dir: %STEAMVR_RUNTIME_DIR%" :: Write out the paths to a config batch file -del SetDriverVars.bat -echo @echo off >> SetDriverVars.bat -echo set PLATFORM=win32>> SetDriverVars.bat -echo set INSTALL_DIR=%STEAMVR_RUNTIME_DIR%\drivers\psmove>> SetDriverVars.bat -echo set BUILD_DIR=..\..\win32\bin>> SetDriverVars.bat -echo set STEAMVR_RUNTIME_DIR=%STEAMVR_RUNTIME_DIR%>> SetDriverVars.bat +del SteamVR_SetDriverVars.bat +echo @echo off >> SteamVR_SetDriverVars.bat +echo set PLATFORM=win32>> SteamVR_SetDriverVars.bat +echo set INSTALL_DIR=%STEAMVR_RUNTIME_DIR%\drivers\psmove>> SteamVR_SetDriverVars.bat +echo set STEAMVR_RUNTIME_DIR=%STEAMVR_RUNTIME_DIR%>> SteamVR_SetDriverVars.bat :: Copy over the openvr drivers -::call ReinstallDriver.bat +call SteamVR_ReinstallDriver.bat pause goto exit diff --git a/src/openvr_plugin/ReinstallDriver.bat b/src/openvr_plugin/SteamVR_ReinstallDriver.bat similarity index 52% rename from src/openvr_plugin/ReinstallDriver.bat rename to src/openvr_plugin/SteamVR_ReinstallDriver.bat index 4d0714c9..a3ef49eb 100644 --- a/src/openvr_plugin/ReinstallDriver.bat +++ b/src/openvr_plugin/SteamVR_ReinstallDriver.bat @@ -1,10 +1,10 @@ @echo off -call SetDriverVars.bat +call SteamVR_SetDriverVars.bat -echo "(Re)Installing PSMoveService OpenVR driver..." +echo "(Re)Installing PSMoveService SteamVR driver..." IF NOT EXIST "%INSTALL_DIR%\bin\%PLATFORM%" mkdir "%INSTALL_DIR%\bin\%PLATFORM%" -copy %BUILD_DIR%\driver_psmoveservice.dll "%INSTALL_DIR%\bin\%PLATFORM%\driver_psmove.dll" -copy %BUILD_DIR%\PSMoveClient.dll "%INSTALL_DIR%\bin\%PLATFORM%" +copy driver_psmove.dll "%INSTALL_DIR%\bin\%PLATFORM%\driver_psmove.dll" +copy PSMoveClient.dll "%INSTALL_DIR%\bin\%PLATFORM%" "%STEAMVR_RUNTIME_DIR%\bin\win32\vrpathreg" adddriver "%INSTALL_DIR%" xcopy /s /i /y "resources" "%STEAMVR_RUNTIME_DIR%\drivers\psmove\resources" diff --git a/src/openvr_plugin/SteamVR_UninstallDriver.bat b/src/openvr_plugin/SteamVR_UninstallDriver.bat new file mode 100644 index 00000000..645a7196 --- /dev/null +++ b/src/openvr_plugin/SteamVR_UninstallDriver.bat @@ -0,0 +1,11 @@ +@echo off +call SteamVR_SetDriverVars.bat + +echo "Unstalling PSMoveService SteamVR driver..." +IF NOT EXIST "%INSTALL_DIR%" goto done +del /F /S /Q "%INSTALL_DIR%*.*" +rmdir /S /Q "%INSTALL_DIR%" + +:done +echo "Done" +pause \ No newline at end of file diff --git a/src/openvr_plugin/driver_psmoveservice.cpp b/src/openvr_plugin/driver_psmoveservice.cpp index 86f4371a..d0eac8e4 100644 --- a/src/openvr_plugin/driver_psmoveservice.cpp +++ b/src/openvr_plugin/driver_psmoveservice.cpp @@ -809,7 +809,6 @@ CPSMoveControllerLatest::CPSMoveControllerLatest( vr::IServerDriverHost * pDrive , m_bIsBatteryCharging(false) , m_fBatteryChargeFraction(1.f) , m_pendingHapticPulseDuration(0) - , m_sentHapticPulseDuration(0) , m_lastTimeRumbleSent() , m_lastTimeRumbleSentValid(false) { @@ -1219,59 +1218,54 @@ void CPSMoveControllerLatest::UpdateTrackingState() void CPSMoveControllerLatest::UpdateRumbleState() { - const float k_max_rumble_update_rate = 100.f; // Don't bother trying to update the rumble faster than 10fps (100ms) + const float k_max_rumble_update_rate = 200.f; // Don't bother trying to update the rumble faster than 5fps (200ms) const float k_max_pulse_microseconds = 1000.f; // Docs suggest max pulse duration of 5ms, but we'll call 1ms max - // Only bother with this if the rumble value actually changed - if (m_pendingHapticPulseDuration != m_sentHapticPulseDuration) + std::chrono::time_point now = std::chrono::high_resolution_clock::now(); + bool bTimoutElapsed= true; + + if (m_lastTimeRumbleSentValid) { - std::chrono::time_point now = std::chrono::high_resolution_clock::now(); - bool bTimoutElapsed= true; + std::chrono::duration timeSinceLastSend = now - m_lastTimeRumbleSent; - if (m_lastTimeRumbleSentValid) - { - std::chrono::duration timeSinceLastSend = now - m_lastTimeRumbleSent; + bTimoutElapsed= timeSinceLastSend.count() >= k_max_rumble_update_rate; + } - bTimoutElapsed= timeSinceLastSend.count() >= k_max_rumble_update_rate; - } + // See if a rumble request hasn't come too recently + if (bTimoutElapsed) + { + float rumble_fraction = static_cast(m_pendingHapticPulseDuration) / k_max_pulse_microseconds; - // See if a rumble request hasn't come too recently - if (bTimoutElapsed) + // Unless a zero runble intensity was explicitly set, + // don't rumble less than 35% (no enough to feel) + if (m_pendingHapticPulseDuration != 0) { - float rumble_fraction = static_cast(m_pendingHapticPulseDuration) / k_max_pulse_microseconds; - - // Unless a zero runble intensity was explicitly set, - // don't rumble less than 35% (no enough to feel) - if (m_pendingHapticPulseDuration != 0) + if (rumble_fraction < 0.35f) { - if (rumble_fraction < 0.35f) - { - // rumble values less 35% isn't noticeable - rumble_fraction = 0.35f; - } + // rumble values less 35% isn't noticeable + rumble_fraction = 0.35f; } + } - // Keep the pulse intensity within reasonable bounds - if (rumble_fraction > 1.f) - { - rumble_fraction = 1.f; - } + // Keep the pulse intensity within reasonable bounds + if (rumble_fraction > 1.f) + { + rumble_fraction = 1.f; + } - // Actually send the rumble to the server - ClientPSMoveAPI::eat_response(ClientPSMoveAPI::set_controller_rumble(m_controller_view, rumble_fraction)); + // Actually send the rumble to the server + ClientPSMoveAPI::set_controller_rumble(m_controller_view, rumble_fraction); - // Remember the last rumble we went and when we sent it - m_sentHapticPulseDuration = m_pendingHapticPulseDuration; - m_lastTimeRumbleSent = now; - m_lastTimeRumbleSentValid= true; + // Remember the last rumble we went and when we sent it + m_lastTimeRumbleSent = now; + m_lastTimeRumbleSentValid= true; - // Reset the pending haptic pulse duration. - // If another call to TriggerHapticPulse() is made later, it will stomp this value. - // If no call to TriggerHapticPulse() is made later, then the next call to UpdateRumbleState() - // in k_max_rumble_update_rate milliseconds will set the rumble_fraction to 0.f - // This effectively makes the shortest rumble pulse k_max_rumble_update_rate milliseconds. - m_pendingHapticPulseDuration = 0; - } + // Reset the pending haptic pulse duration. + // If another call to TriggerHapticPulse() is made later, it will stomp this value. + // If no call to TriggerHapticPulse() is made later, then the next call to UpdateRumbleState() + // in k_max_rumble_update_rate milliseconds will set the rumble_fraction to 0.f + // This effectively makes the shortest rumble pulse k_max_rumble_update_rate milliseconds. + m_pendingHapticPulseDuration = 0; } } diff --git a/src/openvr_plugin/driver_psmoveservice.h b/src/openvr_plugin/driver_psmoveservice.h index 5e8ae12c..c2d7c112 100644 --- a/src/openvr_plugin/driver_psmoveservice.h +++ b/src/openvr_plugin/driver_psmoveservice.h @@ -191,7 +191,6 @@ class CPSMoveControllerLatest : public CPSMoveTrackedDeviceLatest, public vr::IV // Rumble state uint16_t m_pendingHapticPulseDuration; - uint16_t m_sentHapticPulseDuration; std::chrono::time_point m_lastTimeRumbleSent; bool m_lastTimeRumbleSentValid; };