Page 1 of 1

The Right Analogue Stick

Posted: Thu Jun 21, 2018 9:32 am
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:

Re: The Right Analogue Stick

Posted: Thu Jun 21, 2018 10:28 am
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)