set env var PROBE_JOYSTICKS to probe axes and buttons

This commit is contained in:
Brad Grantham 2019-10-15 10:37:18 -07:00
parent 216f74cc32
commit b76c734115

View File

@ -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 float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1, &axis_count);
const unsigned char* buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_1, &button_count); const unsigned char* buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_1, &button_count);
if(false) { {
static bool printedProbing = false; static bool checkedJoystickProbing = false;
if(!printedProbing) { static bool doJoystickProbe = false;
printf("Joystick probing:\n");
printedProbing = true; if(!checkedJoystickProbing) {
doJoystickProbe = (getenv("PROBE_JOYSTICKS") != NULL);
checkedJoystickProbing = true;
} }
for(int i = 0; i < axis_count; i++) {
if(fabsf(axes[i]) > 0.01) { if(doJoystickProbe) {
printf("Axis %d: %f\n", i, axes[i]); static bool printedJoystickProbing = false;
if(!printedJoystickProbing) {
printf("Joystick probing:\n");
printedJoystickProbing = true;
} }
} for(int i = 0; i < axis_count; i++) {
for(int i = 0; i < button_count; i++) { if(fabsf(axes[i]) > 0.01) {
if(buttons[i] == GLFW_PRESS) { printf("Axis %d: %f\n", i, axes[i]);
printf("Button %d: pressed\n", i); }
}
for(int i = 0; i < button_count; i++) {
if(buttons[i] == GLFW_PRESS) {
printf("Button %d: pressed\n", i);
}
} }
} }
} }