Page 2 of 3
Re: joystick:getGamepadMapping(buttonName) always returns nil
Posted: Tue Nov 29, 2016 5:29 pm
by slime
raidho36 wrote:The getGamepadMapping goes down to according SDL function, if there's a bug it's in SDL. Pretty sure though it's just SDL can't pick up the controller as XBox gamepad for whatever reason.
love does some parsing of the SDL mapping string inside getGamepadMapping. There may be a bug in that. In the first post it was already determined that SDL does recognize it as a gamepad (the SDL_GameController API does recognize it), and apparently the input callbacks work.
Re: joystick:getGamepadMapping(buttonName) always returns nil
Posted: Tue Nov 29, 2016 5:34 pm
by raidho36
It will only return nil if SDL_GameControllerMappingForGUID fails or if its returned mapped string doesn't contains the requested input map. So either mapping for that GUID does not exist altogether, or it's empty (since standard map is requested, i.e. it can't be absent from valid standard mapping).
Re: joystick:getGamepadMapping(buttonName) always returns nil
Posted: Tue Nov 29, 2016 7:12 pm
by sandygk
slime wrote:What's the output of [wiki]Joystick:getGUID[/wiki] for you?
Code: Select all
print(love.joystick.getJoysticks()[1]:getGUID())
prints:
78696e70757401000000000000000000
Re: joystick:getGamepadMapping(buttonName) always returns nil
Posted: Tue Nov 29, 2016 7:47 pm
by sandygk
I remember reading that SDL uses this list for mapping:
https://github.com/gabomdq/SDL_GameCont ... llerdb.txt.
If that's the case, my GUID (78696e70757401000000000000000000) does not appear in the list, and there is no entry for Xbox controller for windows in the list which is weird.
Could anyone confirm that this is the default map used by SDL and Love?
Thanks for the help
Re: joystick:getGamepadMapping(buttonName) always returns nil
Posted: Tue Nov 29, 2016 10:05 pm
by slime
It doesn't use that list by default, although you can make use of it with [wiki]love.joystick.loadGamepadMappings[/wiki].
SDL uses an internal list inside its source code by default:
https://github.com/spurious/SDL-mirror/ ... erdb.h#L32
I'm not sure what's up with your GUID. SDL may have changed its XInput controller GUIDs without changing the mapping string in the file above, possibly.
Re: joystick:getGamepadMapping(buttonName) always returns nil
Posted: Tue Nov 29, 2016 11:10 pm
by sandygk
That makes more sense. My GUID does not appear in this list either, but maybe it's not supposed to appear. My controller is recognized as a XInput Controller by LOVE, that's what getName() returns. Maybe it should fall under this case, note that no GUID is used in this case.
Code: Select all
static const char *s_ControllerMappings [] =
{
#if SDL_JOYSTICK_XINPUT
"xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
#endif
...
this code is from the link above.
BTW sorry for my English, is far from good.
Re: joystick:getGamepadMapping(buttonName) always returns nil
Posted: Tue Nov 29, 2016 11:22 pm
by sandygk
can someone check if getGamepadMapping is working with a xbox controller? It does not matter if it is wired or wireless (I have both types to test).
It will be good to know what value of getGUID() do you get for your xbox controller?
and what name do you get from getName()?
this is the code I would like you to test, with a Xbox controller plugged in:
Code: Select all
local joystick = love.joystick.getJoysticks()[1]
local a,b,c = joystick:getGamepadMapping("a")
print(a,b,c)
print(joystick:getGUID())
print(joystick:getName())
this code for me prints:
Code: Select all
nil nil nil
78696e70757401000000000000000000
XInput Controller #1
thanks in advance you are the best
Re: joystick:getGamepadMapping(buttonName) always returns nil
Posted: Wed Nov 30, 2016 12:08 am
by raidho36
Linux here; mine is recognized as
Code: Select all
nil nil nil
030000005e0400008e02000014010000
Microsoft X-Box 360 pad
Still no mappings though.
Re: joystick:getGamepadMapping(buttonName) always returns nil
Posted: Wed Nov 30, 2016 1:00 am
by sandygk
raidho36 wrote:Still no mappings though.
then it is not just me with the nil result.
I think that for an Xbox controller getName is expected to return "Xbox Controller #x" in windows, can somebody confirm if this is the case?
Re: joystick:getGamepadMapping(buttonName) always returns nil
Posted: Wed Nov 30, 2016 1:36 am
by slime
"XInput Controller" is correct for a 360 gamepad on Windows. I just tested (on Windows) with my 360 controller and it returns nil for getGamepadMapping as well, even though [wiki]love.gamepadpressed[/wiki] and related gamepad functionality still works as expected.