Multiple Controller Input [Need Help]

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Semeon
Prole
Posts: 36
Joined: Tue Jul 12, 2016 1:35 pm

Multiple Controller Input [Need Help]

Post 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.
User avatar
Pangit
Party member
Posts: 148
Joined: Thu Jun 16, 2016 9:20 am

Re: Multiple Controller Input [Need Help]

Post 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.
User avatar
Semeon
Prole
Posts: 36
Joined: Tue Jul 12, 2016 1:35 pm

Re: Multiple Controller Input [Need Help]

Post 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.☺☺☺
User avatar
Pangit
Party member
Posts: 148
Joined: Thu Jun 16, 2016 9:20 am

Re: Multiple Controller Input [Need Help]

Post by Pangit »

No problems dude, you should post the solution you found. I would be interested to see how you solved this.
rungo73
Prole
Posts: 11
Joined: Thu Oct 20, 2016 3:43 am

Re: Multiple Controller Input [Need Help]

Post 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
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Multiple Controller Input [Need Help]

Post 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.
rungo73
Prole
Posts: 11
Joined: Thu Oct 20, 2016 3:43 am

Re: Multiple Controller Input [Need Help]

Post by rungo73 »

Of course! Must've been a long day, was looking through the docs and didn't even see it.

Thank you.
nitrofurano
Prole
Posts: 1
Joined: Tue Aug 29, 2017 6:02 pm

Re: Multiple Controller Input [Need Help]

Post by nitrofurano »

where from can we find multiple controller working examples?
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 53 guests