[Super-tux-commit] supertux/src configfile.cpp,1.1,1.2 globals.cpp,1.15,1.16 setup.cpp,1.44,1.45
Brought to you by:
wkendrick
From: Ingo R. <gr...@us...> - 2004-04-20 16:50:43
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4560 Modified Files: configfile.cpp globals.cpp setup.cpp Log Message: - added config options for joystick buttons/axis Index: setup.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/setup.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- setup.cpp 20 Apr 2004 12:12:31 -0000 1.44 +++ setup.cpp 20 Apr 2004 16:50:18 -0000 1.45 @@ -762,8 +762,6 @@ } else { - /* Check for proper joystick configuration: */ - if (SDL_JoystickNumAxes(js) < 2) { fprintf(stderr, @@ -927,6 +925,29 @@ assert(i+1 < argc); joystick_num = atoi(argv[++i]); } + else if (strcmp(argv[i], "--joymap") == 0) + { + assert(i+1 < argc); + if (sscanf(argv[++i], + "%d:%d:%d:%d:%d", + &joystick_keymap.x_axis, + &joystick_keymap.y_axis, + &joystick_keymap.a_button, + &joystick_keymap.b_button, + &joystick_keymap.start_button) != 5) + { + puts("Warning: Invalid or incomplete joymap, should be: 'XAXIS:YAXIS:A:B:START'"); + } + else + { + std::cout << "Using new joymap:\n" + << " X-Axis: " << joystick_keymap.x_axis << "\n" + << " Y-Axis: " << joystick_keymap.y_axis << "\n" + << " A-Button: " << joystick_keymap.a_button << "\n" + << " B-Button: " << joystick_keymap.b_button << "\n" + << " Start-Button: " << joystick_keymap.start_button << std::endl; + } + } else if (strcmp(argv[i], "--worldmap") == 0) { launch_worldmap_mode = true; @@ -1004,6 +1025,8 @@ "\n" "Misc Options:\n" " -j, --joystick NUM Use joystick NUM (default: 0)\n" + " --joymap XAXIS:YAXIS:A:B:START\n" + " Define how joystick buttons and axis should be mapped\n" " --worldmap Start in worldmap-mode (EXPERIMENTAL)\n" " -d, --datadir DIR Load Game data from DIR (default: automatic)\n" " --debug-mode Enables the debug-mode, which is useful for developers.\n" Index: globals.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/globals.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- globals.cpp 20 Apr 2004 16:25:57 -0000 1.15 +++ globals.cpp 20 Apr 2004 16:50:18 -0000 1.16 @@ -27,7 +27,7 @@ { a_button = 0; b_button = 1; - start_button = 9; + start_button = 2; x_axis = 0; y_axis = 1; Index: configfile.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/configfile.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- configfile.cpp 24 Mar 2004 16:13:27 -0000 1.1 +++ configfile.cpp 20 Apr 2004 16:50:18 -0000 1.2 @@ -90,6 +90,13 @@ use_joystick = false; else use_joystick = true; + + reader.read_int ("joystick-x", &joystick_keymap.x_axis); + reader.read_int ("joystick-y", &joystick_keymap.y_axis); + reader.read_int ("joystick-a", &joystick_keymap.a_button); + reader.read_int ("joystick-b", &joystick_keymap.b_button); + reader.read_int ("joystick-start", &joystick_keymap.start_button); + reader.read_int ("joystick-deadzone", &joystick_keymap.dead_zone); } void saveconfig (void) @@ -112,6 +119,14 @@ fprintf(config, "\n\t;; joystick number (-1 means no joystick):\n"); fprintf(config, "\t(joystick %d)\n", use_joystick ? joystick_num : -1); + + fprintf(config, "\t(joystick-x %d)\n", joystick_keymap.x_axis); + fprintf(config, "\t(joystick-y %d)\n", joystick_keymap.y_axis); + fprintf(config, "\t(joystick-a %d)\n", joystick_keymap.a_button); + fprintf(config, "\t(joystick-b %d)\n", joystick_keymap.b_button); + fprintf(config, "\t(joystick-start %d)\n", joystick_keymap.start_button); + fprintf(config, "\t(joystick-deadzone %d)\n", joystick_keymap.dead_zone); + fprintf(config, ")\n"); } } |