diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-01-17 20:45:26 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-01-17 22:19:41 +0300 |
commit | b86c930c9c18c95cf3e838ce56bf3b06cb5ca782 (patch) | |
tree | 2f64ba00fd43b21ae0c4975b99483b0c0f0ce2fa /src/gui/setup_joystick.cpp | |
parent | bc9712cfb34a891a64bd28b76df0f9f4e5d01513 (diff) | |
download | manaverse-b86c930c9c18c95cf3e838ce56bf3b06cb5ca782.tar.gz manaverse-b86c930c9c18c95cf3e838ce56bf3b06cb5ca782.tar.bz2 manaverse-b86c930c9c18c95cf3e838ce56bf3b06cb5ca782.tar.xz manaverse-b86c930c9c18c95cf3e838ce56bf3b06cb5ca782.zip |
Add detect joystick button in settings page.
This need to detect joystick changes.
Diffstat (limited to 'src/gui/setup_joystick.cpp')
-rw-r--r-- | src/gui/setup_joystick.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp index 34b0061a9..8956384c1 100644 --- a/src/gui/setup_joystick.cpp +++ b/src/gui/setup_joystick.cpp @@ -45,6 +45,7 @@ Setup_Joystick::Setup_Joystick(const Widget2 *const widget) : mCalibrateLabel(new Label(this, _("Press the button to start calibration"))), mCalibrateButton(new Button(this, _("Calibrate"), "calibrate", this)), + mDetectButton(new Button(this, _("Detect joysticks"), "detect", this)), mJoystickEnabled(new CheckBox(this, _("Enable joystick"))), mNamesModel(new NamesModel), mNamesDropDown(new DropDown(this, mNamesModel)), @@ -83,8 +84,9 @@ Setup_Joystick::Setup_Joystick(const Widget2 *const widget) : place(0, 0, mJoystickEnabled); place(0, 1, mNamesDropDown); place(0, 2, mUseInactiveCheckBox); - place(0, 3, mCalibrateLabel); - place(0, 4, mCalibrateButton); + place(0, 3, mDetectButton); + place(0, 4, mCalibrateLabel); + place(0, 5, mCalibrateButton); setDimension(gcn::Rectangle(0, 0, 365, 75)); } @@ -97,15 +99,25 @@ Setup_Joystick::~Setup_Joystick() void Setup_Joystick::action(const gcn::ActionEvent &event) { - if (event.getSource() == mJoystickEnabled) + const gcn::Widget *const source = event.getSource(); + if (source == mJoystickEnabled) { setTempEnabled(mJoystickEnabled->isSelected()); } - else if (event.getSource() == mNamesDropDown) + else if (source == mNamesDropDown) { if (joystick) joystick->setNumber(mNamesDropDown->getSelected()); } + else if (source == mDetectButton) + { + if (joystick) + { + joystick->reload(); + Joystick::getNames(mNamesModel->getNames()); + mNamesDropDown->setSelected(joystick->getNumber()); + } + } else { if (!joystick) |