# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

game_device.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2000-2002 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #ifndef NL_GAME_DEVICE_H
00027 #define NL_GAME_DEVICE_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 #include "nel/misc/input_device.h"
00031 #include <string>
00032 #include <vector>
00033 
00034 
00035 namespace NLMISC 
00036 {
00037 
00039 struct CGameDeviceDesc
00040 {
00041         // type of the device
00042         enum TDevType { GamePad, Joystick, DontKnow, DevTypeLast }              DevType;
00043         // Friendly name for the instance. For example, "Joystick 1." 
00044         std::string     InstanceName;
00045         // Friendly name for the product
00046         std::string     ProductName;
00047         // Tells wether this device is connected
00048         bool            Connected;
00049 };
00050 
00051 // a list of game device description
00052 typedef std::vector<CGameDeviceDesc> TDeviceDescVect;
00053 
00055 inline bool operator == (const CGameDeviceDesc &lhs, const CGameDeviceDesc &rhs)
00056 {
00057         return lhs.InstanceName == rhs.InstanceName && lhs.ProductName == rhs.ProductName;
00058 }
00059 //
00060 inline bool operator != (const CGameDeviceDesc &lhs, const CGameDeviceDesc &rhs)
00061 {
00062         return !(lhs == rhs);
00063 }
00064 
00065 
00072 struct IGameDevice : public IInputDevice
00073 {
00074         enum TAxis { XAxis = 0, YAxis, ZAxis, /* translation */
00075                                  RXAxis, RYAxis, RZAxis,   /* rotations */
00076                                  MaxNumAxis
00077                                 };                                                
00078 
00080         virtual const CGameDeviceDesc &getDescription()  const = 0;
00081         
00083 
00084                 // returns the number of buttons available on this game device
00085                 virtual uint  getNumButtons()  const = 0;
00089                 virtual bool            hasAxis(TAxis axis)  const = 0;
00090                 // Check the number of sliders presents on this game device
00091                 virtual uint            getNumSliders()  const = 0;
00092                 // Check the number of point of views controls present on this game device
00093                 virtual uint            getNumPOV()  const = 0;
00095 
00097 
00098                 virtual const char *getButtonName(uint index)  const = 0;
00099                 virtual const char *getAxisName(TAxis axis)  const = 0;
00100                 virtual const char *getSliderName(uint index)  const = 0;
00101                 virtual const char *getPOVName(uint index)  const = 0;
00103 
00105 
00106                 // Return true if the given button is pushed.
00107                 virtual bool            getButtonState(uint index) const = 0;
00108                 // Return a value in [-1, 1] for a translation axis, or an orientation.
00109                 virtual float           getAxisValue(TAxis axis) const = 0;
00110                 // Return a value in [0, 1]
00111                 virtual float           getSliderPos(uint index) const = 0;
00112                 // Return a CCW angle in degrees
00113                 virtual float           getPOVAngle(uint index) const = 0;
00115 };
00116 
00117 
00118 } // NLMISC
00119 
00120 
00121 #endif // NL_GAME_DEVICE_H
00122 
00123 /* End of GAME_device.h */