Skip to content

Commit

Permalink
n64: clamp to octagon edge instead of scale
Browse files Browse the repository at this point in the history
  • Loading branch information
kev4cards authored and LukeUsher committed Aug 1, 2023
1 parent ef3d784 commit c4a5fce
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ares/n64/controller/gamepad/gamepad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,12 @@ auto Gamepad::read() -> n32 {
auto edgey = copysign(min(abs(edgex * slope), cardinalMax / (1.0 / abs(slope) + (cardinalMax - diagonalMax) / diagonalMax)), ay);
edgex = edgey / slope;

auto scale = sqrt(edgex * edgex + edgey * edgey) / outerDeadzoneRadiusMax;
ax *= scale;
ay *= scale;
length = sqrt(ax * ax + ay * ay);
auto distanceToEdge = sqrt(edgex * edgex + edgey * edgey);
if(length > distanceToEdge) {
ax = edgex;
ay = edgey;
}
}

//keep cardinal input within positive and negative bounds of cardinalMax
Expand Down

0 comments on commit c4a5fce

Please sign in to comment.