Orxonox  0.0.5 Codename: Arcturus
JoyStick.h
Go to the documentation of this file.
1 /*
2  * ORXONOX - the hottest 3D action shooter ever to exist
3  * > www.orxonox.net <
4  *
5  *
6  * License notice:
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  * Author:
23  * Reto Grieder
24  * Co-authors:
25  * ...
26  *
27  */
28 
29 #ifndef _Core_JoyStick_H__
30 #define _Core_JoyStick_H__
31 
32 #include "InputPrereqs.h"
33 
34 #include <string>
35 #include <vector>
36 #include <ois/OISJoyStick.h>
37 #include "InputDevice.h"
39 
40 namespace orxonox
41 {
44  {
50  };
51 
61  : public Configurable
62  , public InputDeviceTemplated<JoyStickTraits>
63  , public OIS::JoyStickListener
64  {
68 
69  public:
71  JoyStick(unsigned int id, OIS::InputManager* oisInputManager);
72  ~JoyStick() = default;
73  void setConfigValues();
74 
76  const std::string& getDeviceName() const { return this->deviceName_; }
77 
78  private:
79  virtual void calibrationStarted() override;
80  virtual void calibrationStopped() override;
81  void evaluateCalibration();
82 
83  void clearBuffersImpl();
84  void calibrationFileCallback();
85  void fireAxis(int axis, int value);
86 
88  virtual bool buttonPressed (const OIS::JoyStickEvent &arg, int button) override
89  {
90  super::buttonPressed(static_cast<JoyStickButtonCode::ByEnum>(button));
91  return true;
92  }
93 
95  virtual bool buttonReleased(const OIS::JoyStickEvent &arg, int button) override
96  {
97  super::buttonReleased(static_cast<JoyStickButtonCode::ByEnum>(button));
98  return true;
99  }
100 
101  virtual bool axisMoved (const OIS::JoyStickEvent &arg, int axis) override;
102  virtual bool sliderMoved (const OIS::JoyStickEvent &arg, int id) override;
103  virtual bool povMoved (const OIS::JoyStickEvent &arg, int id) override;
105  virtual bool vector3Moved (const OIS::JoyStickEvent &arg, int id) override { return true; }
106 
108  static std::string getClassNameImpl() { return "JoyStick"; }
109 
111  int povStates_[4];
112  int sliderStates_[4][2];
113 
114  // calibration
115  int zeroValues_[24];
116  float positiveCoeffs_[24];
117  float negativeCoeffs_[24];
118 
119  std::vector<int> configZeroValues_;
120  std::vector<int> configMinValues_;
121  std::vector<int> configMaxValues_;
122 
123  // ConfigValues
125 
127  static std::vector<std::string> deviceNames_s;
128 
130  static const unsigned int sliderAxes_s = 8;
131  };
132 }
133 
134 #endif /* _Core_JoyStick_H__ */
Wraps around an OIS::JoyStick and forwards the input events to a list of input states.
Definition: JoyStick.h:60
To recieve buffered joystick input, derive a class from this, and implement the methods here...
Definition: OISJoyStick.h:131
Heavily templated base class for all three input devices.
Definition: CorePrereqs.h:281
static std::string getClassNameImpl()
Returns the class name as string.
Definition: JoyStick.h:108
static const OIS::Type OISDeviceValue
Definition: JoyStick.h:49
Template parameter collection for the base class
Definition: JoyStick.h:43
::std::string string
Definition: gtest-port.h:756
OIS::JoyStick OISDeviceClass
Definition: JoyStick.h:46
JoyStickButtonCode::ByEnum ButtonTypeParam
Definition: JoyStick.h:48
ByEnum
Definition: InputPrereqs.h:362
virtual bool vector3Moved(const OIS::JoyStickEvent &arg, int id) override
OIS event handler (don&#39;t remove that because of OIS version issues!)
Definition: JoyStick.h:105
InputDeviceTemplated< JoyStickTraits > super
Super class alias.
Definition: JoyStick.h:67
std::string calibrationFilename_
Joy stick calibration ini filename.
Definition: JoyStick.h:124
JoyStick DeviceClass
Definition: JoyStick.h:45
const std::string & getDeviceName() const
Returns the name generated from the number of knobs and the device name.
Definition: JoyStick.h:76
std::vector< int > configMaxValues_
Config file stored maximum axis values.
Definition: JoyStick.h:121
std::vector< int > configZeroValues_
Config file stored axis values when the knob is in the middle.
Definition: JoyStick.h:119
Specialised for joystick events.
Definition: OISJoyStick.h:115
This is the base class of all objects which may contain config values.
Definition: Configurable.h:47
static std::vector< std::string > deviceNames_s
Contains a list of all names to avoid duplicates.
Definition: JoyStick.h:127
Declarations of all key/button/axis code enumeration and string literals and an input device enumerat...
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
#define _CoreExport
Definition: CorePrereqs.h:61
Declaration of Configurable, the base class of all objects which may contain config values...
Joystick base class.
Definition: OISJoyStick.h:159
virtual bool buttonReleased(const OIS::JoyStickEvent &arg, int button) override
OIS event handler.
Definition: JoyStick.h:95
Implementation of InputDevice and InputDeviceTemplated
Type
Each Input class has a General Type variable, a form of RTTI.
Definition: OISPrereqs.h:138
JoyStickButtonCode::ByEnum ButtonType
Definition: JoyStick.h:47
Definition: OISPrereqs.h:143
Base Manager class.
Definition: OISInputManager.h:38
std::string deviceName_
Name generated by the number of knobs and the device name.
Definition: JoyStick.h:110
std::vector< int > configMinValues_
Config file stored minimum axis values.
Definition: JoyStick.h:120
virtual bool buttonPressed(const OIS::JoyStickEvent &arg, int button) override
OIS event handler.
Definition: JoyStick.h:88