Input hints in UI: How to detect currently used input device?

Hi there!

Here’s what I currently do: My UI displays input hints for interacting with the environment (press X to open, press Space to activate etc.). I have already set up the functionality to correctly display icons and button names depending on which kind of input device the player is using. Have a look at the screenshots below.

My Problem is this:

How do I poll for the currently used input device?

My thoughts on this so far are to set up a variable currentInputDevice, probably in the game mode class, along with methods to update this variable whenever the player switched from keyboard and mouse to gamepad or vice versa. I want this to happen on the fly, supporting both types of input simultaneously, so I can’t just make an options item that disables one type of input globally (would be okay as last resort though).

So what I would need to do is something like this:


currentInputDevice    // input device used until now
NewInputType = LastInputAction->getType
if (NewInputType != currentInputDevice) {
    currentInputDevice = NewInputType
    SendUpdateCommandToUserInterface
}

I am already looking through the docs to find if something like this is already set up in the code, but I’d like to know if someone could steer me in the right direction. What would be the easiest way to poll for the input device that was last used? Is there some kind of input stack that has all the input events for the current tick? Anything like that?

Thanks in advance for anything that could help me come closer,

Rames

So what I have done with the my current game is Created a Enum With the different inputs devices I want to be able to use in My game such as Gamepad, Mouse N Keyboard, and Steam Controller. After I have that I went into my Player Controller and Created a function to see where the input is coming from. To do this I created a macro That got the input values of the buttons I am using from the Gampad if they all equal 0 then it changes the the input device to the one the player is using in my case right now I am just testing the ability to switch back and forth from mouse and keyboard (Default) to Gamepad. Here are my blueprint images for the Macro I use to see if inputs is being given from a gamepad and the function that switched between which input to use, This happens on the fly I can pick up my gamepad and use it but as soon as i put it down and start using my keyboard and mouse it transitions smoothly!!!

Hope these help

The described workaround is not enough for our game. We would like to be able to show different UI hints based on the type of controller (PS4, XBox, Keyboard, etc. ) i looked into the source, but i can’t figure out on how to do this. I assume more people would like to do something similar? Any suggestions/ideas?

As an FYI - asking a question is best done via comments or a new question rather than as an answer.

While this response is late, to answer your question for others’ reference - I don’t believe they store device types when they receive input via the XInput/DirectInput APIs. You can modify the engine’s input handling to also query and store the device information to determine this or there may be a plugin out there that already does this that you could use.

Hello, .

May be you found answer?

Thanks.