From a88a30fb1dd4b484d13dc56503435e670824b1c6 Mon Sep 17 00:00:00 2001 From: The Dax Date: Sat, 19 Oct 2013 22:40:52 -0400 Subject: [PATCH 01/10] Add a touch control visibility screen. All touch controls can now be toggled on or off, except for the Pause button on platforms that have it, as a safety precaution. --- Core/Config.cpp | 26 ++++++- Core/Config.h | 12 +++- UI/GameSettingsScreen.cpp | 10 ++- UI/GameSettingsScreen.h | 1 + UI/GamepadEmu.cpp | 42 ++++++++---- UI/TouchControlVisibilityScreen.cpp | 102 ++++++++++++++++++++++++++++ UI/TouchControlVisibilityScreen.h | 39 +++++++++++ 7 files changed, 215 insertions(+), 17 deletions(-) create mode 100644 UI/TouchControlVisibilityScreen.cpp create mode 100644 UI/TouchControlVisibilityScreen.h diff --git a/Core/Config.cpp b/Core/Config.cpp index 164be39d3d..b2d3551f7b 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -191,7 +191,18 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) IniFile::Section *control = iniFile.GetOrCreateSection("Control"); control->Get("HapticFeedback", &bHapticFeedback, true); - control->Get("ShowAnalogStick", &bShowAnalogStick, true); + control->Get("ShowAnalogStick", &bShowTouchAnalogStick, true); + control->Get("ShowTouchCross", bShowTouchCross); + control->Get("ShowTouchCircle", bShowTouchCircle); + control->Get("ShowTouchSquare", bShowTouchSquare); + control->Get("ShowTouchTriangle", bShowTouchTriangle); + control->Get("ShowTouchStart", bShowTouchStart); + control->Get("ShowTouchSelect", bShowTouchSelect); + control->Get("ShowTouchLTrigger", bShowTouchLTrigger); + control->Get("ShowTouchRTrigger", bShowTouchRTrigger); + control->Get("ShowAnalogStick", bShowTouchAnalogStick); + control->Get("ShowTouchUnthrottle", bShowTouchUnthrottle); + #if defined(USING_GLES2) std::string name = System_GetProperty(SYSPROP_NAME); if (KeyMap::HasBuiltinController(name)) { @@ -380,8 +391,19 @@ void Config::Save() { IniFile::Section *control = iniFile.GetOrCreateSection("Control"); control->Set("HapticFeedback", bHapticFeedback); - control->Set("ShowAnalogStick", bShowAnalogStick); + control->Set("ShowTouchControls", bShowTouchControls); + control->Set("ShowTouchCross", bShowTouchCross); + control->Set("ShowTouchCircle", bShowTouchCircle); + control->Set("ShowTouchSquare", bShowTouchSquare); + control->Set("ShowTouchTriangle", bShowTouchTriangle); + control->Set("ShowTouchStart", bShowTouchStart); + control->Set("ShowTouchSelect", bShowTouchSelect); + control->Set("ShowTouchLTrigger", bShowTouchLTrigger); + control->Set("ShowTouchRTrigger", bShowTouchRTrigger); + control->Set("ShowAnalogStick", bShowTouchAnalogStick); + control->Set("ShowTouchUnthrottle", bShowTouchUnthrottle); + // control->Set("KeyMapping",iMappingMap); #ifdef USING_GLES2 control->Set("AccelerometerToAnalogHoriz", bAccelerometerToAnalogHoriz); diff --git a/Core/Config.h b/Core/Config.h index 840fa954d8..ad61c7f1b5 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -105,7 +105,17 @@ public: // Controls bool bShowTouchControls; - bool bShowAnalogStick; + bool bShowTouchCross; + bool bShowTouchCircle; + bool bShowTouchSquare; + bool bShowTouchTriangle; + bool bShowTouchStart; + bool bShowTouchSelect; + bool bShowTouchLTrigger; + bool bShowTouchRTrigger; + bool bShowTouchAnalogStick; + bool bShowTouchUnthrottle; + bool bShowTouchDpad; bool bHapticFeedback; // UI diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 3673265419..a826d507aa 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -29,8 +29,8 @@ #include "UI/MiscScreens.h" #include "UI/ControlMappingScreen.h" #include "UI/DevScreens.h" -//yuck. need a better name #include "UI/TouchControlLayoutScreen.h" +#include "UI/TouchControlVisibilityScreen.h" #include "Core/Config.h" #include "Core/Host.h" @@ -214,9 +214,10 @@ void GameSettingsScreen::CreateViews() { controlsSettings->Add(new ItemHeader(c->T("OnScreen", "On-Screen Touch Controls"))); controlsSettings->Add(new CheckBox(&g_Config.bShowTouchControls, c->T("OnScreen", "On-Screen Touch Controls"))); controlsSettings->Add(new Choice(c->T("Custom layout...")))->OnClick.Handle(this, &GameSettingsScreen::OnTouchControlLayout); + controlsSettings->Add(new Choice("Control Visibility..."))->OnClick.Handle(this, &GameSettingsScreen::OnTouchControlVisibility); 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())); - controlsSettings->Add(new CheckBox(&g_Config.bShowAnalogStick, c->T("Show Left Analog Stick"))); + controlsSettings->Add(new Choice("Control Visibility..."))->OnClick.Handle(this, &GameSettingsScreen::OnTouchControlVisibility); // System ViewGroup *systemSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); @@ -461,6 +462,11 @@ UI::EventReturn GameSettingsScreen::OnTouchControlLayout(UI::EventParams &e){ return UI::EVENT_DONE; }; +UI::EventReturn GameSettingsScreen::OnTouchControlVisibility(UI::EventParams &e){ + screenManager()->push(new TouchControlVisibilityScreen()); + return UI::EVENT_DONE; +}; + void DeveloperToolsScreen::CreateViews() { using namespace UI; root_ = new ScrollView(ORIENT_VERTICAL); diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 77aa17931e..893a99ce96 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -49,6 +49,7 @@ private: // Event handlers UI::EventReturn OnControlMapping(UI::EventParams &e); UI::EventReturn OnTouchControlLayout(UI::EventParams &e); + UI::EventReturn OnTouchControlVisibility(UI::EventParams &e); UI::EventReturn OnDumpNextFrameToLog(UI::EventParams &e); UI::EventReturn OnBack(UI::EventParams &e); UI::EventReturn OnReloadCheats(UI::EventParams &e); diff --git a/UI/GamepadEmu.cpp b/UI/GamepadEmu.cpp index 7b7f768fc4..942eefd83a 100644 --- a/UI/GamepadEmu.cpp +++ b/UI/GamepadEmu.cpp @@ -303,7 +303,7 @@ void InitPadLayout() { int D_pad_X = 2.5 * D_pad_Radius; int D_pad_Y = dp_yres - D_pad_Radius; - if(g_Config.bShowAnalogStick){ + if (g_Config.bShowTouchAnalogStick){ D_pad_Y -= 200 * scale; } @@ -432,28 +432,46 @@ UI::ViewGroup *CreatePadLayout(bool *pause) { if (g_Config.bShowTouchControls) { float scale = g_Config.fButtonScale; +<<<<<<< HEAD #if USE_PAUSE_BUTTON root->Add(new BoolButton(pause, I_ROUND, I_ARROW, scale, new AnchorLayoutParams(halfW, 20, NONE, NONE, true)))->SetAngle(90); #endif +======= + if (g_Config.bShowTouchCircle) +>>>>>>> 86338a5... Add a touch control visibility screen. All touch controls can now be toggled on or off, except for the Pause button on platforms that have it, as a safety precaution. 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_CROSS, I_ROUND, I_CROSS, scale, new AnchorLayoutParams(Action_cross_button_X, Action_cross_button_Y, NONE, NONE, true))); - 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_SQUARE, I_ROUND, I_SQUARE, scale, new AnchorLayoutParams(Action_square_button_X, Action_square_button_Y, NONE, NONE, true))); - 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_SELECT, I_RECT, I_SELECT, scale, new AnchorLayoutParams(select_key_X, select_key_Y, NONE, NONE, true))); - 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); + 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_LTRIGGER, I_SHOULDER, I_L, scale, new AnchorLayoutParams(l_key_X, l_key_Y, NONE, NONE, true))); - root->Add(new PSPButton(CTRL_RTRIGGER, I_SHOULDER, I_R, scale, new AnchorLayoutParams(r_key_X,r_key_Y, NONE, NONE, true)))->FlipImageH(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 PSPCross(I_DIR, I_ARROW, scale, D_pad_Radius, new AnchorLayoutParams(D_pad_X, D_pad_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))); - if (g_Config.bShowAnalogStick) { + 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))); + + 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))); + + 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); + + 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))); + + 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); + + 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))); + + 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))); - } } return root; diff --git a/UI/TouchControlVisibilityScreen.cpp b/UI/TouchControlVisibilityScreen.cpp new file mode 100644 index 0000000000..e8fe19cfb8 --- /dev/null +++ b/UI/TouchControlVisibilityScreen.cpp @@ -0,0 +1,102 @@ +// 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/. + +#include "TouchControlVisibilityScreen.h" +#include "Common/KeyMap.h" +#include "Core/Config.h" +#include "ui/ui_atlas.h" + +#include +#include + +TouchControlVisibilityScreen::TouchControlVisibilityScreen() { + +} + +void TouchControlVisibilityScreen::CreateViews() { + using namespace UI; + + root_ = new ScrollView(ORIENT_VERTICAL); + LinearLayout *vert = root_->Add(new LinearLayout(ORIENT_VERTICAL, new LayoutParams(FILL_PARENT, FILL_PARENT))); + vert->SetSpacing(0); + + LinearLayout *topBar = new LinearLayout(ORIENT_HORIZONTAL); + topBar->Add(new Choice("Back"))->OnClick.Handle(this, &TouchControlVisibilityScreen::OnBack); + topBar->Add(new Choice("Toggle All"))->OnClick.Handle(this, &TouchControlVisibilityScreen::OnToggleAll); + + vert->Add(topBar); + + vert->Add(new ItemHeader("Touch Control Visibility")); + + const int cellSize = 400; + + UI::GridLayoutSettings gridsettings(cellSize, 64, 5); + gridsettings.fillCells = true; + GridLayout *grid = vert->Add(new GridLayout(gridsettings, new LayoutParams(FILL_PARENT, WRAP_CONTENT))); + + std::map keyImages; + keyImages["Circle"] = I_CIRCLE; + keyImages["Cross"] = I_CROSS; + keyImages["Square"] = I_SQUARE; + keyImages["Triangle"] = I_TRIANGLE; + keyImages["Start"] = I_START; + keyImages["Select"] = I_SELECT; + keyImages["L"] = I_L; + keyImages["R"] = I_R; + + std::map keyToggles; + keyToggles["Circle"] = &g_Config.bShowTouchCircle; + keyToggles["Cross"] = &g_Config.bShowTouchCross; + keyToggles["Square"] = &g_Config.bShowTouchSquare; + keyToggles["Triangle"] = &g_Config.bShowTouchTriangle; + keyToggles["L"] = &g_Config.bShowTouchLTrigger; + keyToggles["R"] = &g_Config.bShowTouchRTrigger; + keyToggles["Start"] = &g_Config.bShowTouchStart; + keyToggles["Select"] = &g_Config.bShowTouchSelect; + keyToggles["Dpad"] = &g_Config.bShowTouchDpad; + keyToggles["Analog Stick"] = &g_Config.bShowTouchAnalogStick; + keyToggles["Unthrottle"] = &g_Config.bShowTouchUnthrottle; + + std::map::iterator imageFinder; + + for (auto i = keyToggles.begin(); i != keyToggles.end(); ++i) { + LinearLayout *row = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); + row->SetSpacing(0); + + imageFinder = keyImages.find(i->first); + row->Add(new CheckBox(i->second, "", "", new LinearLayoutParams(50, WRAP_CONTENT))); + + if (imageFinder != keyImages.end()) { + row->Add(new Choice(keyImages[imageFinder->first], new LinearLayoutParams(1.0f))); + } else { + row->Add(new Choice(i->first, new LinearLayoutParams(1.0f))); + } + grid->Add(row); + } +} + +UI::EventReturn TouchControlVisibilityScreen::OnBack(UI::EventParams &e) { + screenManager()->finishDialog(this, DR_OK); + + g_Config.Save(); + + return UI::EVENT_DONE; +} + +UI::EventReturn TouchControlVisibilityScreen::OnToggleAll(UI::EventParams &e) { + return UI::EVENT_DONE; +} diff --git a/UI/TouchControlVisibilityScreen.h b/UI/TouchControlVisibilityScreen.h new file mode 100644 index 0000000000..50abef490b --- /dev/null +++ b/UI/TouchControlVisibilityScreen.h @@ -0,0 +1,39 @@ +// 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/. + +#pragma once + +#include "base/functional.h" +#include "ui/view.h" +#include "MiscScreens.h" +#include + +class TouchControlVisibilityScreen : public UIScreenWithBackground { +public: + TouchControlVisibilityScreen(); + + virtual void CreateViews(); + +protected: + virtual UI::EventReturn OnBack(UI::EventParams &e); + virtual UI::EventReturn OnToggleAll(UI::EventParams &e); + +private: + //DragDropButton *pickedControl_; + //std::vector controls_; + //DragDropButton *getPickedControl(const int x, const int y); +}; \ No newline at end of file From c5c09455591ea5a6bd4d1515bd0b4b95016bef0b Mon Sep 17 00:00:00 2001 From: The Dax Date: Sat, 19 Oct 2013 22:45:58 -0400 Subject: [PATCH 02/10] Adjust a couple styling issues. --- UI/GameSettingsScreen.cpp | 4 ++-- UI/GamepadEmu.cpp | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index a826d507aa..d6ff14d83e 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -457,12 +457,12 @@ UI::EventReturn GameSettingsScreen::OnControlMapping(UI::EventParams &e) { return UI::EVENT_DONE; } -UI::EventReturn GameSettingsScreen::OnTouchControlLayout(UI::EventParams &e){ +UI::EventReturn GameSettingsScreen::OnTouchControlLayout(UI::EventParams &e) { screenManager()->push(new TouchControlLayoutScreen()); return UI::EVENT_DONE; }; -UI::EventReturn GameSettingsScreen::OnTouchControlVisibility(UI::EventParams &e){ +UI::EventReturn GameSettingsScreen::OnTouchControlVisibility(UI::EventParams &e) { screenManager()->push(new TouchControlVisibilityScreen()); return UI::EVENT_DONE; }; diff --git a/UI/GamepadEmu.cpp b/UI/GamepadEmu.cpp index 942eefd83a..65a42ec8c9 100644 --- a/UI/GamepadEmu.cpp +++ b/UI/GamepadEmu.cpp @@ -278,7 +278,7 @@ void InitPadLayout() { //space between the PSP buttons (triangle, circle, square and cross) const int Action_button_spacing = 50 * scale; - if(g_Config.iActionButtonSpacing == -1){ + if (g_Config.iActionButtonSpacing == -1) { g_Config.iActionButtonSpacing = Action_button_spacing; } @@ -297,7 +297,7 @@ void InitPadLayout() { //radius to the D-pad const int D_pad_Radius = 40 * scale; - if(g_Config.iDpadRadius == -1){ + if (g_Config.iDpadRadius == -1){ g_Config.iDpadRadius = D_pad_Radius; } @@ -307,7 +307,7 @@ void InitPadLayout() { D_pad_Y -= 200 * scale; } - if(g_Config.iDpadX == -1 || g_Config.iDpadY == -1 ){ + if(g_Config.iDpadX == -1 || g_Config.iDpadY == -1 ) { //setup defaults g_Config.iDpadX = D_pad_X; g_Config.iDpadY = D_pad_Y; @@ -318,7 +318,7 @@ void InitPadLayout() { int analog_stick_X = D_pad_X; int analog_stick_Y = dp_yres - 80 * scale; - if(g_Config.iAnalogStickX == -1 || g_Config.iAnalogStickY == -1 ){ + if (g_Config.iAnalogStickX == -1 || g_Config.iAnalogStickY == -1 ) { g_Config.iAnalogStickX = analog_stick_X; g_Config.iAnalogStickY = analog_stick_Y; } @@ -330,7 +330,7 @@ void InitPadLayout() { int start_key_X = dp_xres / 2 + (bottom_key_spacing) * scale; int start_key_Y = dp_yres - 60 * scale; - if(g_Config.iStartKeyX == -1 || g_Config.iStartKeyY == -1 ){ + if (g_Config.iStartKeyX == -1 || g_Config.iStartKeyY == -1 ) { g_Config.iStartKeyX = start_key_X; g_Config.iStartKeyY = start_key_Y; } @@ -338,7 +338,7 @@ void InitPadLayout() { int select_key_X = dp_xres / 2; int select_key_Y = dp_yres - 60 * scale; - if (g_Config.iSelectKeyX == -1 || g_Config.iSelectKeyY == -1 ){ + if (g_Config.iSelectKeyX == -1 || g_Config.iSelectKeyY == -1 ) { g_Config.iSelectKeyX = select_key_X; g_Config.iSelectKeyY = select_key_Y; } @@ -346,7 +346,7 @@ void InitPadLayout() { int unthrottle_key_X = dp_xres / 2 - (bottom_key_spacing) * scale; int unthrottle_key_Y = dp_yres - 60 * scale; - if (g_Config.iUnthrottleKeyX == -1 || g_Config.iUnthrottleKeyY == -1 ){ + if (g_Config.iUnthrottleKeyX == -1 || g_Config.iUnthrottleKeyY == -1 ) { g_Config.iUnthrottleKeyX = unthrottle_key_X; g_Config.iUnthrottleKeyY = unthrottle_key_Y; } @@ -355,7 +355,7 @@ void InitPadLayout() { int l_key_X = 70 * scale; int l_key_Y = 40 * scale; - if (g_Config.iLKeyX == -1 || g_Config.iLKeyY == -1 ){ + if (g_Config.iLKeyX == -1 || g_Config.iLKeyY == -1 ) { g_Config.iLKeyX = l_key_X; g_Config.iLKeyY = l_key_Y; } @@ -363,7 +363,7 @@ void InitPadLayout() { int r_key_X = dp_xres - 60 * scale; int r_key_Y = 40 * scale; - if (g_Config.iRKeyX == -1 || g_Config.iRKeyY == -1 ){ + if (g_Config.iRKeyX == -1 || g_Config.iRKeyY == -1 ) { g_Config.iRKeyX = r_key_X; g_Config.iRKeyY = r_key_Y; } From d099692ed0c0cd0c4d2b25f886a23732a8370790 Mon Sep 17 00:00:00 2001 From: The Dax Date: Sat, 19 Oct 2013 23:14:51 -0400 Subject: [PATCH 03/10] Make Toggle All actually function. --- Core/Config.cpp | 21 ++++++++++----------- UI/GameSettingsScreen.cpp | 1 - UI/GamepadEmu.cpp | 8 ++++++-- UI/TouchControlLayoutScreen.cpp | 2 +- UI/TouchControlVisibilityScreen.cpp | 8 +++----- UI/TouchControlVisibilityScreen.h | 8 +++----- 6 files changed, 23 insertions(+), 25 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index b2d3551f7b..e6e8e7ecc0 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -192,16 +192,16 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) IniFile::Section *control = iniFile.GetOrCreateSection("Control"); control->Get("HapticFeedback", &bHapticFeedback, true); control->Get("ShowAnalogStick", &bShowTouchAnalogStick, true); - control->Get("ShowTouchCross", bShowTouchCross); - control->Get("ShowTouchCircle", bShowTouchCircle); - control->Get("ShowTouchSquare", bShowTouchSquare); - control->Get("ShowTouchTriangle", bShowTouchTriangle); - control->Get("ShowTouchStart", bShowTouchStart); - control->Get("ShowTouchSelect", bShowTouchSelect); - control->Get("ShowTouchLTrigger", bShowTouchLTrigger); - control->Get("ShowTouchRTrigger", bShowTouchRTrigger); - control->Get("ShowAnalogStick", bShowTouchAnalogStick); - control->Get("ShowTouchUnthrottle", bShowTouchUnthrottle); + control->Get("ShowTouchCross", &bShowTouchCross); + control->Get("ShowTouchCircle", &bShowTouchCircle); + control->Get("ShowTouchSquare", &bShowTouchSquare); + control->Get("ShowTouchTriangle", &bShowTouchTriangle); + control->Get("ShowTouchStart", &bShowTouchStart); + control->Get("ShowTouchSelect", &bShowTouchSelect); + control->Get("ShowTouchLTrigger", &bShowTouchLTrigger); + control->Get("ShowTouchRTrigger", &bShowTouchRTrigger); + control->Get("ShowAnalogStick", &bShowTouchAnalogStick); + control->Get("ShowTouchUnthrottle", &bShowTouchUnthrottle); #if defined(USING_GLES2) std::string name = System_GetProperty(SYSPROP_NAME); @@ -391,7 +391,6 @@ void Config::Save() { IniFile::Section *control = iniFile.GetOrCreateSection("Control"); control->Set("HapticFeedback", bHapticFeedback); - control->Set("ShowTouchControls", bShowTouchControls); control->Set("ShowTouchCross", bShowTouchCross); control->Set("ShowTouchCircle", bShowTouchCircle); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index d6ff14d83e..defea84d5b 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -217,7 +217,6 @@ void GameSettingsScreen::CreateViews() { controlsSettings->Add(new Choice("Control Visibility..."))->OnClick.Handle(this, &GameSettingsScreen::OnTouchControlVisibility); 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())); - controlsSettings->Add(new Choice("Control Visibility..."))->OnClick.Handle(this, &GameSettingsScreen::OnTouchControlVisibility); // System ViewGroup *systemSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); diff --git a/UI/GamepadEmu.cpp b/UI/GamepadEmu.cpp index 65a42ec8c9..ad64efd5d6 100644 --- a/UI/GamepadEmu.cpp +++ b/UI/GamepadEmu.cpp @@ -286,7 +286,7 @@ void InitPadLayout() { int Action_button_center_X = dp_xres - Action_button_spacing * 2; int Action_button_center_Y = dp_yres - Action_button_spacing * 2; - if(g_Config.iActionButtonCenterX == -1 || g_Config.iActionButtonCenterY == -1 ){ + if(g_Config.iActionButtonCenterX == -1 || g_Config.iActionButtonCenterY == -1 ) { //setup defaults g_Config.iActionButtonCenterX = Action_button_center_X; g_Config.iActionButtonCenterY = Action_button_center_Y; @@ -297,7 +297,7 @@ void InitPadLayout() { //radius to the D-pad const int D_pad_Radius = 40 * scale; - if (g_Config.iDpadRadius == -1){ + if (g_Config.iDpadRadius == -1) { g_Config.iDpadRadius = D_pad_Radius; } @@ -433,12 +433,16 @@ UI::ViewGroup *CreatePadLayout(bool *pause) { float scale = g_Config.fButtonScale; <<<<<<< HEAD +<<<<<<< HEAD #if USE_PAUSE_BUTTON root->Add(new BoolButton(pause, I_ROUND, I_ARROW, scale, new AnchorLayoutParams(halfW, 20, NONE, NONE, true)))->SetAngle(90); #endif ======= +======= + +>>>>>>> 4936897... Make Toggle All actually function. if (g_Config.bShowTouchCircle) >>>>>>> 86338a5... Add a touch control visibility screen. All touch controls can now be toggled on or off, except for the Pause button on platforms that have it, as a safety precaution. root->Add(new PSPButton(CTRL_CIRCLE, I_ROUND, I_CIRCLE, scale, new AnchorLayoutParams(Action_circle_button_X, Action_circle_button_Y, NONE, NONE, true))); diff --git a/UI/TouchControlLayoutScreen.cpp b/UI/TouchControlLayoutScreen.cpp index aab85a125a..e9d6ca9474 100644 --- a/UI/TouchControlLayoutScreen.cpp +++ b/UI/TouchControlLayoutScreen.cpp @@ -272,7 +272,7 @@ void TouchControlLayoutScreen::CreateViews() { rbutton->FlipImageH(true); controls_.push_back(rbutton); - if (g_Config.bShowAnalogStick) { + if (g_Config.bShowTouchAnalogStick) { controls_.push_back(new DragDropButton(g_Config.iAnalogStickX, g_Config.iAnalogStickY, I_STICKBG, I_STICK, scale)); }; I18NCategory *ms = GetI18NCategory("MainSettings"); diff --git a/UI/TouchControlVisibilityScreen.cpp b/UI/TouchControlVisibilityScreen.cpp index e8fe19cfb8..8077d3c472 100644 --- a/UI/TouchControlVisibilityScreen.cpp +++ b/UI/TouchControlVisibilityScreen.cpp @@ -23,10 +23,6 @@ #include #include -TouchControlVisibilityScreen::TouchControlVisibilityScreen() { - -} - void TouchControlVisibilityScreen::CreateViews() { using namespace UI; @@ -58,7 +54,6 @@ void TouchControlVisibilityScreen::CreateViews() { keyImages["L"] = I_L; keyImages["R"] = I_R; - std::map keyToggles; keyToggles["Circle"] = &g_Config.bShowTouchCircle; keyToggles["Cross"] = &g_Config.bShowTouchCross; keyToggles["Square"] = &g_Config.bShowTouchSquare; @@ -98,5 +93,8 @@ UI::EventReturn TouchControlVisibilityScreen::OnBack(UI::EventParams &e) { } UI::EventReturn TouchControlVisibilityScreen::OnToggleAll(UI::EventParams &e) { + for (auto i = keyToggles.begin(); i != keyToggles.end(); ++i) + *i->second = !*i->second; + return UI::EVENT_DONE; } diff --git a/UI/TouchControlVisibilityScreen.h b/UI/TouchControlVisibilityScreen.h index 50abef490b..5b9d880e35 100644 --- a/UI/TouchControlVisibilityScreen.h +++ b/UI/TouchControlVisibilityScreen.h @@ -24,7 +24,7 @@ class TouchControlVisibilityScreen : public UIScreenWithBackground { public: - TouchControlVisibilityScreen(); + TouchControlVisibilityScreen::TouchControlVisibilityScreen() { } virtual void CreateViews(); @@ -33,7 +33,5 @@ protected: virtual UI::EventReturn OnToggleAll(UI::EventParams &e); private: - //DragDropButton *pickedControl_; - //std::vector controls_; - //DragDropButton *getPickedControl(const int x, const int y); -}; \ No newline at end of file + std::map keyToggles; +}; From 3d1f396467e1cfe021e014e03d39364d8a5c62f5 Mon Sep 17 00:00:00 2001 From: The Dax Date: Sat, 19 Oct 2013 23:22:21 -0400 Subject: [PATCH 04/10] Make non-image Choices translatable from the MappableControls section. --- UI/TouchControlVisibilityScreen.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/UI/TouchControlVisibilityScreen.cpp b/UI/TouchControlVisibilityScreen.cpp index 8077d3c472..ce75a74a9d 100644 --- a/UI/TouchControlVisibilityScreen.cpp +++ b/UI/TouchControlVisibilityScreen.cpp @@ -19,6 +19,7 @@ #include "Common/KeyMap.h" #include "Core/Config.h" #include "ui/ui_atlas.h" +#include "i18n/i18n.h" #include #include @@ -68,6 +69,8 @@ void TouchControlVisibilityScreen::CreateViews() { std::map::iterator imageFinder; + I18NCategory *mc = GetI18NCategory("MappableControls"); + for (auto i = keyToggles.begin(); i != keyToggles.end(); ++i) { LinearLayout *row = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); row->SetSpacing(0); @@ -78,7 +81,7 @@ void TouchControlVisibilityScreen::CreateViews() { if (imageFinder != keyImages.end()) { row->Add(new Choice(keyImages[imageFinder->first], new LinearLayoutParams(1.0f))); } else { - row->Add(new Choice(i->first, new LinearLayoutParams(1.0f))); + row->Add(new Choice(mc->T(i->first.c_str()), new LinearLayoutParams(1.0f))); } grid->Add(row); } From 83c70baadaa145529f80aeb508a296028f1236aa Mon Sep 17 00:00:00 2001 From: The Dax Date: Sat, 19 Oct 2013 23:34:00 -0400 Subject: [PATCH 05/10] Add TouchControlVisibility.cpp/h to Visual Studio project "UI". --- UI/UI.vcxproj | 2 ++ UI/UI.vcxproj.filters | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/UI/UI.vcxproj b/UI/UI.vcxproj index 54e9afcd6e..4de78f1d93 100644 --- a/UI/UI.vcxproj +++ b/UI/UI.vcxproj @@ -32,6 +32,7 @@ + @@ -48,6 +49,7 @@ + diff --git a/UI/UI.vcxproj.filters b/UI/UI.vcxproj.filters index da68e560d8..09baf6a7a5 100644 --- a/UI/UI.vcxproj.filters +++ b/UI/UI.vcxproj.filters @@ -34,6 +34,9 @@ Screens + + Screens + @@ -68,6 +71,9 @@ Screens + + Screens + From cdf819c9ebdca49b03319d464ac334052bcb5362 Mon Sep 17 00:00:00 2001 From: The Dax Date: Sat, 19 Oct 2013 23:39:13 -0400 Subject: [PATCH 06/10] Remove rebase junk, update CMakeLists.txt, update Android.mk. --- CMakeLists.txt | 1 + UI/GamepadEmu.cpp | 11 +---------- UI/TouchControlVisibilityScreen.cpp | 4 ++-- android/jni/Android.mk | 1 + 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1bd33d28ea..e635a2d3c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1137,6 +1137,7 @@ set(NativeAppSource UI/GameScreen.cpp UI/GameSettingsScreen.cpp UI/TouchControlLayoutScreen.cpp + UI/TouchControlVisibilityScreen.cpp UI/GamepadEmu.cpp UI/UIShader.cpp UI/OnScreenDisplay.cpp diff --git a/UI/GamepadEmu.cpp b/UI/GamepadEmu.cpp index ad64efd5d6..7eca53adb1 100644 --- a/UI/GamepadEmu.cpp +++ b/UI/GamepadEmu.cpp @@ -303,7 +303,7 @@ void InitPadLayout() { int D_pad_X = 2.5 * D_pad_Radius; int D_pad_Y = dp_yres - D_pad_Radius; - if (g_Config.bShowTouchAnalogStick){ + if (g_Config.bShowTouchAnalogStick) { D_pad_Y -= 200 * scale; } @@ -430,21 +430,12 @@ UI::ViewGroup *CreatePadLayout(bool *pause) { const int halfW = dp_xres / 2; if (g_Config.bShowTouchControls) { - float scale = g_Config.fButtonScale; -<<<<<<< HEAD -<<<<<<< HEAD #if USE_PAUSE_BUTTON root->Add(new BoolButton(pause, I_ROUND, I_ARROW, scale, new AnchorLayoutParams(halfW, 20, NONE, NONE, true)))->SetAngle(90); #endif - -======= -======= - ->>>>>>> 4936897... Make Toggle All actually function. if (g_Config.bShowTouchCircle) ->>>>>>> 86338a5... Add a touch control visibility screen. All touch controls can now be toggled on or off, except for the Pause button on platforms that have it, as a safety precaution. root->Add(new PSPButton(CTRL_CIRCLE, I_ROUND, I_CIRCLE, scale, new AnchorLayoutParams(Action_circle_button_X, Action_circle_button_Y, NONE, NONE, true))); if (g_Config.bShowTouchCross) diff --git a/UI/TouchControlVisibilityScreen.cpp b/UI/TouchControlVisibilityScreen.cpp index ce75a74a9d..aea4d9445a 100644 --- a/UI/TouchControlVisibilityScreen.cpp +++ b/UI/TouchControlVisibilityScreen.cpp @@ -74,10 +74,10 @@ void TouchControlVisibilityScreen::CreateViews() { for (auto i = keyToggles.begin(); i != keyToggles.end(); ++i) { LinearLayout *row = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); row->SetSpacing(0); - - imageFinder = keyImages.find(i->first); row->Add(new CheckBox(i->second, "", "", new LinearLayoutParams(50, WRAP_CONTENT))); + imageFinder = keyImages.find(i->first); + if (imageFinder != keyImages.end()) { row->Add(new Choice(keyImages[imageFinder->first], new LinearLayoutParams(1.0f))); } else { diff --git a/android/jni/Android.mk b/android/jni/Android.mk index 3498f2cf68..500aaaffa2 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -113,6 +113,7 @@ EXEC_AND_LIB_FILES := \ $(SRC)/UI/ControlMappingScreen.cpp \ $(SRC)/UI/GameSettingsScreen.cpp \ $(SRC)/UI/TouchControlLayoutScreen.cpp \ + $(SRC)/UI/TouchControlVisibilityScreen.cpp \ $(SRC)/UI/CwCheatScreen.cpp \ $(SRC)/ext/disarm.cpp \ $(SRC)/ext/libkirk/AES.c \ From 7bfa07137085ce3dfa30da5aa3546309b368ce64 Mon Sep 17 00:00:00 2001 From: The Dax Date: Sat, 19 Oct 2013 23:56:04 -0400 Subject: [PATCH 07/10] Make the header and Control Visibility texts translatable. --- UI/TouchControlVisibilityScreen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UI/TouchControlVisibilityScreen.cpp b/UI/TouchControlVisibilityScreen.cpp index aea4d9445a..43e039802d 100644 --- a/UI/TouchControlVisibilityScreen.cpp +++ b/UI/TouchControlVisibilityScreen.cpp @@ -36,8 +36,8 @@ void TouchControlVisibilityScreen::CreateViews() { topBar->Add(new Choice("Toggle All"))->OnClick.Handle(this, &TouchControlVisibilityScreen::OnToggleAll); vert->Add(topBar); - - vert->Add(new ItemHeader("Touch Control Visibility")); + I18NCategory *co = GetI18NCategory("Control Mapping"); + vert->Add(new ItemHeader(co->T("Touch Control Visibility"))); const int cellSize = 400; From 11a34746cf19f331b3bf6473871282a7eee0e170 Mon Sep 17 00:00:00 2001 From: The Dax Date: Sat, 19 Oct 2013 23:59:57 -0400 Subject: [PATCH 08/10] Default to true for all touch control visibility, and actually translate Control Visibility. --- Core/Config.cpp | 18 +++++++++--------- UI/GameSettingsScreen.cpp | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index e6e8e7ecc0..c8d045ee72 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -192,16 +192,16 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) IniFile::Section *control = iniFile.GetOrCreateSection("Control"); control->Get("HapticFeedback", &bHapticFeedback, true); control->Get("ShowAnalogStick", &bShowTouchAnalogStick, true); - control->Get("ShowTouchCross", &bShowTouchCross); - control->Get("ShowTouchCircle", &bShowTouchCircle); - control->Get("ShowTouchSquare", &bShowTouchSquare); - control->Get("ShowTouchTriangle", &bShowTouchTriangle); - control->Get("ShowTouchStart", &bShowTouchStart); + control->Get("ShowTouchCross", &bShowTouchCross, true); + control->Get("ShowTouchCircle", &bShowTouchCircle, true); + control->Get("ShowTouchSquare", &bShowTouchSquare, true); + control->Get("ShowTouchTriangle", &bShowTouchTriangle, true); + control->Get("ShowTouchStart", &bShowTouchStart, true); control->Get("ShowTouchSelect", &bShowTouchSelect); - control->Get("ShowTouchLTrigger", &bShowTouchLTrigger); - control->Get("ShowTouchRTrigger", &bShowTouchRTrigger); - control->Get("ShowAnalogStick", &bShowTouchAnalogStick); - control->Get("ShowTouchUnthrottle", &bShowTouchUnthrottle); + control->Get("ShowTouchLTrigger", &bShowTouchLTrigger, true); + control->Get("ShowTouchRTrigger", &bShowTouchRTrigger, true); + control->Get("ShowAnalogStick", &bShowTouchAnalogStick, true); + control->Get("ShowTouchUnthrottle", &bShowTouchUnthrottle, true); #if defined(USING_GLES2) std::string name = System_GetProperty(SYSPROP_NAME); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index defea84d5b..56cd34e4fa 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -214,7 +214,7 @@ void GameSettingsScreen::CreateViews() { controlsSettings->Add(new ItemHeader(c->T("OnScreen", "On-Screen Touch Controls"))); controlsSettings->Add(new CheckBox(&g_Config.bShowTouchControls, c->T("OnScreen", "On-Screen Touch Controls"))); controlsSettings->Add(new Choice(c->T("Custom layout...")))->OnClick.Handle(this, &GameSettingsScreen::OnTouchControlLayout); - controlsSettings->Add(new Choice("Control Visibility..."))->OnClick.Handle(this, &GameSettingsScreen::OnTouchControlVisibility); + controlsSettings->Add(new Choice(c->T("Control Visibility...")))->OnClick.Handle(this, &GameSettingsScreen::OnTouchControlVisibility); 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())); From d18253e7d5e6e37f83a971c36e565e5da76e48bb Mon Sep 17 00:00:00 2001 From: The Dax Date: Sun, 20 Oct 2013 00:12:55 -0400 Subject: [PATCH 09/10] Fix Android build, adjust includes. --- UI/TouchControlVisibilityScreen.cpp | 4 ---- UI/TouchControlVisibilityScreen.h | 7 +++---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/UI/TouchControlVisibilityScreen.cpp b/UI/TouchControlVisibilityScreen.cpp index 43e039802d..c7593bc128 100644 --- a/UI/TouchControlVisibilityScreen.cpp +++ b/UI/TouchControlVisibilityScreen.cpp @@ -16,14 +16,10 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include "TouchControlVisibilityScreen.h" -#include "Common/KeyMap.h" #include "Core/Config.h" #include "ui/ui_atlas.h" #include "i18n/i18n.h" -#include -#include - void TouchControlVisibilityScreen::CreateViews() { using namespace UI; diff --git a/UI/TouchControlVisibilityScreen.h b/UI/TouchControlVisibilityScreen.h index 5b9d880e35..248dffed53 100644 --- a/UI/TouchControlVisibilityScreen.h +++ b/UI/TouchControlVisibilityScreen.h @@ -17,14 +17,13 @@ #pragma once -#include "base/functional.h" -#include "ui/view.h" #include "MiscScreens.h" -#include + +#include class TouchControlVisibilityScreen : public UIScreenWithBackground { public: - TouchControlVisibilityScreen::TouchControlVisibilityScreen() { } + TouchControlVisibilityScreen() { } virtual void CreateViews(); From fc64b9a64f4116e5735120eab107381d9481091c Mon Sep 17 00:00:00 2001 From: The Dax Date: Sun, 20 Oct 2013 00:36:05 -0400 Subject: [PATCH 10/10] Make the text and images centered. --- UI/TouchControlVisibilityScreen.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/UI/TouchControlVisibilityScreen.cpp b/UI/TouchControlVisibilityScreen.cpp index c7593bc128..dd3932942e 100644 --- a/UI/TouchControlVisibilityScreen.cpp +++ b/UI/TouchControlVisibilityScreen.cpp @@ -73,11 +73,16 @@ void TouchControlVisibilityScreen::CreateViews() { row->Add(new CheckBox(i->second, "", "", new LinearLayoutParams(50, WRAP_CONTENT))); imageFinder = keyImages.find(i->first); - + Choice *choice; + if (imageFinder != keyImages.end()) { - row->Add(new Choice(keyImages[imageFinder->first], new LinearLayoutParams(1.0f))); + choice = new Choice(keyImages[imageFinder->first], new LinearLayoutParams(1.0f)); + choice->SetCentered(true); + row->Add(choice); } else { - row->Add(new Choice(mc->T(i->first.c_str()), new LinearLayoutParams(1.0f))); + choice = new Choice(mc->T(i->first.c_str()), new LinearLayoutParams(1.0f)); + choice->SetCentered(true); + row->Add(choice); } grid->Add(row); }