Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix glitch when mapping analog inputs, caused by multiple TriggerFinish #17420

Merged
merged 1 commit into from
May 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions Common/UI/UIScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ TouchInput UIScreen::transformTouch(const TouchInput &touch) {
}

void UIScreen::touch(const TouchInput &touch) {
if (root_) {
if (root_ && !ignoreInput_) {
if (ClickDebug && (touch.flags & TOUCH_DOWN)) {
INFO_LOG(SYSTEM, "Touch down!");
std::vector<UI::View *> views;
Expand All @@ -164,13 +164,21 @@ void UIScreen::touch(const TouchInput &touch) {
}

bool UIScreen::key(const KeyInput &key) {
if (root_) {
if (root_ && !ignoreInput_) {
return UI::KeyEvent(key, root_);
}
return false;
}

void UIScreen::axis(const AxisInput &axis) {
if (root_ && !ignoreInput_) {
UI::AxisEvent(axis, root_);
}
}

void UIScreen::TriggerFinish(DialogResult result) {
// From here on, this dialog cannot receive input.
ignoreInput_ = true;
screenManager()->finishDialog(this, result);
}

Expand All @@ -196,12 +204,6 @@ void UIDialogScreen::sendMessage(const char *msg, const char *value) {
}
}

void UIScreen::axis(const AxisInput &axis) {
if (root_) {
UI::AxisEvent(axis, root_);
}
}

UI::EventReturn UIScreen::OnBack(UI::EventParams &e) {
TriggerFinish(DR_BACK);
return UI::EVENT_DONE;
Expand Down Expand Up @@ -313,6 +315,7 @@ void PopupScreen::SetPopupOffset(float y) {

void PopupScreen::TriggerFinish(DialogResult result) {
if (CanComplete(result)) {
ignoreInput_ = true;
finishFrame_ = frames_;
finishResult_ = result;

Expand Down
1 change: 1 addition & 0 deletions Common/UI/UIScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class UIScreen : public Screen {
Vec3 scale_ = Vec3(1.0f);
float alpha_ = 1.0f;
bool ignoreInsets_ = false;
bool ignoreInput_ = false;

private:
void DoRecreateViews();
Expand Down
6 changes: 6 additions & 0 deletions UI/ControlMappingScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ void KeyMappingNewKeyDialog::CreatePopupContents(UI::ViewGroup *parent) {
}

bool KeyMappingNewKeyDialog::key(const KeyInput &key) {
if (ignoreInput_)
return true;
if (time_now_d() < delayUntil_)
return true;
if (key.flags & KEY_DOWN) {
Expand Down Expand Up @@ -390,6 +392,8 @@ void KeyMappingNewMouseKeyDialog::CreatePopupContents(UI::ViewGroup *parent) {
bool KeyMappingNewMouseKeyDialog::key(const KeyInput &key) {
if (mapped_)
return false;
if (ignoreInput_)
return true;
if (key.flags & KEY_DOWN) {
if (key.keyCode == NKCODE_ESCAPE) {
TriggerFinish(DR_OK);
Expand Down Expand Up @@ -428,6 +432,8 @@ void KeyMappingNewKeyDialog::axis(const AxisInput &axis) {
return;
if (IgnoreAxisForMapping(axis.axisId))
return;
if (ignoreInput_)
return;

if (axis.value > AXIS_BIND_THRESHOLD) {
InputMapping mapping(axis.deviceId, axis.axisId, 1);
Expand Down