diff --git a/Common/UI/UIScreen.cpp b/Common/UI/UIScreen.cpp index 643ab6a3c4..768fc88b16 100644 --- a/Common/UI/UIScreen.cpp +++ b/Common/UI/UIScreen.cpp @@ -231,8 +231,10 @@ void PopupScreen::touch(const TouchInput &touch) { UIDialogScreen::touch(touch); } - if (!box_->GetBounds().Contains(touch.x, touch.y)) { - TriggerFinish(DR_BACK); + // Extra bounds to avoid closing the dialog while trying to aim for something + // near the edge. + if (!box_->GetBounds().Expand(100.0f, 60.0f).Contains(touch.x, touch.y)) { + TriggerFinish(DR_CANCEL); } UIDialogScreen::touch(touch); diff --git a/Core/Config.cpp b/Core/Config.cpp index 618a2be5bc..13e1a04e7f 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -975,9 +975,9 @@ static const ConfigSetting controlSettings[] = { ConfigSetting("TiltOrientation", &g_Config.iTiltOrientation, 0, true, true), ConfigSetting("InvertTiltX", &g_Config.bInvertTiltX, false, true, true), ConfigSetting("InvertTiltY", &g_Config.bInvertTiltY, true, true, true), - ConfigSetting("TiltSensitivityX", &g_Config.iTiltSensitivityX, 100, true, true), - ConfigSetting("TiltSensitivityY", &g_Config.iTiltSensitivityY, 100, true, true), - ConfigSetting("DeadzoneRadius", &g_Config.fDeadzoneRadius, 0.2f, true, true), + ConfigSetting("TiltSensitivityX", &g_Config.iTiltSensitivityX, 50, true, true), + ConfigSetting("TiltSensitivityY", &g_Config.iTiltSensitivityY, 50, true, true), + ConfigSetting("DeadzoneRadius", &g_Config.fDeadzoneRadius, 0.05f, true, true), ConfigSetting("TiltDeadzoneSkip", &g_Config.fTiltDeadzoneSkip, 0.0f, true, true), ConfigSetting("TiltInputType", &g_Config.iTiltInputType, 0, true, true), #endif diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 4c9b71c09f..87211c0f83 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1717,7 +1717,7 @@ UI::EventReturn GameSettingsScreen::OnTiltTypeChange(UI::EventParams &e) { }; UI::EventReturn GameSettingsScreen::OnTiltCustomize(UI::EventParams &e) { - screenManager()->push(new TiltAnalogSettingsScreen()); + screenManager()->push(new TiltAnalogSettingsScreen(gamePath_)); return UI::EVENT_DONE; }; diff --git a/UI/JoystickHistoryView.cpp b/UI/JoystickHistoryView.cpp index 73d45eb5bf..fc49622bb5 100644 --- a/UI/JoystickHistoryView.cpp +++ b/UI/JoystickHistoryView.cpp @@ -81,8 +81,8 @@ void JoystickHistoryView::Draw(UIContext &dc) { } // Emphasize the newest (higher) ones. alpha = powf(alpha, 3.7f); - // Highlight the output. - if (alpha >= 1.0f && type_ == StickHistoryViewType::OUTPUT) { + // Highlight the output (and OTHER) + if (alpha >= 1.0f && type_ != StickHistoryViewType::INPUT) { dc.Draw()->DrawImage(ImageID("I_CIRCLE"), x, y, 1.0f, colorAlpha(0xFFFFFF, 1.0), ALIGN_CENTER); } else { dc.Draw()->DrawImage(ImageID("I_CIRCLE"), x, y, 0.8f, colorAlpha(0xC0C0C0, alpha * 0.5f), ALIGN_CENTER); diff --git a/UI/JoystickHistoryView.h b/UI/JoystickHistoryView.h index a68b0d2b60..bbdb8f0fdd 100644 --- a/UI/JoystickHistoryView.h +++ b/UI/JoystickHistoryView.h @@ -6,7 +6,8 @@ enum class StickHistoryViewType { INPUT, - OUTPUT + OUTPUT, + OTHER, }; class JoystickHistoryView : public UI::InertView { diff --git a/UI/TiltAnalogSettingsScreen.cpp b/UI/TiltAnalogSettingsScreen.cpp index 587c3cb082..d110d694dc 100644 --- a/UI/TiltAnalogSettingsScreen.cpp +++ b/UI/TiltAnalogSettingsScreen.cpp @@ -15,20 +15,33 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#include "TiltAnalogSettingsScreen.h" #include "Core/Config.h" #include "Core/System.h" +#include "Core/TiltEventProcessor.h" + +#include "Common/Math/math_util.h" + #include "Common/Data/Text/I18n.h" +#include "UI/JoystickHistoryView.h" +#include "UI/TiltAnalogSettingsScreen.h" + void TiltAnalogSettingsScreen::CreateViews() { using namespace UI; auto co = GetI18NCategory("Controls"); auto di = GetI18NCategory("Dialog"); - root_ = new ScrollView(ORIENT_VERTICAL); + root_ = new LinearLayout(ORIENT_HORIZONTAL); root_->SetTag("TiltAnalogSettings"); + ScrollView *menuRoot = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(650, FILL_PARENT)); + root_->Add(menuRoot); + + // AnchorLayout *rightSide = new AnchorLayout(new LinearLayoutParams(1.0)); + tilt_ = new JoystickHistoryView(StickHistoryViewType::OTHER, "", new LinearLayoutParams(1.0f)); + root_->Add(tilt_); + LinearLayout *settings = new LinearLayoutList(ORIENT_VERTICAL); settings->SetSpacing(0); @@ -53,12 +66,15 @@ void TiltAnalogSettingsScreen::CreateViews() { settings->Add(new PopupSliderChoiceFloat(&g_Config.fDeadzoneRadius, 0.0, 1.0, co->T("Deadzone radius"), 0.01f, screenManager(),"/ 1.0")); settings->Add(new PopupSliderChoiceFloat(&g_Config.fTiltDeadzoneSkip, 0.0, 1.0, co->T("Tilt Base Radius"), 0.01f, screenManager(),"/ 1.0")); - root_->Add(settings); + menuRoot->Add(settings); + settings->Add(new BorderView(BORDER_BOTTOM, BorderStyle::HEADER_FG, 2.0f, new LayoutParams(FILL_PARENT, 40.0f))); settings->Add(new Choice(di->T("Back")))->OnClick.Handle(this, &UIScreen::OnBack); } void TiltAnalogSettingsScreen::axis(const AxisInput &axis) { + // TODO: This code should probably be moved to TiltEventProcessor. + 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. @@ -78,3 +94,10 @@ UI::EventReturn TiltAnalogSettingsScreen::OnCalibrate(UI::EventParams &e) { return UI::EVENT_DONE; } +void TiltAnalogSettingsScreen::update() { + UIDialogScreenWithGameBackground::update(); + + tilt_->SetXY( + Clamp(TiltEventProcessor::rawTiltAnalogX, -1.0f, 1.0f), + Clamp(TiltEventProcessor::rawTiltAnalogY, -1.0f, 1.0f)); +} diff --git a/UI/TiltAnalogSettingsScreen.h b/UI/TiltAnalogSettingsScreen.h index dcc4e9b583..95bb335098 100644 --- a/UI/TiltAnalogSettingsScreen.h +++ b/UI/TiltAnalogSettingsScreen.h @@ -20,15 +20,21 @@ #include "Common/UI/View.h" #include "MiscScreens.h" -class TiltAnalogSettingsScreen : public UIDialogScreenWithBackground { +class JoystickHistoryView; + +class TiltAnalogSettingsScreen : public UIDialogScreenWithGameBackground { public: + TiltAnalogSettingsScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {} + void CreateViews() override; void axis(const AxisInput &axis) override; - + void update() override; const char *tag() const override { return "TiltAnalogSettings"; } private: UI::EventReturn OnCalibrate(UI::EventParams &e); float currentTiltX_ = 0.0f; float currentTiltY_ = 0.0f; + + JoystickHistoryView *tilt_ = nullptr; };