I can’t find that “Any Key” event anywhere in code, are those some sort of dynamic nodes?
I’ve looked through the classes PlayerController, PlayerInput, InputComponent, InputCoreTypes, KismetInputLibrary (which is where I thought the Any Key event would be). I don’t see a way to get any key that was pressed and determine what input device it is.
I’ve search through a lot of posts, but don’t see a real way to do this through code.
Any thoughts on how to detect gamepad/keyboard/mouse through c++?
You will have to have your C++ class inheriting from the right class. Assuming the inputs are set up correctly, this should fire the event and you should be able to handle it in the event.
I think you need a reference to an APlayerController or derived class. If you have it working in BP, why don’t you expose a C++ method to blueprint and call that from within the BP instead.
I am pretty sure you really need a different handler for each key grouping however. The keypress themselves are not passed in. It’s probably easier to set up a series of BindActions instead.
I created the BindAction on AnyKey, but that doesn’t actually show what key was pressed. So there is no way to determine if it was a keyboard, mouse, gamepad, etc…
The easiest way in that case would be a bit more involved. Set up an action in the inputs for each device, add a bindaction for each. Configure an enum or even a series of constants and add a common method that takes the constant/enum, i.e. mouse, keyboard gamepad etc.
Then from each bindAction, call with the correct constant.
This seems kind of hacky, but I could not find any other way to grab if any key was pressed and determine what input device that key was. So I created a BindAction for each device and and that action has every possible input type for that device. It was pretty easy to grab them from InputCoreTypes.h and paste the actions into DefaultInput.ini