Permalink
Browse files

Implement on-screen touch combo keys.

Replace A,B,cross1,square1,triangle1 with number images 1-6

Rebuild the atlas, update the code to use combo keys 1-5

Also add psp_display.png from pull request #8082.
  • Loading branch information...
1 parent 6a373fe commit 14e7658bbb88f38570ed2e16ef5efacf8d43ad23 @xiushudongfang xiushudongfang committed with Jun 28, 2015
View
@@ -32,6 +32,7 @@ ext/_Output
android/lint.xml
PPSSPPWindows64.exe.manifest
PPSSPPWindows.exe.manifest
+assets/flash0
# For Mac
.DS_Store
View
@@ -864,7 +864,8 @@ set(NativeAppSource
UI/CwCheatScreen.cpp
UI/InstallZipScreen.cpp
UI/ProfilerDraw.cpp
- UI/ui_atlas.cpp)
+ UI/ui_atlas.cpp
+ UI/ComboKeyMappingScreen.cpp)
if(ANDROID)
if (ARM)
set(NativeAppSource ${NativeAppSource} android/jni/ArmEmitterTest.cpp)
View
@@ -302,6 +302,7 @@ static ConfigSetting generalSettings[] = {
ConfigSetting("GridView1", &g_Config.bGridView1, true),
ConfigSetting("GridView2", &g_Config.bGridView2, true),
ConfigSetting("GridView3", &g_Config.bGridView3, false),
+ ConfigSetting("ComboMode", &g_Config.iComboMode, 0),
// "default" means let emulator decide, "" means disable.
ConfigSetting("ReportingHost", &g_Config.sReportHost, "default"),
@@ -515,6 +516,18 @@ static ConfigSetting controlSettings[] = {
ConfigSetting("ShowAnalogStick", &g_Config.bShowTouchAnalogStick, true, true, true),
ConfigSetting("ShowTouchDpad", &g_Config.bShowTouchDpad, true, true, true),
ConfigSetting("ShowTouchUnthrottle", &g_Config.bShowTouchUnthrottle, true, true, true),
+
+ ConfigSetting("ShowComboKey0", &g_Config.bShowComboKey0, false, true, true),
+ ConfigSetting("ShowComboKey1", &g_Config.bShowComboKey1, false, true, true),
+ ConfigSetting("ShowComboKey2", &g_Config.bShowComboKey2, false, true, true),
+ ConfigSetting("ShowComboKey3", &g_Config.bShowComboKey3, false, true, true),
+ ConfigSetting("ShowComboKey4", &g_Config.bShowComboKey4, false, true, true),
+ ConfigSetting("ComboKey0Mapping", &g_Config.iCombokey0, 0, true, true),
+ ConfigSetting("ComboKey1Mapping", &g_Config.iCombokey1, 0, true, true),
+ ConfigSetting("ComboKey2Mapping", &g_Config.iCombokey2, 0, true, true),
+ ConfigSetting("ComboKey3Mapping", &g_Config.iCombokey3, 0, true, true),
+ ConfigSetting("ComboKey4Mapping", &g_Config.iCombokey4, 0, true, true),
+
#if !defined(__SYMBIAN32__) && !defined(IOS) && !defined(MAEMO)
#if defined(_WIN32)
// A win32 user seeing touch controls is likely using PPSSPP on a tablet. There it makes
@@ -576,6 +589,22 @@ static ConfigSetting controlSettings[] = {
ConfigSetting("AnalogStickX", &g_Config.fAnalogStickX, -1.0f, true, true),
ConfigSetting("AnalogStickY", &g_Config.fAnalogStickY, -1.0f, true, true),
ConfigSetting("AnalogStickScale", &g_Config.fAnalogStickScale, defaultControlScale, true, true),
+
+ ConfigSetting("fcombo0X", &g_Config.fcombo0X, -1.0f, true, true),
+ ConfigSetting("fcombo0Y", &g_Config.fcombo0Y, -1.0f, true, true),
+ ConfigSetting("comboKeyScale0", &g_Config.fcomboScale0, defaultControlScale, true, true),
+ ConfigSetting("fcombo1X", &g_Config.fcombo1X, -1.0f, true, true),
+ ConfigSetting("fcombo1Y", &g_Config.fcombo1Y, -1.0f, true, true),
+ ConfigSetting("comboKeyScale1", &g_Config.fcomboScale1, defaultControlScale, true, true),
+ ConfigSetting("fcombo2X", &g_Config.fcombo2X, -1.0f, true, true),
+ ConfigSetting("fcombo2Y", &g_Config.fcombo2Y, -1.0f, true, true),
+ ConfigSetting("comboKeyScale2", &g_Config.fcomboScale2, defaultControlScale, true, true),
+ ConfigSetting("fcombo3X", &g_Config.fcombo3X, -1.0f, true, true),
+ ConfigSetting("fcombo3Y", &g_Config.fcombo3Y, -1.0f, true, true),
+ ConfigSetting("comboKeyScale3", &g_Config.fcomboScale3, defaultControlScale, true, true),
+ ConfigSetting("fcombo4X", &g_Config.fcombo4X, -1.0f, true, true),
+ ConfigSetting("fcombo4Y", &g_Config.fcombo4Y, -1.0f, true, true),
+ ConfigSetting("comboKeyScale4", &g_Config.fcomboScale4, defaultControlScale, true, true),
#ifdef _WIN32
ConfigSetting("DInputAnalogDeadzone", &g_Config.fDInputAnalogDeadzone, 0.1f, true, true),
ConfigSetting("DInputAnalogInverseMode", &g_Config.iDInputAnalogInverseMode, 0, true, true),
@@ -830,6 +859,16 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
fRKeyY /= screen_height;
fAnalogStickX /= screen_width;
fAnalogStickY /= screen_height;
+ fcombo0X /= screen_width;
+ fcombo0Y /= screen_height;
+ fcombo1X /= screen_width;
+ fcombo1Y /= screen_height;
+ fcombo2X /= screen_width;
+ fcombo2Y /= screen_height;
+ fcombo3X /= screen_width;
+ fcombo3Y /= screen_height;
+ fcombo4X /= screen_width;
+ fcombo4Y /= screen_height;
}
const char *gitVer = PPSSPP_GIT_VERSION;
@@ -1242,6 +1281,21 @@ void Config::ResetControlLayout() {
g_Config.fAnalogStickX = -1.0;
g_Config.fAnalogStickY = -1.0;
g_Config.fAnalogStickScale = defaultControlScale;
+ g_Config.fcombo0X = -1.0;
+ g_Config.fcombo0Y = -1.0;
+ g_Config.fcomboScale0 = defaultControlScale;
+ g_Config.fcombo1X = -1.0f;
+ g_Config.fcombo1Y = -1.0f;
+ g_Config.fcomboScale1 = defaultControlScale;
+ g_Config.fcombo2X = -1.0f;
+ g_Config.fcombo2Y = -1.0f;
+ g_Config.fcomboScale2 = defaultControlScale;
+ g_Config.fcombo3X = -1.0f;
+ g_Config.fcombo3Y = -1.0f;
+ g_Config.fcomboScale3 = defaultControlScale;
+ g_Config.fcombo4X = -1.0f;
+ g_Config.fcombo4Y = -1.0f;
+ g_Config.fcomboScale4 = defaultControlScale;
}
void Config::GetReportingInfo(UrlEncoder &data) {
View
@@ -231,6 +231,8 @@ struct Config {
bool bGridView1;
bool bGridView2;
bool bGridView3;
+ //Combo key screen flag
+ int iComboMode;
// Disable diagonals
bool bDisableDpadDiagonals;
@@ -273,6 +275,18 @@ struct Config {
float fAnalogStickX, fAnalogStickY;
float fAnalogStickScale;
+ //the Combo Button position
+ float fcombo0X, fcombo0Y;
+ float fcomboScale0;
+ float fcombo1X, fcombo1Y;
+ float fcomboScale1;
+ float fcombo2X, fcombo2Y;
+ float fcomboScale2;
+ float fcombo3X, fcombo3Y;
+ float fcomboScale3;
+ float fcombo4X, fcombo4Y;
+ float fcomboScale4;
+
// Controls Visibility
bool bShowTouchControls;
@@ -291,6 +305,20 @@ struct Config {
bool bShowTouchAnalogStick;
bool bShowTouchDpad;
+ //Combo Button Visibility
+ bool bShowComboKey0;
+ bool bShowComboKey1;
+ bool bShowComboKey2;
+ bool bShowComboKey3;
+ bool bShowComboKey4;
+
+ // Combo_key mapping. These are bitfields.
+ int iCombokey0;
+ int iCombokey1;
+ int iCombokey2;
+ int iCombokey3;
+ int iCombokey4;
+
#if !defined(__SYMBIAN32__) && !defined(IOS) && !defined(MAEMO)
bool bShowTouchPause;
#endif
@@ -0,0 +1,201 @@
+// 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 "Core/Config.h"
+#include "UI/ui_atlas.h"
+#include "i18n/i18n.h"
+#include "ComboKeyMappingScreen.h"
+#include "base/colorutil.h"
+#include "base/display.h"
+#include "base/timeutil.h"
+#include "file/path.h"
+#include "gfx_es2/draw_buffer.h"
+#include "math/curves.h"
+#include "base/stringutil.h"
+#include "ui/ui_context.h"
+#include "ui/view.h"
+#include "ui/viewgroup.h"
+
+void Combo_keyScreen::CreateViews() {
+ using namespace UI;
+ I18NCategory *co = GetI18NCategory("Controls");
+ root_ = new LinearLayout(ORIENT_VERTICAL);
+ root_->Add(new ItemHeader(co->T("Combo Key Setting")));
+ LinearLayout *root__ = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
+ root_->Add(root__);
+ LinearLayout *leftColumn = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(120, FILL_PARENT));
+ I18NCategory *di = GetI18NCategory("Dialog");
+
+ static const int comboKeyImages[5] = {
+ I_1, I_2, I_3, I_4, I_5,
+ };
+
+ comboselect = new ChoiceStrip(ORIENT_VERTICAL, new AnchorLayoutParams(10, 10, NONE, NONE));
+ comboselect->SetSpacing(10);
+ for (int i = 0; i < 5; i++) {
+ comboselect->AddChoice(comboKeyImages[i]);
+ }
+ comboselect->SetSelection(*mode);
+ comboselect->OnChoice.Handle(this, &Combo_keyScreen::onCombo);
+ leftColumn->Add(comboselect);
+ root__->Add(leftColumn);
+ rightScroll_ = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(1.0f));
+ LinearLayout *rightColumn = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(1.0f));
+ rightScroll_->Add(rightColumn);
+ leftColumn->Add(new Spacer(new LinearLayoutParams(1.0f)));
+ leftColumn->Add(new Choice(di->T("Back")))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
+ root__->Add(rightScroll_);
+
+ const int cellSize = 400;
+
+ UI::GridLayoutSettings gridsettings(cellSize, 64, 5);
+ gridsettings.fillCells = true;
+ GridLayout *grid = rightColumn->Add(new GridLayout(gridsettings, new LayoutParams(FILL_PARENT, WRAP_CONTENT)));
+
+ memset(array, 0, sizeof(array));
+ switch (*mode) {
+ case 0:
+ for (int i = 0; i < 16; i++)
+ array[i] = (0x01 == ((g_Config.iCombokey0 >> i) & 0x01));
+ break;
+ case 1:
+ for (int i = 0; i < 16; i++)
+ array[i] = (0x01 == ((g_Config.iCombokey1 >> i) & 0x01));
+ break;
+ case 2:
+ for (int i = 0; i < 16; i++)
+ array[i] = (0x01 == ((g_Config.iCombokey2 >> i) & 0x01));
+ break;
+ case 3:
+ for (int i = 0; i < 16; i++)
+ array[i] = (0x01 == ((g_Config.iCombokey3 >> i) & 0x01));
+ break;
+ case 4:
+ for (int i = 0; i < 16; i++)
+ array[i] = (0x01 == ((g_Config.iCombokey4 >> i) & 0x01));
+ break;
+ }
+
+ std::map<std::string, int> keyImages;
+ keyImages["Circle"] = I_CIRCLE;
+ keyImages["Cross"] = I_CROSS;
+ keyImages["Square"] = I_SQUARE;
+ keyImages["Triangle"] = I_TRIANGLE;
+ keyImages["L"] = I_L;
+ keyImages["R"] = I_R;
+ keyImages["Start"] = I_START;
+ keyImages["Select"] = I_SELECT;
+ keyToggles["Circle"] = &array[13];
+ keyToggles["Cross"] = &array[14];
+ keyToggles["Square"] = &array[15];
+ keyToggles["Triangle"] = &array[12];
+ keyToggles["L"] = &array[8];
+ keyToggles["R"] = &array[9];
+ keyToggles[co->T("Left")] = &array[7];
+ keyToggles[co->T("Up")] = &array[4];
+ keyToggles[co->T("Right")] = &array[5];
+ keyToggles[co->T("Down")] = &array[6];
+ keyToggles["Start"] = &array[3];
+ keyToggles["Select"] = &array[0];
+
+ std::map<std::string, int>::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);
+
+ CheckBox *checkbox = new CheckBox(i->second, "", "", new LinearLayoutParams(50, WRAP_CONTENT));
+ row->Add(checkbox);
+
+ imageFinder = keyImages.find(i->first);
+ Choice *choice;
+ if (imageFinder != keyImages.end()) {
+ choice = new Choice(keyImages[imageFinder->first], new LinearLayoutParams(1.0f));
+ }
+ else {
+ choice = new Choice(mc->T(i->first.c_str()), new LinearLayoutParams(1.0f));
+ }
+
+ ChoiceEventHandler *choiceEventHandler = new ChoiceEventHandler(checkbox);
+ choice->OnClick.Handle(choiceEventHandler, &ChoiceEventHandler::onChoiceClick);
+
+ choice->SetCentered(true);
+
+ row->Add(choice);
+ grid->Add(row);
+
+ }
+}
+
+static int arrayToInt(bool ary[16]) {
+ int value = 0;
+ for (int i = 15; i >= 0; i--) {
+ value |= ary[i] ? 1 : 0;
+ value = value << 1;
+ }
+ return value >> 1;
+}
+
+void Combo_keyScreen::onFinish(DialogResult result) {
+ switch (*mode) {
+ case 0:
+ g_Config.iCombokey0 = arrayToInt(array);
+ break;
+ case 1:
+ g_Config.iCombokey1 = arrayToInt(array);
+ break;
+ case 2:
+ g_Config.iCombokey2 = arrayToInt(array);
+ break;
+ case 3:
+ g_Config.iCombokey3 = arrayToInt(array);
+ break;
+ case 4:
+ g_Config.iCombokey4 = arrayToInt(array);
+ break;
+ }
+ g_Config.Save();
+}
+
+UI::EventReturn Combo_keyScreen::ChoiceEventHandler::onChoiceClick(UI::EventParams &e){
+ checkbox_->Toggle();
+
+
+ return UI::EVENT_DONE;
+};
+
+UI::EventReturn Combo_keyScreen::onCombo(UI::EventParams &e) {
+ switch (*mode){
+ case 0:g_Config.iCombokey0 = arrayToInt(array);
+ break;
+ case 1:g_Config.iCombokey1 = arrayToInt(array);
+ break;
+ case 2:g_Config.iCombokey2 = arrayToInt(array);
+ break;
+ case 3:g_Config.iCombokey3 = arrayToInt(array);
+ break;
+ case 4:g_Config.iCombokey4 = arrayToInt(array);
+ }
+ *mode = comboselect->GetSelection();
+ CreateViews();
+ return UI::EVENT_DONE;
+}
+
+
Oops, something went wrong.

0 comments on commit 14e7658

Please sign in to comment.