Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Enable/disable user input devices #136

Merged
merged 16 commits into from
Mar 6, 2023

Conversation

hmuurine
Copy link
Collaborator

@hmuurine hmuurine commented Mar 2, 2023

Summary

Added configuration for enabling & disabling the following user input devices:

  • Keyboard
  • Mouse
  • Touch
  • Game pad
  • XR controller

The config can be given either as initial configuration when creating the Config object, or can be changed on the fly. The changed config is applied immediately by removing/reapplying the event handlers related to user input.

Added the new configuration items also to the sample UI so that they can be toggled on demand.

The event unregistering is done via a new utility class EventListenerTracker that keeps track of the registered event handlers and can execute unregister commands for them when needed. This same mechanism can be used later if implementing teardown functionality that unregisters everything.

Test plan

Configuration via API

  • Started a new Pixel Streaming session and verified that mouse/keyboard/touch/game pad input were all enabled by default and worked as before
  • Modified player.ts to disable all user input on init
    Screenshot 2023-03-02 at 16 20 34
  • Verified that now the UI did not respond to any mouse/keyboard/touch/game pad input when connected

Dynamic run-time config change

  • Started a new session with all user input enabled
  • Enabled & disabled mouse/keyboard/touch/game pad input one by one and verified that each configuration change enabled/disabled the corresponding input device as expected
Screen.Recording.2023-03-02.at.16.32.32.mp4

@hmuurine hmuurine changed the title Configurable user input Enable/disable user input devices Mar 2, 2023
@hmuurine
Copy link
Collaborator Author

hmuurine commented Mar 2, 2023

Notice if someone wants to test Gamepad functionality, at least the demo UE app sent an invalid Protocol message that had the wrong messageLength for GamepadAnalog input (had length 3, but should be 10). To test game pad support properly, I needed to overwrite GamepadAnalog length by value 10 after receiving the wrong value from UE. Did not submit that into this PR since it's an UE side issue.

Might be just an issue in my test application though, which is just something grabbed from UE samples. Maybe some newer test programs send a proper value and don't need the hack.

@lukehb
Copy link
Contributor

lukehb commented Mar 2, 2023

@Belchy06 To review this one.

Also Will can you look into the gamepad issue reported here.

Copy link
Contributor

@lukehb lukehb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also do the same for XR inputs?

@hmuurine
Copy link
Collaborator Author

hmuurine commented Mar 3, 2023

Should we also do the same for XR inputs?

I did look at this yesterday, but the XR input seems to work in a slightly different way compared to the rest of the input methods. The code doesn't register any event listeners. It's instead requesting a XR session, and when the session is active, the code has access to XR controller state. So I'm not 100% sure it fits into this same pattern.

Maybe we could add the XR flag in Config, and if that's disabled, block sending the controller update messages to UE. Wouldn't work the same way under the hood, but looking from the dev point of view could be nice to have that flag available.

@hmuurine
Copy link
Collaborator Author

hmuurine commented Mar 3, 2023

XR flag implemented in commit 71daadf

@Belchy06
Copy link
Collaborator

Belchy06 commented Mar 6, 2023

Looks good. I just made one change to simplifying the flag names from EnableDeviceInput to DeviceInput as user's should be able to get the idea of enabling/disabling from the toggle itself.

I was unable to repro the issue you brought up with the analogue gamepad input, with mine 'just working'. Which samples were you using and I'll look to seeing if it need to be fixed?

@hmuurine
Copy link
Collaborator Author

hmuurine commented Mar 6, 2023

I was unable to repro the issue you brought up with the analogue gamepad input, with mine 'just working'. Which samples were you using and I'll look to seeing if it need to be fixed?

I was using a sample I found at the Samples tab in Epic Games Store.
egs-ps-demo

Just loaded that sample into UE, built a Windows executable and started it with Pixel Streaming command line arguments. Didn't make any code changes to the sample application. Also used UE version 5.1 if that makes a difference.

@Belchy06
Copy link
Collaborator

Belchy06 commented Mar 6, 2023

@lukehb lukehb merged commit 95f2bef into EpicGames:master Mar 6, 2023
@lukehb
Copy link
Contributor

lukehb commented Mar 6, 2023

re: gamepad issue - @Belchy06 I'll leave it up to you to open a ticket UE side if needed.

@lukehb lukehb mentioned this pull request Mar 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants