2013-10-28 15:45:25 +00:00
|
|
|
// Copyright (c) 2013- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
2013-10-27 17:58:47 +00:00
|
|
|
#include "TiltAnalogSettingsScreen.h"
|
|
|
|
#include "Core/Config.h"
|
|
|
|
#include "Core/System.h"
|
2020-10-01 11:05:04 +00:00
|
|
|
#include "Common/Data/Text/I18n.h"
|
2013-10-27 17:58:47 +00:00
|
|
|
|
2013-10-28 11:28:46 +00:00
|
|
|
void TiltAnalogSettingsScreen::CreateViews() {
|
2013-10-27 17:58:47 +00:00
|
|
|
using namespace UI;
|
|
|
|
|
2020-01-26 18:43:18 +00:00
|
|
|
auto co = GetI18NCategory("Controls");
|
|
|
|
auto di = GetI18NCategory("Dialog");
|
2013-10-27 17:58:47 +00:00
|
|
|
|
2013-10-28 15:04:53 +00:00
|
|
|
root_ = new ScrollView(ORIENT_VERTICAL);
|
2016-01-23 06:52:13 +00:00
|
|
|
root_->SetTag("TiltAnalogSettings");
|
2013-10-27 17:58:47 +00:00
|
|
|
|
2021-02-22 02:41:08 +00:00
|
|
|
LinearLayout *settings = new LinearLayoutList(ORIENT_VERTICAL);
|
2013-10-27 17:58:47 +00:00
|
|
|
|
2013-10-28 15:04:53 +00:00
|
|
|
settings->SetSpacing(0);
|
2015-07-01 20:31:04 +00:00
|
|
|
settings->Add(new ItemHeader(co->T("Invert Axes")));
|
|
|
|
settings->Add(new CheckBox(&g_Config.bInvertTiltX, co->T("Invert Tilt along X axis")));
|
|
|
|
settings->Add(new CheckBox(&g_Config.bInvertTiltY, co->T("Invert Tilt along Y axis")));
|
2020-03-04 07:44:10 +00:00
|
|
|
static const char* tiltMode[] = { "Screen aligned to ground", "Screen at right angle to ground", "Auto-switch" };
|
2019-12-31 10:08:48 +00:00
|
|
|
settings->Add(new PopupMultiChoice(&g_Config.iTiltOrientation, co->T("Base tilt position"), tiltMode, 0, ARRAY_SIZE(tiltMode), co->GetName(), screenManager()));
|
2013-10-27 17:58:47 +00:00
|
|
|
|
2015-07-01 20:31:04 +00:00
|
|
|
settings->Add(new ItemHeader(co->T("Sensitivity")));
|
2013-10-27 17:58:47 +00:00
|
|
|
//TODO: allow values greater than 100? I'm not sure if that's needed.
|
2015-11-06 07:25:40 +00:00
|
|
|
settings->Add(new PopupSliderChoice(&g_Config.iTiltSensitivityX, 0, 100, co->T("Tilt Sensitivity along X axis"), screenManager(),"%"));
|
|
|
|
settings->Add(new PopupSliderChoice(&g_Config.iTiltSensitivityY, 0, 100, co->T("Tilt Sensitivity along Y axis"), screenManager(),"%"));
|
|
|
|
settings->Add(new PopupSliderChoiceFloat(&g_Config.fDeadzoneRadius, 0.0, 1.0, co->T("Deadzone Radius"), 0.01f, screenManager(),"/ 1.0"));
|
2020-03-23 15:32:42 +00:00
|
|
|
settings->Add(new PopupSliderChoiceFloat(&g_Config.fTiltDeadzoneSkip, 0.0, 1.0, co->T("Tilt Base Radius"), 0.01f, screenManager(),"/ 1.0"));
|
2013-10-27 17:58:47 +00:00
|
|
|
|
2015-07-01 20:31:04 +00:00
|
|
|
settings->Add(new ItemHeader(co->T("Calibration")));
|
|
|
|
InfoItem *calibrationInfo = new InfoItem(co->T("To Calibrate", "To calibrate, keep device on a flat surface and press calibrate."), "");
|
2013-10-27 17:58:47 +00:00
|
|
|
settings->Add(calibrationInfo);
|
|
|
|
|
2015-07-01 20:31:04 +00:00
|
|
|
Choice *calibrate = new Choice(co->T("Calibrate D-Pad"));
|
2013-10-27 17:58:47 +00:00
|
|
|
calibrate->OnClick.Handle(this, &TiltAnalogSettingsScreen::OnCalibrate);
|
|
|
|
settings->Add(calibrate);
|
|
|
|
|
|
|
|
root_->Add(settings);
|
2013-10-28 17:28:08 +00:00
|
|
|
settings->Add(new ItemHeader(""));
|
2015-07-01 21:26:55 +00:00
|
|
|
settings->Add(new Choice(di->T("Back")))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
|
2013-10-28 15:45:25 +00:00
|
|
|
}
|
2013-10-27 17:58:47 +00:00
|
|
|
|
2017-03-15 03:52:30 +00:00
|
|
|
bool TiltAnalogSettingsScreen::axis(const AxisInput &axis) {
|
|
|
|
if (axis.deviceId == DEVICE_ID_ACCELEROMETER) {
|
|
|
|
// Historically, we've had X and Y swapped, likely due to portrait vs landscape.
|
|
|
|
// TODO: We may want to configure this based on screen orientation.
|
|
|
|
if (axis.axisId == JOYSTICK_AXIS_ACCELEROMETER_X) {
|
|
|
|
currentTiltY_ = axis.value;
|
|
|
|
}
|
|
|
|
if (axis.axisId == JOYSTICK_AXIS_ACCELEROMETER_Y) {
|
|
|
|
currentTiltX_ = axis.value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2013-10-28 15:45:25 +00:00
|
|
|
}
|
2013-10-27 17:58:47 +00:00
|
|
|
|
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;
|
2013-10-28 15:45:25 +00:00
|
|
|
}
|
2013-10-27 17:58:47 +00:00
|
|
|
|