Problem with gamepad input ! No Reaction...
Posted: Sun May 03, 2020 7:49 pm
Hey there i try to implement a joystick class and for some reason no input changes:
local joystick = {}
joystick.__index = joystick
joystick.arrow = love.graphics.newImage('Assets/test_arrow_numberouno.png')
love.joystick.loadGamepadMappings('ControlManager/controllermapping.txt')
function joystick.new()
local self = {}
self.joysticks = love.joystick.getJoysticks()
setmetatable(self, joystick)
return self
end
function joystick:update(dt)
local count = self.joysticks[1]:getAxisCount()
print("Axes")
print(count)
local ak1 = self.joysticks[1]:getAxis(1)
local ak2 = self.joysticks[1]:getAxis(2)
local ak3 = self.joysticks[1]:getAxis(3)
local ak4 = self.joysticks[1]:getAxis(4)
local ak5 = self.joysticks[1]:getAxis(5)
local ak6 = self.joysticks[1]:getAxis(6)
print("Axes:")
print(ak1)
print(ak2)
print(ak3)
print(ak4)
print(ak5)
print(ak6)
if self.joysticks[1]:isGamepadDown("start") then
love.event.quit()
end
for key, value in ipairs(self.joysticks) do
value:setVibration(1 ,1 , 1000)
end
end
--check if any joystick is connected
function joystick:checkJoysticks()
local maxCount = #self.joysticks
if maxCount <= 0 then
love.graphics.print("No Joystick connected !", 0, 0)
return
end
end
--give joystick a id
function joystick:assignID()
for i = 1, #self.joysticks do
love.graphics.print(self.joysticks:getName())
end
end
function joystick:draw()
love.graphics.draw(self.arrow,0, 0)
end
return joystick
Can you may tell me why ? Here is my output --> https://snipboard.io/XaqS52.jpg
Thanks in advance !
local joystick = {}
joystick.__index = joystick
joystick.arrow = love.graphics.newImage('Assets/test_arrow_numberouno.png')
love.joystick.loadGamepadMappings('ControlManager/controllermapping.txt')
function joystick.new()
local self = {}
self.joysticks = love.joystick.getJoysticks()
setmetatable(self, joystick)
return self
end
function joystick:update(dt)
local count = self.joysticks[1]:getAxisCount()
print("Axes")
print(count)
local ak1 = self.joysticks[1]:getAxis(1)
local ak2 = self.joysticks[1]:getAxis(2)
local ak3 = self.joysticks[1]:getAxis(3)
local ak4 = self.joysticks[1]:getAxis(4)
local ak5 = self.joysticks[1]:getAxis(5)
local ak6 = self.joysticks[1]:getAxis(6)
print("Axes:")
print(ak1)
print(ak2)
print(ak3)
print(ak4)
print(ak5)
print(ak6)
if self.joysticks[1]:isGamepadDown("start") then
love.event.quit()
end
for key, value in ipairs(self.joysticks) do
value:setVibration(1 ,1 , 1000)
end
end
--check if any joystick is connected
function joystick:checkJoysticks()
local maxCount = #self.joysticks
if maxCount <= 0 then
love.graphics.print("No Joystick connected !", 0, 0)
return
end
end
--give joystick a id
function joystick:assignID()
for i = 1, #self.joysticks do
love.graphics.print(self.joysticks:getName())
end
end
function joystick:draw()
love.graphics.draw(self.arrow,0, 0)
end
return joystick
Can you may tell me why ? Here is my output --> https://snipboard.io/XaqS52.jpg
Thanks in advance !