mirror of
https://github.com/glfw/glfw.git
synced 2025-10-04 13:46:37 +00:00
Added support for joystick button and axis callbacks
This commit is contained in:
parent
4e8d5ded78
commit
ed211f35b5
@ -474,6 +474,18 @@ static void joystick_callback(int joy, int event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void joystick_button_callback(int joy, int button, int action)
|
||||||
|
{
|
||||||
|
printf("%08x at %0.3f: Joystick %i button %i was %s\n",
|
||||||
|
counter++, glfwGetTime(), joy, button, get_action_name(action));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void joystick_axis_callback(int joy, int axis, float value)
|
||||||
|
{
|
||||||
|
printf("%08x at %0.3f: Joystick %i axis %i was moved to %f\n",
|
||||||
|
counter++, glfwGetTime(), joy, axis, value);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
Slot* slots;
|
Slot* slots;
|
||||||
@ -491,6 +503,8 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
glfwSetMonitorCallback(monitor_callback);
|
glfwSetMonitorCallback(monitor_callback);
|
||||||
glfwSetJoystickCallback(joystick_callback);
|
glfwSetJoystickCallback(joystick_callback);
|
||||||
|
glfwSetJoystickButtonCallback(joystick_button_callback);
|
||||||
|
glfwSetJoystickAxisCallback(joystick_axis_callback);
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "hfn:")) != -1)
|
while ((ch = getopt(argc, argv, "hfn:")) != -1)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user