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

Fixed back button problems in UWP #5810

Merged
merged 2 commits into from
Sep 11, 2017
Merged

Conversation

timgott
Copy link
Contributor

@timgott timgott commented Jul 11, 2017

The back button on Windows 10 Mobile was not always reliable because GamePad.Back could be changed by the UI thread during a tick. Sometimes the button would do nothing because the game checked GamePadState before GamePad.Back was changed, which was reset to false in the end of the tick.

@nkast
Copy link
Contributor

nkast commented Jul 12, 2017

It sounds right to me.

@atomgott ,
While you are at it, is it possible to move the code inside UAPGameWindow.ProcessWindowEvents() ?

void ProcessWindowEvents()
{
// Update input
_inputEvents.UpdateState();
// Update TextInput
if(!_textQueue.IsEmpty)
UpdateTextInput();
// Update size
if (_isSizeChanged)
UpdateSize();
// Update orientation
if (_isOrientationChanged)
UpdateOrientation();
if (_isFocusChanged)
UpdateFocus();
}
internal void Tick()
{
// Update state based on window events.
ProcessWindowEvents();

This way we will have all Event Sync code nice and tide in one place.

@Jjagg
Copy link
Contributor

Jjagg commented Jul 12, 2017

@atomgott Don't worry about the build failure, it's not because of this PR :)

@timgott
Copy link
Contributor Author

timgott commented Jul 12, 2017

Oh ok :)
I'm sorry about all the whitespace changes, I think that was Visual Studio trying to help

@Jjagg
Copy link
Contributor

Jjagg commented Jul 12, 2017

You can see the diff without the whitespace changes by adding ?w=1 to the URL like so: https://github.com/MonoGame/MonoGame/pull/5810/files?w=1

@nkast
Copy link
Contributor

nkast commented Jul 13, 2017

Great job @atomgott

I just have to say that there's still a race condition although a very slim possibility of occurring.
thread#0 L314: GamePad.Back = _backPressed;
thread#1 L307: _backPressed = true;
thread#0 L315: _backPressed = false;
edit: It would be tricky to resolve this without expensive locking or whatever. Anyways, this is definitely a major improvement from before.

@tomspilman tomspilman added this to the 3.7 Release milestone Sep 11, 2017
@tomspilman tomspilman merged commit 5d4583c into MonoGame:develop Sep 11, 2017
nkast pushed a commit to nkast/MonoGame that referenced this pull request Sep 19, 2017
* Fixed back button race condition

* Moved back button logic to UAPGameWindow.ProcessWindowEvents
nkast pushed a commit to nkast/MonoGame that referenced this pull request Sep 19, 2017
* Fixed back button race condition

* Moved back button logic to UAPGameWindow.ProcessWindowEvents
nkast pushed a commit to nkast/MonoGame that referenced this pull request Sep 20, 2017
* Fixed back button race condition

* Moved back button logic to UAPGameWindow.ProcessWindowEvents
nkast pushed a commit to nkast/MonoGame that referenced this pull request Jun 26, 2018
* Fixed back button race condition

* Moved back button logic to UAPGameWindow.ProcessWindowEvents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants