[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Feuerkraft-CVS] rev 326 - in trunk: data src src/input
From: |
Ingo Ruhnke |
Subject: |
[Feuerkraft-CVS] rev 326 - in trunk: data src src/input |
Date: |
Sat, 13 Dec 2003 00:12:23 +0100 |
Author: grumbel
Date: 2003-12-13 00:12:22 +0100 (Sat, 13 Dec 2003)
New Revision: 326
Added:
trunk/data/controller.scm
trunk/src/feuerkraft_error.hxx
Modified:
trunk/src/Makefile.am
trunk/src/feuerkraft.cxx
trunk/src/guile.cxx
trunk/src/input/Makefile.am
trunk/src/input/axis_factory.cxx
trunk/src/input/button_factory.cxx
trunk/src/input/input_manager.cxx
trunk/src/input/input_manager_custom.cxx
trunk/src/input/input_manager_player.cxx
trunk/src/path_manager.cxx
Log:
- cleaned up stdout a bit
- reading default controller now from file, instead of hardcoded
Added: trunk/data/controller.scm
===================================================================
--- trunk/data/controller.scm 2003-12-11 12:59:04 UTC (rev 325)
+++ trunk/data/controller.scm 2003-12-12 23:12:22 UTC (rev 326)
@@ -0,0 +1,12 @@
+(feuerkraft-controller
+
+ (primary-button (joystick-button 1 9))
+ (secondary-button (joystick-button 1 8))
+ (use-button (joystick-button 1 3))
+ (menu-button (joystick-button 1 2))
+
+ (orientation-axis (joystick-axis 1 0))
+ (accelerate-axis (joystick-axis 1 1))
+ (strafe-axis (joystick-axis 1 2)))
+
+;; EOF ;;
\ No newline at end of file
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2003-12-11 12:59:04 UTC (rev 325)
+++ trunk/src/Makefile.am 2003-12-12 23:12:22 UTC (rev 326)
@@ -44,6 +44,7 @@
explosion.hxx \
feuerkraft.cxx \
feuerkraft.hxx \
+feuerkraft_error.hxx \
field.hxx \
fonts.hxx \
fonts.cxx \
Modified: trunk/src/feuerkraft.cxx
===================================================================
--- trunk/src/feuerkraft.cxx 2003-12-11 12:59:04 UTC (rev 325)
+++ trunk/src/feuerkraft.cxx 2003-12-12 23:12:22 UTC (rev 326)
@@ -112,9 +112,20 @@
KeyboardManager::instance();
if (args->playback_file.empty())
- InputManager::init(args->controller_file);
+ {
+ if (args->controller_file.empty())
+ {
+ InputManager::init(path_manager.complete("controller.scm"));
+ }
+ else
+ {
+ InputManager::init(args->controller_file);
+ }
+ }
else
- InputManager::init_playback(args->playback_file);
+ {
+ InputManager::init_playback(args->playback_file);
+ }
if (!args->event_record_file.empty())
InputManager::setup_recorder(args->event_record_file);
@@ -154,7 +165,7 @@
// Shutdown everything
deinit();
}
- catch (CL_Error err)
+ catch (CL_Error& err)
{
std::cout << "CL_Error: " << err.message.c_str() << std::endl;
}
Added: trunk/src/feuerkraft_error.hxx
===================================================================
--- trunk/src/feuerkraft_error.hxx 2003-12-11 12:59:04 UTC (rev 325)
+++ trunk/src/feuerkraft_error.hxx 2003-12-12 23:12:22 UTC (rev 326)
@@ -0,0 +1,39 @@
+// $Id$
+//
+// Pingus - A free Lemmings clone
+// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef HEADER_FEUERKRAFT_ERROR_HXX
+#define HEADER_FEUERKRAFT_ERROR_HXX
+
+#include <string>
+
+/** Exception class for all Feuerkraft errors */
+class FeuerkraftError
+{
+private:
+ std::string message;
+public:
+ FeuerkraftError(const std::string& message)
+ : message(message) {}
+
+ const char* what() const throw();
+};
+
+#endif
+
+/* EOF */
Modified: trunk/src/guile.cxx
===================================================================
--- trunk/src/guile.cxx 2003-12-11 12:59:04 UTC (rev 325)
+++ trunk/src/guile.cxx 2003-12-12 23:12:22 UTC (rev 326)
@@ -29,15 +29,22 @@
std::string
scm2string (SCM data)
{
- cl_assert(gh_string_p(data));
-
- char* tmpstr = gh_scm2newstr(data, 0);
- std::string str = tmpstr;
-
-#ifdef WIN32 // the free causes throuble on Win32, so we disable it
- free (tmpstr);
-#endif
-
+ std::string str;
+
+ if (gh_string_p(data))
+ {
+ char* tmpstr = gh_scm2newstr(data, 0);
+ str = tmpstr;
+ free(tmpstr);
+ } else {
+ SCM scmstr = scm_make_string(SCM_MAKINUM(0), SCM_UNDEFINED);
+ SCM port = scm_mkstrport(SCM_INUM0, scmstr,
+ SCM_OPN | SCM_WRTNG, "scm_mkstrport");
+ scm_display(data, port);
+ char* tmpstr = gh_scm2newstr(scmstr, 0);
+ str = tmpstr;
+ free(tmpstr);
+ }
return str;
}
Modified: trunk/src/input/Makefile.am
===================================================================
--- trunk/src/input/Makefile.am 2003-12-11 12:59:04 UTC (rev 325)
+++ trunk/src/input/Makefile.am 2003-12-12 23:12:22 UTC (rev 326)
@@ -1,11 +1,5 @@
noinst_LIBRARIES = libfeuerkraft_input.a
-libfeuerkraft_input_a_LIBDADD = \
- @WINDSTILLE_LIBS@
-
-libfeuerkraft_input_a_CPPFLAGS = \
- @WINDSTILLE_CFLAGS@
-
libfeuerkraft_input_a_SOURCES = \
controller.hxx \
controller.cxx \
Modified: trunk/src/input/axis_factory.cxx
===================================================================
--- trunk/src/input/axis_factory.cxx 2003-12-11 12:59:04 UTC (rev 325)
+++ trunk/src/input/axis_factory.cxx 2003-12-12 23:12:22 UTC (rev 326)
@@ -17,9 +17,10 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#include <iostream>
#include <ClanLib/Display/joystick.h>
#include "input_axis_input_device.hxx"
+#include "../feuerkraft_error.hxx"
+#include "../guile.hxx"
#include "button_factory.hxx"
#include "button_axis.hxx"
#include "axis_factory.hxx"
@@ -42,7 +43,7 @@
}
else
{
- std::cout << "AxisFactory::create: parse error" << std::endl;
+ throw FeuerkraftError("AxisFactory::create: parse error");
}
lst = gh_cdr(lst);
@@ -60,7 +61,8 @@
return new InputAxisInputDevice(CL_Joystick::get_device(device_num),
axis_num);
else
{
- std::cout << "Error: AxisFactory::create_joystick_axis(SCM lst)" <<
std::endl;
+ throw FeuerkraftError("Error: AxisFactory::create_joystick_axis: "
+ + Guile::scm2string(lst));
return 0;
}
}
Modified: trunk/src/input/button_factory.cxx
===================================================================
--- trunk/src/input/button_factory.cxx 2003-12-11 12:59:04 UTC (rev 325)
+++ trunk/src/input/button_factory.cxx 2003-12-12 23:12:22 UTC (rev 326)
@@ -20,6 +20,7 @@
#include <ClanLib/Display/joystick.h>
#include <ClanLib/Display/keyboard.h>
#include "../guile.hxx"
+#include "../feuerkraft_error.hxx"
#include "input_button.hxx"
#include "input_button_input_device.hxx"
#include "button_factory.hxx"
@@ -39,9 +40,8 @@
}
else
{
- std::cout << "ButtonFactory::create: parse error: " << std::flush;
- scm_flush_all_ports();
- gh_display(lst); std::cout << std::endl;
+ throw FeuerkraftError("ButtonFactory::create: parse error: "
+ + Guile::scm2string(lst));
}
return 0;
@@ -57,17 +57,16 @@
return new InputButtonInputDevice(CL_Joystick::get_device(device_num),
button_num);
else
{
- std::cout << "Error: ButtonFactory::create_joystick_button(SCM lst)" <<
std::endl;
- return 0;
+ throw FeuerkraftError("Error: ButtonFactory::create_joystick_button: "
+ + Guile::scm2string(lst));
}
}
InputButton*
ButtonFactory::create_keyboard_button(SCM lst)
{
- //gh_display(lst);
std::string key_str = Guile::scm2string(gh_car(lst));
- int key_num = CL_Keyboard::get_device().keyid_to_string(key_str);
+ int key_num = CL_Keyboard::get_device().keyid_to_string(key_str);
// FIXME: No error checking
return new InputButtonInputDevice(CL_Keyboard::get_device(), key_num);
Modified: trunk/src/input/input_manager.cxx
===================================================================
--- trunk/src/input/input_manager.cxx 2003-12-11 12:59:04 UTC (rev 325)
+++ trunk/src/input/input_manager.cxx 2003-12-12 23:12:22 UTC (rev 326)
@@ -18,10 +18,11 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <assert.h>
-#include <iostream>
#include <stdexcept>
#include <sstream>
#include <ClanLib/Display/joystick.h>
+
+#include "../feuerkraft_error.hxx"
#include "input_manager_custom.hxx"
#include "input_manager_player.hxx"
#include "input_manager_impl.hxx"
@@ -40,43 +41,19 @@
void
InputManager::init(const std::string& filename)
{
- if (!filename.empty())
- {
- std::cout << "InputManager: Reading: " << filename << std::endl;
- SCM port = scm_open_file(gh_str02scm(filename.c_str()),
- gh_str02scm("r"));
- SCM lst = scm_read(port);
+ SCM port = scm_open_file(gh_str02scm(filename.c_str()),
+ gh_str02scm("r"));
+ SCM lst = scm_read(port);
- gh_call1(gh_lookup("display"), lst);
- gh_call1(gh_lookup("display"), gh_car(lst));
- gh_call1(gh_lookup("display"), gh_symbol2scm("feuerkraft-controller"));
-
- if (gh_equal_p(gh_symbol2scm("feuerkraft-controller"), gh_car(lst)))
- {
- impl = new InputManagerCustom(gh_cdr(lst));
- }
- else
- {
- std::cout << "Error: not a valid controller file: " << filename <<
std::endl;
- }
- scm_close_port(port);
+ if (gh_equal_p(gh_symbol2scm("feuerkraft-controller"), gh_car(lst)))
+ {
+ impl = new InputManagerCustom(gh_cdr(lst));
}
-
- if (!impl)
- {
- // FIXME: Default to keyboard would be better
- // Set default configuration
- impl = new InputManagerCustom
- (gh_eval_str("'("
- "(primary-button (joystick-button 1 9))"
- "(secondary-button (joystick-button 1 8))"
- "(use-button (joystick-button 1 3))"
- "(menu-button (joystick-button 1 2))"
- "(orientation-axis (joystick-axis 1 0))"
- "(accelerate-axis (joystick-axis 1 1))"
- "(strafe-axis (joystick-axis 1 2))"
- ")"));
- }
+ else
+ {
+ throw FeuerkraftError("Error: not a valid controller file: " + filename);
+ }
+ scm_close_port(port);
}
void
Modified: trunk/src/input/input_manager_custom.cxx
===================================================================
--- trunk/src/input/input_manager_custom.cxx 2003-12-11 12:59:04 UTC (rev
325)
+++ trunk/src/input/input_manager_custom.cxx 2003-12-12 23:12:22 UTC (rev
326)
@@ -46,7 +46,8 @@
}
else
{
- std::cout << "Button " << i << " not configured" << std::endl;
+ std::cout << "# Warrning: Button '" <<
ControllerDef::button_id2name(i)
+ << "' not configured and will not be usable" << std::endl;
}
}
@@ -58,7 +59,8 @@
}
else
{
- std::cout << "Axis " << i << " not configured" << std::endl;
+ std::cout << "# Warrning: Axis '" << ControllerDef::axis_id2name(i)
+ << "' not configured and will not be usable" << std::endl;
}
}
}
@@ -69,15 +71,11 @@
buttons.resize(ControllerDef::get_button_count());
axes.resize(ControllerDef::get_axis_count());
- std::cout << "InputManagerCustom::init" << std::endl;
while (gh_pair_p(lst))
{
- //gh_display(gh_car(lst)); gh_newline();
SCM sym = gh_caar(lst);
SCM data = gh_cadar(lst);
- //gh_display(sym); gh_newline();
-
std::string name = Guile::symbol2string(sym);
int id = ControllerDef::button_name2id(name);
@@ -94,7 +92,8 @@
}
else
{
- std::cout << "InputManagerCustom::init: Error unknown tag: " <<
Guile::symbol2string(sym) << std::endl;
+ std::cout << "# Warning: InputManagerCustom::init: Error unknown
tag: "
+ << Guile::scm2string(sym) << std::endl;
}
}
Modified: trunk/src/input/input_manager_player.cxx
===================================================================
--- trunk/src/input/input_manager_player.cxx 2003-12-11 12:59:04 UTC (rev
325)
+++ trunk/src/input/input_manager_player.cxx 2003-12-12 23:12:22 UTC (rev
326)
@@ -18,6 +18,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <iostream>
+#include "../guile.hxx"
#include "input_manager_player.hxx"
InputManagerPlayer::InputManagerPlayer(const std::string& filename)
@@ -38,11 +39,8 @@
lst.push_back(scm2event(gh_car(entry)));
entry = gh_cdr(entry);
}
-
- std::cout << "Entry: " << entry_num << " events: " << lst.size() <<
std::endl;
entries.push(Entry(entry_num, lst));
}
- //gh_display(entry);gh_newline();
scm_close_port(port);
}
@@ -67,10 +65,7 @@
}
else
{
- std::cout << "scm2event: Unknown sym: " << std::flush;
- gh_display(sym);
- scm_flush_all_ports();
- std::cout << std::endl;
+ std::cout << "scm2event: Unknown sym: " << Guile::scm2string(sym) <<
std::endl;
}
return event;
}
@@ -78,7 +73,6 @@
void
InputManagerPlayer::update(float delta)
{
- //std::cout << "Got: " << entry_counter << " " << entries.front().entry_num
<< std::endl;
if (entries.front().entry_num == entry_counter)
{
events = entries.front().events;
Modified: trunk/src/path_manager.cxx
===================================================================
--- trunk/src/path_manager.cxx 2003-12-11 12:59:04 UTC (rev 325)
+++ trunk/src/path_manager.cxx 2003-12-12 23:12:22 UTC (rev 326)
@@ -35,7 +35,7 @@
void
PathManager::add_path (const std::string& path)
{
- std::cout << "PathManager: add_path: " << path << std::endl;
+ //std::cout << "PathManager: add_path: " << path << std::endl;
path_list.push_back (path);
}
@@ -43,7 +43,7 @@
PathManager::complete (const std::string& relative_path)
{
std::string comp_path = base_path + "/" + relative_path;
- std::cout << "PathManager: " << relative_path << " -> " << comp_path <<
std::endl;
+ //std::cout << "PathManager: " << relative_path << " -> " << comp_path <<
std::endl;
return comp_path;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Feuerkraft-CVS] rev 326 - in trunk: data src src/input,
Ingo Ruhnke <=