From 57ad83802bd66f6f3346cdeddd6e7e474b793511 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 9 Jun 2007 17:51:16 +0000 Subject: Initial joystick calibration code. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 898 --- setup/joystick.c | 162 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 162 insertions(+) (limited to 'setup') diff --git a/setup/joystick.c b/setup/joystick.c index ce6a81ec..8a7ff012 100644 --- a/setup/joystick.c +++ b/setup/joystick.c @@ -26,6 +26,13 @@ #include "joystick.h" +typedef enum +{ + CALIBRATE_CENTER, + CALIBRATE_LEFT, + CALIBRATE_UP, +} calibration_stage_t; + // Joystick enable/disable int usejoystick = 0; @@ -55,6 +62,159 @@ int joystick_y_invert = 0; static txt_button_t *joystick_button; +// +// Calibration +// + +static txt_window_t *calibration_window; +static txt_label_t *calibration_label; +static calibration_stage_t calibrate_stage; +static SDL_Joystick **all_joysticks = NULL; + +// Try to open all joysticks visible to SDL. + +static int OpenAllJoysticks(void) +{ + int i; + int num_joysticks; + int result; + + // SDL_JoystickOpen() all joysticks. + + num_joysticks = SDL_NumJoysticks(); + + all_joysticks = malloc(sizeof(SDL_Joystick *) * num_joysticks); + + result = 0; + + for (i=0; i