Jump to content

Recognizing inputs from two separate controllers

Recommended Posts

I'm back on my mad science because trying to play local multiplayer smashup on a keyboard is awful.

So I've got two USB controllers plugged in and I can do  "TheInput:EnableAllControllers()" to get it accepting inputs from both controllers. TheInput:GetInputDevices() will show that it recognizes two separate controllers as well.

So the question is; is it possible to differentiate between the inputs of both controllers somehow? TheInputProxy:GetLastActiveControllerIndex()  always returns 2 no matter which controller I've most recently pressed buttons on, unfortunately. 

I've been looking through some of the input files but nothing immediately jumps out at me, apart from  Input:OnControlMapped(deviceId, controlId, inputId, hasChanged)  taking deviceId as an input, but I'm not sure what I'd do with that...

Link to comment
Share on other sites

Ok, I've been digging into this for a while and going back and fourth with a few other modders and from what it looks like, I don't think there's a way to directly get the device Id of the controller that a controlhandler event comes from.

BUT, I found out that I can remap the controls of one controller while leaving the other one alone, and that is how I will be able to differentiate which controller is pressing which button. By remapping all of p2's controls onto a separate set of buttons that do functionally the same thing.

The only problem is... Remapping controls is really weird. I've been going over optionsscreen.lua and from what we've found, control remapping is done by doing "TheInputProxy:StartMappingControls()" and then the engine physically listens to the player's button presses to determine which key to remap to. 

I was told by some people smarter than me that the only thing left to do at this point is ask a dev. which feels a bit pretentious to do but hey, if a dev happens to see this and knows an answer I would greatly appreciate it. 

So my question is; is there any way to remap controls with code? Not just adding controlhandlers, but remapping them because otherwise both controllers would activate the listeners. I'm hoping to do this without needing physical keypresses because it would suck if users had to manually press every key in order to rebind.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...