Add option for very transparent touch buttons

This commit is contained in:
Henrik Rydgård 2013-06-17 20:28:22 +02:00
parent 490f841093
commit c4abec3560
7 changed files with 32 additions and 23 deletions

View File

@ -25,18 +25,12 @@
Config g_Config;
#ifdef IOS
extern bool isJailed;
#endif
Config::Config()
{
}
Config::~Config()
{
}
Config::Config() { }
Config::~Config() { }
void Config::Load(const char *iniFileName)
{
@ -143,6 +137,7 @@ void Config::Load(const char *iniFileName)
control->Get("AccelerometerToAnalogHoriz", &bAccelerometerToAnalogHoriz, false);
control->Get("ForceInputDevice", &iForceInputDevice, -1);
control->Get("RightStickBind", &iRightStickBind, 0);
control->Get("TouchButtonOpacity", &iTouchButtonOpacity, 65);
IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam");
pspConfig->Get("NickName", &sNickName, "shadow");
@ -236,6 +231,7 @@ void Config::Save()
control->Set("AccelerometerToAnalogHoriz", bAccelerometerToAnalogHoriz);
control->Set("ForceInputDevice", iForceInputDevice);
control->Set("RightStickBind", iRightStickBind);
control->Set("TouchButtonOpacity", iTouchButtonOpacity);
IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam");

View File

@ -90,7 +90,7 @@ public:
// Sound
bool bEnableSound;
bool bEnableAtrac3plus;
// UI
bool bShowTouchControls;
bool bShowDebuggerOnLoad;
@ -109,6 +109,7 @@ public:
// Control
std::map<int,int> iMappingMap; // Can be used differently depending on systems
int iForceInputDevice;
int iTouchButtonOpacity;
// SystemParam
std::string sNickName;

View File

@ -795,7 +795,7 @@ int PSPOskDialog::Update()
selectedChar = (selectedChar + (numKeyCols[currentKeyboard] * numKeyRows[currentKeyboard])) % (numKeyCols[currentKeyboard] * numKeyRows[currentKeyboard]);
if (IsButtonPressed(CTRL_CROSS) && g_Config.bButtonPreference || IsButtonPressed(CTRL_CIRCLE) && !g_Config.bButtonPreference)
if ((IsButtonPressed(CTRL_CROSS) && g_Config.bButtonPreference) || (IsButtonPressed(CTRL_CIRCLE) && !g_Config.bButtonPreference))
{
inputChars = CombinationString(true);
}
@ -816,7 +816,7 @@ int PSPOskDialog::Update()
selectedChar = selectedRow * numKeyCols[currentKeyboard] + selectedExtra;
}
else if (IsButtonPressed(CTRL_CIRCLE) && g_Config.bButtonPreference || IsButtonPressed(CTRL_CROSS) && !g_Config.bButtonPreference)
else if ((IsButtonPressed(CTRL_CIRCLE) && g_Config.bButtonPreference) || (IsButtonPressed(CTRL_CROSS) && !g_Config.bButtonPreference))
{
if (inputChars.size() > 0)
{

View File

@ -233,12 +233,15 @@ void EmuScreen::update(InputState &input) {
__CtrlSetAnalog(rightstick_x, rightstick_x, 1);
if (PSP_CoreParameter().fpsLimit != 2) {
// Don't really need to show these, it's pretty obvious what unthrottle does,
// in contrast to the three state toggle
/*
if (input.pad_buttons_down & PAD_BUTTON_UNTHROTTLE) {
osm.Show(s->T("unlimited", "Speed: unlimited!"), 1.0, 0x50E0FF);
}
if (input.pad_buttons_up & PAD_BUTTON_UNTHROTTLE) {
osm.Show(s->T("standard", "Speed: standard"), 1.0);
}
}*/
}
if (input.pad_buttons & PAD_BUTTON_UNTHROTTLE) {
PSP_CoreParameter().unthrottle = true;
@ -249,22 +252,22 @@ void EmuScreen::update(InputState &input) {
if (PSP_CoreParameter().fpsLimit != 0 && PSP_CoreParameter().fpsLimit != 1 && PSP_CoreParameter().fpsLimit != 2) {
PSP_CoreParameter().fpsLimit = 0;
}
//Toggle between 3 different states of fpsLimit
if (input.pad_buttons_down & PAD_BUTTON_LEFT_THUMB) {
if (PSP_CoreParameter().fpsLimit == 0) {
PSP_CoreParameter().fpsLimit = 1;
osm.Show(s->T("fixed", "Speed: fixed"), 1.0);
}
else if (PSP_CoreParameter().fpsLimit == 1){
else if (PSP_CoreParameter().fpsLimit == 1) {
PSP_CoreParameter().fpsLimit = 2;
osm.Show(s->T("unlimited", "Speed: unlimited!"), 1.0, 0x50E0FF);
}
else if (PSP_CoreParameter().fpsLimit == 2){
else if (PSP_CoreParameter().fpsLimit == 2) {
PSP_CoreParameter().fpsLimit = 0;
osm.Show(s->T("standard", "Speed: standard"), 1.0);
}
}
if (input.pad_buttons_down & (PAD_BUTTON_MENU | PAD_BUTTON_BACK | PAD_BUTTON_RIGHT_THUMB)) {
if (g_Config.bBufferedRendering)
@ -313,8 +316,9 @@ void EmuScreen::render() {
ui_draw2d.Begin(UIShader_Get(), DBMODE_NORMAL);
float touchOpacity = g_Config.iTouchButtonOpacity / 100.0f;
if (g_Config.bShowTouchControls)
DrawGamepad(ui_draw2d);
DrawGamepad(ui_draw2d, touchOpacity);
DrawWatermark();

View File

@ -16,8 +16,9 @@
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "GamepadEmu.h"
#include "base/colorutil.h"
#include "ui/virtual_input.h"
#include "../../Core/Config.h"
#include "Core/Config.h"
#include "ui_atlas.h"
TouchButton buttonX(&ui_atlas, I_ROUND, I_CROSS, PAD_BUTTON_A);
@ -112,10 +113,11 @@ void UpdateGamepad(InputState &input_state)
leftStick.update(input_state);
}
void DrawGamepad(DrawBuffer &db)
void DrawGamepad(DrawBuffer &db, float opacity)
{
uint32_t color = 0xa0c0b080;
uint32_t colorOverlay = 0xa0FFFFFF;
uint32_t color = colorAlpha(0xc0b080, opacity);
uint32_t colorOverlay = colorAlpha(0xFFFFFF, opacity);
buttonO.draw(db, color, colorOverlay);
buttonX.draw(db, color, colorOverlay);
buttonTri.draw(db, color, colorOverlay);

View File

@ -22,4 +22,4 @@
void LayoutGamepad(int w, int h);
void UpdateGamepad(InputState &input_state);
void DrawGamepad(DrawBuffer &db);
void DrawGamepad(DrawBuffer &db, float opacity);

View File

@ -658,7 +658,7 @@ void DeveloperScreen::render() {
}
if (UIButton(GEN_ID, vlinear, w, 0, d->T("Save language ini"), ALIGN_LEFT)) {
i18nrepo.SaveIni(g_Config.languageIni);
i18nrepo.SaveIni(g_Config.languageIni);
}
if (UIButton(GEN_ID, vlinear, w, 0, d->T("Run CPU tests"), ALIGN_LEFT)) {
@ -1119,7 +1119,13 @@ void ControlsScreen::render() {
if (g_Config.bShowTouchControls) {
UICheckBox(GEN_ID, x, y += stride, c->T("Large Controls"), ALIGN_TOPLEFT, &g_Config.bLargeControls);
UICheckBox(GEN_ID, x, y += stride, c->T("Show Analog Stick"), ALIGN_TOPLEFT, &g_Config.bShowAnalogStick);
}
// This will be a slider in the new UI later
bool bTransparent = g_Config.iTouchButtonOpacity < 30;
bool prev = bTransparent;
UICheckBox(GEN_ID, x, y += stride, c->T("Transparent Buttons"), ALIGN_TOPLEFT, &bTransparent);
if (bTransparent != prev)
g_Config.iTouchButtonOpacity = bTransparent ? 15 : 65;
}
UICheckBox(GEN_ID, x, y += stride, c->T("Tilt", "Tilt to Analog (horizontal)"), ALIGN_TOPLEFT, &g_Config.bAccelerometerToAnalogHoriz);
UIEnd();