diff --git a/OpenVR/FreeTrack/samples/driver_sample/driver_sample.cpp b/OpenVR/FreeTrack/samples/driver_sample/driver_sample.cpp index 430ba43..37f1818 100644 --- a/OpenVR/FreeTrack/samples/driver_sample/driver_sample.cpp +++ b/OpenVR/FreeTrack/samples/driver_sample/driver_sample.cpp @@ -67,6 +67,8 @@ static const char * const k_pch_Sample_DistortionK1_Float = "DistortionK1"; static const char * const k_pch_Sample_DistortionK2_Float = "DistortionK2"; static const char * const k_pch_Sample_ZoomWidth_Float = "ZoomWidth"; static const char * const k_pch_Sample_ZoomHeight_Float = "ZoomHeight"; +static const char * const k_pch_Sample_DistanceBetweenEyes_Int32 = "DistanceBetweenEyes"; +static const char * const k_pch_Sample_ScreenOffsetX_Int32 = "ScreenOffsetX"; static const char * const k_pch_Sample_DebugMode_Bool = "DebugMode"; #define FREETRACK_HEAP "FT_SharedMem" @@ -121,7 +123,7 @@ FTData *FreeTrack; bool HMDConnected = false; std::thread *pFTthread = NULL; -//FreeTrack implementation from https://github.com/opentrack/opentrack/tree/unstable/freetrackclient +//FreeTrack implementation from OpenTrack (https://github.com/opentrack/opentrack/tree/unstable/freetrackclient) static BOOL impl_create_mapping(void) { if (ipc_heap != NULL) @@ -273,6 +275,8 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV m_fDistortionK2 = vr::VRSettings()->GetFloat(k_pch_Sample_Section, k_pch_Sample_DistortionK2_Float); m_fZoomWidth = vr::VRSettings()->GetFloat(k_pch_Sample_Section, k_pch_Sample_ZoomWidth_Float); m_fZoomHeight = vr::VRSettings()->GetFloat(k_pch_Sample_Section, k_pch_Sample_ZoomHeight_Float); + m_nDistanceBetweenEyes = vr::VRSettings()->GetFloat(k_pch_Sample_Section, k_pch_Sample_DistanceBetweenEyes_Int32); + m_nScreenOffsetX = vr::VRSettings()->GetFloat(k_pch_Sample_Section, k_pch_Sample_ScreenOffsetX_Int32); m_bDebugMode = vr::VRSettings()->GetBool(k_pch_Sample_Section, k_pch_Sample_DebugMode_Bool); //DriverLog( "driver_null: Serial Number: %s\n", m_sSerialNumber.c_str() ); @@ -317,7 +321,7 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV // avoid "not fullscreen" warnings from vrmonitor vr::VRProperties()->SetBoolProperty( m_ulPropertyContainer, Prop_IsOnDesktop_Bool, false ); - //Debug mode activate Windowed Mode (borderless fullscreen) on "Headset Window" and you can move window to second screen with buttons (Shift + Win + Right or Left), but lock to 30 FPS + //Debug mode activate Windowed Mode (borderless fullscreen), lock to 30 FPS vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, Prop_DisplayDebugMode_Bool, m_bDebugMode); // Icons can be configured in code or automatically configured by an external file "drivername\resources\driver.vrresources". // Icon properties NOT configured in code (post Activate) are then auto-configured by the optional presence of a driver's "drivername\resources\driver.vrresources". @@ -418,17 +422,17 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV virtual void GetEyeOutputViewport( EVREye eEye, uint32_t *pnX, uint32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) { - *pnY = 0; + *pnY = m_nScreenOffsetX; *pnWidth = m_nWindowWidth / 2; *pnHeight = m_nWindowHeight; - - if ( eEye == Eye_Left ) + + if (eEye == Eye_Left) { - *pnX = 0; + *pnX = m_nDistanceBetweenEyes; } else { - *pnX = m_nWindowWidth / 2; + *pnX = (m_nWindowWidth / 2) - m_nDistanceBetweenEyes; } } @@ -534,6 +538,8 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV float m_fDistortionK2; float m_fZoomWidth; float m_fZoomHeight; + int32_t m_nDistanceBetweenEyes; + int32_t m_nScreenOffsetX; bool m_bDebugMode; }; diff --git a/OpenVR/UDP/samples/driver_sample/driver_sample.cpp b/OpenVR/UDP/samples/driver_sample/driver_sample.cpp index 436ccbe..941459e 100644 --- a/OpenVR/UDP/samples/driver_sample/driver_sample.cpp +++ b/OpenVR/UDP/samples/driver_sample/driver_sample.cpp @@ -69,6 +69,8 @@ static const char * const k_pch_Sample_DistortionK1_Float = "DistortionK1"; static const char * const k_pch_Sample_DistortionK2_Float = "DistortionK2"; static const char * const k_pch_Sample_ZoomWidth_Float = "ZoomWidth"; static const char * const k_pch_Sample_ZoomHeight_Float = "ZoomHeight"; +static const char * const k_pch_Sample_DistanceBetweenEyes_Int32 = "DistanceBetweenEyes"; +static const char * const k_pch_Sample_ScreenOffsetX_Int32 = "ScreenOffsetX"; static const char * const k_pch_Sample_DebugMode_Bool = "DebugMode"; //OpenTrack vars @@ -250,6 +252,8 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV m_fDistortionK2 = vr::VRSettings()->GetFloat(k_pch_Sample_Section, k_pch_Sample_DistortionK2_Float); m_fZoomWidth = vr::VRSettings()->GetFloat(k_pch_Sample_Section, k_pch_Sample_ZoomWidth_Float); m_fZoomHeight = vr::VRSettings()->GetFloat(k_pch_Sample_Section, k_pch_Sample_ZoomHeight_Float); + m_nDistanceBetweenEyes = vr::VRSettings()->GetFloat(k_pch_Sample_Section, k_pch_Sample_DistanceBetweenEyes_Int32); + m_nScreenOffsetX = vr::VRSettings()->GetFloat(k_pch_Sample_Section, k_pch_Sample_ScreenOffsetX_Int32); m_bDebugMode = vr::VRSettings()->GetBool(k_pch_Sample_Section, k_pch_Sample_DebugMode_Bool); //DriverLog( "driver_null: Serial Number: %s\n", m_sSerialNumber.c_str() ); @@ -428,17 +432,17 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV virtual void GetEyeOutputViewport( EVREye eEye, uint32_t *pnX, uint32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) { - *pnY = 0; + *pnY = m_nScreenOffsetX; *pnWidth = m_nWindowWidth / 2; *pnHeight = m_nWindowHeight; - - if ( eEye == Eye_Left ) + + if (eEye == Eye_Left) { - *pnX = 0; + *pnX = m_nDistanceBetweenEyes; } else { - *pnX = m_nWindowWidth / 2; + *pnX = (m_nWindowWidth / 2) - m_nDistanceBetweenEyes; } } @@ -545,6 +549,8 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV float m_fDistortionK2; float m_fZoomWidth; float m_fZoomHeight; + int32_t m_nDistanceBetweenEyes; + int32_t m_nScreenOffsetX; bool m_bDebugMode; };