Back to index

supertuxkart  0.5+dfsg1
sdldrv.hpp
Go to the documentation of this file.
00001 //  $Id: sdldrv.hpp 694 2006-08-29 07:42:36Z hiker $
00002 //
00003 //  SuperTuxKart - a fun racing game with go-kart
00004 //  Copyright (C) 2004-2006 Steve Baker <sjbaker1@airmail.net>
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 HEADER_SDLDRV_H
00021 #define HEADER_SDLDRV_H
00022 
00023 #include <string>
00024 #include <vector>
00025 
00026 #include <SDL/SDL.h>
00027 
00028 #include "input.hpp"
00029 
00030 class ActionMap;
00031 
00032 enum MouseState { INITIAL, MOVED, RESET_NEEDED }; 
00033 
00034 enum InputDriverMode {
00035        MENU = 0,
00036        INGAME,
00037        INPUT_SENSE,
00038        LOWLEVEL,
00039        BOOTSTRAP
00040 };
00041 
00042 class SDLDriver
00043 {
00044        class StickInfo {
00045        public:
00046               SDL_Joystick *sdlJoystick;
00047 
00048               std::string *id;
00049                             
00050               int deadzone;
00051               
00052               int index;
00053               
00054               AxisDirection *prevAxisDirections;
00055 
00056               StickInfo(int);
00057                             
00058               ~StickInfo();
00059        };
00060 
00061        Input *sensedInput;
00062        ActionMap *actionMap;
00063        
00064        SDL_Surface *mainSurface;
00065        long flags;
00066 
00067        StickInfo **stickInfos;
00068               
00069        InputDriverMode mode;
00070        
00071        /* Helper values to store and track the relative mouse movements. If these
00072        * values exceed the deadzone value the input is reported to the game. This
00073        * makes the mouse behave like an analog axis on a gamepad/joystick.
00074        */
00075        int mouseValX;
00076        int mouseValY;
00077        
00078        void showPointer();
00079        
00080        void hidePointer();
00081        
00082        void input(InputType, int, int, int, int);
00083        
00084 public:
00085        SDLDriver();
00086        ~SDLDriver();
00087                      
00088        void initStickInfos();
00089 
00090        void toggleFullscreen(bool resetTextures=1);
00091               
00092        void setVideoMode(bool resetTextures=1);
00093 
00094        void input();
00095 
00096        void setMode(InputDriverMode);
00097               
00098        bool isInMode(InputDriverMode);
00099 
00100        Input &getSensedInput();
00101 };
00102 
00103 extern SDLDriver *inputDriver;
00104 
00105 #endif