Hi,
I've looked through the joystick API, but I'm a bit confused about how I go about doing this.
I have an xbox 360 controlled plugged in, a ps2 (with usb converter) plugged in, and a ps3 controller
obviously they all show different button ids for each button press (the ps2 right stick on the Y is reversed too )
what is the best practise for syncing all the controllers with the correct button mappings ? I assume it has something to do with this :
http://love2d.org/wiki/love.joystick.setGamepadMapping
But I really dont get it atm lol
Any pointers/advice would be greatly appreciated !
gamepads || joysticks - how to tell what is plugged in
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: gamepads || joysticks - how to tell what is plugged in
SDL2 contains a database of common gamepads and controllers. If your controller is in this database, then you can avoid using the button numbers altogether and directly use the GamepadButton-labels. See here: isGamepadDown.
To get started, first check, if your controller is recognized as a gamepad:
If so, then you should be able to use the isGamepadDown function:
(You have to assign the joystick to the variable "yourJoystick" first.)
Disclaimer: I haven't tested this code, but from how I understand the wiki, this is how it should work.
To get started, first check, if your controller is recognized as a gamepad:
Code: Select all
if yourJoystick:isGamepad() then
print('Recognized as a gamepad')
else
print('not recognized as a gamepad')
end
Code: Select all
function love.draw()
if yourJoystick:isGamepadDown('a') then
love.graphics.print('pressing A',10,10)
end
end
Disclaimer: I haven't tested this code, but from how I understand the wiki, this is how it should work.
Check out my blog on gamedev
Re: gamepads || joysticks - how to tell what is plugged in
ok that makes sense
360 controller is (of course) true for isGamepad()
ps2 via usb converter is false
ps3 controller is true
how could i add my ps2 controller so its buttons can be seen also as A etc...
Im writting a multiplayer game to play when friends come over, and have many ps2 controllers, so this is a must for me atm lol
cheers for the info ! spot on stuff
360 controller is (of course) true for isGamepad()
ps2 via usb converter is false
ps3 controller is true
how could i add my ps2 controller so its buttons can be seen also as A etc...
Im writting a multiplayer game to play when friends come over, and have many ps2 controllers, so this is a must for me atm lol
cheers for the info ! spot on stuff
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: gamepads || joysticks - how to tell what is plugged in
You can write a mapping, and set it with setGamepadMapping, it's perhaps easier to configure the controller in steam big picture mode and launch your game from there, that automatically passes along the mappings set.
Re: gamepads || joysticks - how to tell what is plugged in
i have no idea what 'steam big picture mode' is lol
and i havent launched any of my .love through steam tbh so not 100% sure how that would work out
i think the gamepadmapping has finally clicked though, something like this:
i assume, i'd have to run this at the start every time ?
is it possible for me to add to that SDL2 db ?
and i havent launched any of my .love through steam tbh so not 100% sure how that would work out
i think the gamepadmapping has finally clicked though, something like this:
Code: Select all
love.joystick.setGamePadMapping(ps2_guid, "a", "button", 5);
is it possible for me to add to that SDL2 db ?
Who is online
Users browsing this forum: Google [Bot] and 58 guests