Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 28, 2008, 12:01:16 AM (16 years ago)
Author:
rgrieder
Message:

Added 'calibrate' command for the joystick
Simply type 'calibrate', move your axes around, center them press enter again.
Values are stored in keybindings.ini

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/core/InputManager.h

    r1428 r1444  
    7676    std::vector<std::vector<JoyStickHandler*> > activeJoyStickHandlers_;
    7777    std::vector<std::pair<InputTickable*, HandlerState> > activeHandlers_;
     78  };
     79
     80  struct JoyStickCalibration
     81  {
     82    int zeroStates[24];
     83    float positiveCoeff[24];
     84    float negativeCoeff[24];
    7885  };
    7986
     
    98105      IS_DETECT,    //!< All the input additionally goes to the KeyDetector
    99106      IS_NODETECT,  //!< remove KeyDetector
     107      IS_NOCALIBRATE,
     108      IS_CALIBRATE,
    100109      IS_CUSTOM     //!< Any possible configuration.
    101110    };
     111
     112  public: // member functions
     113    void setConfigValues();
    102114
    103115  public: // static functions
     
    129141    static void keyBind(const std::string& command);
    130142
     143    static void calibrate();
     144
    131145    static bool addKeyHandler                 (KeyHandler* handler, const std::string& name);
    132146    static bool removeKeyHandler              (const std::string& name);
     
    171185    void _saveState();
    172186    void _restoreState();
     187
     188    void _completeCalibration();
     189
     190    void _fireAxis(unsigned int iJoyStick, int axis, int value);
     191    unsigned int _getJoystick(const OIS::JoyStickEvent& arg);
    173192
    174193    void tick(float dt);
     
    200219    KeyDetector*                                keyDetector_;     //!< KeyDetector instance
    201220    InputBuffer*                                buffer_;          //!< InputBuffer instance
     221    CalibratorCallback*                         calibratorCallback_;
    202222
    203223    InputState state_;
    204224    InputState stateRequest_;
     225    InputState savedState_;
    205226    unsigned int keyboardModifiers_;
    206     InputState savedState_;
    207227    StoredState savedHandlers_;
     228
     229    // joystick calibration
     230    //std::vector<int> marginalsMaxConfig_;
     231    //std::vector<int> marginalsMinConfig_;
     232    int marginalsMax_[24];
     233    int marginalsMin_[24];
     234    bool bCalibrated_;
    208235
    209236    //! Keeps track of the joy stick POV states
     
    211238    //! Keeps track of the possibly two slider axes
    212239    std::vector<SliderStates>                   sliderStates_;
     240    std::vector<JoyStickCalibration>            joySticksCalibration_;
    213241
    214242    std::map<std::string, KeyHandler*>          keyHandlers_;
Note: See TracChangeset for help on using the changeset viewer.