diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index a410df17be..719a71e82f 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -287,12 +287,12 @@ void KeyMappingNewKeyDialog::CreatePopupContents(UI::ViewGroup *parent) { parent->Add(new TextView(std::string(keyI18N->T("Map a new key for")) + " " + pspButtonName, new LinearLayoutParams(Margins(10,0)))); } -void KeyMappingNewKeyDialog::key(const KeyInput &key) { +bool KeyMappingNewKeyDialog::key(const KeyInput &key) { if (mapped_) - return; + return false; if (key.flags & KEY_DOWN) { if (key.keyCode == NKCODE_EXT_MOUSEBUTTON_1) { - return; + return true; } mapped_ = true; @@ -301,24 +301,25 @@ void KeyMappingNewKeyDialog::key(const KeyInput &key) { if (callback_) callback_(kdf); } + return true; } -void KeyMappingNewKeyDialog::axis(const AxisInput &axis) { +bool KeyMappingNewKeyDialog::axis(const AxisInput &axis) { if (mapped_) - return; + return false; switch (axis.axisId) { // Ignore the accelerometer for mapping for now. case JOYSTICK_AXIS_ACCELEROMETER_X: case JOYSTICK_AXIS_ACCELEROMETER_Y: case JOYSTICK_AXIS_ACCELEROMETER_Z: - return; + return false; // Also ignore some weird axis events we get on Ouya. case JOYSTICK_AXIS_OUYA_UNKNOWN1: case JOYSTICK_AXIS_OUYA_UNKNOWN2: case JOYSTICK_AXIS_OUYA_UNKNOWN3: case JOYSTICK_AXIS_OUYA_UNKNOWN4: - return; + return false; default: ; @@ -339,4 +340,5 @@ void KeyMappingNewKeyDialog::axis(const AxisInput &axis) { if (callback_) callback_(kdf); } + return true; } diff --git a/UI/ControlMappingScreen.h b/UI/ControlMappingScreen.h index f1dfa70514..e9e9664dd5 100644 --- a/UI/ControlMappingScreen.h +++ b/UI/ControlMappingScreen.h @@ -31,8 +31,8 @@ public: ControlMappingScreen() {} void KeyMapped(int pspkey); // Notification to let us refocus the same one after recreating views. protected: - virtual void CreateViews(); - virtual void sendMessage(const char *message, const char *value); + virtual void CreateViews() override; + virtual void sendMessage(const char *message, const char *value) override; private: UI::EventReturn OnDefaultMapping(UI::EventParams ¶ms); UI::EventReturn OnClearMapping(UI::EventParams ¶ms); @@ -51,15 +51,15 @@ public: pspBtn_ = btn; } - void key(const KeyInput &key); - void axis(const AxisInput &axis); + virtual bool key(const KeyInput &key) override; + virtual bool axis(const AxisInput &axis) override; protected: - void CreatePopupContents(UI::ViewGroup *parent); + void CreatePopupContents(UI::ViewGroup *parent) override; - virtual bool FillVertical() const { return false; } - virtual bool ShowButtons() const { return true; } - virtual void OnCompleted(DialogResult result) {} + virtual bool FillVertical() const override { return false; } + virtual bool ShowButtons() const override { return true; } + virtual void OnCompleted(DialogResult result) override {} private: int pspBtn_; diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index 8065bb2b87..815179d682 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -344,7 +344,7 @@ void AddressPromptScreen::UpdatePreviewDigits() { } } -void AddressPromptScreen::key(const KeyInput &key) { +bool AddressPromptScreen::key(const KeyInput &key) { if (key.flags & KEY_DOWN) { if (key.keyCode >= NKCODE_0 && key.keyCode <= NKCODE_9) { AddDigit(key.keyCode - NKCODE_0); @@ -356,13 +356,13 @@ void AddressPromptScreen::key(const KeyInput &key) { } else if (key.keyCode == NKCODE_ENTER) { OnCompleted(DR_OK); screenManager()->finishDialog(this, DR_OK); - return; } else { - UIDialogScreen::key(key); + return UIDialogScreen::key(key); } } else { - UIDialogScreen::key(key); + return UIDialogScreen::key(key); } + return true; } // Three panes: Block chooser, MIPS view, ARM/x86 view diff --git a/UI/DevScreens.h b/UI/DevScreens.h index 9a9d9ee61d..0a1c475371 100644 --- a/UI/DevScreens.h +++ b/UI/DevScreens.h @@ -75,12 +75,12 @@ public: memset(buttons_, 0, sizeof(buttons_)); } - virtual void key(const KeyInput &key); + virtual bool key(const KeyInput &key) override; UI::Event OnChoice; protected: - void CreatePopupContents(UI::ViewGroup *parent); + virtual void CreatePopupContents(UI::ViewGroup *parent) override; virtual void OnCompleted(DialogResult result); UI::EventReturn OnDigitButton(UI::EventParams &e); UI::EventReturn OnBackspace(UI::EventParams &e); diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index f9d2bdc92f..837d8913e5 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -252,9 +252,13 @@ inline float clamp1(float x) { return x; } -void EmuScreen::touch(const TouchInput &touch) { - if (root_) +bool EmuScreen::touch(const TouchInput &touch) { + if (root_) { root_->Touch(touch); + return true; + } else { + return false; + } } void EmuScreen::onVKeyDown(int virtualKeyCode) { @@ -386,16 +390,23 @@ inline void EmuScreen::setVKeyAnalogY(int stick, int virtualKeyMin, int virtualK __CtrlSetAnalogY(axis, stick); } -void EmuScreen::key(const KeyInput &key) { +bool EmuScreen::key(const KeyInput &key) { if ((key.flags & KEY_DOWN) && key.keyCode == NKCODE_BACK) { pauseTrigger_ = true; } std::vector pspKeys; KeyMap::KeyToPspButton(key.deviceId, key.keyCode, &pspKeys); + + if (pspKeys.size() && (key.flags & KEY_IS_REPEAT)) { + // Claim that we handled this. Prevents volume key repeats from popping up the volume control on Android. + return true; + } + for (size_t i = 0; i < pspKeys.size(); i++) { pspKey(pspKeys[i], key.flags); } + return pspKeys.size() > 0; } void EmuScreen::pspKey(int pspKeyCode, int flags) { @@ -418,16 +429,20 @@ void EmuScreen::pspKey(int pspKeyCode, int flags) { } } -void EmuScreen::axis(const AxisInput &axis) { +bool EmuScreen::axis(const AxisInput &axis) { if (axis.value > 0) { processAxis(axis, 1); + return true; } else if (axis.value < 0) { processAxis(axis, -1); + return true; } else if (axis.value == 0) { // Both directions! Prevents sticking for digital input devices that are axises (like HAT) processAxis(axis, 1); processAxis(axis, -1); + return true; } + return false; } void EmuScreen::processAxis(const AxisInput &axis, int direction) { diff --git a/UI/EmuScreen.h b/UI/EmuScreen.h index 79d5b38ca5..707e825adc 100644 --- a/UI/EmuScreen.h +++ b/UI/EmuScreen.h @@ -32,15 +32,15 @@ public: EmuScreen(const std::string &filename); ~EmuScreen(); - virtual void update(InputState &input); - virtual void render(); - virtual void deviceLost(); - virtual void dialogFinished(const Screen *dialog, DialogResult result); - virtual void sendMessage(const char *msg, const char *value); + virtual void update(InputState &input) override; + virtual void render() override; + virtual void deviceLost() override; + virtual void dialogFinished(const Screen *dialog, DialogResult result) override; + virtual void sendMessage(const char *msg, const char *value) override; - virtual void touch(const TouchInput &touch); - virtual void key(const KeyInput &key); - virtual void axis(const AxisInput &axis); + virtual bool touch(const TouchInput &touch) override; + virtual bool key(const KeyInput &key) override; + virtual bool axis(const AxisInput &axis) override; protected: virtual void CreateViews(); diff --git a/UI/InstallZipScreen.cpp b/UI/InstallZipScreen.cpp index b01d223c81..a66a795aa2 100644 --- a/UI/InstallZipScreen.cpp +++ b/UI/InstallZipScreen.cpp @@ -60,11 +60,12 @@ void InstallZipScreen::CreateViews() { rightColumnItems->Add(new CheckBox(&deleteZipFile_, iz->T("Delete ZIP file"))); } -void InstallZipScreen::key(const KeyInput &key) { +bool InstallZipScreen::key(const KeyInput &key) { // Ignore all key presses during installation to avoid user escape if (!g_GameManager.IsInstallInProgress()) { - UIScreen::key(key); + return UIScreen::key(key); } + return false; } UI::EventReturn InstallZipScreen::OnInstall(UI::EventParams ¶ms) { diff --git a/UI/InstallZipScreen.h b/UI/InstallZipScreen.h index a4fb41960e..c340cf8271 100644 --- a/UI/InstallZipScreen.h +++ b/UI/InstallZipScreen.h @@ -26,11 +26,11 @@ class InstallZipScreen : public UIDialogScreenWithBackground { public: InstallZipScreen(std::string zipPath) : installChoice_(0), doneView_(0), zipPath_(zipPath), installStarted_(false), deleteZipFile_(false) {} - virtual void update(InputState &input); - virtual void key(const KeyInput &key); + virtual void update(InputState &input) override; + virtual bool key(const KeyInput &key) override; protected: - virtual void CreateViews(); + virtual void CreateViews() override; private: UI::EventReturn OnInstall(UI::EventParams ¶ms); diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index 7e65453380..b9c78bca5f 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -376,10 +376,12 @@ void LogoScreen::sendMessage(const char *message, const char *value) { } } -void LogoScreen::key(const KeyInput &key) { +bool LogoScreen::key(const KeyInput &key) { if (key.deviceId != DEVICE_ID_MOUSE) { Next(); + return true; } + return false; } void LogoScreen::render() { diff --git a/UI/MiscScreens.h b/UI/MiscScreens.h index 2160751256..081c7dab0a 100644 --- a/UI/MiscScreens.h +++ b/UI/MiscScreens.h @@ -35,7 +35,7 @@ public: UIScreenWithBackground() : UIScreen() {} protected: virtual void DrawBackground(UIContext &dc); - virtual void sendMessage(const char *message, const char *value); + virtual void sendMessage(const char *message, const char *value) override; virtual UI::EventReturn OnLanguageChange(UI::EventParams &e); }; @@ -53,7 +53,7 @@ public: UIDialogScreenWithBackground() : UIDialogScreen() {} protected: virtual void DrawBackground(UIContext &dc); - virtual void sendMessage(const char *message, const char *value); + virtual void sendMessage(const char *message, const char *value) override; virtual UI::EventReturn OnLanguageChange(UI::EventParams &e); }; @@ -71,7 +71,7 @@ public: PromptScreen(std::string message, std::string yesButtonText, std::string noButtonText, std::function callback = &NoOpVoidBool); - virtual void CreateViews(); + virtual void CreateViews() override; private: UI::EventReturn OnYes(UI::EventParams &e); @@ -89,7 +89,7 @@ public: private: virtual void OnCompleted(DialogResult result); - virtual bool ShowButtons() const { return true; } + virtual bool ShowButtons() const override { return true; } std::map> langValuesMapping; std::map titleCodeMapping; std::vector langs_; @@ -101,7 +101,7 @@ public: private: virtual void OnCompleted(DialogResult result); - virtual bool ShowButtons() const { return true; } + virtual bool ShowButtons() const override { return true; } std::vector shaders_; }; @@ -109,10 +109,10 @@ class LogoScreen : public UIScreen { public: LogoScreen() : frames_(0), switched_(false) {} - void key(const KeyInput &key); - void update(InputState &input); - void render(); - void sendMessage(const char *message, const char *value); + bool key(const KeyInput &key) override; + virtual void update(InputState &input) override; + virtual void render() override; + virtual void sendMessage(const char *message, const char *value) override; virtual void CreateViews() {} private: @@ -124,8 +124,8 @@ private: class CreditsScreen : public UIDialogScreenWithBackground { public: CreditsScreen() : frames_(0) {} - void update(InputState &input); - void render(); + virtual void update(InputState &input) override; + virtual void render() override; virtual void CreateViews(); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 7871582400..f09e002b41 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -721,9 +721,10 @@ bool NativeKey(const KeyInput &key) { } #endif g_buttonTracker.Process(key); + bool retval = false; if (screenManager) - screenManager->key(key); - return true; + retval = screenManager->key(key); + return retval; } bool NativeAxis(const AxisInput &key) { diff --git a/UI/TouchControlLayoutScreen.cpp b/UI/TouchControlLayoutScreen.cpp index 601dedfeec..6a41b7779b 100644 --- a/UI/TouchControlLayoutScreen.cpp +++ b/UI/TouchControlLayoutScreen.cpp @@ -214,7 +214,7 @@ TouchControlLayoutScreen::TouchControlLayoutScreen() { pickedControl_ = 0; }; -void TouchControlLayoutScreen::touch(const TouchInput &touch) { +bool TouchControlLayoutScreen::touch(const TouchInput &touch) { UIScreen::touch(touch); using namespace UI; @@ -275,6 +275,7 @@ void TouchControlLayoutScreen::touch(const TouchInput &touch) { pickedControl_->SavePosition(); pickedControl_ = 0; } + return true; }; void TouchControlLayoutScreen::onFinish(DialogResult reason) { diff --git a/UI/TouchControlLayoutScreen.h b/UI/TouchControlLayoutScreen.h index d62ee916e5..342c5d418a 100644 --- a/UI/TouchControlLayoutScreen.h +++ b/UI/TouchControlLayoutScreen.h @@ -29,10 +29,10 @@ class TouchControlLayoutScreen : public UIDialogScreenWithBackground { public: TouchControlLayoutScreen(); - virtual void CreateViews(); - virtual void touch(const TouchInput &touch); - virtual void dialogFinished(const Screen *dialog, DialogResult result); - virtual void onFinish(DialogResult reason); + virtual void CreateViews() override; + virtual bool touch(const TouchInput &touch) override; + virtual void dialogFinished(const Screen *dialog, DialogResult result) override; + virtual void onFinish(DialogResult reason) override; protected: virtual UI::EventReturn OnReset(UI::EventParams &e); diff --git a/native b/native index 6739fc5654..a3e23f0ac6 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit 6739fc565464ec4cb830ad16ca73605519ab3223 +Subproject commit a3e23f0ac6266507ecf24a5f4d59087a089ceda3