diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-02-06 10:33:41 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-02-06 10:33:41 +0000 |
commit | a626ab48948941c3ec86d3ee6a3ab3bc2a98538c (patch) | |
tree | 9aab3c81fa8aad5433da55face7a94d2899876a0 /src/gui | |
parent | b0bc59179bd64ad6b1f006f8e109cbeb16ad7094 (diff) | |
download | mana-a626ab48948941c3ec86d3ee6a3ab3bc2a98538c.tar.gz mana-a626ab48948941c3ec86d3ee6a3ab3bc2a98538c.tar.bz2 mana-a626ab48948941c3ec86d3ee6a3ab3bc2a98538c.tar.xz mana-a626ab48948941c3ec86d3ee6a3ab3bc2a98538c.zip |
Added a Joystick class.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/setup.cpp | 53 | ||||
-rw-r--r-- | src/gui/setup.h | 4 |
2 files changed, 8 insertions, 49 deletions
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index c47d12da..c73d1de0 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -38,15 +38,14 @@ #include "../configuration.h" #include "../graphics.h" +#include "../joystick.h" #include "../log.h" #include "../main.h" #include "../sound.h" extern Graphics *graphics; -extern SDL_Joystick *joypad; - -extern SDL_Joystick *joypad; +extern Joystick *joystick; extern Window *statusWindow; extern Window *minimap; @@ -100,8 +99,7 @@ std::string ModeListModel::getElementAt(int i) Setup::Setup(): - Window("Setup"), mCalibrating(false), leftTolerance(0), rightTolerance(0), - upTolerance(0), downTolerance(0) + Window("Setup") { modeListModel = new ModeListModel(); modeList = new ListBox(modeListModel); @@ -268,27 +266,20 @@ void Setup::action(const std::string &eventId) config.setValue("customcursor", customCursorCheckBox->isMarked() ? 1 : 0); } - else if (eventId == "calibrate" && joypad != NULL) + else if (eventId == "calibrate" && joystick != NULL) { - if (mCalibrating) + if (joystick->isCalibrating()) { calibrateButton->setCaption("Calibrate"); calibrateLabel->setCaption("Press the button to start calibration"); - config.setValue("leftTolerance", leftTolerance); - config.setValue("rightTolerance", rightTolerance); - config.setValue("upTolerance", upTolerance); - config.setValue("downTolerance", downTolerance); + joystick->finishCalibration(); } else { calibrateButton->setCaption("Stop"); - calibrateLabel->setCaption("Rotate the stick"); - leftTolerance = 0; - rightTolerance = 0; - upTolerance = 0; - downTolerance = 0; + calibrateLabel->setCaption("Rotate the stick"); + joystick->startCalibration(); } - mCalibrating = !mCalibrating; } else if (eventId == "apply") { @@ -406,31 +397,3 @@ void Setup::action(const std::string &eventId) skillDialog->resetToDefaultSize(); } } - -void Setup::logic() -{ - Window::logic(); - if (mCalibrating) - { - SDL_JoystickUpdate(); - int position = SDL_JoystickGetAxis(joypad, 0); - if (position > rightTolerance) - { - rightTolerance = position; - } - else if (position < leftTolerance) - { - leftTolerance = position; - } - - position = SDL_JoystickGetAxis(joypad, 1); - if (position > downTolerance) - { - downTolerance = position; - } - else if (position < upTolerance) - { - upTolerance = position; - } - } -} diff --git a/src/gui/setup.h b/src/gui/setup.h index 0b62fee6..91f181d5 100644 --- a/src/gui/setup.h +++ b/src/gui/setup.h @@ -88,8 +88,6 @@ class Setup : public Window, public gcn::ActionListener */ void action(const std::string& eventId); - - void logic(); private: ModeListModel *modeListModel; @@ -117,8 +115,6 @@ class Setup : public Window, public gcn::ActionListener bool openGLEnabled; bool customCursorEnabled; bool soundEnabled; - bool mCalibrating; - int leftTolerance, rightTolerance, upTolerance, downTolerance; }; #endif |