Announcement

Collapse
No announcement yet.

Background Processing of Joystick/Gamepad Input when not in focus

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [FEATURE REQUEST] Background Processing of Joystick/Gamepad Input when not in focus

    Hi,

    I'd like to be able to continue controlling the player even while the window is not in focus using a joystick or gamepad but this doesn't seem possible as it stands today. Is this something that we could please get added? I've been testing on Windows but I suspect that it is the same case on Linux and Mac as well.

    Any help on this would be very much appreciated.

    #2
    You always have your Input processing, probably you're confused with Input mode concept.
    You can pass your input data to UI only, Game Logic only or both if you want to.
    In PlayerController look at Set Input Mode Game/UI/Game&UI nodes
    SuperGrid: Marketplace Page | Feedback Thread | Demo | Website
    Level design and prototyping for newbies

    Comment


      #3
      Originally posted by zeOrb View Post
      You always have your Input processing, probably you're confused with Input mode concept.
      You can pass your input data to UI only, Game Logic only or both if you want to.
      In PlayerController look at Set Input Mode Game/UI/Game&UI nodes
      Do you mean that joystick input is still being captured even when the Unreal window is not in focus and that by setting the input mode I can capture that? My intention is to still allow user movement in the game world even when the user has alt+tab'ed to another non-Unreal window on his computer.

      Comment


        #4
        Originally posted by hesham View Post
        Do you mean that joystick input is still being captured even when the Unreal window is not in focus and that by setting the input mode I can capture that? My intention is to still allow user movement in the game world even when the user has alt+tab'ed to another non-Unreal window on his computer.
        You would need to modify the core files of UE4 that interact with the OS to always listen for input events to do this (if that is even possible), but I would not recommend doing so. Overriding default behavior of the OS will create more problems than it's worth. Potential security issues would be one reason as you could be opening a backdoor into the OS for hackers to exploit, and is generally something to avoid unless absolutely necessary.

        I'm curious why you want to add that behavior though, are you launching a separate program along with the game?
        Free Community Ocean & Sky Project || Join us on Discord! || Trello Roadmap

        Comment


          #5
          Originally posted by DotCam View Post
          You would need to modify the core files of UE4 that interact with the OS to always listen for input events to do this (if that is even possible), but I would not recommend doing so. Overriding default behavior of the OS will create more problems than it's worth. Potential security issues would be one reason as you could be opening a backdoor into the OS for hackers to exploit, and is generally something to avoid unless absolutely necessary.

          I'm curious why you want to add that behavior though, are you launching a separate program along with the game?
          This is 100% not true. By default, programs will continue to receive controller input even when they do not have focus (This is not the case for keyboard events). Unreal will be choosing to ignore this input somewhere in the engine code.

          You can easily confirm this by putting a breakpoint in the SendControllerEvents function that applies to you and then pushing a button. The engine will respond, but no input event is fired in the game.

          I found this thread while looking for the same thing as the OP. It's super frustrating to try to debug input based blueprints since you can't be looking at the blueprint when pressing the buttons/sticks. So if someone does know how to fix this (or if they can even just point me to the code where Unreal discards the input events), I would appreciate it.

          Comment


            #6
            Originally posted by hesham View Post
            Hi,

            I'd like to be able to continue controlling the player even while the window is not in focus using a joystick or gamepad but this doesn't seem possible as it stands today. Is this something that we could please get added? I've been testing on Windows but I suspect that it is the same case on Linux and Mac as well.

            Any help on this would be very much appreciated.
            As time has passed, it may not be necessary anymore ...

            When focus lost UGameViewportClient :: LostFocus() is called.
            At that time, APlayerController :: FlushPressedKeys () called and the inputs are erased.
            You can do this by overrideing this function so that it does not clear the key.

            Comment


              #7
              Could you please explain what steps I would need to take in order to overload the function?

              Comment

              Working...
              X