Trying out 0.9.0 gamepad API.

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
NuclearSailor
Prole
Posts: 9
Joined: Wed Oct 16, 2013 2:43 am

Trying out 0.9.0 gamepad API.

Post by NuclearSailor »

It may be from drowsiness but I can't seem to figure out how to use the new gamepad API. I am trying to see if one of the d-pad buttons is pushed down using this: http://www.love2d.org/wiki/Joystick:isGamepadDown but I don't think I'm putting the right code in.

Code: Select all

if love.joystick:isGamepadDown("dpup") then
	objects.ball.body:applyForce(0, -400)
end
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Trying out 0.9.0 gamepad API.

Post by slime »

0.9 changes the Joystick API to have Joystick objects. So instead of love.joystick having all the functions which apply to single joysticks, the Joystick objects have methods for those.

To get the joystick objects you can use [wiki]love.joystick.getJoysticks[/wiki]. The joystick events ([wiki]love.gamepadpressed[/wiki], for example) also give them as arguments.
NuclearSailor
Prole
Posts: 9
Joined: Wed Oct 16, 2013 2:43 am

Re: Trying out 0.9.0 gamepad API.

Post by NuclearSailor »

Awesome now if I can just figure out why it's saying:

Code: Select all

attempt to get call field 'getjoysticks' (a nil value)
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

Re: Trying out 0.9.0 gamepad API.

Post by Plu »

It's case sensitive, you have to use getJoysticks with a capital J.
NuclearSailor
Prole
Posts: 9
Joined: Wed Oct 16, 2013 2:43 am

Re: Trying out 0.9.0 gamepad API.

Post by NuclearSailor »

yeah it does have a capitol J in the code. it still returns that error though.

Code: Select all

joysticks = love.joystick.getJoysticks()
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Trying out 0.9.0 gamepad API.

Post by slime »

How old is the build of 0.9.0 you have (where did you get it from)? The ones on http://nightly.projecthawkthorne.com haven't been updated in 2 months unfortunately, so they're missing a lot of the changes (like the love.joystick rewrite.)

If you're on Windows, you can download a more up-to-date build here: 32 bit or 64 bit.
NuclearSailor
Prole
Posts: 9
Joined: Wed Oct 16, 2013 2:43 am

Re: Trying out 0.9.0 gamepad API.

Post by NuclearSailor »

Thanks. I new they were old builds but I wasn't aware of any newer ones.
NuclearSailor
Prole
Posts: 9
Joined: Wed Oct 16, 2013 2:43 am

Re: Trying out 0.9.0 gamepad API.

Post by NuclearSailor »

Yeah everything works fine now.

This is fun.
NuclearSailor
Prole
Posts: 9
Joined: Wed Oct 16, 2013 2:43 am

Re: Trying out 0.9.0 gamepad API.

Post by NuclearSailor »

Hey I don't want to start a new thread so i'll ask this here. If I want to use the left stick of my xbox controller to move a circle around the screen. How would I get that the stick is being moved and in what direction?
kingslovelua
Citizen
Posts: 71
Joined: Mon Sep 26, 2011 7:16 pm

Re: Trying out 0.9.0 gamepad API.

Post by kingslovelua »

NuclearSailor wrote:Hey I don't want to start a new thread so i'll ask this here. If I want to use the left stick of my xbox controller to move a circle around the screen. How would I get that the stick is being moved and in what direction?

I'm trying to figure out the same thing I'm not sure what I'm down.
Post Reply

Who is online

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