none
[JavaScript][UWP] Auto navigation in DOM, navigator.gamepadInputEmulation = "keyboard" RRS feed

  • Question

  • Hi,

    I was wondering if setting 'navigator.gamepadInputEmulation = "keyboard"' also enables some form of automatic navigation around the DOM on Xbox/UWP.

    I'm running into a strange issue navigating where if I reach the bottom of a list while navigating down the focus will be lost despite this being handled programmatically to stop at the end of the list and remain focused on that last element when pressing the DOWN key.

    However, this only seems to happen if there are elements in the DOM below or at around the same vertical position. If the last element of the list is at the clearly at bottom of the page and nothing is below it the focus doesn't get lost which is the expected behavior.

    This issue is only occurring when setting up our web app for Xbox/UWP. Running it simply in a browser works as expected.

    Thanks.

    Saturday, September 21, 2019 12:36 AM

Answers

  • Hi Roy,

    So I think I finally figured it out.

    There is automatic navigation going on when,

    navigator.gamepadInputEmulation = "keyboard";

    It's called XYFocus. It just wasn't obvious to me looking at the documentation at first glance that this was enabled. But, I seem to be able to block the random focusing by adding the following,

    WinJS.UI.XYFocus.addEventListener("focuschanging", (eventArgs) => { eventArgs.preventDefault(); });

    Thanks,

    • Marked as answer by jmombo Thursday, October 3, 2019 4:40 PM
    Thursday, October 3, 2019 4:40 PM

All replies

  • Hi,

    I have a question here. What's the OS version of the device and what's the target version of your app? 

    Also, could you please share me a simple demo about this? A sample that could reproduce this issue will be enough. Please delete all the sensitive code and just keep the necessary code which could reproduce the issue.

    This could help to find out the problem.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, September 23, 2019 3:25 AM
    Moderator
  • Hi Roy,

    I am working exclusively on Xbox.

    OS: 10.0.18362.6065.

    Target version: 10.0.17763.0

    Min version: 10.0.15063.0

    Unfortunately I don't think I am able to share a demo project. Our codebase has quite a few dependencies and configurations/data which makes it difficult to make a simplified version of things that would actually be accurate/helpful.

    I have continued trying to debug and have found a difference between running the app on Xbox and a local web browser however. I appears that when navigating using the Xbox controller a key press will automatically trigger a blur event on a focused DOM element. This doesn't happen when running in a local web browser and using basic up/down/left/right arrows on keyboard.

    Is this a part of how the Xbox UWP JavaScript browser engine always executes a controller input? If so, is there any way to disable this globally?

    Thanks.

    Monday, September 23, 2019 8:31 PM
  • Hi,

    Can you create a simple project to reproduce it? Create a new blank app and add list to the page, then handle the event as you did in the real project. When the new project could reproduce the behavior you said, then you could share it to me. It's important because I can't tell why it shows the behavior and confirm if it is not expected unless I could debug the repro demo.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, September 24, 2019 6:28 AM
    Moderator
  • Hi Roy,

    So I think I finally figured it out.

    There is automatic navigation going on when,

    navigator.gamepadInputEmulation = "keyboard";

    It's called XYFocus. It just wasn't obvious to me looking at the documentation at first glance that this was enabled. But, I seem to be able to block the random focusing by adding the following,

    WinJS.UI.XYFocus.addEventListener("focuschanging", (eventArgs) => { eventArgs.preventDefault(); });

    Thanks,

    • Marked as answer by jmombo Thursday, October 3, 2019 4:40 PM
    Thursday, October 3, 2019 4:40 PM