Page 1 of 1

Multiple Controller Input [Need Help]

Posted: Sat Jul 16, 2016 10:59 am
by Semeon
Hey,
I have a game with joystick controls. The problem is that say I want to have 2 or 3 controllers connected and have the same controls. How can I do this? If it is possible. Also I am using the joystick module no external libraries.

Re: Multiple Controller Input [Need Help]

Posted: Sat Jul 16, 2016 11:11 am
by Pangit
I haven't tested it but it should work just fine.(famous last words..) How I do it is I look at the first data table in the object, depending on how many joysticks are connected you just look at the other tables.

So if the object I have for joystick is called Joysticks, I am looking at Joysticks[1] for the first joysticks inputs, Joysticks[2] for the second inputs, Joystick[3] for the third, Joystick[4] for the fourth.. and so on... Joystick[n]

Because the other joysticks are going to update different players right, your going to need to assign different functionality to them. So I would assume you would need to set-up a different control scheme but I am probably wrong about that.

The way I would have done it, your need to a guard to avoid situations where the program loads when you don't have multiple controllers connected otherwise its going to crash. That was a bug in my demo with just one joystick. But I assume you have that already in your program. You can't just assume they will be present on the target machine. You got weird edge cases like someone unplugging the controller from the machine and you having code/logic in the program that assumes these controllers are present. Need to account for that edge case also.

Re: Multiple Controller Input [Need Help]

Posted: Sat Jul 16, 2016 3:50 pm
by Semeon
Hey,
Thanks for your support but I found the way to do it after messing with the code if you want me I can share it with you it is simple you just got to pay attention.☺☺☺

Re: Multiple Controller Input [Need Help]

Posted: Sun Jul 17, 2016 12:36 am
by Pangit
No problems dude, you should post the solution you found. I would be interested to see how you solved this.

Re: Multiple Controller Input [Need Help]

Posted: Mon Oct 31, 2016 6:29 am
by rungo73
Hey @Semeon - how did you end up doing the multiple gamepads? I'm looking at doing this at the moment but not sure how to proceed.

Cheers,
Tom

Re: Multiple Controller Input [Need Help]

Posted: Mon Oct 31, 2016 3:42 pm
by raidho36
You call love.joystick.getJoysticks() and that returns a list of joysticks. Then you read input from every gamepad you need input from.

Re: Multiple Controller Input [Need Help]

Posted: Mon Oct 31, 2016 7:35 pm
by rungo73
Of course! Must've been a long day, was looking through the docs and didn't even see it.

Thank you.

Re: Multiple Controller Input [Need Help]

Posted: Tue Aug 29, 2017 6:07 pm
by nitrofurano
where from can we find multiple controller working examples?