Skip to content
Permalink
Browse files

Merge pull request #12300 from hrydgard/assorted-defaults

Some defaults and fixes
  • Loading branch information...
unknownbrackets committed Sep 2, 2019
2 parents 57c6ab7 + 90de634 commit 9db48075769d37076429404ec4b7fee2e9084c0c
Showing with 76 additions and 43 deletions.
  1. +44 −11 Common/KeyMap.cpp
  2. +2 −0 Common/KeyMap.h
  3. +8 −13 Core/Config.cpp
  4. +16 −17 UI/ControlMappingScreen.cpp
  5. +3 −0 UI/DevScreens.cpp
  6. +3 −2 Windows/MainWindow.cpp
@@ -15,23 +15,24 @@
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.

#include <set>
#include <algorithm>

#if defined(SDL)
#include <SDL_keyboard.h>
#elif defined(USING_WIN_UI)
#include "CommonWindows.h"
#endif
#include <set>

#include "base/logging.h"
#include "base/NativeApp.h"
#include "file/ini_file.h"
#include "input/input_state.h"
#include "ppsspp_config.h"

#include "KeyMap.h"
#include "../Core/HLE/sceUtility.h"
#include "../Core/Config.h"

#include <algorithm>
#include "Core/HLE/sceUtility.h"
#include "Core/Config.h"

