From b76c734115877d4ccb01c17fa56e757a58e4beb6 Mon Sep 17 00:00:00 2001 From: Brad Grantham Date: Tue, 15 Oct 2019 10:37:18 -0700 Subject: [PATCH] set env var PROBE_JOYSTICKS to probe axes and buttons --- interface.cpp | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/interface.cpp b/interface.cpp index 17c0166..baa8d66 100644 --- a/interface.cpp +++ b/interface.cpp @@ -1783,20 +1783,30 @@ void iterate(const ModeHistory& history, unsigned long long current_byte, float const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1, &axis_count); const unsigned char* buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_1, &button_count); - if(false) { - static bool printedProbing = false; - if(!printedProbing) { - printf("Joystick probing:\n"); - printedProbing = true; + { + static bool checkedJoystickProbing = false; + static bool doJoystickProbe = false; + + if(!checkedJoystickProbing) { + doJoystickProbe = (getenv("PROBE_JOYSTICKS") != NULL); + checkedJoystickProbing = true; } - for(int i = 0; i < axis_count; i++) { - if(fabsf(axes[i]) > 0.01) { - printf("Axis %d: %f\n", i, axes[i]); + + if(doJoystickProbe) { + static bool printedJoystickProbing = false; + if(!printedJoystickProbing) { + printf("Joystick probing:\n"); + printedJoystickProbing = true; } - } - for(int i = 0; i < button_count; i++) { - if(buttons[i] == GLFW_PRESS) { - printf("Button %d: pressed\n", i); + for(int i = 0; i < axis_count; i++) { + if(fabsf(axes[i]) > 0.01) { + printf("Axis %d: %f\n", i, axes[i]); + } + } + for(int i = 0; i < button_count; i++) { + if(buttons[i] == GLFW_PRESS) { + printf("Button %d: pressed\n", i); + } } } }