diff --git a/src/openvr_plugin/InitialSetup.bat b/src/openvr_plugin/InitialSetup.bat index a52f179d..66f337c5 100644 --- a/src/openvr_plugin/InitialSetup.bat +++ b/src/openvr_plugin/InitialSetup.bat @@ -5,15 +5,29 @@ setlocal set "psCommand="(new-object -COM 'Shell.Application')^ .BrowseForFolder(0,'Please select the root folder for steam (ex: c:\Program Files (x86)\steam).',0,0).self.path"" for /f "usebackq delims=" %%I in (`powershell %psCommand%`) do set "STEAM_ROOT_PATH=%%I" -if NOT DEFINED STEAM_ROOT_PATH (goto failure) +IF NOT DEFINED STEAM_ROOT_PATH (goto failure) + +IF EXIST "%STEAM_ROOT_PATH%\steamapps\common\OpenVR" GOTO use_openvr +IF EXIST "%STEAM_ROOT_PATH%\steamapps\common\SteamVR" GOTO use_steamvr +goto no_steamvr_installed + +:no_steamvr_installed +echo "No steamvr folder found at %STEAM_ROOT_PATH%! Please install steamvr." +goto failure + +:use_openvr +set STEAMVR_RUNTIME_DIR=%STEAM_ROOT_PATH%\steamapps\common\OpenVR + +:use_steamvr +set STEAMVR_RUNTIME_DIR=%STEAM_ROOT_PATH%\steamapps\common\SteamVR :: 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=%STEAM_ROOT_PATH%\steamapps\common\OpenVR\drivers\psmove>> 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=%STEAM_ROOT_PATH%\steamapps\common\OpenVR>> SetDriverVars.bat +echo set STEAMVR_RUNTIME_DIR=%STEAMVR_RUNTIME_DIR%>> SetDriverVars.bat :: Copy over the openvr drivers ::call ReinstallDriver.bat @@ -21,6 +35,7 @@ pause goto exit :failure +pause goto exit :exit diff --git a/src/openvr_plugin/driver_psmoveservice.cpp b/src/openvr_plugin/driver_psmoveservice.cpp index 8af7491c..4821ebff 100644 --- a/src/openvr_plugin/driver_psmoveservice.cpp +++ b/src/openvr_plugin/driver_psmoveservice.cpp @@ -554,12 +554,16 @@ vr::EVRInitError CClientDriver_PSMoveService::SetDisplayId( const char * pchDisp vr::HiddenAreaMesh_t CClientDriver_PSMoveService::GetHiddenAreaMesh( vr::EVREye eEye ) { - return vr::HiddenAreaMesh_t(); + vr::HiddenAreaMesh_t hiddenAreaMesh= vr::HiddenAreaMesh_t(); + + return hiddenAreaMesh; } uint32_t CClientDriver_PSMoveService::GetMCImage( uint32_t * pImgWidth, uint32_t * pImgHeight, uint32_t * pChannels, void * pDataBuffer, uint32_t unBufferLen ) { - return uint32_t(); + uint32_t image= uint32_t(); + + return image; } //================================================================================================== @@ -613,11 +617,6 @@ void CPSMoveTrackedDeviceLatest::PowerOff() void *CPSMoveTrackedDeviceLatest::GetComponent(const char *pchComponentNameAndVersion) { - if (!strcasecmp(pchComponentNameAndVersion, vr::IVRControllerComponent_Version)) - { - return (vr::IVRControllerComponent*)this; - } - return NULL; } @@ -804,9 +803,14 @@ const char *CPSMoveTrackedDeviceLatest::GetSerialNumber() const CPSMoveControllerLatest::CPSMoveControllerLatest( vr::IServerDriverHost * pDriverHost, int controllerId ) : CPSMoveTrackedDeviceLatest(pDriverHost) - , m_nControllerId( controllerId ) - , m_nPoseSequenceNumber( 0 ) - + , m_nControllerId(controllerId) + , m_controller_view(nullptr) + , m_nPoseSequenceNumber(0) + , m_bIsBatteryCharging(false) + , m_fBatteryChargeFraction(1.f) + , m_pendingHapticPulseDuration(0) + , m_sentHapticPulseDuration(0) + , m_lastTimeRumbleSent() { char buf[256]; GenerateControllerSerialNumber(buf, sizeof(buf), controllerId); @@ -815,11 +819,7 @@ CPSMoveControllerLatest::CPSMoveControllerLatest( vr::IServerDriverHost * pDrive // Tell psmoveapi that we are listening to this controller id m_controller_view = ClientPSMoveAPI::allocate_controller_view(controllerId); - memset( &m_ControllerState, 0, sizeof( m_ControllerState ) ); - - //###HipsterSloth $TODO - Register for updates from the service about these values changing - m_bIsBatteryCharging= false; - m_fBatteryChargeFraction= 1.f; + memset(&m_ControllerState, 0, sizeof(vr::VRControllerState_t)); // Load config from steamvr.vrsettings //vr::IVRSettings *settings_; @@ -854,6 +854,16 @@ void CPSMoveControllerLatest::Deactivate() ClientPSMoveAPI::stop_controller_data_stream(m_controller_view); } +void *CPSMoveControllerLatest::GetComponent(const char *pchComponentNameAndVersion) +{ + if (!strcasecmp(pchComponentNameAndVersion, vr::IVRControllerComponent_Version)) + { + return (vr::IVRControllerComponent*)this; + } + + return NULL; +} + bool CPSMoveControllerLatest::GetBoolTrackedDeviceProperty( vr::ETrackedDeviceProperty prop, vr::ETrackedPropertyError * pError) @@ -1018,9 +1028,7 @@ uint32_t CPSMoveControllerLatest::GetStringTrackedDeviceProperty( vr::VRControllerState_t CPSMoveControllerLatest::GetControllerState() { - // This is only called at startup to synchronize with the driver. - // Future updates are driven by our thread calling TrackedDeviceButton*() and TrackedDeviceAxis*() - return vr::VRControllerState_t(); + return m_ControllerState; } bool CPSMoveControllerLatest::TriggerHapticPulse( uint32_t unAxisId, uint16_t usPulseDurationMicroseconds ) @@ -1210,8 +1218,8 @@ void CPSMoveControllerLatest::UpdateTrackingState() void CPSMoveControllerLatest::UpdateRumbleState() { - const float k_max_rumble_update_rate = 13.f; // Don't bother trying to update the rumble faster than 60fps (13ms) - const float k_max_pulse_microseconds = 5000.f; // Docs suggest max pulse duration of 5ms + 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_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) @@ -1224,9 +1232,18 @@ void CPSMoveControllerLatest::UpdateRumbleState() { float rumble_fraction = static_cast(m_pendingHapticPulseDuration) / k_max_pulse_microseconds; - if (rumble_fraction > 1.f) + // Keep the pulse intensity within reasonable bounds + if (m_pendingHapticPulseDuration != 0) { - rumble_fraction = 1.f; + if (rumble_fraction < 0.35f) + { + // rumble values less 35% isn't noticeable + rumble_fraction = 0.35f; + } + else if (rumble_fraction > 1.f) + { + rumble_fraction = 1.f; + } } // Actually send the rumble to the server @@ -1235,6 +1252,13 @@ void CPSMoveControllerLatest::UpdateRumbleState() // Remember the last rumble we went and when we sent it m_sentHapticPulseDuration = m_pendingHapticPulseDuration; m_lastTimeRumbleSent = now; + + // 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 a811ae30..b328271c 100644 --- a/src/openvr_plugin/driver_psmoveservice.h +++ b/src/openvr_plugin/driver_psmoveservice.h @@ -140,6 +140,7 @@ class CPSMoveControllerLatest : public CPSMoveTrackedDeviceLatest, public vr::IV // Overridden Implementation of vr::ITrackedDeviceServerDriver virtual vr::EVRInitError Activate(uint32_t unObjectId) override; virtual void Deactivate() override; + virtual void *GetComponent(const char *pchComponentNameAndVersion) override; virtual bool GetBoolTrackedDeviceProperty( vr::ETrackedDeviceProperty prop, vr::ETrackedPropertyError * pError ) override; virtual float GetFloatTrackedDeviceProperty( vr::ETrackedDeviceProperty prop, vr::ETrackedPropertyError * pError ) override; virtual int32_t GetInt32TrackedDeviceProperty( vr::ETrackedDeviceProperty prop, vr::ETrackedPropertyError * pError ) override; diff --git a/src/psmoveclient/ClientNetworkManager.cpp b/src/psmoveclient/ClientNetworkManager.cpp index 5dfc49f6..9509ccdc 100644 --- a/src/psmoveclient/ClientNetworkManager.cpp +++ b/src/psmoveclient/ClientNetworkManager.cpp @@ -470,7 +470,7 @@ class ClientNetworkManagerImpl if (m_pending_requests.size() > 0 && !m_has_pending_tcp_write) { - RequestPtr request= m_pending_requests.front(); + RequestPtr request= m_pending_requests[0]; m_packed_request.set_msg(request); m_packed_request.pack(m_write_bufer);