Changeset 3274 for code/branches/core4/src/core/input/JoyStick.h
- Timestamp:
- Jul 12, 2009, 4:12:04 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core4/src/core/input/JoyStick.h
r3270 r3274 27 27 */ 28 28 29 /** 30 @file 31 @brief 32 */ 29 #ifndef _Core_JoyStick_H__ 30 #define _Core_JoyStick_H__ 33 31 34 #ifndef _JoyStick_H__ 35 #define _JoyStick_H__ 36 37 #include "core/CorePrereqs.h" 32 #include "InputPrereqs.h" 38 33 39 34 #include <string> 40 35 #include <vector> 41 #include "Input Interfaces.h"36 #include "InputDevice.h" 42 37 43 38 namespace orxonox 44 39 { 45 class _CoreExport JoyStick : public OrxonoxClass, public OIS::JoyStickListener 40 /** 41 @brief 42 Wraps around an OIS::JoyStick and forwards the input events to 43 a list of input states. 44 45 The class also supports joy stick calibration and stores the values 46 in an ini-file. 47 */ 48 class _CoreExport JoyStick 49 : public OrxonoxClass 50 , public InputDeviceTemplated<JoyStickTraits> 51 , public OIS::JoyStickListener 46 52 { 47 private: 48 struct JoyStickCalibration 49 { 50 }; 53 friend class InputDeviceTemplated<JoyStickTraits>; 54 //! Super class alias 55 typedef InputDeviceTemplated<JoyStickTraits> super; 51 56 52 57 public: 53 JoyStick(const std::vector<InputState*>& states, unsigned int id);54 ~JoyStick();55 58 //! Assigns a generated ID string and loads the calibration (if present) 59 JoyStick(unsigned int id); 60 ~JoyStick() { } 56 61 void setConfigValues(); 57 62 58 OIS::JoyStick* getOISJoyStick() { return this->oisJoyStick_; }63 //! Returns the generated (from the number of knobs and the device name) ID string 59 64 const std::string& getIDString() const { return this->idString_; } 60 65 61 void startCalibration(); 62 void stopCalibration(); 66 private: 67 void calibrationStarted(); 68 void calibrationStopped(); 69 void evaluateCalibration(); 63 70 64 void capture(); 65 void clearBuffer(); 66 67 private: 71 void clearBuffersImpl(); 68 72 void calibrationFileCallback(); 69 void evaluateCalibration();70 73 void fireAxis(int axis, int value); 71 74 72 bool buttonPressed (const OIS::JoyStickEvent &arg, int button); 73 bool buttonReleased(const OIS::JoyStickEvent &arg, int button); 75 //! OIS event handler 76 bool buttonPressed (const OIS::JoyStickEvent &arg, int button) 77 { 78 super::buttonPressed(static_cast<JoyStickButtonCode::ByEnum>(button)); 79 return true; 80 } 81 82 //! OIS event handler 83 bool buttonReleased(const OIS::JoyStickEvent &arg, int button) 84 { 85 super::buttonReleased(static_cast<JoyStickButtonCode::ByEnum>(button)); 86 return true; 87 } 88 74 89 bool axisMoved (const OIS::JoyStickEvent &arg, int axis); 75 90 bool sliderMoved (const OIS::JoyStickEvent &arg, int id); 76 91 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..)92 //!< OIS event handler (don't remove that because of OIS version issues!) 78 93 bool vector3Moved (const OIS::JoyStickEvent &arg, int id) { return true; } 79 94 80 static const unsigned int sliderAxes_s = 8; 81 82 OIS::JoyStick* oisJoyStick_; 83 const unsigned int id_; 84 std::string idString_; 95 std::string idString_; //!< ID string generated by the number of knobs and the device name 96 int povStates_[4]; //!< Internal states for the POVs 97 int sliderStates_[4][2]; //!< Internal states for the Sliders (each slider has X and Y!) 85 98 86 99 // calibration 87 bool bCalibrating_; 88 int zeroValues_[24]; 89 float positiveCoeffs_[24]; 90 float negativeCoeffs_[24]; 100 int zeroValues_[24]; //!< Axes values when the knob is in the middle 101 float positiveCoeffs_[24]; //!< Maps the negative part of an axis to a 0.0 to 1.0 floating range 102 float negativeCoeffs_[24]; //!< Maps the positive part of an axis to a 0.0 to 1.0 floating range 91 103 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_; 104 std::vector<int> configZeroValues_; //!< Config file stored axis values when the knob is in the middle 105 std::vector<int> configMinValues_; //!< Config file stored minimum axis values 106 std::vector<int> configMaxValues_; //!< Config file stored maximum axis values 102 107 103 108 // ConfigValues 104 std::string calibrationFilename_; //!< Joy stick calibration ini filename 109 std::string calibrationFilename_; //!< Joy stick calibration ini filename 110 111 //!< Maximum number of slider axes 112 static const unsigned int sliderAxes_s = 8; 105 113 }; 106 114 } 107 115 108 #endif /* _ JoyStick_H__ */116 #endif /* _Core_JoyStick_H__ */
Note: See TracChangeset
for help on using the changeset viewer.