From b55f90cbe18642007827921560f75607456f36a6 Mon Sep 17 00:00:00 2001 From: Holger Frydrych Date: Sat, 26 Aug 2023 18:27:40 +0200 Subject: [PATCH] Allow unbinding vehicle accelerate/brake to just use the stick for driving --- Sources/CryGame C++/Solution1/CryGame/VRInput.cpp | 15 +++++++++++---- Sources/CryGame C++/Solution1/CryGame/VRInput.h | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Sources/CryGame C++/Solution1/CryGame/VRInput.cpp b/Sources/CryGame C++/Solution1/CryGame/VRInput.cpp index 973fe11..0eb71a1 100644 --- a/Sources/CryGame C++/Solution1/CryGame/VRInput.cpp +++ b/Sources/CryGame C++/Solution1/CryGame/VRInput.cpp @@ -190,10 +190,15 @@ void VRInput::ProcessInputInVehicles() HandleBooleanAction(m_vehiclesAttack, &CXClient::TriggerFire0); // combine accelerate/brake to movement value - float accel = GetFloatValue(m_vehiclesAccelerate); - float brake = GetFloatValue(m_vehiclesBrake); + bool isAccelActive = false, isBrakeActive = false; + float accel = GetFloatValue(m_vehiclesAccelerate, 0, &isAccelActive); + float brake = GetFloatValue(m_vehiclesBrake, 0, &isBrakeActive); float move = accel - brake; - m_pGame->GetClient()->TriggerMoveFB(move, XActivationEvent()); + + if (isAccelActive && isBrakeActive) + m_pGame->GetClient()->TriggerMoveFB(move, XActivationEvent()); + else + HandleAnalogAction(m_vehiclesSteer, 1, &CXClient::TriggerMoveFB); } else { @@ -264,10 +269,12 @@ void VRInput::HandleAnalogAction(vr::VRActionHandle_t actionHandle, int axis, Tr (m_pGame->GetClient()->*trigger)(value, XActivationEvent()); } -float VRInput::GetFloatValue(vr::VRActionHandle_t actionHandle, int axis) +float VRInput::GetFloatValue(vr::VRActionHandle_t actionHandle, int axis, bool* isActive) { vr::InputAnalogActionData_t actionData; vr::VRInput()->GetAnalogActionData(actionHandle, &actionData, sizeof(vr::InputAnalogActionData_t), vr::k_ulInvalidInputValueHandle); + if (isActive != nullptr) + *isActive = actionData.bActive; if (!actionData.bActive) return 0.f; diff --git a/Sources/CryGame C++/Solution1/CryGame/VRInput.h b/Sources/CryGame C++/Solution1/CryGame/VRInput.h index cc486d2..fc0d43c 100644 --- a/Sources/CryGame C++/Solution1/CryGame/VRInput.h +++ b/Sources/CryGame C++/Solution1/CryGame/VRInput.h @@ -68,7 +68,7 @@ class VRInput void HandleBooleanAction(vr::VRActionHandle_t actionHandle, TriggerFn trigger, bool continuous = true); void HandleAnalogAction(vr::VRActionHandle_t actionHandle, int axis, TriggerFn trigger); - float GetFloatValue(vr::VRActionHandle_t actionHandle, int axis = 0); + float GetFloatValue(vr::VRActionHandle_t actionHandle, int axis = 0, bool *isActive = nullptr); void InitDoubleBindAction(DoubleBindAction& action, const char* actionName); void HandleDoubleBindAction(DoubleBindAction& action, TriggerFn shortPressTrigger, TriggerFn longPressTrigger, bool longContinuous = true);