summaryrefslogtreecommitdiff
path: root/src/gui/setup.cpp
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2006-02-06 10:33:41 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2006-02-06 10:33:41 +0000
commita626ab48948941c3ec86d3ee6a3ab3bc2a98538c (patch)
tree9aab3c81fa8aad5433da55face7a94d2899876a0 /src/gui/setup.cpp
parentb0bc59179bd64ad6b1f006f8e109cbeb16ad7094 (diff)
downloadmana-client-a626ab48948941c3ec86d3ee6a3ab3bc2a98538c.tar.gz
mana-client-a626ab48948941c3ec86d3ee6a3ab3bc2a98538c.tar.bz2
mana-client-a626ab48948941c3ec86d3ee6a3ab3bc2a98538c.tar.xz
mana-client-a626ab48948941c3ec86d3ee6a3ab3bc2a98538c.zip
Added a Joystick class.
Diffstat (limited to 'src/gui/setup.cpp')
-rw-r--r--src/gui/setup.cpp53
1 files changed, 8 insertions, 45 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;
- }
- }
-}