From a6c7663ea8c1cc374430df7e34f843f0bf72c4d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 2 Dec 2013 15:15:19 +0100 Subject: [PATCH] Allow resizing touch buttons individually. --- Core/Config.cpp | 32 +++-- Core/Config.h | 20 ++- UI/ControlMappingScreen.cpp | 7 +- UI/GameSettingsScreen.cpp | 10 -- UI/GameSettingsScreen.h | 14 --- UI/GamepadEmu.cpp | 152 +++++++++++------------ UI/GamepadEmu.h | 13 +- UI/MiscScreens.cpp | 2 +- UI/TouchControlLayoutScreen.cpp | 207 ++++++++++++++++++++------------ UI/TouchControlLayoutScreen.h | 8 ++ 10 files changed, 263 insertions(+), 202 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 9f20e11971..ce1469bd2b 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -257,28 +257,36 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) { #endif control->Get("TouchButtonOpacity", &iTouchButtonOpacity, 65); - control->Get("ButtonScale", &fButtonScale, 1.15); //set these to -1 if not initialized. initializing these //requires pixel coordinates which is not known right now. //will be initialized in GamepadEmu::CreatePadLayout - control->Get("ActionButtonSpacing", &iActionButtonSpacing, -1); + float defaultScale = 1.15f; + control->Get("ActionButtonSpacing2", &fActionButtonSpacing, 1.0f); control->Get("ActionButtonCenterX", &fActionButtonCenterX, -1.0); control->Get("ActionButtonCenterY", &fActionButtonCenterY, -1.0); - control->Get("DPadRadius", &iDpadRadius, -1); + control->Get("ActionButtonScale", &fActionButtonScale, defaultScale); control->Get("DPadX", &fDpadX, -1.0); control->Get("DPadY", &fDpadY, -1.0); + control->Get("DPadScale", &fDpadScale, defaultScale); + control->Get("DPadSpacing", &fDpadSpacing, 1.0f); control->Get("StartKeyX", &fStartKeyX, -1.0); control->Get("StartKeyY", &fStartKeyY, -1.0); + control->Get("StartKeyScale", &fStartKeyScale, defaultScale); control->Get("SelectKeyX", &fSelectKeyX, -1.0); control->Get("SelectKeyY", &fSelectKeyY, -1.0); + control->Get("SelectKeyScale", &fSelectKeyScale, defaultScale); control->Get("UnthrottleKeyX", &fUnthrottleKeyX, -1.0); control->Get("UnthrottleKeyY", &fUnthrottleKeyY, -1.0); + control->Get("UnthrottleKeyScale", &fUnthrottleKeyScale, defaultScale); control->Get("LKeyX", &fLKeyX, -1.0); control->Get("LKeyY", &fLKeyY, -1.0); + control->Get("LKeyScale", &fLKeyScale, defaultScale); control->Get("RKeyX", &fRKeyX, -1.0); control->Get("RKeyY", &fRKeyY, -1.0); + control->Get("RKeyScale", &fRKeyScale, defaultScale); control->Get("AnalogStickX", &fAnalogStickX, -1.0); control->Get("AnalogStickY", &fAnalogStickY, -1.0); + control->Get("AnalogStickScale", &fAnalogStickScale, defaultScale); // MIGRATION: For users who had the old static touch layout, aren't I nice? if (fDpadX > 1.0 || fDpadY > 1.0) // Likely the rest are too! @@ -507,32 +515,38 @@ void Config::Save() { control->Set("DeadzoneRadius", fDeadzoneRadius); #endif control->Set("TouchButtonOpacity", iTouchButtonOpacity); - control->Set("ButtonScale", fButtonScale); - control->Set("ActionButtonSpacing", iActionButtonSpacing); + control->Set("ActionButtonScale", fActionButtonScale); + control->Set("ActionButtonSpacing2", fActionButtonSpacing); control->Set("ActionButtonCenterX", fActionButtonCenterX); control->Set("ActionButtonCenterY", fActionButtonCenterY); - control->Set("DPadRadius", iDpadRadius); control->Set("DPadX", fDpadX); control->Set("DPadY", fDpadY); + control->Set("DPadScale", fDpadScale); + control->Set("DPadSpacing", fDpadSpacing); control->Set("StartKeyX", fStartKeyX); control->Set("StartKeyY", fStartKeyY); + control->Set("StartKeyScale", fStartKeyScale); control->Set("SelectKeyX", fSelectKeyX); control->Set("SelectKeyY", fSelectKeyY); + control->Set("SelectKeyScale", fSelectKeyScale); control->Set("UnthrottleKeyX", fUnthrottleKeyX); control->Set("UnthrottleKeyY", fUnthrottleKeyY); + control->Set("UnthrottleKeyScale", fUnthrottleKeyScale); control->Set("LKeyX", fLKeyX); control->Set("LKeyY", fLKeyY); + control->Set("LKeyScale", fLKeyScale); control->Set("RKeyX", fRKeyX); control->Set("RKeyY", fRKeyY); + control->Set("RKeyScale", fRKeyScale); control->Set("AnalogStickX", fAnalogStickX); control->Set("AnalogStickY", fAnalogStickY); - + control->Set("AnalogStickScale", fAnalogStickScale); IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam"); pspConfig->Set("PSPModel", iPSPModel); pspConfig->Set("NickName", sNickName.c_str()); - pspConfig->Set("proAdhocServer", proAdhocServer.c_str()); - pspConfig->Set("MacAddress", localMacAddress.c_str()); + pspConfig->Set("proAdhocServer", proAdhocServer.c_str()); + pspConfig->Set("MacAddress", localMacAddress.c_str()); pspConfig->Set("Language", iLanguage); pspConfig->Set("TimeFormat", iTimeFormat); pspConfig->Set("DateFormat", iDateFormat); diff --git a/Core/Config.h b/Core/Config.h index 98d5b3ca8f..9bd4a34ca8 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -147,24 +147,36 @@ public: // Control Positions int iTouchButtonOpacity; - float fButtonScale; //space between PSP buttons - int iActionButtonSpacing; //the PSP button's center (triangle, circle, square, cross) float fActionButtonCenterX, fActionButtonCenterY; + float fActionButtonScale; + float fActionButtonSpacing; //radius of the D-pad (PSP cross) - int iDpadRadius; + // int iDpadRadius; //the D-pad (PSP cross) position float fDpadX, fDpadY; + float fDpadScale; + float fDpadSpacing; //the start key position float fStartKeyX, fStartKeyY; - //the select key position; + float fStartKeyScale; + //the select key position; float fSelectKeyX, fSelectKeyY; + float fSelectKeyScale; + float fUnthrottleKeyX, fUnthrottleKeyY; + float fUnthrottleKeyScale; + float fLKeyX, fLKeyY; + float fLKeyScale; + float fRKeyX, fRKeyY; + float fRKeyScale; + //position of the analog stick float fAnalogStickX, fAnalogStickY; + float fAnalogStickScale; // Controls Visibility bool bShowTouchControls; diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index ff0b4b20a1..b27b54b805 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -194,11 +194,7 @@ void ControlMappingScreen::CreateViews() { leftColumn->Add(new Choice(k->T("Default All")))->OnClick.Handle(this, &ControlMappingScreen::OnDefaultMapping); leftColumn->Add(new Spacer(new LinearLayoutParams(1.0f))); leftColumn->Add(new Choice(d->T("Back")))->OnClick.Handle(this, &UIScreen::OnBack); - /* - ChoiceStrip *mode = leftColumn->Add(new ChoiceStrip(ORIENT_VERTICAL)); - mode->AddChoice("Replace"); - mode->AddChoice("Add"); - */ + ScrollView *rightScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(1.0f)); rightScroll->SetScrollToTop(false); LinearLayout *rightColumn = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(1.0f)); @@ -235,7 +231,6 @@ UI::EventReturn ControlMappingScreen::OnDefaultMapping(UI::EventParams ¶ms) return UI::EVENT_DONE; } - void KeyMappingNewKeyDialog::CreatePopupContents(UI::ViewGroup *parent) { using namespace UI; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 1afc8adfaa..340252f280 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -156,9 +156,6 @@ void GameSettingsScreen::CreateViews() { graphicsSettings->Add(new CheckBox(&g_Config.bLowQualitySplineBezier, gs->T("LowCurves", "Low quality spline/bezier curves"))); - // This setting is not really useful for anyone atm. - // graphicsSettings->Add(new CheckBox(&g_Config.bTrueColor, gs->T("True Color"))); - // In case we're going to add few other antialiasing option like MSAA in the future. // graphicsSettings->Add(new CheckBox(&g_Config.bFXAA, gs->T("FXAA"))); graphicsSettings->Add(new ItemHeader(gs->T("Texture Scaling"))); @@ -246,8 +243,6 @@ void GameSettingsScreen::CreateViews() { layoutEditorChoice_->OnClick.Handle(this, &GameSettingsScreen::OnTouchControlLayout); layoutEditorChoice_->SetEnabledPtr(&g_Config.bShowTouchControls); controlsSettings->Add(new PopupSliderChoice(&g_Config.iTouchButtonOpacity, 0, 100, c->T("Button Opacity"), screenManager())); - controlsSettings->Add(new PopupSliderChoiceFloat(&g_Config.fButtonScale, 0.80, 2.0, c->T("Button Scaling"), screenManager())) - ->OnChange.Handle(this, &GameSettingsScreen::OnChangeControlScaling); // System ViewGroup *systemSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); @@ -304,11 +299,6 @@ void GameSettingsScreen::CreateViews() { systemSettings->Add(new PopupMultiChoice(&g_Config.iButtonPreference, s->T("Confirmation Button"), buttonPref, 0, 2, s, screenManager())); } -UI::EventReturn GameSettingsScreen::OnChangeControlScaling(UI::EventParams &e) { - UpdateDpadRadius(); - return UI::EVENT_DONE; -} - UI::EventReturn GameSettingsScreen::OnRenderingMode(UI::EventParams &e) { // We do not want to report when rendering mode is Framebuffer to memory - so many issues // are caused by that (framebuffer copies overwriting display lists, etc). diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 736db2dbd2..cb138171c7 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -69,7 +69,6 @@ private: UI::EventReturn OnShaderChange(UI::EventParams &e); UI::EventReturn OnRestoreDefaultSettings(UI::EventParams &e); UI::EventReturn OnRenderingMode(UI::EventParams &e); - UI::EventReturn OnChangeControlScaling(UI::EventParams &e); // Temporaries to convert bools to int settings bool cap60FPS_; @@ -78,19 +77,6 @@ private: bool showDebugStats_; }; -/* -class GlobalSettingsScreen : public UIDialogScreenWithBackground { -public: - GlobalSettingsScreen() {} - -protected: - virtual void CreateViews(); - -private: - // Temporaries to convert bools to other kinds of settings -};*/ - - class DeveloperToolsScreen : public UIDialogScreenWithBackground { public: DeveloperToolsScreen() {} diff --git a/UI/GamepadEmu.cpp b/UI/GamepadEmu.cpp index 8722845dd0..22b1f71773 100644 --- a/UI/GamepadEmu.cpp +++ b/UI/GamepadEmu.cpp @@ -99,16 +99,17 @@ bool PSPButton::IsDown() { } -PSPCross::PSPCross(int arrowIndex, int overlayIndex, float scale, float radius, UI::LayoutParams *layoutParams) - : UI::View(layoutParams), arrowIndex_(arrowIndex), overlayIndex_(overlayIndex), scale_(scale), radius_(radius), dragPointerId_(-1), down_(0) { +PSPDpad::PSPDpad(int arrowIndex, int overlayIndex, float scale, float spacing, UI::LayoutParams *layoutParams) + : UI::View(layoutParams), arrowIndex_(arrowIndex), overlayIndex_(overlayIndex), + scale_(scale), spacing_(spacing), dragPointerId_(-1), down_(0) { } -void PSPCross::GetContentDimensions(const UIContext &dc, float &w, float &h) const { - w = radius_ * 4; - h = radius_ * 4; +void PSPDpad::GetContentDimensions(const UIContext &dc, float &w, float &h) const { + w = D_pad_Radius * spacing_ * 4; + h = D_pad_Radius * spacing_ * 4; } -void PSPCross::Touch(const TouchInput &input) { +void PSPDpad::Touch(const TouchInput &input) { int lastDown = down_; if (input.flags & TOUCH_DOWN) { @@ -130,14 +131,14 @@ void PSPCross::Touch(const TouchInput &input) { } } -void PSPCross::ProcessTouch(float x, float y, bool down) { - float stick_size_ = radius_; - float inv_stick_size = 1.0f / (stick_size_ * scale_); +void PSPDpad::ProcessTouch(float x, float y, bool down) { + float stick_size = spacing_ * D_pad_Radius * scale_; + float inv_stick_size = 1.0f / (stick_size * scale_); const float deadzone = 0.17f; float dx = (x - bounds_.centerX()) * inv_stick_size; float dy = (y - bounds_.centerY()) * inv_stick_size; - float rad = sqrtf(dx*dx+dy*dy); + float rad = sqrtf(dx*dx + dy*dy); if (rad < deadzone || rad > 2.0f) down = false; @@ -174,7 +175,7 @@ void PSPCross::ProcessTouch(float x, float y, bool down) { } } -void PSPCross::Draw(UIContext &dc) { +void PSPDpad::Draw(UIContext &dc) { float opacity = g_Config.iTouchButtonOpacity / 100.0f; uint32_t colorBg = colorAlpha(0xc0b080, opacity); @@ -185,8 +186,8 @@ void PSPCross::Draw(UIContext &dc) { static const int dir[4] = {CTRL_RIGHT, CTRL_DOWN, CTRL_LEFT, CTRL_UP}; int buttons = __CtrlPeekButtons(); for (int i = 0; i < 4; i++) { - float x = bounds_.centerX() + xoff[i] * radius_; - float y = bounds_.centerY() + yoff[i] * radius_; + float x = bounds_.centerX() + xoff[i] * D_pad_Radius * spacing_; + float y = bounds_.centerY() + yoff[i] * D_pad_Radius * spacing_; float angle = i * M_PI / 2; float imgScale = (buttons & dir[i]) ? scale_ * 2 : scale_; dc.Draw()->DrawImageRotated(arrowIndex_, x, y, imgScale, angle + PI, colorBg, false); @@ -195,7 +196,7 @@ void PSPCross::Draw(UIContext &dc) { } } -PSPStick::PSPStick(int bgImg, int stickImg, int stick, float scale, UI::LayoutParams *layoutParams) +PSPStick::PSPStick(int bgImg, int stickImg, int stick, float scale, UI::LayoutParams *layoutParams) : UI::View(layoutParams), dragPointerId_(-1), bgImg_(bgImg), stickImageIndex_(stickImg), stick_(stick), scale_(scale) { stick_size_ = 50; } @@ -269,26 +270,17 @@ void PSPStick::ProcessTouch(float x, float y, bool down) { } } -// Should we really have a specific float for dpad radius? There's no UI to change it. -void UpdateDpadRadius() { - float scale = g_Config.fButtonScale; - const int D_pad_Radius = 40 * scale; - g_Config.iDpadRadius = D_pad_Radius; -} - -void InitPadLayout() { - - // TODO: See if we can make some kind of global scaling for views instead of this hackery. - float scale = g_Config.fButtonScale; +void InitPadLayout(float globalScale) { + const float scale = globalScale; // PSP buttons (triangle, circle, square, cross)--------------------- // space between the PSP buttons (triangle, circle, square and cross) - const int Action_button_spacing = 50 * scale; - if (g_Config.iActionButtonSpacing == -1) { - g_Config.iActionButtonSpacing = Action_button_spacing; + if (g_Config.fActionButtonSpacing < 0) { + g_Config.fActionButtonSpacing = 1.0f; } // Position of the circle button (the PSP circle button). It is the farthest to the left + float Action_button_spacing = g_Config.fActionButtonSpacing * baseActionButtonSpacing; int Action_button_center_X = dp_xres - Action_button_spacing * 2; int Action_button_center_Y = dp_yres - Action_button_spacing * 2; @@ -300,11 +292,10 @@ void InitPadLayout() { //D-PAD (up down left right) (aka PSP cross)---------------------------- //radius to the D-pad - UpdateDpadRadius(); + // TODO: Make configurable - const int D_pad_Radius = 40 * scale; - int D_pad_X = 2.5 * D_pad_Radius; - int D_pad_Y = dp_yres - D_pad_Radius; + int D_pad_X = 2.5 * D_pad_Radius * scale; + int D_pad_Y = dp_yres - D_pad_Radius * scale; if (g_Config.bShowTouchAnalogStick) { D_pad_Y -= 200 * scale; } @@ -323,6 +314,7 @@ void InitPadLayout() { if (g_Config.fAnalogStickX == -1.0 || g_Config.fAnalogStickY == -1.0 ) { g_Config.fAnalogStickX = (float)analog_stick_X / dp_xres; g_Config.fAnalogStickY = (float)analog_stick_Y / dp_yres; + g_Config.fAnalogStickScale = scale; } //select, start, throttle-------------------------------------------- @@ -335,6 +327,7 @@ void InitPadLayout() { if (g_Config.fStartKeyX == -1.0 || g_Config.fStartKeyY == -1.0 ) { g_Config.fStartKeyX = (float)start_key_X / dp_xres; g_Config.fStartKeyY = (float)start_key_Y / dp_yres; + g_Config.fStartKeyScale = scale; } int select_key_X = dp_xres / 2; @@ -343,6 +336,7 @@ void InitPadLayout() { if (g_Config.fSelectKeyX == -1.0 || g_Config.fSelectKeyY == -1.0 ) { g_Config.fSelectKeyX = (float)select_key_X / dp_xres; g_Config.fSelectKeyY = (float)select_key_Y / dp_yres; + g_Config.fSelectKeyScale = scale; } int unthrottle_key_X = dp_xres / 2 - (bottom_key_spacing) * scale; @@ -351,6 +345,7 @@ void InitPadLayout() { if (g_Config.fUnthrottleKeyX == -1.0 || g_Config.fUnthrottleKeyY == -1.0 ) { g_Config.fUnthrottleKeyX = (float)unthrottle_key_X / dp_xres; g_Config.fUnthrottleKeyY = (float)unthrottle_key_Y / dp_yres; + g_Config.fUnthrottleKeyScale = scale; } //L and R------------------------------------------------------------ @@ -360,6 +355,7 @@ void InitPadLayout() { if (g_Config.fLKeyX == -1.0 || g_Config.fLKeyY == -1.0 ) { g_Config.fLKeyX = (float)l_key_X / dp_xres; g_Config.fLKeyY = (float)l_key_Y / dp_yres; + g_Config.fLKeyScale = scale; } int r_key_X = dp_xres - 60 * scale; @@ -368,11 +364,10 @@ void InitPadLayout() { if (g_Config.fRKeyX == -1.0 || g_Config.fRKeyY == -1.0 ) { g_Config.fRKeyX = (float)r_key_X / dp_xres; g_Config.fRKeyY = (float)r_key_Y / dp_yres; + g_Config.fRKeyScale = scale; } }; - - UI::ViewGroup *CreatePadLayout(bool *pause) { //standard coord system @@ -382,93 +377,98 @@ UI::ViewGroup *CreatePadLayout(bool *pause) { //PSP buttons (triangle, circle, square, cross)--------------------- //space between the PSP buttons (traingle, circle, square and cross) - const int Action_button_spacing = g_Config.iActionButtonSpacing; + const float Action_button_scale = g_Config.fActionButtonScale; + const float Action_button_spacing = g_Config.fActionButtonSpacing * baseActionButtonSpacing; //position of the circle button (the PSP circle button). It is the farthest to the left - int Action_button_center_X = g_Config.fActionButtonCenterX * dp_xres; - int Action_button_center_Y = g_Config.fActionButtonCenterY * dp_yres; + float Action_button_center_X = g_Config.fActionButtonCenterX * dp_xres; + float Action_button_center_Y = g_Config.fActionButtonCenterY * dp_yres; - const int Action_circle_button_X = Action_button_center_X + Action_button_spacing; - const int Action_circle_button_Y = Action_button_center_Y; + const float Action_circle_button_X = Action_button_center_X + Action_button_spacing; + const float Action_circle_button_Y = Action_button_center_Y; - const int Action_cross_button_X = Action_button_center_X; - const int Action_cross_button_Y = Action_button_center_Y + Action_button_spacing; + const float Action_cross_button_X = Action_button_center_X; + const float Action_cross_button_Y = Action_button_center_Y + Action_button_spacing; - const int Action_triangle_button_X = Action_button_center_X; - const int Action_triangle_button_Y = Action_button_center_Y - Action_button_spacing; + const float Action_triangle_button_X = Action_button_center_X; + const float Action_triangle_button_Y = Action_button_center_Y - Action_button_spacing; - const int Action_square_button_X = Action_button_center_X - Action_button_spacing; - const int Action_square_button_Y = Action_button_center_Y; + const float Action_square_button_X = Action_button_center_X - Action_button_spacing; + const float Action_square_button_Y = Action_button_center_Y; //D-PAD (up down left right) (aka PSP cross)-------------------------------------------------------------- //radius to the D-pad - const int D_pad_Radius = g_Config.iDpadRadius; - int D_pad_X = g_Config.fDpadX * dp_xres; - int D_pad_Y = g_Config.fDpadY * dp_yres; + float D_pad_X = g_Config.fDpadX * dp_xres; + float D_pad_Y = g_Config.fDpadY * dp_yres; + float D_pad_scale = g_Config.fDpadScale; + float D_pad_spacing = g_Config.fDpadSpacing; //select, start, throttle-------------------------------------------- //space between the bottom keys (space between select, start and un-throttle) - int start_key_X = g_Config.fStartKeyX * dp_xres; - int start_key_Y = g_Config.fStartKeyY * dp_yres; + float start_key_X = g_Config.fStartKeyX * dp_xres; + float start_key_Y = g_Config.fStartKeyY * dp_yres; + float start_key_scale = g_Config.fStartKeyScale; - int select_key_X = g_Config.fSelectKeyX * dp_xres; - int select_key_Y = g_Config.fSelectKeyY * dp_yres; + float select_key_X = g_Config.fSelectKeyX * dp_xres; + float select_key_Y = g_Config.fSelectKeyY * dp_yres; + float select_key_scale = g_Config.fSelectKeyScale; - int unthrottle_key_X = g_Config.fUnthrottleKeyX * dp_xres; - int unthrottle_key_Y = g_Config.fUnthrottleKeyY * dp_yres; + float unthrottle_key_X = g_Config.fUnthrottleKeyX * dp_xres; + float unthrottle_key_Y = g_Config.fUnthrottleKeyY * dp_yres; + float unthrottle_key_scale = g_Config.fUnthrottleKeyScale; //L and R------------------------------------------------------------ - int l_key_X = g_Config.fLKeyX * dp_xres; - int l_key_Y = g_Config.fLKeyY * dp_yres; + float l_key_X = g_Config.fLKeyX * dp_xres; + float l_key_Y = g_Config.fLKeyY * dp_yres; + float l_key_scale = g_Config.fLKeyScale; - int r_key_X = g_Config.fRKeyX * dp_xres; - int r_key_Y = g_Config.fRKeyY * dp_yres; + float r_key_X = g_Config.fRKeyX * dp_xres; + float r_key_Y = g_Config.fRKeyY * dp_yres; + float r_key_scale = g_Config.fRKeyScale; - //analog stick------------------------------------------------------- - int analog_stick_X = g_Config.fAnalogStickX * dp_xres; - int analog_stick_Y = g_Config.fAnalogStickY * dp_yres; - + float analog_stick_X = g_Config.fAnalogStickX * dp_xres; + float analog_stick_Y = g_Config.fAnalogStickY * dp_yres; + float analog_stick_scale = g_Config.fAnalogStickScale; + const int halfW = dp_xres / 2; if (g_Config.bShowTouchControls) { - float scale = g_Config.fButtonScale; - #if USE_PAUSE_BUTTON - root->Add(new BoolButton(pause, I_ROUND, I_ARROW, scale, new AnchorLayoutParams(halfW, 20, NONE, NONE, true)))->SetAngle(90); + root->Add(new BoolButton(pause, I_ROUND, I_ARROW, 1.0f, new AnchorLayoutParams(halfW, 20, NONE, NONE, true)))->SetAngle(90); #endif if (g_Config.bShowTouchCircle) - root->Add(new PSPButton(CTRL_CIRCLE, I_ROUND, I_CIRCLE, scale, new AnchorLayoutParams(Action_circle_button_X, Action_circle_button_Y, NONE, NONE, true))); + root->Add(new PSPButton(CTRL_CIRCLE, I_ROUND, I_CIRCLE, Action_button_scale, new AnchorLayoutParams(Action_circle_button_X, Action_circle_button_Y, NONE, NONE, true))); if (g_Config.bShowTouchCross) - root->Add(new PSPButton(CTRL_CROSS, I_ROUND, I_CROSS, scale, new AnchorLayoutParams(Action_cross_button_X, Action_cross_button_Y, NONE, NONE, true))); + root->Add(new PSPButton(CTRL_CROSS, I_ROUND, I_CROSS, Action_button_scale, new AnchorLayoutParams(Action_cross_button_X, Action_cross_button_Y, NONE, NONE, true))); if (g_Config.bShowTouchTriangle) - root->Add(new PSPButton(CTRL_TRIANGLE, I_ROUND, I_TRIANGLE, scale, new AnchorLayoutParams(Action_triangle_button_X, Action_triangle_button_Y, NONE, NONE, true))); + root->Add(new PSPButton(CTRL_TRIANGLE, I_ROUND, I_TRIANGLE, Action_button_scale, new AnchorLayoutParams(Action_triangle_button_X, Action_triangle_button_Y, NONE, NONE, true))); if (g_Config.bShowTouchSquare) - root->Add(new PSPButton(CTRL_SQUARE, I_ROUND, I_SQUARE, scale, new AnchorLayoutParams(Action_square_button_X, Action_square_button_Y, NONE, NONE, true))); + root->Add(new PSPButton(CTRL_SQUARE, I_ROUND, I_SQUARE, Action_button_scale, new AnchorLayoutParams(Action_square_button_X, Action_square_button_Y, NONE, NONE, true))); if (g_Config.bShowTouchStart) - root->Add(new PSPButton(CTRL_START, I_RECT, I_START, scale, new AnchorLayoutParams(start_key_X, start_key_Y, NONE, NONE, true))); + root->Add(new PSPButton(CTRL_START, I_RECT, I_START, start_key_scale, new AnchorLayoutParams(start_key_X, start_key_Y, NONE, NONE, true))); if (g_Config.bShowTouchSelect) - root->Add(new PSPButton(CTRL_SELECT, I_RECT, I_SELECT, scale, new AnchorLayoutParams(select_key_X, select_key_Y, NONE, NONE, true))); + root->Add(new PSPButton(CTRL_SELECT, I_RECT, I_SELECT, select_key_scale, new AnchorLayoutParams(select_key_X, select_key_Y, NONE, NONE, true))); if (g_Config.bShowTouchUnthrottle) - root->Add(new BoolButton(&PSP_CoreParameter().unthrottle, I_RECT, I_ARROW, scale, new AnchorLayoutParams(unthrottle_key_X, unthrottle_key_Y, NONE, NONE, true)))->SetAngle(180); + root->Add(new BoolButton(&PSP_CoreParameter().unthrottle, I_RECT, I_ARROW, unthrottle_key_scale, new AnchorLayoutParams(unthrottle_key_X, unthrottle_key_Y, NONE, NONE, true)))->SetAngle(180); if (g_Config.bShowTouchLTrigger) - root->Add(new PSPButton(CTRL_LTRIGGER, I_SHOULDER, I_L, scale, new AnchorLayoutParams(l_key_X, l_key_Y, NONE, NONE, true))); + root->Add(new PSPButton(CTRL_LTRIGGER, I_SHOULDER, I_L, l_key_scale, new AnchorLayoutParams(l_key_X, l_key_Y, NONE, NONE, true))); if (g_Config.bShowTouchRTrigger) - root->Add(new PSPButton(CTRL_RTRIGGER, I_SHOULDER, I_R, scale, new AnchorLayoutParams(r_key_X,r_key_Y, NONE, NONE, true)))->FlipImageH(true); + root->Add(new PSPButton(CTRL_RTRIGGER, I_SHOULDER, I_R, r_key_scale, new AnchorLayoutParams(r_key_X,r_key_Y, NONE, NONE, true)))->FlipImageH(true); if (g_Config.bShowTouchDpad) - root->Add(new PSPCross(I_DIR, I_ARROW, scale, D_pad_Radius, new AnchorLayoutParams(D_pad_X, D_pad_Y, NONE, NONE, true))); + root->Add(new PSPDpad(I_DIR, I_ARROW, D_pad_scale, D_pad_spacing, new AnchorLayoutParams(D_pad_X, D_pad_Y, NONE, NONE, true))); if (g_Config.bShowTouchAnalogStick) - root->Add(new PSPStick(I_STICKBG, I_STICK, 0, scale, new AnchorLayoutParams(analog_stick_X, analog_stick_Y, NONE, NONE, true))); + root->Add(new PSPStick(I_STICKBG, I_STICK, 0, analog_stick_scale, new AnchorLayoutParams(analog_stick_X, analog_stick_Y, NONE, NONE, true))); } return root; diff --git a/UI/GamepadEmu.h b/UI/GamepadEmu.h index f79bff9aa8..a28f64018b 100644 --- a/UI/GamepadEmu.h +++ b/UI/GamepadEmu.h @@ -75,9 +75,9 @@ private: int pspButtonBit_; }; -class PSPCross : public UI::View { +class PSPDpad : public UI::View { public: - PSPCross(int arrowIndex, int overlayIndex, float scale, float radius, UI::LayoutParams *layoutParams); + PSPDpad(int arrowIndex, int overlayIndex, float scale, float spacing, UI::LayoutParams *layoutParams); virtual void Key(const KeyInput &input) {} virtual void Update(const InputState &input) {} @@ -91,7 +91,7 @@ private: int overlayIndex_; float scale_; - float radius_; + float spacing_; int dragPointerId_; int down_; @@ -122,6 +122,9 @@ private: //initializes the layout from Config. if a default layout does not exist, //it sets up default values -void InitPadLayout(); -void UpdateDpadRadius(); // TODO: get rid of somehow +void InitPadLayout(float globalScale = 1.15f); UI::ViewGroup *CreatePadLayout(bool *pause); + +const int D_pad_Radius = 50; +const int baseActionButtonSpacing = 60; + diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index 69ed22f173..0452772d03 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -231,7 +231,7 @@ NewLanguageScreen::NewLanguageScreen(const std::string &title) : ListPopupScreen if (tempLangs[i].name.find("README") != std::string::npos) { continue; } - + #ifndef _WIN32 // ar_AE only works on Windows. if (tempLangs[i].name.find("ar_AE") != std::string::npos) { diff --git a/UI/TouchControlLayoutScreen.cpp b/UI/TouchControlLayoutScreen.cpp index b12a3b3972..183a848df4 100644 --- a/UI/TouchControlLayoutScreen.cpp +++ b/UI/TouchControlLayoutScreen.cpp @@ -28,45 +28,53 @@ #include "GamepadEmu.h" #include "i18n/i18n.h" -static const int leftMargin = 140; +static const int leftColumnWidth = 140; -// convert from screen coordinates (leftMargin to dp_xres) to actual fullscreen coordinates (0 to 1.0) +// convert from screen coordinates (leftColumnWidth to dp_xres) to actual fullscreen coordinates (0 to 1.0) static inline float toFullscreenCoord(int screenx) { - return (float)(screenx - leftMargin) / (dp_xres - leftMargin); + return (float)(screenx - leftColumnWidth) / (dp_xres - leftColumnWidth); } -// convert from external fullscreen coordinates(0 to 1.0) to the current partial coordinates (leftMargin to dp_xres) +// convert from external fullscreen coordinates(0 to 1.0) to the current partial coordinates (leftColumnWidth to dp_xres) static inline int fromFullscreenCoord(float controllerX) { - return leftMargin + (dp_xres - leftMargin) * controllerX; + return leftColumnWidth + (dp_xres - leftColumnWidth) * controllerX; }; class DragDropButton : public MultiTouchButton { public: - DragDropButton(float &x, float &y, int bgImg, int img, float scale) + DragDropButton(float &x, float &y, int bgImg, int img, float &scale) : MultiTouchButton(bgImg, img, scale, new UI::AnchorLayoutParams(fromFullscreenCoord(x), y*dp_yres, UI::NONE, UI::NONE, true)), - x_(x), y_(y) { - scale_ = scale; + x_(x), y_(y), theScale_(scale) { + scale_ = theScale_; } virtual bool IsDown() { - //don't want the button to enlarge and throw the user's perspective - //of button size off whack. + // Don't want the button to enlarge and throw the user's perspective + // of button size off whack. return false; }; - void SavePosition() { + virtual void SavePosition() { x_ = toFullscreenCoord(bounds_.centerX()); y_ = bounds_.centerY() / dp_yres; + scale_ = theScale_; } + virtual float GetScale() const { return theScale_; } + virtual void SetScale(float s) { theScale_ = s; scale_ = s; } + + virtual float GetSpacing() const { return 1.0f; } + virtual void SetSpacing(float s) { } + private: float &x_, &y_; + float &theScale_; }; class PSPActionButtons : public DragDropButton { public: - PSPActionButtons(float &x, float &y, int actionButtonSpacing, float scale) - : DragDropButton(x, y, -1, -1, scale), actionButtonSpacing_(actionButtonSpacing) { + PSPActionButtons(float &x, float &y, float &scale, float &spacing) + : DragDropButton(x, y, -1, -1, scale), spacing_(spacing) { using namespace UI; roundId_ = I_ROUND; @@ -103,50 +111,55 @@ public: int centerX = bounds_.centerX(); int centerY = bounds_.centerY(); + float spacing = spacing_ * baseActionButtonSpacing; if (circleVisible_) { - dc.Draw()->DrawImageRotated(roundId_, centerX + actionButtonSpacing_, centerY, scale_, 0, colorBg, false); - dc.Draw()->DrawImageRotated(circleId_, centerX + actionButtonSpacing_, centerY, scale_, 0, color, false); + dc.Draw()->DrawImageRotated(roundId_, centerX + spacing, centerY, scale_, 0, colorBg, false); + dc.Draw()->DrawImageRotated(circleId_, centerX + spacing, centerY, scale_, 0, color, false); } if (crossVisible_) { - dc.Draw()->DrawImageRotated(roundId_, centerX, centerY + actionButtonSpacing_, scale_, 0, colorBg, false); - dc.Draw()->DrawImageRotated(crossId_, centerX, centerY + actionButtonSpacing_, scale_, 0, color, false); + dc.Draw()->DrawImageRotated(roundId_, centerX, centerY + spacing, scale_, 0, colorBg, false); + dc.Draw()->DrawImageRotated(crossId_, centerX, centerY + spacing, scale_, 0, color, false); } if (triangleVisible_) { - dc.Draw()->DrawImageRotated(roundId_, centerX, centerY - actionButtonSpacing_, scale_, 0, colorBg, false); - dc.Draw()->DrawImageRotated(triangleId_, centerX, centerY - actionButtonSpacing_, scale_, 0, color, false); + dc.Draw()->DrawImageRotated(roundId_, centerX, centerY - spacing, scale_, 0, colorBg, false); + dc.Draw()->DrawImageRotated(triangleId_, centerX, centerY - spacing, scale_, 0, color, false); } - - if (squareVisible_){ - dc.Draw()->DrawImageRotated(roundId_, centerX - actionButtonSpacing_, centerY, scale_, 0, colorBg, false); - dc.Draw()->DrawImageRotated(squareId_, centerX - actionButtonSpacing_, centerY, scale_, 0, color, false); + + if (squareVisible_) { + dc.Draw()->DrawImageRotated(roundId_, centerX - spacing, centerY, scale_, 0, colorBg, false); + dc.Draw()->DrawImageRotated(squareId_, centerX - spacing, centerY, scale_, 0, color, false); } }; void GetContentDimensions(const UIContext &dc, float &w, float &h) const{ const AtlasImage &image = dc.Draw()->GetAtlas()->images[roundId_]; - w = 2 * actionButtonSpacing_ + image.w * scale_; - h = 2 * actionButtonSpacing_ + image.h * scale_; - //w += 2 * actionButtonSpacing_; - //h += 2 * actionButtonSpacing_; - }; + w = (2 * baseActionButtonSpacing * spacing_) + image.w * scale_; + h = (2 * baseActionButtonSpacing * spacing_) + image.h * scale_; + } + + virtual float GetSpacing() const { return spacing_; } + virtual void SetSpacing(float s) { spacing_ = s; } + + virtual void SavePosition() { + DragDropButton::SavePosition(); + } private: - bool circleVisible_, crossVisible_, triangleVisible_, squareVisible_; int roundId_; int circleId_, crossId_, triangleId_, squareId_; - int actionButtonSpacing_; + float &spacing_; }; class PSPDPadButtons : public DragDropButton { public: - PSPDPadButtons(float &x, float &y, int DpadRadius, float scale) - : DragDropButton(x, y, -1, -1, scale), DpadRadius_(DpadRadius) { + PSPDPadButtons(float &x, float &y, float &scale, float &spacing) + : DragDropButton(x, y, -1, -1, scale), spacing_(spacing) { } void Draw(UIContext &dc) { @@ -159,8 +172,8 @@ public: static const float yoff[4] = {0, 1, 0, -1}; for (int i = 0; i < 4; i++) { - float x = bounds_.centerX() + xoff[i] * DpadRadius_; - float y = bounds_.centerY() + yoff[i] * DpadRadius_; + float x = bounds_.centerX() + xoff[i] * D_pad_Radius * spacing_; + float y = bounds_.centerY() + yoff[i] * D_pad_Radius * spacing_; float angle = i * M_PI / 2; dc.Draw()->DrawImageRotated(I_DIR, x, y, scale_, angle + PI, colorBg, false); @@ -170,16 +183,16 @@ public: void GetContentDimensions(const UIContext &dc, float &w, float &h) const{ const AtlasImage &image = dc.Draw()->GetAtlas()->images[I_DIR]; - w = 2 * DpadRadius_ + image.w * scale_; - h = 2 * DpadRadius_ + image.h * scale_; - - //w += 2 * DpadRadius_; - //h += 2 * DpadRadius_; + w = 2 * D_pad_Radius * spacing_ + image.w * scale_; + h = 2 * D_pad_Radius * spacing_ + image.h * scale_; }; + + float GetSpacing() const { return spacing_; } + virtual void SetSpacing(float s) { spacing_ = s; } private: - int DpadRadius_; -}; + float &spacing_; +}; TouchControlLayoutScreen::TouchControlLayoutScreen() { pickedControl_ = 0; @@ -190,37 +203,58 @@ void TouchControlLayoutScreen::touch(const TouchInput &touch) { using namespace UI; + int mode = mode_->GetSelection(); + if ((touch.flags & TOUCH_MOVE) && pickedControl_ != 0) { - const Bounds &bounds = pickedControl_->GetBounds(); - - int mintouchX = leftMargin + bounds.w * 0.5; - int maxTouchX = dp_xres - bounds.w * 0.5; + if (mode == 0) { + const Bounds &bounds = pickedControl_->GetBounds(); - int minTouchY = bounds.h * 0.5; - int maxTouchY = dp_yres - bounds.h * 0.5; + int mintouchX = leftColumnWidth + bounds.w * 0.5; + int maxTouchX = dp_xres - bounds.w * 0.5; - int newX = bounds.centerX(), newY = bounds.centerY(); + int minTouchY = bounds.h * 0.5; + int maxTouchY = dp_yres - bounds.h * 0.5; - //we have to handle x and y separately since even if x is blocked, y may not be. - if (touch.x > mintouchX && touch.x < maxTouchX) { - //if the leftmost point of the control is ahead of the margin, - //move it. Otherwise, don't. - newX = touch.x; + int newX = bounds.centerX(), newY = bounds.centerY(); + + // we have to handle x and y separately since even if x is blocked, y may not be. + if (touch.x > mintouchX && touch.x < maxTouchX) { + // if the leftmost point of the control is ahead of the margin, + // move it. Otherwise, don't. + newX = touch.x; + } + if (touch.y > minTouchY && touch.y < maxTouchY) { + newY = touch.y; + } + pickedControl_->ReplaceLayoutParams(new UI::AnchorLayoutParams(newX, newY, NONE, NONE, true)); + } else if (mode == 1) { + // Resize. Vertical = scaling, horizontal = spacing; + // Up should be bigger so let's negate in that direction + float diffX = (touch.x - startX_); + float diffY = -(touch.y - startY_); + + float movementScale = 0.02f; + float newScale = startScale_ + diffY * movementScale; + float newSpacing = startSpacing_ + diffX * movementScale; + if (newScale > 3.0f) newScale = 3.0f; + if (newScale < 0.5f) newScale = 0.5f; + if (newSpacing > 3.0f) newSpacing = 3.0f; + if (newSpacing < 0.5f) newSpacing = 0.5f; + pickedControl_->SetSpacing(newSpacing); + pickedControl_->SetScale(newScale); } - if (touch.y > minTouchY && touch.y < maxTouchY) { - newY = touch.y; - } - - // ILOG("position: x = %d; y = %d", newX, newY); - pickedControl_->ReplaceLayoutParams(new UI::AnchorLayoutParams(newX, newY, NONE, NONE, true)); } if ((touch.flags & TOUCH_DOWN) && pickedControl_ == 0) { - ILOG("->->->picked up") pickedControl_ = getPickedControl(touch.x, touch.y); + if (pickedControl_) { + startX_ = touch.x; + startY_ = touch.y; + startSpacing_ = pickedControl_->GetSpacing(); + startScale_ = pickedControl_->GetScale(); + } } if ((touch.flags & TOUCH_UP) && pickedControl_ != 0) { pickedControl_->SavePosition(); - ILOG("->->->dropped down") pickedControl_ = 0; } }; @@ -235,24 +269,34 @@ UI::EventReturn TouchControlLayoutScreen::OnVisibility(UI::EventParams &e) { } UI::EventReturn TouchControlLayoutScreen::OnReset(UI::EventParams &e) { - g_Config.iActionButtonSpacing = -1; + ILOG("Resetting touch control layout"); + float defaultScale = 1.15; + g_Config.fActionButtonScale = defaultScale; + g_Config.fActionButtonSpacing = 1.0f; g_Config.fActionButtonCenterX = -1.0; g_Config.fActionButtonCenterY = -1.0; - g_Config.iDpadRadius = -1; + g_Config.fDpadScale = defaultScale; + g_Config.fDpadSpacing = 1.0f; g_Config.fDpadX = -1.0; g_Config.fDpadY = -1.0; g_Config.fStartKeyX = -1.0; g_Config.fStartKeyY = -1.0; + g_Config.fStartKeyScale = defaultScale; g_Config.fSelectKeyX = -1.0; g_Config.fSelectKeyY = -1.0; + g_Config.fSelectKeyScale = defaultScale; g_Config.fUnthrottleKeyX = -1.0; g_Config.fUnthrottleKeyY = -1.0; + g_Config.fUnthrottleKeyScale = defaultScale; g_Config.fLKeyX = -1.0; g_Config.fLKeyY = -1.0; + g_Config.fLKeyScale = defaultScale; g_Config.fRKeyX = -1.0; g_Config.fRKeyY = -1.0; + g_Config.fRKeyScale = defaultScale; g_Config.fAnalogStickX = -1.0; g_Config.fAnalogStickY = -1.0; + g_Config.fAnalogStickScale = defaultScale; InitPadLayout(); RecreateViews(); return UI::EVENT_DONE; @@ -273,17 +317,26 @@ void TouchControlLayoutScreen::CreateViews() { root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); - Choice *reset = new Choice(d->T("Reset"), "", false, new AnchorLayoutParams(leftMargin, WRAP_CONTENT, 10, NONE, NONE, 84)); - Choice *back = new Choice(d->T("Back"), "", false, new AnchorLayoutParams(leftMargin, WRAP_CONTENT, 10, NONE, NONE, 10)); - Choice *visibility = new Choice(c->T("Visibility"), "", false, new AnchorLayoutParams(leftMargin, WRAP_CONTENT, 10, NONE, NONE, 158)); + Choice *reset = new Choice(d->T("Reset"), "", false, new AnchorLayoutParams(leftColumnWidth, WRAP_CONTENT, 10, NONE, NONE, 84)); + Choice *back = new Choice(d->T("Back"), "", false, new AnchorLayoutParams(leftColumnWidth, WRAP_CONTENT, 10, NONE, NONE, 10)); + Choice *visibility = new Choice(c->T("Visibility"), "", false, new AnchorLayoutParams(leftColumnWidth, WRAP_CONTENT, 10, NONE, NONE, 158)); + // controlsSettings->Add(new PopupSliderChoiceFloat(&g_Config.fButtonScale, 0.80, 2.0, c->T("Button Scaling"), screenManager())) + // ->OnChange.Handle(this, &GameSettingsScreen::OnChangeControlScaling); + + mode_ = new ChoiceStrip(ORIENT_VERTICAL, new AnchorLayoutParams(leftColumnWidth, WRAP_CONTENT, 10, NONE, NONE, 158 + 64 + 10)); + mode_->AddChoice(d->T("Move")); + mode_->AddChoice(d->T("Resize")); + mode_->SetSelection(0); + reset->OnClick.Handle(this, &TouchControlLayoutScreen::OnReset); back->OnClick.Handle(this, &UIScreen::OnBack); visibility->OnClick.Handle(this, &TouchControlLayoutScreen::OnVisibility); + root_->Add(mode_); root_->Add(visibility); root_->Add(reset); root_->Add(back); - TabHolder *tabHolder = new TabHolder(ORIENT_VERTICAL, leftMargin, new AnchorLayoutParams(10, 0, 10, 0, false)); + TabHolder *tabHolder = new TabHolder(ORIENT_VERTICAL, leftColumnWidth, new AnchorLayoutParams(10, 0, 10, 0, false)); root_->Add(tabHolder); // this is more for show than anything else. It's used to provide a boundary @@ -295,14 +348,14 @@ void TouchControlLayoutScreen::CreateViews() { tabHolder->AddTab(ms->T("Controls"), controlsHolder); - if (!g_Config.bShowTouchControls){ + if (!g_Config.bShowTouchControls) { + // Shouldn't even be able to get here as the way into this dialog should be closed. return; } - float scale = g_Config.fButtonScale; controls_.clear(); - PSPActionButtons *actionButtons = new PSPActionButtons(g_Config.fActionButtonCenterX, g_Config.fActionButtonCenterY, g_Config.iActionButtonSpacing, scale); + PSPActionButtons *actionButtons = new PSPActionButtons(g_Config.fActionButtonCenterX, g_Config.fActionButtonCenterY, g_Config.fActionButtonScale, g_Config.fActionButtonSpacing); actionButtons->setCircleVisibility(g_Config.bShowTouchCircle); actionButtons->setCrossVisibility(g_Config.bShowTouchCross); actionButtons->setTriangleVisibility(g_Config.bShowTouchTriangle); @@ -311,35 +364,35 @@ void TouchControlLayoutScreen::CreateViews() { controls_.push_back(actionButtons); if (g_Config.bShowTouchDpad) { - controls_.push_back(new PSPDPadButtons(g_Config.fDpadX, g_Config.fDpadY, g_Config.iDpadRadius, scale)); + controls_.push_back(new PSPDPadButtons(g_Config.fDpadX, g_Config.fDpadY, g_Config.fDpadScale, g_Config.fDpadSpacing)); } if (g_Config.bShowTouchSelect) { - controls_.push_back(new DragDropButton(g_Config.fSelectKeyX, g_Config.fSelectKeyY, I_RECT, I_SELECT, scale)); + controls_.push_back(new DragDropButton(g_Config.fSelectKeyX, g_Config.fSelectKeyY, I_RECT, I_SELECT, g_Config.fSelectKeyScale)); } if (g_Config.bShowTouchStart) { - controls_.push_back(new DragDropButton(g_Config.fStartKeyX, g_Config.fStartKeyY, I_RECT, I_START, scale)); + controls_.push_back(new DragDropButton(g_Config.fStartKeyX, g_Config.fStartKeyY, I_RECT, I_START, g_Config.fStartKeyScale)); } if (g_Config.bShowTouchUnthrottle) { - DragDropButton *unthrottle = new DragDropButton(g_Config.fUnthrottleKeyX, g_Config.fUnthrottleKeyY, I_RECT, I_ARROW, scale); + DragDropButton *unthrottle = new DragDropButton(g_Config.fUnthrottleKeyX, g_Config.fUnthrottleKeyY, I_RECT, I_ARROW, g_Config.fUnthrottleKeyScale); unthrottle->SetAngle(180.0f); controls_.push_back(unthrottle); } if (g_Config.bShowTouchLTrigger) { - controls_.push_back(new DragDropButton(g_Config.fLKeyX, g_Config.fLKeyY, I_SHOULDER, I_L, scale)); + controls_.push_back(new DragDropButton(g_Config.fLKeyX, g_Config.fLKeyY, I_SHOULDER, I_L, g_Config.fLKeyScale)); } if (g_Config.bShowTouchRTrigger) { - DragDropButton *rbutton = new DragDropButton(g_Config.fRKeyX, g_Config.fRKeyY, I_SHOULDER, I_R, scale); + DragDropButton *rbutton = new DragDropButton(g_Config.fRKeyX, g_Config.fRKeyY, I_SHOULDER, I_R, g_Config.fRKeyScale); rbutton->FlipImageH(true); controls_.push_back(rbutton); } if (g_Config.bShowTouchAnalogStick) { - controls_.push_back(new DragDropButton(g_Config.fAnalogStickX, g_Config.fAnalogStickY, I_STICKBG, I_STICK, scale)); + controls_.push_back(new DragDropButton(g_Config.fAnalogStickX, g_Config.fAnalogStickY, I_STICKBG, I_STICK, g_Config.fAnalogStickScale)); }; for (size_t i = 0; i < controls_.size(); i++) { diff --git a/UI/TouchControlLayoutScreen.h b/UI/TouchControlLayoutScreen.h index 728361b5cc..d62ee916e5 100644 --- a/UI/TouchControlLayoutScreen.h +++ b/UI/TouchControlLayoutScreen.h @@ -19,6 +19,7 @@ #include "base/functional.h" #include "ui/view.h" +#include "ui/viewgroup.h" #include "MiscScreens.h" #include @@ -40,5 +41,12 @@ protected: private: DragDropButton *pickedControl_; std::vector controls_; + UI::ChoiceStrip *mode_; DragDropButton *getPickedControl(const int x, const int y); + + // Touch down state for drag to resize etc + float startX_; + float startY_; + float startScale_; + float startSpacing_; };