Back to index

supertuxkart  0.5+dfsg1
input.hpp
Go to the documentation of this file.
00001 //  $Id: input.hpp 694 2006-08-29 07:42:36Z hiker $
00002 //
00003 //  SuperTuxKart - a fun racing game with go-kart
00004 //  Copyright (C) 2007-2008 Robert Schuster <robertschuster@fsfe.org>
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #ifndef TUXKART_INPUT_H
00021 #define TUXKART_INPUT_H
00022 
00023 enum AxisDirection {
00024        AD_NEGATIVE,
00025        AD_POSITIVE,
00026        AD_NEUTRAL
00027 };
00028 
00029 enum InputType {
00030        IT_NONE = 0,
00031        IT_KEYBOARD,
00032        IT_STICKMOTION,
00033        IT_STICKBUTTON,
00034        IT_STICKHAT,
00035        IT_MOUSEMOTION,
00036        IT_MOUSEBUTTON
00037 };
00038 const int IT_LAST = IT_MOUSEBUTTON;
00039 
00040 struct Input
00041 {
00042     InputType type;
00043     int id0;
00044     int id1;
00045     int id2;
00046 
00047        // Esoteric C++ feature alarm: structs are classes where the fields and
00048        // methods are public by default. I just needed some convenient constructors
00049        // for this struct.
00050        Input()
00051               : type(IT_NONE), id0(0), id1(0), id2(0)
00052        {
00053               // Nothing to do.
00054        }
00055        
00079        Input(InputType ntype, int nid0 , int nid1 = 0, int nid2= 0) 
00080               : type(ntype), id0(nid0), id1(nid1), id2(nid2)
00081        {
00082               // Nothing to do.
00083        }
00084 };
00085 
00086 //When adding any action at the beginning or at the end, remember to update
00087 //the KA_FIRST and/or KA_LAST constants.
00088 enum KartAction {
00089        KA_LEFT,
00090        KA_RIGHT,
00091        KA_ACCEL,
00092        KA_BRAKE,
00093        KA_WHEELIE,
00094        KA_JUMP,
00095        KA_RESCUE,
00096        KA_FIRE,
00097        KA_LOOK_BACK
00098 };
00099 const int KA_FIRST = KA_LEFT;
00100 const int KA_LAST = KA_LOOK_BACK;
00101 const int KC_COUNT = (KA_LAST + 1);
00102 
00103 enum GameAction
00104 {
00105        // Below this are synthetic game actions which are never triggered through
00106        // an input device.
00107        GA_NULL,                           // Nothing dummy entry.
00108        GA_SENSE_CANCEL,            // Input sensing canceled.
00109        GA_SENSE_COMPLETE,          // Input sensing successfully finished.
00110        
00111        // Below this point are the game actions which can happen while in menu
00112        // mode.
00113               
00114        GA_ENTER,                          // Enter menu, acknowledge, ...
00115        GA_LEAVE,                          // Leave a menu.
00116        
00117        GA_CLEAR_MAPPING,           // Clear an input mapping.
00118        
00119        GA_INC_SCROLL_SPEED,
00120        GA_INC_SCROLL_SPEED_FAST,
00121        GA_DEC_SCROLL_SPEED,
00122        GA_DEC_SCROLL_SPEED_FAST,
00123        
00124        GA_CURSOR_UP,
00125        GA_CURSOR_DOWN,
00126        GA_CURSOR_LEFT,
00127        GA_CURSOR_RIGHT,
00128        
00129        // The following game actions occur when in ingame mode (= within a race).
00130 
00131        GA_P1_LEFT,
00132        GA_P1_RIGHT,
00133        GA_P1_ACCEL,
00134        GA_P1_BRAKE,
00135        GA_P1_WHEELIE,
00136        GA_P1_JUMP,
00137        GA_P1_RESCUE,
00138        GA_P1_FIRE,
00139        GA_P1_LOOK_BACK,
00140        
00141        GA_P2_LEFT,
00142        GA_P2_RIGHT,
00143        GA_P2_ACCEL,
00144        GA_P2_BRAKE,
00145        GA_P2_WHEELIE,
00146        GA_P2_JUMP,
00147        GA_P2_RESCUE,
00148        GA_P2_FIRE,
00149        GA_P2_LOOK_BACK,
00150        
00151        GA_P3_LEFT,
00152        GA_P3_RIGHT,
00153        GA_P3_ACCEL,
00154        GA_P3_BRAKE,
00155        GA_P3_WHEELIE,
00156        GA_P3_JUMP,
00157        GA_P3_RESCUE,
00158        GA_P3_FIRE,
00159        GA_P3_LOOK_BACK,
00160        
00161        GA_P4_LEFT,
00162        GA_P4_RIGHT,
00163        GA_P4_ACCEL,
00164        GA_P4_BRAKE,
00165        GA_P4_WHEELIE,
00166        GA_P4_JUMP,
00167        GA_P4_RESCUE,
00168        GA_P4_FIRE,
00169        GA_P4_LOOK_BACK,
00170 
00171        GA_TOGGLE_FULLSCREEN,       // Switch between windowed/fullscreen mode
00172        GA_LEAVE_RACE,                     // Switch from race to menu.
00173        
00174        GA_DEBUG_ADD_MISSILE,
00175        GA_DEBUG_ADD_SPARK,
00176        GA_DEBUG_ADD_HOMING,
00177        GA_DEBUG_TOGGLE_FPS,
00178        GA_DEBUG_TOGGLE_WIREFRAME,
00179        GA_DEBUG_HISTORY
00180        
00181 };
00182 /* Some constants to make future changes more easier to handle. If you use
00183  * any of the GameAction constants to mark the beginning or end of a range
00184  * or denote a count then something is wrong with your code. ;)
00185  */
00186 
00188 const int GA_FIRST = GA_NULL;
00189 
00193 const int GA_COUNT = (GA_DEBUG_HISTORY + 1);
00194 
00195 /* The range of GameAction constants that is used while in menu mode. */
00196 const int GA_FIRST_MENU = GA_ENTER;
00197 const int GA_LAST_MENU = GA_CURSOR_RIGHT;
00198 
00199 /* The range of GameAction constants that is used while in ingame (race) mode. */
00200 const int GA_FIRST_INGAME = GA_P1_LEFT;
00201 const int GA_LAST_INGAME = GA_DEBUG_HISTORY;
00202 
00203 /* The range of GameAction constants which are used ingame but are considered
00204  * fixed and their Inputs should not be used by the players.
00205  */
00206 const int GA_FIRST_INGAME_FIXED = GA_TOGGLE_FULLSCREEN;
00207 const int GA_LAST_INGAME_FIXED = GA_DEBUG_HISTORY;
00208 
00215 const int GA_FIRST_KARTACTION = GA_P1_LEFT;
00216 const int GA_LAST_KARTACTION = GA_P4_LOOK_BACK;
00217 
00218 #endif