Skip to content

Commit

Permalink
Allow unbinding vehicle accelerate/brake to just use the stick for dr…
Browse files Browse the repository at this point in the history
…iving
  • Loading branch information
fholger committed Aug 26, 2023
1 parent 4f44292 commit b55f90c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions Sources/CryGame C++/Solution1/CryGame/VRInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion Sources/CryGame C++/Solution1/CryGame/VRInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b55f90c

Please sign in to comment.