deeb8e639ea766f408c9d23161e7ed120b9c94d9
[supertux.git] / src / control / controller.hpp
1 //  $Id$
2 //
3 //  SuperTux
4 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
5 //
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.
10 //
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.
15 //
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.
19
20 #ifndef __CONTROLLER_H__
21 #define __CONTROLLER_H__
22
23 class Controller
24 {
25 public:
26   static const char* controlNames[];
27   
28   enum Control {
29     LEFT = 0,
30     RIGHT,
31     UP,
32     DOWN,
33     JUMP,
34     ACTION,
35     PAUSE_MENU,
36     MENU_SELECT,
37     CONSOLE,
38     PEEK_LEFT,
39     PEEK_RIGHT,
40     
41     CONTROLCOUNT
42   };
43
44   Controller();
45   virtual ~Controller();
46
47   /** returns true if the control is pressed down */
48   bool hold(Control control);
49   /** returns true if the control has just been pressed down this frame */
50   bool pressed(Control control);
51   /** returns true if the control has just been released this frame */ 
52   bool released(Control control);
53
54   virtual void reset();
55   virtual void update();
56
57 protected:
58   /** current control status */
59   bool controls[CONTROLCOUNT];
60   /** control status at last frame */
61   bool oldControls[CONTROLCOUNT];
62 };
63
64 #endif