joystickpressed is called, but gamepadpressed is not called (Logitech f310)

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
andras
Prole
Posts: 14
Joined: Thu Jun 14, 2018 12:03 pm

joystickpressed is called, but gamepadpressed is not called (Logitech f310)

Post by andras »

Hello there!

I recently added controller support to my game which was a breeze with the baton library. Worked great with an official XBox 360 controller. So I bought a Logitech F310 controller, which is pretty much the same thing. The joystick is registered and everything, it claims to be a "Xbox 360 Wired Controller", however, love.gamepadpressed is not called when I press a button, while love.joystickpressed does get called. isDown also returns a button number.

Code: Select all

function love.gamepadpressed( joystick, button )
  print('gamepad pressed')
  print(joystick)
  print(button)
end
function love.joystickpressed( joystick, button )
  print('joystick pressed')
  print(joystick)
  print(button)
end

function love.load()
  local j = love.joystick.getJoysticks()[1]
  print(j)
  print(j:getName())
  print(j:getButtonCount())
end
Output after pressing A and B:

Code: Select all

Joystick: 0x7fbd6d202060
Xbox 360 Wired Controller
15
joystick pressed
Joystick: 0x7fbd6d202060
1
joystick pressed
Joystick: 0x7fbd6d202060
2
I even tried loading the SDL controller mappings with love.joystick.loadGamepadMappings('gamecontrollerdb.txt'), it didn't help. Baton seems to be using the gamepad API, so my game doesn't work with my new controller.

What might be the problem? Thanks, Andras
User avatar
andras
Prole
Posts: 14
Joined: Thu Jun 14, 2018 12:03 pm

Re: joystickpressed is called, but gamepadpressed is not called (Logitech f310)

Post by andras »

Nevermind, I figured out how this is supposed to work. My Logitech F310 gamepad must be a new make or something as its GUID wasn't included in the de facto standard gamecontrollerdb.txt https://raw.githubusercontent.com/gabom ... llerdb.txt
So love2d didn't recognize it as a gamepad (as I could very well check it with the isGamepad method), so I couldn't use the gamepad API, only the lower level joystick API. I have retrieved my controller's GUID with

Code: Select all

myJoystick:getGUID()
and added it to the gamecontrollerdb.txt by copying and modifying a different line corresponding to a slightly different Logitech F310 controller.

Looks like a good scout would send a pull request to the SDL_GameControllerDB repo? I'll try to do that.
Post Reply

Who is online

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