Skip to content

Commit

Permalink
Fix glitch when mapping analog inputs, caused by multiple TriggerFini…
Browse files Browse the repository at this point in the history
…sh caused by stray analog axis events.

ADd some guards all over the place against the same thing.
  • Loading branch information
hrydgard committed May 6, 2023
1 parent 23c24d2 commit 8cdf353
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
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
2 changes: 1 addition & 1 deletion SDL/macOS
Submodule macOS updated 86 files
+ .DS_Store
+1 −0 SDL2.framework/Versions/A/Frameworks/hidapi.framework/Resources
+16 −0 SDL2.framework/Versions/A/Frameworks/hidapi.framework/Versions/A/Resources/AUTHORS.txt
+46 −0 SDL2.framework/Versions/A/Frameworks/hidapi.framework/Versions/A/Resources/Info.plist
+26 −0 SDL2.framework/Versions/A/Frameworks/hidapi.framework/Versions/A/Resources/LICENSE-bsd.txt
+674 −0 SDL2.framework/Versions/A/Frameworks/hidapi.framework/Versions/A/Resources/LICENSE-gpl3.txt
+9 −0 SDL2.framework/Versions/A/Frameworks/hidapi.framework/Versions/A/Resources/LICENSE-orig.txt
+13 −0 SDL2.framework/Versions/A/Frameworks/hidapi.framework/Versions/A/Resources/LICENSE.txt
+207 −0 SDL2.framework/Versions/A/Frameworks/hidapi.framework/Versions/A/_CodeSignature/CodeResources
+ SDL2.framework/Versions/A/Frameworks/hidapi.framework/Versions/A/hidapi
+1 −0 SDL2.framework/Versions/A/Frameworks/hidapi.framework/Versions/Current
+1 −0 SDL2.framework/Versions/A/Frameworks/hidapi.framework/hidapi
+36 −48 SDL2.framework/Versions/A/Headers/SDL.h
+14 −16 SDL2.framework/Versions/A/Headers/SDL_assert.h
+6 −42 SDL2.framework/Versions/A/Headers/SDL_atomic.h
+39 −354 SDL2.framework/Versions/A/Headers/SDL_audio.h
+5 −5 SDL2.framework/Versions/A/Headers/SDL_bits.h
+10 −8 SDL2.framework/Versions/A/Headers/SDL_blendmode.h
+8 −60 SDL2.framework/Versions/A/Headers/SDL_clipboard.h
+11 −17 SDL2.framework/Versions/A/Headers/SDL_config.h
+9 −10 SDL2.framework/Versions/A/Headers/SDL_config_macosx.h
+1 −1 SDL2.framework/Versions/A/Headers/SDL_copying.h
+9 −79 SDL2.framework/Versions/A/Headers/SDL_cpuinfo.h
+56 −88 SDL2.framework/Versions/A/Headers/SDL_endian.h
+6 −14 SDL2.framework/Versions/A/Headers/SDL_error.h
+21 −89 SDL2.framework/Versions/A/Headers/SDL_events.h
+6 −10 SDL2.framework/Versions/A/Headers/SDL_filesystem.h
+13 −217 SDL2.framework/Versions/A/Headers/SDL_gamecontroller.h
+7 −7 SDL2.framework/Versions/A/Headers/SDL_gesture.h
+0 −100 SDL2.framework/Versions/A/Headers/SDL_guid.h
+7 −28 SDL2.framework/Versions/A/Headers/SDL_haptic.h
+0 −451 SDL2.framework/Versions/A/Headers/SDL_hidapi.h
+52 −781 SDL2.framework/Versions/A/Headers/SDL_hints.h
+12 −257 SDL2.framework/Versions/A/Headers/SDL_joystick.h
+8 −67 SDL2.framework/Versions/A/Headers/SDL_keyboard.h
+6 −13 SDL2.framework/Versions/A/Headers/SDL_keycode.h
+5 −11 SDL2.framework/Versions/A/Headers/SDL_loadso.h
+5 −7 SDL2.framework/Versions/A/Headers/SDL_locale.h
+6 −34 SDL2.framework/Versions/A/Headers/SDL_log.h
+8 −97 SDL2.framework/Versions/A/Headers/SDL_main.h
+5 −7 SDL2.framework/Versions/A/Headers/SDL_messagebox.h
+5 −14 SDL2.framework/Versions/A/Headers/SDL_metal.h
+5 −5 SDL2.framework/Versions/A/Headers/SDL_misc.h
+7 −40 SDL2.framework/Versions/A/Headers/SDL_mouse.h
+5 −41 SDL2.framework/Versions/A/Headers/SDL_mutex.h
+1 −1 SDL2.framework/Versions/A/Headers/SDL_name.h
+55 −4 SDL2.framework/Versions/A/Headers/SDL_opengl.h
+231 −2,260 SDL2.framework/Versions/A/Headers/SDL_opengl_glext.h
+2 −2 SDL2.framework/Versions/A/Headers/SDL_opengles.h
+7 −7 SDL2.framework/Versions/A/Headers/SDL_opengles2.h
+339 −374 SDL2.framework/Versions/A/Headers/SDL_opengles2_gl2.h
+1,484 −3,467 SDL2.framework/Versions/A/Headers/SDL_opengles2_gl2ext.h
+9 −6 SDL2.framework/Versions/A/Headers/SDL_opengles2_gl2platform.h
+14 −43 SDL2.framework/Versions/A/Headers/SDL_opengles2_khrplatform.h
+5 −36 SDL2.framework/Versions/A/Headers/SDL_pixels.h
+9 −37 SDL2.framework/Versions/A/Headers/SDL_platform.h
+4 −6 SDL2.framework/Versions/A/Headers/SDL_power.h
+3 −3 SDL2.framework/Versions/A/Headers/SDL_quit.h
+9 −167 SDL2.framework/Versions/A/Headers/SDL_rect.h
+17 −311 SDL2.framework/Versions/A/Headers/SDL_render.h
+1 −6 SDL2.framework/Versions/A/Headers/SDL_revision.h
+26 −455 SDL2.framework/Versions/A/Headers/SDL_rwops.h
+23 −48 SDL2.framework/Versions/A/Headers/SDL_scancode.h
+8 −59 SDL2.framework/Versions/A/Headers/SDL_sensor.h
+8 −16 SDL2.framework/Versions/A/Headers/SDL_shape.h
+32 −168 SDL2.framework/Versions/A/Headers/SDL_stdinc.h
+18 −128 SDL2.framework/Versions/A/Headers/SDL_surface.h
+12 −160 SDL2.framework/Versions/A/Headers/SDL_system.h
+9 −17 SDL2.framework/Versions/A/Headers/SDL_syswm.h
+18 −28 SDL2.framework/Versions/A/Headers/SDL_thread.h
+8 −58 SDL2.framework/Versions/A/Headers/SDL_timer.h
+6 −18 SDL2.framework/Versions/A/Headers/SDL_touch.h
+2 −2 SDL2.framework/Versions/A/Headers/SDL_types.h
+11 −43 SDL2.framework/Versions/A/Headers/SDL_version.h
+27 −276 SDL2.framework/Versions/A/Headers/SDL_video.h
+8 −10 SDL2.framework/Versions/A/Headers/SDL_vulkan.h
+5 −26 SDL2.framework/Versions/A/Headers/begin_code.h
+1 −1 SDL2.framework/Versions/A/Headers/close_code.h
+0 −48 SDL2.framework/Versions/A/Resources/CMake/sdl2-config-version.cmake
+0 −69 SDL2.framework/Versions/A/Resources/CMake/sdl2-config.cmake
+10 −10 SDL2.framework/Versions/A/Resources/Info.plist
+1 −1 SDL2.framework/Versions/A/Resources/License.txt
+1 −13 SDL2.framework/Versions/A/Resources/ReadMe.txt
+ SDL2.framework/Versions/A/Resources/default.metallib
+ SDL2.framework/Versions/A/SDL2
+149 −192 SDL2.framework/Versions/A/_CodeSignature/CodeResources
7 changes: 7 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 All @@ -448,6 +454,7 @@ void KeyMappingNewKeyDialog::axis(const AxisInput &axis) {
InputMapping pos(axis.deviceId, axis.axisId, 1);
if (triggeredAxes_.find(neg) != triggeredAxes_.end() || triggeredAxes_.find(pos) != triggeredAxes_.end()) {
// "Key-up" the axis.
NOTICE_LOG(COMMON, "TriggerFInish");
TriggerFinish(DR_YES);
if (callback_)
callback_(mapping_);
Expand Down
2 changes: 1 addition & 1 deletion ext/zstd
Submodule zstd updated 407 files

0 comments on commit 8cdf353

Please sign in to comment.