begin binding gamepad functions from GLFW to SML

This commit is contained in:
2026-01-19 13:23:47 +00:00
parent c6dee6e9f9
commit 6f89fbc89c
4 changed files with 64 additions and 0 deletions

View File

@@ -40,3 +40,29 @@ void setKeyCallback(GLFWwindow *window) {
glfwSetKeyCallback(window, keyCallback);
}
// gamepad code
GLFWgamepadstate state;
float* axes;
int axesCount = -1;
void getGamepadState(int joystickID) {
if (glfwGetGamepadState(joystickID, &state)) {
axes = glfwGetJoystickAxes(joystickID, &axesCount);
}
}
float getLeftJoystickXAxisState() {
if (axesCount >= 2) {
return axes[0];
} else {
return 99.0;
}
}
float getLeftJoystickYAxisState() {
if (axesCount >= 2) {
return axes[1];
} else {
return 99.0;
}
}