begin binding gamepad functions from GLFW to SML
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,4 +52,12 @@ struct
|
||||
val (KEY_ARROW_DOWN, _) =
|
||||
_symbol "KEY_ARROW_DOWN" public : ( unit -> int ) * ( int -> unit );
|
||||
val KEY_ARROW_DOWN = KEY_ARROW_DOWN ()
|
||||
|
||||
val getGamepadState =
|
||||
_import "getGamepadState" public : int -> unit;
|
||||
|
||||
val getLeftJoystickXAxisState =
|
||||
_import "getLeftJoystickXAxisState" public : unit -> Real32.real;
|
||||
val getLeftJoystickYAxisState =
|
||||
_import "getLeftJoystickYAxisState" public : unit -> Real32.real;
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user