Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

inputaxis_group.h

Go to the documentation of this file.
00001 /*
00002         $Id: inputaxis_group.h,v 1.1 2001/03/06 15:09:10 mbn Exp $
00003 
00004         ------------------------------------------------------------------------
00005         ClanLib, the platform independent game SDK.
00006 
00007         This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00008         version 2. See COPYING for details.
00009 
00010         For a total list of contributers see CREDITS.
00011 
00012         ------------------------------------------------------------------------
00013 */
00014 
00016 
00017 #ifndef header_inputaxis_group
00018 #define header_inputaxis_group
00019 
00020 #include "../Input/inputaxis.h"
00021 
00022 class CL_InputAxis_Group : public CL_InputAxis
00023 //: CL_InputAxis container class. Groups a set of axes.
00024 {
00025         std::list<CL_InputAxis*> axes;
00026 public:
00027         void add(CL_InputAxis *add_axis)
00028         {
00029                 axes.push_back(add_axis);
00030         }
00031         //: Adds a input axis to the group.
00033 
00034         void remove(CL_InputAxis *remove_axis)
00035         {
00036                 axes.remove(remove_axis);
00037         }
00038         //: Removes a input axis from the group.
00040 
00041         virtual float get_pos()
00042         {
00043                 float pos = 0;
00044 
00045                 for (
00046                         std::list<CL_InputAxis *>::iterator it = axes.begin();
00047                         it != axes.end();
00048                         it++)
00049                 {
00050                         pos += (*it)->get_pos();
00051                 }
00052 
00053                 if (pos > 1) pos = 1;
00054                 if (pos < -1) pos = -1;
00055 
00056                 return pos;
00057         }
00058         //: Returns the current axis position. This is calculated by sumarizing
00059         //: all the input axes positions and return that value.
00061 };
00062 
00063 #endif

Generated at Wed Apr 4 19:54:00 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001