From 1b48a2ce50b0f202506701224a5249b68441c6e2 Mon Sep 17 00:00:00 2001 From: HipsterSloth Date: Thu, 7 Jul 2016 21:37:13 -0700 Subject: [PATCH] Build fixes for OpenVR API 1.0.2 * Fixed up CClientDriver_PSMoveService::Init to accept a driver * Fixed size_t warnings --- src/openvr_plugin/driver_psmoveservice.cpp | 39 ++++++++++++++++------ src/openvr_plugin/driver_psmoveservice.h | 3 +- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/openvr_plugin/driver_psmoveservice.cpp b/src/openvr_plugin/driver_psmoveservice.cpp index 9ac380f6..ddd8afb1 100644 --- a/src/openvr_plugin/driver_psmoveservice.cpp +++ b/src/openvr_plugin/driver_psmoveservice.cpp @@ -213,7 +213,7 @@ const char * const *CServerDriver_PSMoveService::GetInterfaceVersions() uint32_t CServerDriver_PSMoveService::GetTrackedDeviceCount() { - return m_vecTrackedDevices.size(); + return static_cast(m_vecTrackedDevices.size()); } vr::ITrackedDeviceServerDriver * CServerDriver_PSMoveService::GetTrackedDeviceDriver( @@ -583,11 +583,28 @@ CClientDriver_PSMoveService::~CClientDriver_PSMoveService() { } -vr::EVRInitError CClientDriver_PSMoveService::Init( vr::IDriverLog * pDriverLog, vr::IClientDriverHost * pDriverHost, const char * pchUserDriverConfigDir, const char * pchDriverInstallDir ) +vr::EVRInitError CClientDriver_PSMoveService::Init( + vr::EClientDriverMode driverMode, + vr::IDriverLog * pDriverLog, + vr::IClientDriverHost * pDriverHost, + const char * pchUserDriverConfigDir, + const char * pchDriverInstallDir ) { - InitDriverLog( pDriverLog ); - m_pDriverHost = pDriverHost; - return vr::VRInitError_None; + vr::EVRInitError result= vr::VRInitError_Driver_Failed; + + switch(driverMode) + { + case vr::ClientDriverMode_Normal: + InitDriverLog( pDriverLog ); + m_pDriverHost = pDriverHost; + result= vr::VRInitError_None; + break; + case vr::ClientDriverMode_Watchdog: // client should return VRInitError_Init_LowPowerWatchdogNotSupported if it can't support this mode + result= vr::VRInitError_Init_LowPowerWatchdogNotSupported; + break; + } + + return result; } void CClientDriver_PSMoveService::Cleanup() @@ -805,13 +822,13 @@ uint32_t CPSMoveTrackedDeviceLatest::GetStringTrackedDeviceProperty( else if (sRetVal.size() + 1 > unBufferSize) { *pError = vr::TrackedProp_BufferTooSmall; - return sRetVal.size() + 1; // caller needs to know how to size buffer + return static_cast(sRetVal.size() + 1); // caller needs to know how to size buffer } else { snprintf(pchValue, unBufferSize, sRetVal.c_str()); *pError = vr::TrackedProp_Success; - return sRetVal.size() + 1; + return static_cast(sRetVal.size() + 1); } } @@ -1118,13 +1135,13 @@ uint32_t CPSMoveControllerLatest::GetStringTrackedDeviceProperty( else if ( sRetVal.size() + 1 > unBufferSize ) { *pError = vr::TrackedProp_BufferTooSmall; - return sRetVal.size() + 1; // caller needs to know how to size buffer + return static_cast(sRetVal.size() + 1); // caller needs to know how to size buffer } else { snprintf( pchValue, unBufferSize, sRetVal.c_str() ); *pError = vr::TrackedProp_Success; - return sRetVal.size() + 1; + return static_cast(sRetVal.size() + 1); } } @@ -1596,13 +1613,13 @@ uint32_t CPSMoveTrackerLatest::GetStringTrackedDeviceProperty( else if (sRetVal.size() + 1 > unBufferSize) { *pError = vr::TrackedProp_BufferTooSmall; - return sRetVal.size() + 1; // caller needs to know how to size buffer + return static_cast(sRetVal.size() + 1); // caller needs to know how to size buffer } else { snprintf(pchValue, unBufferSize, sRetVal.c_str()); *pError = vr::TrackedProp_Success; - return sRetVal.size() + 1; + return static_cast(sRetVal.size() + 1); } } diff --git a/src/openvr_plugin/driver_psmoveservice.h b/src/openvr_plugin/driver_psmoveservice.h index 49b71ed1..f650b4cd 100644 --- a/src/openvr_plugin/driver_psmoveservice.h +++ b/src/openvr_plugin/driver_psmoveservice.h @@ -76,7 +76,7 @@ class CClientDriver_PSMoveService : public vr::IClientTrackedDeviceProvider virtual ~CClientDriver_PSMoveService(); // Inherited via IClientTrackedDeviceProvider - virtual vr::EVRInitError Init( vr::IDriverLog * pDriverLog, vr::IClientDriverHost * pDriverHost, const char * pchUserDriverConfigDir, const char * pchDriverInstallDir ) override; + virtual vr::EVRInitError Init( vr::EClientDriverMode eDriverMode, vr::IDriverLog * pDriverLog, vr::IClientDriverHost * pDriverHost, const char * pchUserDriverConfigDir, const char * pchDriverInstallDir ) override; virtual void Cleanup() override; virtual bool BIsHmdPresent( const char * pchUserConfigDir ) override; virtual vr::EVRInitError SetDisplayId( const char * pchDisplayId ) override; @@ -85,7 +85,6 @@ class CClientDriver_PSMoveService : public vr::IClientTrackedDeviceProvider private: vr::IClientDriverHost* m_pDriverHost; - }; class CPSMoveTrackedDeviceLatest : public vr::ITrackedDeviceServerDriver