Skip to content

Commit

Permalink
InputManager: Always treat Touch as the active controller.
Browse files Browse the repository at this point in the history
  • Loading branch information
CrossVR committed Jan 17, 2021
1 parent ad6a132 commit 4c47618
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
26 changes: 9 additions & 17 deletions ReviveXR/InputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,18 @@ ovrResult InputManager::GetInputState(ovrSession session, ovrControllerType cont
{
memset(inputState, 0, sizeof(ovrInputState));

uint32_t types = 0;
if (controllerType == ovrControllerType_Active)
controllerType = ovrControllerType_Touch;

for (InputDevice* device : m_InputDevices)
{
ovrControllerType type = device->GetType();
if (device->IsConnected())
{
if (controllerType & type)
{
if (device->GetInputState(session->Session, controllerType, inputState))
types |= type;
}
}
if (controllerType & type && device->IsConnected())
device->GetInputState(session->Session, controllerType, inputState);
}

inputState->TimeInSeconds = ovr_GetTimeInSeconds();
inputState->ControllerType = (ovrControllerType)types;
inputState->ControllerType = controllerType;
return ovrSuccess;
}

Expand Down Expand Up @@ -531,7 +527,7 @@ bool InputManager::OculusTouch::IsConnected() const
return true;
}

bool InputManager::OculusTouch::GetInputState(XrSession session, ovrControllerType controllerType, ovrInputState* inputState)
void InputManager::OculusTouch::GetInputState(XrSession session, ovrControllerType controllerType, ovrInputState* inputState)
{
if (m_Button_Enter.GetDigital(session))
inputState->Buttons |= ovrButton_Enter;
Expand Down Expand Up @@ -618,8 +614,6 @@ bool InputManager::OculusTouch::GetInputState(XrSession session, ovrControllerTy
inputState->Buttons |= (hand == ovrHand_Left) ? buttons << 8 : buttons;
inputState->Touches |= (hand == ovrHand_Left) ? touches << 8 : touches;
}

return true;
}

ovrResult InputManager::OculusTouch::SetVibration(XrSession session, ovrControllerType controllerType, float frequency, float amplitude)
Expand Down Expand Up @@ -679,7 +673,7 @@ bool InputManager::OculusRemote::IsConnected() const
return m_IsConnected;
}

bool InputManager::OculusRemote::GetInputState(XrSession session, ovrControllerType controllerType, ovrInputState* inputState)
void InputManager::OculusRemote::GetInputState(XrSession session, ovrControllerType controllerType, ovrInputState* inputState)
{
unsigned int buttons = 0;

Expand Down Expand Up @@ -712,7 +706,6 @@ bool InputManager::OculusRemote::GetInputState(XrSession session, ovrControllerT
buttons |= ovrButton_VolDown;

inputState->Buttons |= buttons;
return buttons != 0;
}

void InputManager::OculusRemote::GetActiveSets(std::vector<XrActiveActionSet>& outSets) const
Expand Down Expand Up @@ -780,7 +773,7 @@ XrPath InputManager::XboxGamepad::GetSuggestedBindings(std::vector<XrActionSugge
return GetXrPath("/interaction_profiles/microsoft/xbox_controller");
}

bool InputManager::XboxGamepad::GetInputState(XrSession session, ovrControllerType controllerType, ovrInputState* inputState)
void InputManager::XboxGamepad::GetInputState(XrSession session, ovrControllerType controllerType, ovrInputState* inputState)
{
unsigned int buttons = 0;

Expand Down Expand Up @@ -847,7 +840,6 @@ bool InputManager::XboxGamepad::GetInputState(XrSession session, ovrControllerTy
}

inputState->Buttons |= buttons;
return buttons != 0;
}

ovrResult InputManager::XboxGamepad::SetVibration(XrSession session, ovrControllerType controllerType, float frequency, float amplitude)
Expand Down
8 changes: 4 additions & 4 deletions ReviveXR/InputManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class InputManager
// Input
virtual ovrControllerType GetType() const = 0;
virtual bool IsConnected() const = 0;
virtual bool GetInputState(XrSession session, ovrControllerType controllerType, ovrInputState* inputState) = 0;
virtual void GetInputState(XrSession session, ovrControllerType controllerType, ovrInputState* inputState) = 0;

// Bindings
virtual XrPath GetSuggestedBindings(std::vector<XrActionSuggestedBinding>& outBindings) const { return XR_NULL_PATH; }
Expand Down Expand Up @@ -71,7 +71,7 @@ class InputManager

virtual ovrControllerType GetType() const override;
virtual bool IsConnected() const override;
virtual bool GetInputState(XrSession session, ovrControllerType controllerType, ovrInputState* inputState) override;
virtual void GetInputState(XrSession session, ovrControllerType controllerType, ovrInputState* inputState) override;
virtual XrPath GetSuggestedBindings(std::vector<XrActionSuggestedBinding>& outBindings) const override;
virtual void GetActionSpaces(XrSession session, std::vector<XrSpace>& outSpaces) const override;
virtual void GetActiveSets(std::vector<XrActiveActionSet>& outSets) const override;
Expand Down Expand Up @@ -114,7 +114,7 @@ class InputManager

virtual ovrControllerType GetType() const override { return ovrControllerType_Remote; }
virtual bool IsConnected() const override;
virtual bool GetInputState(XrSession session, ovrControllerType controllerType, ovrInputState* inputState) override;
virtual void GetInputState(XrSession session, ovrControllerType controllerType, ovrInputState* inputState) override;
virtual void GetActiveSets(std::vector<XrActiveActionSet>& outSets) const override;

private:
Expand All @@ -139,7 +139,7 @@ class InputManager

virtual ovrControllerType GetType() const override { return ovrControllerType_XBox; }
virtual bool IsConnected() const override { return true; }
virtual bool GetInputState(XrSession session, ovrControllerType controllerType, ovrInputState* inputState) override;
virtual void GetInputState(XrSession session, ovrControllerType controllerType, ovrInputState* inputState) override;
virtual XrPath GetSuggestedBindings(std::vector<XrActionSuggestedBinding>& outBindings) const override;
virtual void GetActiveSets(std::vector<XrActiveActionSet>& outSets) const override;
virtual ovrResult SetVibration(XrSession session, ovrControllerType controllerType, float frequency, float amplitude) override;
Expand Down

0 comments on commit 4c47618

Please sign in to comment.