So I have gone through all other gamepad related posts on the forum and found that by calling loadGamepadMappings("gamecontrollerdb.txt") it detects my Super Famicom NES-like Controller correctly.
The problem: The DPAD does not work out the box, and I call setGamepadMapping() to foolishly attempt configuring the DPAD. The Down and Right directions seem to work, but Up and Left do not. I suspect because it reports AxisCount of 2, any mappings beyond that are simply ignored.
I am a fan of restrictions when developing games to inspire creativity, but making all my games with only Right & Down movement is a bit absurd. Any tips to point out my mistake is welcome, please!
Pertinent Details:
OS: Windows (10)
Löve version: 11.3
Gamepad purchased from: https://raspberry.piaustralia.com.au/co ... controller
Code: Select all
function love.load()
-- https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt
love.joystick.loadGamepadMappings("gamecontrollerdb.txt")
end
function love.update(dt)
end
function love.keypressed(key)
love.event.quit()
end
function love.joystickadded(joystick)
print("Name", joystick:getName())
print("ID", joystick:getID())
print("GUID", joystick:getGUID())
print("ButtonCount", joystick:getButtonCount())
print("Info", joystick:getDeviceInfo())
print("AxisCount", joystick:getAxisCount())
print("isGamepad", joystick:isGamepad())
-- map right dpad - works
print(love.joystick.setGamepadMapping(joystick:getGUID(), "dpright", "axis", 1))
-- map down dpad - works
print(love.joystick.setGamepadMapping(joystick:getGUID(), "dpdown", "axis", 2))
-- no error, no input -- obviously limited to AxisCount. How to map rest of DPAD?
print(love.joystick.setGamepadMapping(joystick:getGUID(), "dpleft", "axis", 3))
--print(love.joystick.setGamepadMapping(joystick:getGUID(), "dpleft", "axis", 4))
--print(love.joystick.setGamepadMapping(joystick:getGUID(), "dpleft", "axis", 5))
--print(love.joystick.setGamepadMapping(joystick:getGUID(), "dpleft", "axis", .. all through including 10))
-- attempt using hat input with a gamepad clearly without a hat -- no error, no input
--print(love.joystick.setGamepadMapping(joystick:getGUID(), "dpup", "hat", 1, "u"))
-- map a, b, x, y - works without loadGamepadMappings(), redundant with loadGamepadMappings().
--print(love.joystick.setGamepadMapping(joystick:getGUID(), "a", "button", 2))
--print(love.joystick.setGamepadMapping(joystick:getGUID(), "b", "button", 3))
--print(love.joystick.setGamepadMapping(joystick:getGUID(), "x", "button", 1))
--print(love.joystick.setGamepadMapping(joystick:getGUID(), "y", "button", 4))
end
function love.gamepadpressed(joystick, button)
print(joystick:getName(), button)
end
function love.joystickremoved(joystick)
print("removed", joystick:getName())
end
Code: Select all
Name USB gamepad
ID 1 1
GUID 030000001f08000001e4000000000000
ButtonCount 10
Info 2079 58369 0
AxisCount 2
isGamepad true
true
true
USB gamepad dpdown
USB gamepad dpdown
USB gamepad dpdown
USB gamepad dpdown
USB gamepad dpdown
USB gamepad dpright
USB gamepad dpright
USB gamepad dpright
USB gamepad dpright