2013-10-27 17:58:47 +00:00
|
|
|
#include "TiltAnalogSettingsScreen.h"
|
|
|
|
#include "Core/Config.h"
|
|
|
|
#include "Core/System.h"
|
|
|
|
#include "i18n/i18n.h"
|
|
|
|
|
2013-10-28 11:28:46 +00:00
|
|
|
void TiltAnalogSettingsScreen::CreateViews() {
|
2013-10-27 17:58:47 +00:00
|
|
|
using namespace UI;
|
|
|
|
|
|
|
|
I18NCategory *c = GetI18NCategory("Controls");
|
|
|
|
|
2013-10-28 15:04:53 +00:00
|
|
|
root_ = new ScrollView(ORIENT_VERTICAL);
|
2013-10-27 17:58:47 +00:00
|
|
|
|
|
|
|
LinearLayout *settings = new LinearLayout(ORIENT_VERTICAL);
|
|
|
|
|
2013-10-28 15:04:53 +00:00
|
|
|
settings->SetSpacing(0);
|
2013-10-27 17:58:47 +00:00
|
|
|
settings->Add(new ItemHeader(c->T("Invert Axes")));
|
|
|
|
settings->Add(new CheckBox(&g_Config.bInvertTiltX, c->T("Invert Tilt along X axis")));
|
|
|
|
settings->Add(new CheckBox(&g_Config.bInvertTiltY, c->T("Invert Tilt along Y axis")));
|
|
|
|
|
|
|
|
settings->Add(new ItemHeader(c->T("Sensitivity")));
|
|
|
|
//TODO: allow values greater than 100? I'm not sure if that's needed.
|
|
|
|
settings->Add(new PopupSliderChoice(&g_Config.iTiltSensitivityX, 0, 100, c->T("Tilt Sensitivity along X axis"), screenManager()));
|
|
|
|
settings->Add(new PopupSliderChoice(&g_Config.iTiltSensitivityY, 0, 100, c->T("Tilt Sensitivity along Y axis"), screenManager()));
|
2013-10-28 11:13:42 +00:00
|
|
|
settings->Add(new PopupSliderChoiceFloat(&g_Config.fDeadzoneRadius, 0.0, 1.0, c->T("Deadzone Radius"), screenManager()));
|
2013-10-27 17:58:47 +00:00
|
|
|
|
|
|
|
settings->Add(new ItemHeader(c->T("Calibration")));
|
|
|
|
InfoItem *calibrationInfo = new InfoItem("To calibrate, keep device on a flat surface and press calibrate.", "");
|
|
|
|
settings->Add(calibrationInfo);
|
|
|
|
|
|
|
|
Choice *calibrate = new Choice(c->T("Calibrate D-Pad"));
|
|
|
|
calibrate->OnClick.Handle(this, &TiltAnalogSettingsScreen::OnCalibrate);
|
|
|
|
settings->Add(calibrate);
|
|
|
|
|
|
|
|
root_->Add(settings);
|
|
|
|
};
|
|
|
|
|
2013-10-28 11:28:46 +00:00
|
|
|
void TiltAnalogSettingsScreen::update(InputState &input) {
|
2013-10-27 17:58:47 +00:00
|
|
|
UIScreen::update(input);
|
|
|
|
//I'm not sure why y is x and x is y. i's probably because of the orientation
|
|
|
|
//of the screen (the x and y are in portrait coordinates). once portrait and
|
|
|
|
//reverse-landscape is enabled, this will probably have to change.
|
|
|
|
//If needed, we can add a "swap x and y" option.
|
|
|
|
currentTiltX_ = input.acc.y;
|
|
|
|
currentTiltY_ = input.acc.x;
|
|
|
|
};
|
|
|
|
|
2013-10-28 11:28:46 +00:00
|
|
|
UI::EventReturn TiltAnalogSettingsScreen::OnCalibrate(UI::EventParams &e) {
|
2013-10-27 17:58:47 +00:00
|
|
|
g_Config.fTiltBaseX = currentTiltX_;
|
|
|
|
g_Config.fTiltBaseY = currentTiltY_;
|
|
|
|
|
|
|
|
return UI::EVENT_DONE;
|
|
|
|
};
|
|
|
|
|