PixelLightAPI  .
Axis.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: Axis.h                                         *
00003  *
00004  *  Copyright (C) 2002-2011 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLINPUT_AXIS_H__
00024 #define __PLINPUT_AXIS_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLInput/Input/Controls/Control.h"
00032 
00033 
00034 //[-------------------------------------------------------]
00035 //[ Namespace                                             ]
00036 //[-------------------------------------------------------]
00037 namespace PLInput {
00038 
00039 
00040 //[-------------------------------------------------------]
00041 //[ Classes                                               ]
00042 //[-------------------------------------------------------]
00043 /**
00044 *  @brief
00045 *    Axis control
00046 */
00047 class Axis : public Control {
00048 
00049 
00050     //[-------------------------------------------------------]
00051     //[ Class definition                                      ]
00052     //[-------------------------------------------------------]
00053     pl_class(PLINPUT_RTTI_EXPORT, Axis, "PLInput", PLInput::Control, "Axis control")
00054         #ifdef PLINPUT_EXPORTS  // The following is only required when compiling PLInput
00055             // Methods
00056             pl_method_0(GetValue,           pl_ret_type(float),                 "Returns the axis value.",                                                                                                                                  "")
00057             pl_method_2(SetValue,           pl_ret_type(void),  float,  bool,   "Set axis value. Current value as first parameter. As second parameter 'true' if the current value is relative, else 'false' if it's a absolute value.",    "")
00058             pl_method_0(IsValueRelative,    pl_ret_type(bool),                  "Returns 'true' if the current value is relative, else 'false' if it's a absolute value.",                                                                  "")
00059         #endif
00060     pl_class_end
00061 
00062 
00063     //[-------------------------------------------------------]
00064     //[ Public functions                                      ]
00065     //[-------------------------------------------------------]
00066     public:
00067         /**
00068         *  @brief
00069         *    Constructor
00070         *
00071         *  @param[in] pController
00072         *    Owning controller, can, but shouldn't be a null pointer
00073         *  @param[in] sName
00074         *    Control name
00075         *  @param[in] sDescription
00076         *    Control description
00077         */
00078         PLINPUT_API Axis(Controller *pController, const PLCore::String &sName, const PLCore::String &sDescription);
00079 
00080         /**
00081         *  @brief
00082         *    Copy constructor
00083         *
00084         *  @param[in] cOther
00085         *    Other axis
00086         */
00087         PLINPUT_API Axis(const Axis &cOther);
00088 
00089         /**
00090         *  @brief
00091         *    Destructor
00092         */
00093         PLINPUT_API virtual ~Axis();
00094 
00095         /**
00096         *  @brief
00097         *    Comparison operator
00098         *
00099         *  @param[in] cOther
00100         *    Axis to compare with
00101         *
00102         *  @return
00103         *    'true', if both axes are equal, else 'false'
00104         */
00105         PLINPUT_API bool operator ==(const Axis &cOther) const;
00106 
00107         /**
00108         *  @brief
00109         *    Copy operator
00110         *
00111         *  @param[in] cOther
00112         *    Other axis
00113         *
00114         *  @return
00115         *    Reference to this axis
00116         */
00117         PLINPUT_API Axis &operator =(const Axis &cOther);
00118 
00119         /**
00120         *  @brief
00121         *    Get axis value
00122         *
00123         *  @return
00124         *    Current value
00125         *
00126         *  @remarks
00127         *    Please note that a value can be absolute (for instance the x-axis of a joystick) or
00128         *    relative (for instance the x-axis of a mouse). While an absolute axis is usually timing
00129         *    independent, a relative axis just tells you about a state change since the last update.
00130         *    Therefore, we strongly recommend to always use "IsValueRelative()" to check for the value
00131         *    type in order to, for instance, multiply a absolute value with the current time difference
00132         *    since the last frame/update to get correctly timed movement.
00133         */
00134         PLINPUT_API float GetValue() const;
00135 
00136         /**
00137         *  @brief
00138         *    Set axis value
00139         *
00140         *  @param[in] fValue
00141         *    Current value
00142         *  @param[in] bValueRelative
00143         *    'true' if the current value is relative, else 'false' if it's a absolute value
00144         */
00145         PLINPUT_API void SetValue(float fValue, bool bValueRelative);
00146 
00147         /**
00148         *  @brief
00149         *    Return whether the current value is relative or absolute
00150         *
00151         *  @return
00152         *    'true' if the current value is relative, else 'false' if it's a absolute value
00153         */
00154         PLINPUT_API bool IsValueRelative() const;
00155 
00156 
00157     //[-------------------------------------------------------]
00158     //[ Private data                                          ]
00159     //[-------------------------------------------------------]
00160     private:
00161         float m_fValue;         /**< Value of the axis */
00162         bool  m_bValueRelative; /**< Is the current value a relative one? */
00163 
00164 
00165 };
00166 
00167 
00168 //[-------------------------------------------------------]
00169 //[ Namespace                                             ]
00170 //[-------------------------------------------------------]
00171 } // PLInput
00172 
00173 
00174 #endif // __PLINPUT_AXIS_H__


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:50:51
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported