From 54c072f383066768bfbe184ec525d5c3ae86de09 Mon Sep 17 00:00:00 2001 From: rsn8887 Date: Fri, 4 Aug 2017 11:15:00 -0500 Subject: [PATCH] PFBA: fix analog stick angular zone sizes (22.5 degrees now) --- pfba/deps/libcross2d/src/sdl2/sdl2_input.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pfba/deps/libcross2d/src/sdl2/sdl2_input.cpp b/pfba/deps/libcross2d/src/sdl2/sdl2_input.cpp index 192069c..7e22e0d 100644 --- a/pfba/deps/libcross2d/src/sdl2/sdl2_input.cpp +++ b/pfba/deps/libcross2d/src/sdl2/sdl2_input.cpp @@ -134,6 +134,7 @@ void SDL2Input::process_axis(Input::Player &player, int rotate) { bool up = false, down = false, left = false, right = false; Axis *currentStickXAxis = NULL; Axis *currentStickYAxis = NULL; + float slope = 0.414214f; // tangent of 22.5 degrees for size of angular zones for (int i = 0; i<=1; i++) { @@ -163,27 +164,27 @@ void SDL2Input::process_axis(Input::Player &player, int rotate) { analogY = -analogY; if (analogY > 0 && analogX > 0) { // upper right quadrant - if (2*analogY > analogX) + if (analogY > slope * analogX) up = true; - if (2*analogX > analogY) + if (analogX > slope * analogY) right = true; } else if (analogY > 0 && analogX <= 0) { // upper left quadrant - if (2*analogY > (-analogX)) + if (analogY > slope * (-analogX)) up = true; - if (2*(-analogX) > analogY) + if ((-analogX) > slope * analogY) left = true; } else if (analogY <= 0 && analogX > 0) { // lower right quadrant - if (2*(-analogY) > analogX) + if ((-analogY) > slope * analogX) down = true; - if (2*analogX > (-analogY)) + if (analogX > slope * (-analogY)) right = true; } else if (analogY <= 0 && analogX <= 0) { // lower left quadrant - if (2*(-analogY) > (-analogX)) + if ((-analogY) > slope * (-analogX)) down = true; - if (2*(-analogX) > (-analogY)) + if ((-analogX) > slope * (-analogY)) left = true; }