mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-01-31 02:23:51 +00:00
Tilt: Add visualizer to customize tilt dialog. Improve defaults.
This commit is contained in:
parent
3b36a1bb66
commit
9e3cc66809
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
|
@ -6,7 +6,8 @@
|
||||
|
||||
enum class StickHistoryViewType {
|
||||
INPUT,
|
||||
OUTPUT
|
||||
OUTPUT,
|
||||
OTHER,
|
||||
};
|
||||
|
||||
class JoystickHistoryView : public UI::InertView {
|
||||
|
@ -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<UIScreen>(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));
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user