static int CalibrationEventCallback(SDL_Event *event, void *user_data) { if (event->type != SDL_JOYBUTTONDOWN) { return 0; } // At this point, we have a button press. // In the first "center" stage, we're just trying to work out which // joystick is being configured and which button the user is pressing. joystick_index = event->jbutton.which; calibrate_button = event->jbutton.button; // If the joystick is a known one, auto-load default // config for it. Otherwise, proceed with calibration. if (IsKnownJoystick(joystick_index)) { LoadKnownConfiguration(); usejoystick = 1; TXT_CloseWindow(calibration_window); } else { TXT_CloseWindow(calibration_window); // Calibrate joystick axes: Y axis first, then X axis once // completed. TXT_ConfigureJoystickAxis(y_axis_widget, calibrate_button, CalibrateXAxis); } return 1; }
static int TXT_JoystickAxisKeyPress(TXT_UNCAST_ARG(joystick_axis), int key) { TXT_CAST_ARG(txt_joystick_axis_t, joystick_axis); if (key == KEY_ENTER) { TXT_ConfigureJoystickAxis(joystick_axis, -1, NULL); return 1; } if (key == KEY_BACKSPACE || key == KEY_DEL) { *joystick_axis->axis = -1; } return 0; }
static void CalibrateXAxis(void) { TXT_ConfigureJoystickAxis(x_axis_widget, calibrate_button, NULL); }