4 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef __JOYSTICKKEYBOARDCONTROLLER_H__
21 #define __JOYSTICKKEYBOARDCONTROLLER_H__
23 #include "controller.hpp"
24 #include "lisp/lisp.hpp"
25 #include "lisp/writer.hpp"
32 class JoystickKeyboardController : public Controller
35 JoystickKeyboardController();
36 virtual ~JoystickKeyboardController();
38 /** Process an SDL Event and return true if the event has been used
40 void process_event(const SDL_Event& event);
42 void write(lisp::Writer& writer);
43 void read(const lisp::Lisp& lisp);
46 Menu* get_key_options_menu();
47 Menu* get_joystick_options_menu();
50 void process_key_event(const SDL_Event& event);
51 void process_hat_event(const SDL_JoyHatEvent& jhat);
52 void process_axis_event(const SDL_JoyAxisEvent& jaxis);
53 void process_console_key_event(const SDL_Event& event);
54 void process_menu_key_event(const SDL_Event& event);
56 typedef std::map<SDLKey, Control> KeyMap;
59 typedef std::map<int, Control> ButtonMap;
60 ButtonMap joy_button_map;
62 typedef std::map<int, Control> AxisMap;
65 typedef std::map<int, Control> HatMap;
68 std::vector<SDL_Joystick*> joysticks;
73 /// the number of buttons all joysticks have
75 /// the max number of buttons a joystick has
84 SDLKey reversemap_key(Control c);
85 int reversemap_joybutton(Control c);
86 int reversemap_joyaxis(Control c);
87 int reversemap_joyhat(Control c);
89 void unbind_control(Control c);
91 void reset_joybutton(int button, Control c);
92 void reset_joyaxis(int axis, Control c);
93 void reset_joyhat(int dir, Control c);
94 void reset_key(SDLKey key, Control c);
97 int wait_for_joystick;
102 KeyboardMenu* key_options_menu;
103 JoystickMenu* joystick_options_menu;
104 friend class KeyboardMenu;
105 friend class JoystickMenu;