Skip to content

Commit

Permalink
Check the existence of oculus_quest_controller_left model and use it …
Browse files Browse the repository at this point in the history
…when client is Quest.

Ignore controller assignment settings on Touch Controller.
Remove unused input entry for left(or right) Touch Controller.
  • Loading branch information
polygraphene committed May 26, 2019
1 parent b11743a commit 6fdecc7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 22 deletions.
13 changes: 10 additions & 3 deletions ALVR/ServerConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,16 @@ public bool Save(DeviceDescriptor device)
driverConfig.controllerTrackingSystemName = "ALVR Remote Controller";
driverConfig.controllerManufacturerName = "ALVR";
driverConfig.controllerModelNumber = "ALVR Remote Controller";
// There is not render model for Oculus Touch.
driverConfig.controllerRenderModelNameLeft = "oculus_cv1_controller_left";
driverConfig.controllerRenderModelNameRight = "oculus_cv1_controller_right";
if (!Directory.Exists(Utils.GetDriverPath() + "resources\\rendermodels\\oculus_quest_controller_left"))
{
driverConfig.controllerRenderModelNameLeft = "oculus_cv1_controller_left";
driverConfig.controllerRenderModelNameRight = "oculus_cv1_controller_right";
}
else
{
driverConfig.controllerRenderModelNameLeft = Utils.GetDriverPath() + "resources\\rendermodels\\oculus_quest_controller_left";
driverConfig.controllerRenderModelNameRight = Utils.GetDriverPath() + "resources\\rendermodels\\oculus_quest_controller_right";
}
driverConfig.controllerSerialNumber = "ALVR Remote Controller";
driverConfig.controllerType = "oculus_touch";
driverConfig.controllerLegacyInputProfile = "oculus_touch";
Expand Down
46 changes: 27 additions & 19 deletions alvr_server/RemoteController.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,20 @@ class RemoteControllerServerDriver : public vr::ITrackedDeviceServerDriver
vr::VRDriverInput()->CreateScalarComponent(m_ulPropertyContainer, "/input/grip/value", &m_handles[ALVR_INPUT_GRIP_VALUE], vr::VRScalarType_Absolute, vr::VRScalarUnits_NormalizedOneSided);
vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/grip/touch", &m_handles[ALVR_INPUT_GRIP_TOUCH]);

vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/a/click", &m_handles[ALVR_INPUT_A_CLICK]);
vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/a/touch", &m_handles[ALVR_INPUT_A_TOUCH]);
vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/b/click", &m_handles[ALVR_INPUT_B_CLICK]);
vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/b/touch", &m_handles[ALVR_INPUT_B_TOUCH]);
vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/x/click", &m_handles[ALVR_INPUT_X_CLICK]);
vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/x/touch", &m_handles[ALVR_INPUT_X_TOUCH]);
vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/y/click", &m_handles[ALVR_INPUT_Y_CLICK]);
vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/y/touch", &m_handles[ALVR_INPUT_Y_TOUCH]);
if (!m_hand) {
// A,B for right hand.
vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/a/click", &m_handles[ALVR_INPUT_A_CLICK]);
vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/a/touch", &m_handles[ALVR_INPUT_A_TOUCH]);
vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/b/click", &m_handles[ALVR_INPUT_B_CLICK]);
vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/b/touch", &m_handles[ALVR_INPUT_B_TOUCH]);
}
else {
// X,Y for left hand.
vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/x/click", &m_handles[ALVR_INPUT_X_CLICK]);
vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/x/touch", &m_handles[ALVR_INPUT_X_TOUCH]);
vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/y/click", &m_handles[ALVR_INPUT_Y_CLICK]);
vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/y/touch", &m_handles[ALVR_INPUT_Y_TOUCH]);
}

vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/joystick/click", &m_handles[ALVR_INPUT_JOYSTICK_CLICK]);
vr::VRDriverInput()->CreateScalarComponent(m_ulPropertyContainer, "/input/joystick/x", &m_handles[ALVR_INPUT_JOYSTICK_X], vr::VRScalarType_Absolute, vr::VRScalarUnits_NormalizedTwoSided);
Expand Down Expand Up @@ -243,17 +249,19 @@ class RemoteControllerServerDriver : public vr::ITrackedDeviceServerDriver
uint64_t b = ALVR_BUTTON_FLAG(i);
if ((m_previousButtons & b) != (c.buttons & b)) {
int mapped = i;
if (i == ALVR_INPUT_TRIGGER_CLICK) {
mapped = Settings::Instance().m_controllerTriggerMode;
}
else if (i == ALVR_INPUT_TRACKPAD_CLICK) {
mapped = Settings::Instance().m_controllerTrackpadClickMode;
}
else if (i == ALVR_INPUT_TRACKPAD_TOUCH) {
mapped = Settings::Instance().m_controllerTrackpadTouchMode;
}
else if (i == ALVR_INPUT_BACK_CLICK) {
mapped = Settings::Instance().m_controllerBackMode;
if (!mIsTouch) {
if (i == ALVR_INPUT_TRIGGER_CLICK) {
mapped = Settings::Instance().m_controllerTriggerMode;
}
else if (i == ALVR_INPUT_TRACKPAD_CLICK) {
mapped = Settings::Instance().m_controllerTrackpadClickMode;
}
else if (i == ALVR_INPUT_TRACKPAD_TOUCH) {
mapped = Settings::Instance().m_controllerTrackpadTouchMode;
}
else if (i == ALVR_INPUT_BACK_CLICK) {
mapped = Settings::Instance().m_controllerBackMode;
}
}
bool value = (c.buttons & b) != 0;
if (mapped != -1 && mapped <= ALVR_INPUT_MAX && m_handles[mapped] != vr::k_ulInvalidInputComponentHandle) {
Expand Down

0 comments on commit 6fdecc7

Please sign in to comment.