Skip to content

Commit

Permalink
2 Axis fix: Reverts forza compatibility change for 2 axis mode.
Browse files Browse the repository at this point in the history
1 axis mode always applies force vector, 2 axis sets axis gain 1 if
enableAxis bit is set
  • Loading branch information
Ultrawipf committed Jun 23, 2024
1 parent a3d9f31 commit 517597c
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions Firmware/FFBoard/Src/HidFFB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,21 @@ void HidFFB::set_effect(FFB_SetEffect_t* effect){
}

float phaseX = M_PI*2.0 * (effect->directionX/36000.0);
// Angular vector if dirEnable used or axis enabled otherwise 0 if axis disabled
effect_p->axisMagnitudes[0] = (directionEnable || (effect->enableAxis & X_AXIS_ENABLE) ? sin(phaseX) : 0);
effect_p->axisMagnitudes[1] = (directionEnable || (effect->enableAxis & Y_AXIS_ENABLE) ? cos(phaseX) : 0);

if(axisCount == 1){
/*
* Angular vector if dirEnable used or axis enabled otherwise 0 if axis disabled
* Compatibility fix.
* Some single axis games send no directionEnable but enableAxis but still use phase vectors to scale a single axis effect
*/
effect_p->axisMagnitudes[0] = (directionEnable || (effect->enableAxis & X_AXIS_ENABLE) ? sin(phaseX) : 0);
}else{
/*
* Some 2 axis games send no vector and require the axis to be enable via enableAxis
*/
effect_p->axisMagnitudes[0] = directionEnable ? sin(phaseX) : (effect->enableAxis & X_AXIS_ENABLE ? 1 : 0); // Angular vector if dirEnable used otherwise full or 0 if axis enabled
effect_p->axisMagnitudes[1] = directionEnable ? cos(phaseX) : (effect->enableAxis & Y_AXIS_ENABLE ? 1 : 0); // Angular vector if
}

#if MAX_AXIS == 3
float phaseY = M_PI*2.0 * (effect->directionY/36000.0);
Expand Down

0 comments on commit 517597c

Please sign in to comment.