Fix assorted key mapping issues affecting Shield and probably pads in general on Android. See #7976

This commit is contained in:
Henrik Rydgård committed 2015-09-17 22:46:59 +02:00
1 parent aa4a33e6db
commit 9636e4cef4
6 files changed
+34 -7

No files matched your search

+17 -2
View File
@@ -288,12 +288,13 @@ static const DefMappingStruct defaultXperiaPlay[] = {
{VIRTKEY_AXIS_Y_MAX, JOYSTICK_AXIS_Y, +1},
};
static void KeyCodesFromPspButton(int btn, std::vector<keycode_t> *keycodes) {
void KeyCodesFromPspButton(int btn, std::vector<keycode_t> *keycodes) {
for (auto i = g_controllerMap[btn].begin(), end = g_controllerMap[btn].end(); i != end; ++i) {
keycodes->push_back((keycode_t)i->keyCode);
}
}
// TODO: This is such a mess...
void UpdateNativeMenuKeys() {
std::vector<KeyDef> confirmKeys, cancelKeys;
std::vector<KeyDef> tabLeft, tabRight;
@@ -311,10 +312,19 @@ void UpdateNativeMenuKeys() {
KeyFromPspButton(CTRL_LEFT, &leftKeys);
KeyFromPspButton(CTRL_RIGHT, &rightKeys);
#ifdef ANDROID
// Hardcode DPAD on Android
upKeys.push_back(KeyDef(DEVICE_ID_ANY, NKCODE_DPAD_UP));
downKeys.push_back(KeyDef(DEVICE_ID_ANY, NKCODE_DPAD_DOWN));
leftKeys.push_back(KeyDef(DEVICE_ID_ANY, NKCODE_DPAD_LEFT));
rightKeys.push_back(KeyDef(DEVICE_ID_ANY, NKCODE_DPAD_RIGHT));
#endif
// Push several hard-coded keys before submitting to native.
const KeyDef hardcodedConfirmKeys[] = {
KeyDef(DEVICE_ID_KEYBOARD, NKCODE_SPACE),
KeyDef(DEVICE_ID_KEYBOARD, NKCODE_ENTER),
KeyDef(DEVICE_ID_ANY, NKCODE_BUTTON_A),
};
// If they're not already bound, add them in.
@@ -326,6 +336,7 @@ void UpdateNativeMenuKeys() {
const KeyDef hardcodedCancelKeys[] = {
KeyDef(DEVICE_ID_KEYBOARD, NKCODE_ESCAPE),
KeyDef(DEVICE_ID_ANY, NKCODE_BACK),
KeyDef(DEVICE_ID_ANY, NKCODE_BUTTON_B),
};
for (size_t i = 0; i < ARRAY_SIZE(hardcodedCancelKeys); i++) {
@@ -890,7 +901,7 @@ void LoadFromIni(IniFile &file) {
// Erase default mapping
g_controllerMap.erase(psp_button_names[i].key);
if (value.empty())
if (value.empty())
continue;
std::vector<std::string> mappings;
@@ -937,6 +948,10 @@ bool IsNvidiaShield(const std::string &name) {
return name == "NVIDIA:SHIELD";
}
bool IsNvidiaShieldTV(const std::string &name) {
return name == "NVIDIA:SHIELD Android TV";
}
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";
}
+1
View File
@@ -130,6 +130,7 @@ namespace KeyMap {
void NotifyPadConnected(const std::string &name);
bool IsNvidiaShield(const std::string &name);
bool IsNvidiaShieldTV(const std::string &name);
bool IsBlackberryQWERTY(const std::string &name);
bool IsXperiaPlay(const std::string &name);
bool IsOuya(const std::string &name);
+11 -3
View File
@@ -422,14 +422,20 @@ void JoystickHistoryView::Update(const InputState &input_state) {
}
bool AnalogTestScreen::key(const KeyInput &key) {
bool retval = true;
if (UI::IsEscapeKey(key)) {
screenManager()->finishDialog(this, DR_BACK);
return true;
}
char buf[512];
snprintf(buf, sizeof(buf), "Keycode: %d Device ID: %d [%s%s%s%s]", key.keyCode, key.deviceId,
(key.flags & KEY_IS_REPEAT) ? "REP" : "",
(key.flags & KEY_UP) ? "UP" : "",
(key.flags & KEY_DOWN) ? "DOWN" : "",
(key.flags & KEY_CHAR) ? "CHAR" : "");
lastLastKeyEvent_->SetText(lastKeyEvent_->GetText());
lastKeyEvent_->SetText(buf);
return true;
return retval;
}
bool AnalogTestScreen::axis(const AxisInput &axis) {
@@ -439,9 +445,9 @@ bool AnalogTestScreen::axis(const AxisInput &axis) {
// a controller would be confusing for the user.
char buf[512];
if (axis.value > AXIS_BIND_THRESHOLD || axis.value < -AXIS_BIND_THRESHOLD) {
int value = axis.value > AXIS_BIND_THRESHOLD ? 1 : -1;
snprintf(buf, sizeof(buf), "Axis: %d (value %1.3f) Device ID: %d",
axis.axisId, axis.value, axis.deviceId);
lastLastKeyEvent_->SetText(lastKeyEvent_->GetText());
lastKeyEvent_->SetText(buf);
return true;
}
@@ -472,7 +478,9 @@ void AnalogTestScreen::CreateViews() {
root_->Add(theTwo);
lastKeyEvent_ = root_->Add(new TextView("", new LayoutParams(FILL_PARENT, WRAP_CONTENT)));
lastLastKeyEvent_ = root_->Add(new TextView("-", new LayoutParams(FILL_PARENT, WRAP_CONTENT)));
lastLastKeyEvent_->SetTextColor(0x80FFFFFF); // semi-transparent
lastKeyEvent_ = root_->Add(new TextView("-", new LayoutParams(FILL_PARENT, WRAP_CONTENT)));
root_->Add(new Button(di->T("Back")))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
}
+1
View File
@@ -80,4 +80,5 @@ protected:
virtual void CreateViews() override;
UI::TextView *lastKeyEvent_;
UI::TextView *lastLastKeyEvent_;
};
@@ -1,8 +1,6 @@
package org.ppsspp.ppsspp;
import android.app.AlertDialog;
import android.app.UiModeManager;
import android.content.res.Configuration;
import android.graphics.Point;
import android.os.Build;
import android.os.Bundle;
+4
View File
@@ -600,6 +600,9 @@ public:
void SetText(const std::string &text) {
text_ = text;
}
const std::string &GetText() const {
return text_;
}
void SetRightText(const std::string &text) {
rightText_ = text;
}
@@ -676,6 +679,7 @@ public:
void Draw(UIContext &dc) override;
void SetText(const std::string &text) { text_ = text; }
const std::string &GetText() const { return text_; }
void SetSmall(bool small) { small_ = small; }
void SetTextColor(uint32_t color) { textColor_ = color; }
void SetShadow(bool shadow) { shadow_ = shadow; }