Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core4/src/core/input/JoyStick.h @ 3271

Last change on this file since 3271 was 3270, checked in by rgrieder, 15 years ago

Extracted joy stick related code from InputManager to a new JoyStick class in order to make the InputManger less of a monster class and to apply a little bit more OO.

  • Property svn:eol-style set to native
File size: 3.1 KB
Line 
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/**
30@file
31@brief
32*/
33
34#ifndef _JoyStick_H__
35#define _JoyStick_H__
36
37#include "core/CorePrereqs.h"
38
39#include <string>
40#include <vector>
41#include "InputInterfaces.h"
42
43namespace orxonox
44{
45    class _CoreExport JoyStick : public OrxonoxClass, public OIS::JoyStickListener
46    {
47    private:
48        struct JoyStickCalibration
49        {
50        };
51
52    public:
53        JoyStick(const std::vector<InputState*>& states, unsigned int id);
54        ~JoyStick();
55
56        void setConfigValues();
57
58        OIS::JoyStick* getOISJoyStick() { return this->oisJoyStick_; }
59        const std::string& getIDString() const { return this->idString_; }
60
61        void startCalibration();
62        void stopCalibration();
63
64        void capture();
65        void clearBuffer();
66
67    private:
68        void calibrationFileCallback();
69        void evaluateCalibration();
70        void fireAxis(int axis, int value);
71
72        bool buttonPressed (const OIS::JoyStickEvent &arg, int button);
73        bool buttonReleased(const OIS::JoyStickEvent &arg, int button);
74        bool axisMoved     (const OIS::JoyStickEvent &arg, int axis);
75        bool sliderMoved   (const OIS::JoyStickEvent &arg, int id);
76        bool povMoved      (const OIS::JoyStickEvent &arg, int id);
77        // don't remove that! Or else add OIS as dependency library to orxonox (it actually is..)
78        bool vector3Moved  (const OIS::JoyStickEvent &arg, int id) { return true; }
79
80        static const unsigned int sliderAxes_s = 8;
81
82        OIS::JoyStick* oisJoyStick_;
83        const unsigned int id_;
84        std::string idString_;
85
86        // calibration
87        bool bCalibrating_;
88        int zeroValues_[24];
89        float positiveCoeffs_[24];
90        float negativeCoeffs_[24];
91
92        std::vector<int> configMinValues_;
93        std::vector<int> configMaxValues_;
94        std::vector<int> configZeroValues_;
95
96        int povStates_[4];
97        int sliderStates_[4][2];
98        std::vector<JoyStickButtonCode::ByEnum> pressedButtons_;
99
100        // InputState handling
101        const std::vector<InputState*>& inputStates_;
102
103        // ConfigValues
104        std::string calibrationFilename_;  //!< Joy stick calibration ini filename
105    };
106}
107
108#endif /* _JoyStick_H__ */
Note: See TracBrowser for help on using the repository browser.