namespace KeyMap {

@@ -184,6 +185,27 @@ static const DefMappingStruct defaultShieldKeyMap[] = {
{VIRTKEY_PAUSE, NKCODE_BACK },
};

static const DefMappingStruct defaultMOQI7SKeyMap[] = {
{CTRL_CROSS, NKCODE_BUTTON_A},
{CTRL_CIRCLE, NKCODE_BUTTON_B},
{CTRL_SQUARE, NKCODE_BUTTON_X},
{CTRL_TRIANGLE, NKCODE_BUTTON_Y},
{CTRL_START, JOYSTICK_AXIS_Z, +1},
{CTRL_SELECT, JOYSTICK_AXIS_Z, -1},
{CTRL_LTRIGGER, NKCODE_BUTTON_L1},
{CTRL_RTRIGGER, NKCODE_BUTTON_R1},
{VIRTKEY_AXIS_X_MIN, JOYSTICK_AXIS_X, -1},
{VIRTKEY_AXIS_X_MAX, JOYSTICK_AXIS_X, +1},
{VIRTKEY_AXIS_Y_MIN, JOYSTICK_AXIS_Y, +1},
{VIRTKEY_AXIS_Y_MAX, JOYSTICK_AXIS_Y, -1},
{CTRL_LEFT, JOYSTICK_AXIS_HAT_X, -1},
{CTRL_RIGHT, JOYSTICK_AXIS_HAT_X, +1},
{CTRL_UP, JOYSTICK_AXIS_HAT_Y, -1},
{CTRL_DOWN, JOYSTICK_AXIS_HAT_Y, +1},
{VIRTKEY_UNTHROTTLE, JOYSTICK_AXIS_RZ, +1 },
{VIRTKEY_PAUSE, NKCODE_BACK },
};

static const DefMappingStruct defaultPadMap[] = {
#if defined(__ANDROID__)
{CTRL_CROSS , NKCODE_BUTTON_A},
@@ -384,6 +406,9 @@ void SetDefaultKeyMap(DefaultMaps dmap, bool replace) {
case DEFAULT_MAPPING_SHIELD:
SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultShieldKeyMap, ARRAY_SIZE(defaultShieldKeyMap), replace);
break;
case DEFAULT_MAPPING_MOQI_I7S:
SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultMOQI7SKeyMap, ARRAY_SIZE(defaultMOQI7SKeyMap), replace);
break;
case DEFAULT_MAPPING_PAD:
SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultPadMap, ARRAY_SIZE(defaultPadMap), replace);
break;
@@ -853,20 +878,24 @@ void SetAxisMapping(int btn, int deviceId, int axisId, int direction, bool repla
// Note that it's easy to add other defaults if desired.
void RestoreDefault() {
g_controllerMap.clear();
#if defined(_WIN32)
#if PPSSPP_PLATFORM(WINDOWS)
SetDefaultKeyMap(DEFAULT_MAPPING_KEYBOARD, true);
SetDefaultKeyMap(DEFAULT_MAPPING_X360, false);
SetDefaultKeyMap(DEFAULT_MAPPING_PAD, false);
#elif defined(__ANDROID__)
// Autodetect a few common devices
#elif PPSSPP_PLATFORM(ANDROID)
// Autodetect a few common (and less common) devices
std::string name = System_GetProperty(SYSPROP_NAME);
if (IsNvidiaShield(name) || IsNvidiaShieldTV(name)) {
SetDefaultKeyMap(DEFAULT_MAPPING_SHIELD, true);
} else if (IsOuya(name)) { // TODO: check!
} else if (IsOuya(name)) {
SetDefaultKeyMap(DEFAULT_MAPPING_OUYA, true);
} else if (IsXperiaPlay(name)) {
SetDefaultKeyMap(DEFAULT_MAPPING_XPERIA_PLAY, true);
} else if (IsMOQII7S(name)) {
ILOG("MOQI pad map");
SetDefaultKeyMap(DEFAULT_MAPPING_MOQI_I7S, true);
} else {
ILOG("Default pad map");
SetDefaultKeyMap(DEFAULT_MAPPING_PAD, true);
}
#else
@@ -944,16 +973,20 @@ bool IsXperiaPlay(const std::string &name) {
return name == "Sony Ericsson:R800a" || name == "Sony Ericsson:R800i" || name == "Sony Ericsson:R800x" || name == "Sony Ericsson:R800at" || name == "Sony Ericsson:SO-01D" || name == "Sony Ericsson:zeus";
}

bool IsMOQII7S(const std::string &name) {
return name == "MOQI:I7S";
}

bool HasBuiltinController(const std::string &name) {
return IsOuya(name) || IsXperiaPlay(name) || IsNvidiaShield(name);
return IsOuya(name) || IsXperiaPlay(name) || IsNvidiaShield(name) || IsMOQII7S(name);
}

void NotifyPadConnected(const std::string &name) {
g_seenPads.insert(name);
}

void AutoConfForPad(const std::string &name) {
ILOG("Autoconfiguring pad for %s", name.c_str());
ILOG("Autoconfiguring pad for '%s'", name.c_str());
if (name == "Xbox 360 Pad") {
SetDefaultKeyMap(DEFAULT_MAPPING_X360, true);
} else {
@@ -68,6 +68,7 @@ enum DefaultMaps {
DEFAULT_MAPPING_SHIELD,
DEFAULT_MAPPING_OUYA,
DEFAULT_MAPPING_XPERIA_PLAY,
DEFAULT_MAPPING_MOQI_I7S,
};

const float AXIS_BIND_THRESHOLD = 0.75f;
@@ -141,6 +142,7 @@ namespace KeyMap {
bool IsNvidiaShieldTV(const std::string &name);
bool IsXperiaPlay(const std::string &name);
bool IsOuya(const std::string &name);
bool IsMOQII7S(const std::string &name);
bool HasBuiltinController(const std::string &name);

const std::set<std::string> &GetSeenPads();
@@ -507,15 +507,6 @@ static ConfigSetting cpuSettings[] = {
ConfigSetting(false),
};

static int DefaultRenderingMode() {
// Workaround for ancient device. Can probably be removed now as we do no longer
// support Froyo (Android 2.2)...
if (System_GetProperty(SYSPROP_NAME) == "samsung:GT-S5360") {
return 0; // Non-buffered
}
return 1;
}

static int DefaultInternalResolution() {
// Auto on Windows, 2x on large screens, 1x elsewhere.
#if defined(USING_WIN_UI)
@@ -575,9 +566,9 @@ static int DefaultGPUBackend() {
return (int)GPUBackend::DIRECT3D11;
}
#elif PPSSPP_PLATFORM(ANDROID)
// Default to Vulkan only on Pie (level 28) devices or newer. Drivers before Pie
// Default to Vulkan only on Oreo 8.1 (level 27) devices or newer. Drivers before
// were generally too unreliable to default to (with some exceptions, of course).
if (System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= 28) {
if (System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= 27) {
return (int)GPUBackend::VULKAN;
}
#endif
@@ -628,10 +619,14 @@ int Config::NextValidBackend() {
}
#endif

// They've all failed. Let them try the default.
// They've all failed. Let them try the default - or on Android, OpenGL.
sFailedGPUBackends += ",ALL";
ERROR_LOG(LOADER, "All graphics backends failed");
#if PPSSPP_PLATFORM(ANDROID)
return (int)GPUBackend::OPENGL;
#else
return DefaultGPUBackend();
#endif
}

return iGPUBackend;
@@ -710,7 +705,7 @@ static ConfigSetting graphicsSettings[] = {
ConfigSetting("D3D11Device", &g_Config.sD3D11Device, "", true, false),
#endif
ConfigSetting("VendorBugChecksEnabled", &g_Config.bVendorBugChecksEnabled, true, false, false),
ReportedConfigSetting("RenderingMode", &g_Config.iRenderingMode, &DefaultRenderingMode, true, true),
ReportedConfigSetting("RenderingMode", &g_Config.iRenderingMode, 1, true, true),
ConfigSetting("SoftwareRenderer", &g_Config.bSoftwareRendering, false, true, true),
ReportedConfigSetting("HardwareTransform", &g_Config.bHardwareTransform, true, true, true),
ReportedConfigSetting("SoftwareSkinning", &g_Config.bSoftwareSkinning, true, true, true),
@@ -432,9 +432,7 @@ class JoystickHistoryView : public UI::InertView {
JoystickHistoryView(int xAxis, int xDevice, int xDir, int yAxis, int yDevice, int yDir, UI::LayoutParams *layoutParams = nullptr)
: UI::InertView(layoutParams),
xAxis_(xAxis), xDir_(xDir),
yAxis_(yAxis), yDir_(yDir),
curX_(0.0f), curY_(0.0f),
maxCount_(500) {}
yAxis_(yAxis), yDir_(yDir) {}
void Draw(UIContext &dc) override;
void Update() override;
void Axis(const AxisInput &input) override {
@@ -448,8 +446,6 @@ class JoystickHistoryView : public UI::InertView {

private:
struct Location {
Location() : x(0.0f), y(0.0f) {}
Location(float xx, float yy) : x(xx), y(yy) {}
float x;
float y;
};
@@ -459,40 +455,44 @@ class JoystickHistoryView : public UI::InertView {
int yAxis_;
int yDir_;

float curX_;
float curY_;
float curX_ = 0.0f;
float curY_ = 0.0f;

std::deque<Location> locations_;
int maxCount_;
int maxCount_ = 500;
};

void JoystickHistoryView::Draw(UIContext &dc) {
if (xAxis_ > -1 && yAxis_ > -1) {
const AtlasImage &image = dc.Draw()->GetAtlas()->images[I_CROSS];
float minRadius = std::min(bounds_.w, bounds_.h) * 0.5f - image.w;

dc.Begin();
int a = maxCount_ - (int)locations_.size();
for (auto iter = locations_.begin(); iter != locations_.end(); ++iter) {
float x = bounds_.centerX() + minRadius * iter->x;
float y = bounds_.centerY() - minRadius * iter->y;
float alpha = (float)a / maxCount_;
if (alpha < 0.0f) alpha = 0.0f;
if (alpha < 0.0f) {
alpha = 0.0f;
}
dc.Draw()->DrawImage(I_CROSS, x, y, 0.8f, colorAlpha(0xFFFFFF, alpha), ALIGN_CENTER);
a++;
}
dc.Flush();
dc.BeginNoTex();
dc.Draw()->RectOutline(bounds_.centerX() - minRadius, bounds_.centerY() - minRadius, minRadius * 2, minRadius * 2, 0x80FFFFFF);
dc.Draw()->RectOutline(bounds_.centerX() - minRadius, bounds_.centerY() - minRadius, minRadius * 2.0f, minRadius * 2.0f, 0x80FFFFFF);
dc.Flush();
dc.Begin();
} else {
dc.DrawText("N/A", bounds_.centerX(), bounds_.centerY(), 0xFFFFFFFF, ALIGN_CENTER);
}
}

void JoystickHistoryView::Update() {
locations_.push_back(Location(curX_, curY_));
if ((int)locations_.size() > maxCount_) {
locations_.pop_front();
if (xAxis_ > -1 && yAxis_ > -1) {
locations_.push_back(Location{ curX_, curY_ });
if ((int)locations_.size() > maxCount_) {
locations_.pop_front();
}
}
}

@@ -521,12 +521,11 @@ bool AnalogTestScreen::axis(const AxisInput &axis) {
// This is mainly to catch axis events that would otherwise get translated
// into arrow keys, since seeing keyboard arrow key events appear when using
// a controller would be confusing for the user.
char buf[512];

if (IgnoreAxisForMapping(axis.axisId))
return false;

if (axis.value > AXIS_BIND_THRESHOLD || axis.value < -AXIS_BIND_THRESHOLD) {
char buf[512];
snprintf(buf, sizeof(buf), "Axis: %d (value %1.3f) Device ID: %d",
axis.axisId, axis.value, axis.deviceId);
// Null-check just in case they weren't created yet.
@@ -439,6 +439,9 @@ void SystemInfoScreen::CreateViews() {

deviceSpecs->Add(new ItemHeader(si->T("System Information")));
deviceSpecs->Add(new InfoItem(si->T("System Name", "Name"), System_GetProperty(SYSPROP_NAME)));
#if PPSSPP_PLATFORM(ANDROID)
deviceSpecs->Add(new InfoItem(si->T("System Version"), StringFromInt(System_GetPropertyInt(SYSPROP_SYSTEMVERSION))));
#endif
deviceSpecs->Add(new InfoItem(si->T("Lang/Region"), System_GetProperty(SYSPROP_LANGREGION)));
std::string board = System_GetProperty(SYSPROP_BOARDNAME);
if (!board.empty())
@@ -258,7 +258,7 @@ namespace MainWindow
}
}

void RelaseMouseWheel() {
void ReleaseMouseWheel() {
// For simplicity release both wheel events
KeyInput key;
key.deviceId = DEVICE_ID_MOUSE;
@@ -816,7 +816,8 @@ namespace MainWindow
return 0;
// Hack: need to release wheel event with a delay for games to register it was "pressed down".
case TIMER_WHEELRELEASE:
RelaseMouseWheel();
ReleaseMouseWheel();
KillTimer(hWnd, TIMER_WHEELRELEASE);
return 0;
}
break;

0 comments on commit 9db4807

Please sign in to comment.
You can’t perform that action at this time.