Page 1 of 3
joystick:getGamepadMapping(buttonName) always returns nil
Posted: Mon Nov 28, 2016 9:36 pm
by sandygk
I am using a xbox 360 controller, when I try to get the inputindex for any button using the Joystick:getGamepadMapping()function I always get nil results, the function Joystick:isGamepadDown() works fine tho. This is the code:
Code: Select all
local inputtype, inputindex, hatdirection = joystick:getGamepadMapping("a")
print("name", joystick:getName())
print("is gamepad", joystick:isGamepad())
print("inputtype", inputtype)
print("inputindex", inputindex)
print("hatdirection", hatdirection)
prints:
name XInput Controller #1
is gamepad true
inputtype nil
inputindex nil
hatdirection nil
note the results of the function are nil
I tried different controllers, they are all original Xbox controllers. I am currently using Love version 0.10.2 but I tried different versions to see if it was a bug introduced recently but got the same results in all the versions I tried
any help would be truly appreciated
Re: joystick:getGamepadMapping(buttonName) always returns nil
Posted: Tue Nov 29, 2016 12:00 am
by raidho36
Returns nil if the Joystick isn't recognized as a gamepad or the virtual gamepad axis is not bound to a Joystick input.
I suppose no binding is present since it's a nondescript Xinput gamepad.
Re: joystick:getGamepadMapping(buttonName) always returns nil
Posted: Tue Nov 29, 2016 12:35 am
by Beelz
With an Xbox 360 controller, you can use
Joystick:isGamepad and the accompanying callbacks.
Re: joystick:getGamepadMapping(buttonName) always returns nil
Posted: Tue Nov 29, 2016 2:17 am
by zorg
Beelz wrote:With an Xbox 360 controller, you can use
Joystick:isGamepad and the accompanying callbacks.
That's the issue, that he can't; for some reason, his xbox360 controller gets reported as a generic one, as raidho said.
And while :isGamepad returns true, the other function doesn't work.
Re: joystick:getGamepadMapping(buttonName) always returns nil
Posted: Tue Nov 29, 2016 5:52 am
by sandygk
raidho36 wrote:I suppose no binding is present since it's a nondescript Xinput gamepad.
what do you think could be the cause for this? the controller works fine with all my games and it works fine in LOVE too. The only issue I'm having is with the function getGamepadMapping. I tried to look for drivers, but the controller is plug and play, it should install the drivers automatically
Re: joystick:getGamepadMapping(buttonName) always returns nil
Posted: Tue Nov 29, 2016 5:57 am
by sandygk
yes I can, and they work fine, but that's not what I am trying to do, I need to use the function getGamepadMapping.
Thanks to all the people that are trying to help, you are great!
Re: joystick:getGamepadMapping(buttonName) always returns nil
Posted: Tue Nov 29, 2016 1:29 pm
by raidho36
sandygk wrote:what do you think could be the cause for this? the controller works fine with all my games and it works fine in LOVE too. The only issue I'm having is with the function getGamepadMapping. I tried to look for drivers, but the controller is plug and play, it should install the drivers automatically
Drivers are clearly present - otherwise it won't work at all. It's just drivers won't recognize it as XBox controller. Try installing controller-specific drivers.
Re: joystick:getGamepadMapping(buttonName) always returns nil
Posted: Tue Nov 29, 2016 4:40 pm
by sandygk
windows recognize the controller name without problems, apparently the drivers are not the problem, see attachment:
Re: joystick:getGamepadMapping(buttonName) always returns nil
Posted: Tue Nov 29, 2016 4:54 pm
by slime
It's possible there's a bug in getGamepadMapping. Can anyone else use it successfully? Does it work on different controllers?
What's the output of [wiki]Joystick:getGUID[/wiki] for you?
Re: joystick:getGamepadMapping(buttonName) always returns nil
Posted: Tue Nov 29, 2016 5:10 pm
by raidho36
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.