Joystick:isDown and Joystick:isGamepadDown inconsis.[solved]

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
SimonLarsen
Party member
Posts: 100
Joined: Thu Mar 31, 2011 4:47 pm
Location: Denmark
Contact:

Joystick:isDown and Joystick:isGamepadDown inconsis.[solved]

Post by SimonLarsen »

I'm currently trying out the new joystick API which is great, but something confuses me.
I'm using a standard Dual Shock 3 (Playstation 3) controller under Linux. Probably with the xpad og xboxdrv drivers, not entirely sure.

When running the following code:

Code: Select all

function love.load()
	joystick = love.joystick.getJoysticks()[1]

	if joystick:isGamepad() == true then
		print("joystick 1 \"" .. joystick:getName() .. "\" is a gamepad")
	end
	_, abutton = joystick:getGamepadMapping("a")
	print("A button is " .. abutton)
end

function love.update(dt)
	if joystick:isGamepadDown("a") then
		print("isGamepadDown(a) == true")
	end
	if joystick:isDown(abutton) then
		print("isDown(a) == true")
	end
end
it prints

Code: Select all

joystick 1 "Sony PLAYSTATION(R)3 Controller" is a gamepad
A is button 15
as expected. However

Code: Select all

isGamepadDown(a) == true
is printed only when the X-button is held while

Code: Select all

isDown(a) == true
is printed only when the square-button is held.

Am I wrong in assuming getGamepadMapping should give the same button id that isGamepadDown uses?
Last edited by SimonLarsen on Thu Jan 02, 2014 1:06 am, edited 1 time in total.
User avatar
SimonLarsen
Party member
Posts: 100
Joined: Thu Mar 31, 2011 4:47 pm
Location: Denmark
Contact:

Re: Joystick:isDown and Joystick:isGamepadDown inconsistenci

Post by SimonLarsen »

Nevermind. Just found the notice on the Wiki:

Code: Select all

There is a bug in version 0.9.0 which requires the button indices passed to Joystick:isDown to be 0-based instead of 1-based, for example button 1 would be 0 for this function.
So the workaround is to simply call joystick:isDown(button-1) instead, until it is resolved?
User avatar
slime
Solid Snayke
Posts: 3132
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Joystick:isDown and Joystick:isGamepadDown inconsistenci

Post by slime »

SimonLarsen wrote:So the workaround is to simply call joystick:isDown(button-1) instead, until it is resolved?
Yeah. The next version of LÖVE will definitely have the fix (it's been committed already.) Sorry about the bug! :(
Post Reply

Who is online

Users browsing this forum: No registered users and 89 guests