Skip to content

Commit

Permalink
Added offset output views
Browse files Browse the repository at this point in the history
  • Loading branch information
r57zone committed Jan 16, 2018
1 parent cdf3bc3 commit 1135d7a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
20 changes: 13 additions & 7 deletions OpenVR/FreeTrack/samples/driver_sample/driver_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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() );
Expand Down Expand Up @@ -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".
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
};

Expand Down
16 changes: 11 additions & 5 deletions OpenVR/UDP/samples/driver_sample/driver_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() );
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
};

Expand Down

0 comments on commit 1135d7a

Please sign in to comment.