Skip to content

Commit

Permalink
Touchpad fix
Browse files Browse the repository at this point in the history
  • Loading branch information
r57zone committed Sep 2, 2018
1 parent 6140ff5 commit 50b614d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 38 deletions.
69 changes: 34 additions & 35 deletions OpenVR/samples/driver_sample/driver_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,37 +552,29 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV

if (myCtrl.Buttons & THUMBSTICKBTN) {
VRServerDriverHost()->TrackedDeviceButtonPressed(ctrlLeft.getObjectID(), vr::k_EButton_SteamVR_Touchpad, 0.0);
}
else {
} else {
VRServerDriverHost()->TrackedDeviceButtonUnpressed(ctrlLeft.getObjectID(), vr::k_EButton_SteamVR_Touchpad, 0.0);
}

if (myCtrl.Buttons & MENUBTN) {
VRServerDriverHost()->TrackedDeviceButtonPressed(ctrlLeft.getObjectID(), vr::k_EButton_ApplicationMenu, 0.0);
}
else {
} else {
VRServerDriverHost()->TrackedDeviceButtonUnpressed(ctrlLeft.getObjectID(), vr::k_EButton_ApplicationMenu, 0.0);
}

if (myCtrl.Buttons & SYSTEMBTN) {
VRServerDriverHost()->TrackedDeviceButtonPressed(ctrlLeft.getObjectID(), vr::k_EButton_System, 0.0);
}
else {
} else {
VRServerDriverHost()->TrackedDeviceButtonUnpressed(ctrlLeft.getObjectID(), vr::k_EButton_System, 0.0);
}

//Centring
if ((myCtrl.Buttons & GRIPBTN) && (myCtrl.Buttons & MENUBTN) && (myCtrl.Trigger > 0))
SetCentering(1);

