-// $Id$
-//
// SuperTux
// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
//
-// 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 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 3 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
// 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.
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef HEADER_SUPERTUX_CONTROL_JOYSTICKKEYBOARDCONTROLLER_HPP
+#define HEADER_SUPERTUX_CONTROL_JOYSTICKKEYBOARDCONTROLLER_HPP
-#ifndef __JOYSTICKKEYBOARDCONTROLLER_H__
-#define __JOYSTICKKEYBOARDCONTROLLER_H__
+#include "control/controller.hpp"
-#include "controller.hpp"
-#include "lisp/lisp.hpp"
-#include "lisp/writer.hpp"
#include <SDL.h>
-#include <string>
+
#include <map>
+#include <string>
+#include <vector>
+
+#include "util/reader_fwd.hpp"
+#include "util/writer_fwd.hpp"
class Menu;
+class KeyboardMenu;
+class JoystickMenu;
class JoystickKeyboardController : public Controller
{
*/
void process_event(const SDL_Event& event);
- void write(lisp::Writer& writer);
- void read(const lisp::Lisp& lisp);
+ void write(Writer& writer);
+ void read(const Reader& lisp);
void reset();
Menu* get_key_options_menu();
Menu* get_joystick_options_menu();
+ void updateAvailableJoysticks();
private:
void process_key_event(const SDL_Event& event);
void print_joystick_mappings();
+ SDLKey reversemap_key(Control c);
+ int reversemap_joybutton(Control c);
+ int reversemap_joyaxis(Control c);
+ int reversemap_joyhat(Control c);
+
+ void unbind_joystick_control(Control c);
+
+ void bind_joybutton(int button, Control c);
+ void bind_joyaxis(int axis, Control c);
+ void bind_joyhat(int dir, Control c);
+ void bind_key(SDLKey key, Control c);
+
+ void set_joy_controls(Control id, bool value);
+
+private:
+ friend class KeyboardMenu;
+ friend class JoystickMenu;
+
typedef std::map<SDLKey, Control> KeyMap;
+ typedef std::map<int, Control> ButtonMap;
+ typedef std::map<int, Control> AxisMap;
+ typedef std::map<int, Control> HatMap;
+
+private:
KeyMap keymap;
- typedef std::map<int, Control> ButtonMap;
ButtonMap joy_button_map;
- typedef std::map<int, Control> AxisMap;
AxisMap joy_axis_map;
- typedef std::map<int, Control> HatMap;
HatMap joy_hat_map;
std::vector<SDL_Joystick*> joysticks;
Uint8 hat_state;
- bool jump_with_up; // Joystick up jumps
- bool jump_with_up_key; // Keyboard up jumps
-
- SDLKey reversemap_key(Control c);
- int reversemap_joybutton(Control c);
- int reversemap_joyaxis(Control c);
- int reversemap_joyhat(Control c);
-
- void unbind_joystick_control(Control c);
-
- void bind_joybutton(int button, Control c);
- void bind_joyaxis(int axis, Control c);
- void bind_joyhat(int dir, Control c);
- void bind_key(SDLKey key, Control c);
-
- void set_joy_controls(Control id, bool value);
+ bool jump_with_up_joy; // Joystick up jumps
+ bool jump_with_up_kbd; // Keyboard up jumps
int wait_for_key;
int wait_for_joystick;
- class KeyboardMenu;
- class JoystickMenu;
-
KeyboardMenu* key_options_menu;
JoystickMenu* joystick_options_menu;
- friend class KeyboardMenu;
- friend class JoystickMenu;
+
+private:
+ JoystickKeyboardController(const JoystickKeyboardController&);
+ JoystickKeyboardController& operator=(const JoystickKeyboardController&);
};
#endif
+
+/* EOF */