[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Feuerkraft-CVS] rev 309 - in trunk/src: . input
From: |
Ingo Ruhnke |
Subject: |
[Feuerkraft-CVS] rev 309 - in trunk/src: . input |
Date: |
Sun, 07 Dec 2003 21:54:12 +0100 |
Author: grumbel
Date: 2003-12-07 21:54:11 +0100 (Sun, 07 Dec 2003)
New Revision: 309
Modified:
trunk/src/command_line_arguments.cxx
trunk/src/command_line_arguments.hxx
trunk/src/feuerkraft.cxx
trunk/src/input/input_manager.cxx
trunk/src/keyboard_manager.cxx
Log:
- made joystick/keyboard support a bit configurable
Modified: trunk/src/command_line_arguments.cxx
===================================================================
--- trunk/src/command_line_arguments.cxx 2003-12-07 20:35:51 UTC (rev
308)
+++ trunk/src/command_line_arguments.cxx 2003-12-07 20:54:11 UTC (rev
309)
@@ -36,6 +36,7 @@
{"fps", 'f', "FPS", 0, "Limit of frames per second" },
{"music", 'm', 0, 0, "Enable music" },
{"sound", 's', 0, 0, "Enable sound" },
+ {"joystick", 'j', "NUM", 0, "Use Joystick number NUM, instead of
keyboard" },
{"geometry", 'g', "WIDTHxHEIGHT", 0, "Set screen size" },
{ 0 }
};
@@ -64,6 +65,7 @@
mission_file = "";
fps = 30.0f;
+ joystick = -1;
verbose = true;
datadir = "";
music_enabled = false;
@@ -132,6 +134,14 @@
music_enabled = true;
break;
+ case 'j':
+ if (sscanf(arg, "%d", &joystick) != 1)
+ {
+ std::cout << "Argument to joystick must be a number" << std::endl;
+ exit(EXIT_FAILURE);
+ }
+ break;
+
case 's':
sound_enabled = true;
break;
Modified: trunk/src/command_line_arguments.hxx
===================================================================
--- trunk/src/command_line_arguments.hxx 2003-12-07 20:35:51 UTC (rev
308)
+++ trunk/src/command_line_arguments.hxx 2003-12-07 20:54:11 UTC (rev
309)
@@ -38,6 +38,9 @@
/** number of fps to which the game should limit itself */
float fps;
+ /** Number of the joystick to use, -1 for keyboard support */
+ int joystick;
+
bool music_enabled;
bool sound_enabled;
Modified: trunk/src/feuerkraft.cxx
===================================================================
--- trunk/src/feuerkraft.cxx 2003-12-07 20:35:51 UTC (rev 308)
+++ trunk/src/feuerkraft.cxx 2003-12-07 20:54:11 UTC (rev 309)
@@ -151,9 +151,9 @@
{
std::cout << "CL_Error: " << err.message.c_str() << std::endl;
}
- catch (...)
+ catch (std::exception& err)
{
- std::cout << "Something catched..." << std::endl;
+ std::cout << "Error: " << err.what() << std::endl;
}
// Display console close message and wait for a key
Modified: trunk/src/input/input_manager.cxx
===================================================================
--- trunk/src/input/input_manager.cxx 2003-12-07 20:35:51 UTC (rev 308)
+++ trunk/src/input/input_manager.cxx 2003-12-07 20:54:11 UTC (rev 309)
@@ -19,12 +19,16 @@
#include <assert.h>
#include <iostream>
+#include <stdexcept>
+#include <sstream>
#include <ClanLib/Display/joystick.h>
+#include "../command_line_arguments.hxx"
#include "input_manager_clanlib.hxx"
#include "input_manager_keyboard.hxx"
#include "input_manager_impl.hxx"
#include "input_manager.hxx"
+extern CommandLineArguments* args;
InputManagerImpl* InputManager::impl = 0;
void
@@ -34,10 +38,20 @@
{
impl = arg_impl;
}
- else if (CL_Joystick::get_device_count() > 0)
+ else if (args->joystick != -1)
{
- std::cout << "InputManager: Using joystick" << std::endl;
- impl = new InputManagerClanLib();
+ if (args->joystick < CL_Joystick::get_device_count())
+ {
+ std::cout << "InputManager: Using joystick " << args->joystick <<
std::endl;
+ impl = new InputManagerClanLib();
+ }
+ else
+ {
+ std::ostringstream os;
+ os << "Feuerkraft: ClanLib doesn't have joystick number " <<
args->joystick
+ << ", only " << CL_Joystick::get_device_count() << " joysticks
available" << std::endl;
+ throw std::runtime_error(os.str());
+ }
}
else
{
Modified: trunk/src/keyboard_manager.cxx
===================================================================
--- trunk/src/keyboard_manager.cxx 2003-12-07 20:35:51 UTC (rev 308)
+++ trunk/src/keyboard_manager.cxx 2003-12-07 20:54:11 UTC (rev 309)
@@ -21,8 +21,10 @@
#include <ClanLib/Display/keyboard.h>
#include <ClanLib/Display/joystick.h>
#include <ClanLib/Display/mouse.h>
+#include "command_line_arguments.hxx"
#include "keyboard_manager.hxx"
+extern CommandLineArguments* args;
KeyboardManager* KeyboardManager::instance_ = 0;
KeyboardManager::KeyboardManager()
@@ -32,11 +34,14 @@
slots.push_back(CL_Mouse::sig_key_down().connect(this,
&KeyboardManager::button_down));
slots.push_back(CL_Mouse::sig_key_up().connect(this,
&KeyboardManager::button_up));
- for (int i = 0; i < CL_Joystick::get_device_count(); ++i)
+ if (args->joystick != -1)
{
- CL_InputDevice joy = CL_Joystick::get_device(i);
- slots.push_back(joy.sig_key_up().connect(this,
&KeyboardManager::button_up));
- slots.push_back(joy.sig_key_down().connect(this,
&KeyboardManager::button_down));
+ for (int i = 0; i < CL_Joystick::get_device_count(); ++i)
+ {
+ CL_InputDevice joy = CL_Joystick::get_device(i);
+ slots.push_back(joy.sig_key_up().connect(this,
&KeyboardManager::button_up));
+ slots.push_back(joy.sig_key_down().connect(this,
&KeyboardManager::button_down));
+ }
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Feuerkraft-CVS] rev 309 - in trunk/src: . input,
Ingo Ruhnke <=