//Trigger ctrl1
ctrl1State = ctrlLeft.GetControllerState();
if (myCtrl.Trigger > 0) {
VRServerDriverHost()->TrackedDeviceButtonPressed(ctrlLeft.getObjectID(), vr::k_EButton_SteamVR_Trigger, 0.0);
ctrl1State.rAxis[1].x = ConvAxis(myCtrl.Trigger * 0.003921568627451);
VRServerDriverHost()->TrackedDeviceAxisUpdated(ctrlLeft.getObjectID(), 1, ctrl1State.rAxis[1]);
}
else {
VRServerDriverHost()->TrackedDeviceButtonPressed(ctrlLeft.getObjectID(), vr::k_EButton_SteamVR_Trigger, 0.0);
} else {
ctrl1State.rAxis[1].x = 0.0f;
VRServerDriverHost()->TrackedDeviceAxisUpdated(ctrlLeft.getObjectID(), 1, ctrl1State.rAxis[1]);
VRServerDriverHost()->TrackedDeviceButtonUnpressed(ctrlLeft.getObjectID(), vr::k_EButton_SteamVR_Trigger, 0.0);
Expand All @@ -591,13 +583,16 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV
//TouchPad ctrl1
if (myCtrl.ThumbX != 0 || myCtrl.ThumbY != 0) {
ctrl1State.rAxis[0].x = ConvAxis(myCtrl.ThumbX * 0.00003051758);
ctrl1State.rAxis[0].y = ConvAxis(myCtrl.ThumbX * 0.00003051758);
ctrl1State.rAxis[0].y = ConvAxis(myCtrl.ThumbY * 0.00003051758);
VRServerDriverHost()->TrackedDeviceAxisUpdated(ctrlLeft.getObjectID(), 0, ctrl1State.rAxis[0]);
} else{
VRServerDriverHost()->TrackedDeviceButtonTouched(ctrlLeft.getObjectID(), vr::k_EButton_Axis0, 0.0);
} else {
ctrl1State.rAxis[0].x = 0.0f;
ctrl1State.rAxis[0].y = 0.0f;
VRServerDriverHost()->TrackedDeviceAxisUpdated(ctrlLeft.getObjectID(), 0, ctrl1State.rAxis[0]);
VRServerDriverHost()->TrackedDeviceButtonUntouched(ctrlLeft.getObjectID(), vr::k_EButton_Axis0, 0.0);
}


//Controller 2
ctrlRightPosRot = ctrlRight.GetPose();
Expand All @@ -613,44 +608,35 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV
//Buttons controller 2
if (myCtrl2.Buttons & GRIPBTN) {
VRServerDriverHost()->TrackedDeviceButtonPressed(ctrlRight.getObjectID(), vr::k_EButton_Grip, 0.0);
}
else {
} else {
VRServerDriverHost()->TrackedDeviceButtonUnpressed(ctrlRight.getObjectID(), vr::k_EButton_Grip, 0.0);
}

if (myCtrl2.Buttons & THUMBSTICKBTN) {
VRServerDriverHost()->TrackedDeviceButtonPressed(ctrlRight.getObjectID(), vr::k_EButton_SteamVR_Touchpad, 0.0);
}
else {
} else {
VRServerDriverHost()->TrackedDeviceButtonUnpressed(ctrlRight.getObjectID(), vr::k_EButton_SteamVR_Touchpad, 0.0);
}

if (myCtrl2.Buttons & MENUBTN) {
VRServerDriverHost()->TrackedDeviceButtonPressed(ctrlRight.getObjectID(), vr::k_EButton_ApplicationMenu, 0.0);
}
else {
} else {
VRServerDriverHost()->TrackedDeviceButtonUnpressed(ctrlRight.getObjectID(), vr::k_EButton_ApplicationMenu, 0.0);
}

if (myCtrl2.Buttons & SYSTEMBTN) {
VRServerDriverHost()->TrackedDeviceButtonPressed(ctrlRight.getObjectID(), vr::k_EButton_System, 0.0);
}
else {
} else {
VRServerDriverHost()->TrackedDeviceButtonUnpressed(ctrlRight.getObjectID(), vr::k_EButton_System, 0.0);
}

//Centring
if ((myCtrl2.Buttons & GRIPBTN) && (myCtrl2.Buttons & MENUBTN) && (myCtrl2.Trigger > 0))
SetCentering(2);

//Trigger ctrl2
ctrl2State = ctrlRight.GetControllerState();
if (myCtrl2.Trigger > 0) {
VRServerDriverHost()->TrackedDeviceButtonPressed(ctrlRight.getObjectID(), vr::k_EButton_SteamVR_Trigger, 0.0);
ctrl2State.rAxis[1].x = ConvAxis(myCtrl2.Trigger * 0.003921568627451);
VRServerDriverHost()->TrackedDeviceAxisUpdated(ctrlRight.getObjectID(), 1, ctrl2State.rAxis[1]);
}
else {
VRServerDriverHost()->TrackedDeviceButtonPressed(ctrlRight.getObjectID(), vr::k_EButton_SteamVR_Trigger, 0.0);
} else {
ctrl2State.rAxis[1].x = 0.0f;
VRServerDriverHost()->TrackedDeviceAxisUpdated(ctrlRight.getObjectID(), 1, ctrl2State.rAxis[1]);
VRServerDriverHost()->TrackedDeviceButtonUnpressed(ctrlRight.getObjectID(), vr::k_EButton_SteamVR_Trigger, 0.0);
Expand All @@ -659,17 +645,29 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV
//TouchPad ctrl2
if (myCtrl2.ThumbX != 0 || myCtrl2.ThumbY != 0) {
ctrl2State.rAxis[0].x = ConvAxis(myCtrl2.ThumbX * 0.00003051758);
ctrl2State.rAxis[0].y = ConvAxis(myCtrl2.ThumbX * 0.00003051758);
ctrl2State.rAxis[0].y = ConvAxis(myCtrl2.ThumbY * 0.00003051758);
VRServerDriverHost()->TrackedDeviceAxisUpdated(ctrlRight.getObjectID(), 0, ctrl2State.rAxis[0]);
VRServerDriverHost()->TrackedDeviceButtonTouched(ctrlRight.getObjectID(), vr::k_EButton_Axis0, 0.0);
}
else {
else
{
ctrl2State.rAxis[0].x = 0.0f;
ctrl2State.rAxis[0].y = 0.0f;
VRServerDriverHost()->TrackedDeviceAxisUpdated(ctrlRight.getObjectID(), 0, ctrl2State.rAxis[0]);
VRServerDriverHost()->TrackedDeviceButtonUntouched(ctrlRight.getObjectID(), vr::k_EButton_Axis0, 0.0);
}

ctrlRight.updateControllerPose(ctrlRightPosRot);
VRServerDriverHost()->TrackedDevicePoseUpdated(ctrlRight.getObjectID(), ctrlRight.GetPose(), sizeof(DriverPose_t));

//Centring
if ((myCtrl.Buttons & SYSTEMBTN) && (myCtrl.Buttons & GRIPBTN) && (myCtrl2.Buttons & SYSTEMBTN) && (myCtrl2.Buttons & GRIPBTN))
{
SetCentering(0);
SetCentering(1);
SetCentering(2);
}

}
}

Expand Down Expand Up @@ -753,9 +751,10 @@ EVRInitError CServerDriver_Sample::Init( vr::IVRDriverContext *pDriverContext )
ctrlLeft = DummyController("example_con1", false, InitPose, InitState);
ctrlRight = DummyController("example_con2", true, InitPose, InitState);

VRServerDriverHost()->TrackedDeviceAdded("example_con1", vr::TrackedDeviceClass_Controller, &ctrlLeft);
VRServerDriverHost()->TrackedDeviceAdded("example_con2", vr::TrackedDeviceClass_Controller, &ctrlRight);

if (ctrlsConnected) {
VRServerDriverHost()->TrackedDeviceAdded("example_con1", vr::TrackedDeviceClass_Controller, &ctrlLeft);
VRServerDriverHost()->TrackedDeviceAdded("example_con2", vr::TrackedDeviceClass_Controller, &ctrlRight);
}

return VRInitError_None;
}
Expand Down
2 changes: 1 addition & 1 deletion OpenVR/samples/driver_sample/driver_sample.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<ProjectGuid>{A47C788B-1BDA-4057-87A9-FC35ED711B44}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>driver_sample</RootNamespace>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ An SteamVR driver with TrueOpenVR standard support.

**[Download](https://github.com/TrueOpenVR/SteamVR-TrueOpenVR/releases)**
## Centring
HMD - CTRL + ALT + R or NumPad 5
**HMD** - "CTRL" + "ALT" + "R" or "Numpad 5"

Controllers - Grip + Menu + Trigger
**HMD and controllers** - "Grip" + "System" on two controllers.

0 comments on commit 50b614d

Please sign in to comment.