The Right Analogue Stick

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
StormtrooperCat
Prole
Posts: 11
Joined: Fri Mar 09, 2018 12:29 am
Contact:

The Right Analogue Stick

Post by StormtrooperCat »

Hello All,
I was wondering if there was any way to get the axis of the right analogue stick on an Xbox 360 control using love2d's Joystick function?
I was thinking of using it for a aiming stick in a rogue like style game.

Thanks for any help you can provide. :awesome:
User avatar
Link
Prole
Posts: 19
Joined: Tue Jun 19, 2018 4:09 am

Re: The Right Analogue Stick

Post by Link »

Here's my code for accessing the analog sticks.

Inside love.load:

Code: Select all

-- Get any attached joysticks (aka gamepads) - assume final joystick found is player 1 for now
local joysticks_found = love.joystick.getJoysticks()
for i, joy in ipairs(joysticks_found) do
	player_1_joystick = joy
end
Inside love.update:

Code: Select all

-- Left analog
left_analog_vector_x = player_1_joystick:getAxis(1)
left_analog_vector_y = player_1_joystick:getAxis(2)

-- Right analog
right_analog_vector_x = player_1_joystick:getAxis(3)
right_analog_vector_y = player_1_joystick:getAxis(4)
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 47 guests