Index: code/branches/core4/src/core/input/JoyStick.h
===================================================================
--- code/branches/core4/src/core/input/JoyStick.h	(revision 3270)
+++ code/branches/core4/src/core/input/JoyStick.h	(revision 3274)
@@ -27,82 +27,90 @@
  */
 
-/**
-@file
-@brief 
-*/
+#ifndef _Core_JoyStick_H__
+#define _Core_JoyStick_H__
 
-#ifndef _JoyStick_H__
-#define _JoyStick_H__
-
-#include "core/CorePrereqs.h"
+#include "InputPrereqs.h"
 
 #include <string>
 #include <vector>
-#include "InputInterfaces.h"
+#include "InputDevice.h"
 
 namespace orxonox
 {
-    class _CoreExport JoyStick : public OrxonoxClass, public OIS::JoyStickListener
+    /**
+    @brief
+        Wraps around an OIS::JoyStick and forwards the input events to
+        a list of input states.
+
+        The class also supports joy stick calibration and stores the values
+        in an ini-file.
+    */
+    class _CoreExport JoyStick
+        : public OrxonoxClass
+        , public InputDeviceTemplated<JoyStickTraits>
+        , public OIS::JoyStickListener
     {
-    private:
-        struct JoyStickCalibration
-        {
-        };
+        friend class InputDeviceTemplated<JoyStickTraits>;
+        //! Super class alias
+        typedef InputDeviceTemplated<JoyStickTraits> super;
 
     public:
-        JoyStick(const std::vector<InputState*>& states, unsigned int id);
-        ~JoyStick();
-
+        //! Assigns a generated ID string and loads the calibration (if present)
+        JoyStick(unsigned int id);
+        ~JoyStick() { }
         void setConfigValues();
 
-        OIS::JoyStick* getOISJoyStick() { return this->oisJoyStick_; }
+        //! Returns the generated (from the number of knobs and the device name) ID string
         const std::string& getIDString() const { return this->idString_; }
 
-        void startCalibration();
-        void stopCalibration();
+    private:
+        void calibrationStarted();
+        void calibrationStopped();
+        void evaluateCalibration();
 
-        void capture();
-        void clearBuffer();
-
-    private:
+        void clearBuffersImpl();
         void calibrationFileCallback();
-        void evaluateCalibration();
         void fireAxis(int axis, int value);
 
-        bool buttonPressed (const OIS::JoyStickEvent &arg, int button);
-        bool buttonReleased(const OIS::JoyStickEvent &arg, int button);
+        //! OIS event handler
+        bool buttonPressed (const OIS::JoyStickEvent &arg, int button)
+        {
+            super::buttonPressed(static_cast<JoyStickButtonCode::ByEnum>(button));
+            return true;
+        }
+
+        //! OIS event handler
+        bool buttonReleased(const OIS::JoyStickEvent &arg, int button)
+        {
+            super::buttonReleased(static_cast<JoyStickButtonCode::ByEnum>(button));
+            return true;
+        }
+
         bool axisMoved     (const OIS::JoyStickEvent &arg, int axis);
         bool sliderMoved   (const OIS::JoyStickEvent &arg, int id);
         bool povMoved      (const OIS::JoyStickEvent &arg, int id);
-        // don't remove that! Or else add OIS as dependency library to orxonox (it actually is..)
+        //!< OIS event handler (don't remove that because of OIS version issues!)
         bool vector3Moved  (const OIS::JoyStickEvent &arg, int id) { return true; }
 
-        static const unsigned int sliderAxes_s = 8;
-
-        OIS::JoyStick* oisJoyStick_;
-        const unsigned int id_;
-        std::string idString_;
+        std::string idString_;                //!< ID string generated by the number of knobs and the device name
+        int povStates_[4];                    //!< Internal states for the POVs
+        int sliderStates_[4][2];              //!< Internal states for the Sliders (each slider has X and Y!)
 
         // calibration
-        bool bCalibrating_;
-        int zeroValues_[24];
-        float positiveCoeffs_[24];
-        float negativeCoeffs_[24];
+        int zeroValues_[24];                  //!< Axes values when the knob is in the middle
+        float positiveCoeffs_[24];            //!< Maps the negative part of an axis to a 0.0 to 1.0 floating range
+        float negativeCoeffs_[24];            //!< Maps the positive part of an axis to a 0.0 to 1.0 floating range
 
-        std::vector<int> configMinValues_;
-        std::vector<int> configMaxValues_;
-        std::vector<int> configZeroValues_;
-
-        int povStates_[4];
-        int sliderStates_[4][2];
-        std::vector<JoyStickButtonCode::ByEnum> pressedButtons_;
-
-        // InputState handling
-        const std::vector<InputState*>& inputStates_;
+        std::vector<int> configZeroValues_;   //!< Config file stored axis values when the knob is in the middle
+        std::vector<int> configMinValues_;    //!< Config file stored minimum axis values
+        std::vector<int> configMaxValues_;    //!< Config file stored maximum axis values
 
         // ConfigValues
-        std::string calibrationFilename_;  //!< Joy stick calibration ini filename
+        std::string calibrationFilename_;     //!< Joy stick calibration ini filename
+
+        //!< Maximum number of slider axes
+        static const unsigned int sliderAxes_s = 8;
     };
 }
 
-#endif /* _JoyStick_H__ */
+#endif /* _Core_JoyStick_H__ */
