Page 1 of 1

A few questions about controllers

Posted: Tue Mar 20, 2018 3:48 am
by kraftman
Wow, apparently it's been 4 years since I last posted :(

So anyway, https://love2d.org/wiki/Joystick:getID this says that the ID stays the same even if i disconnect/reconnect a joystick, but if i unplug one and plug in another, the new one gets the ID of the first. Am I missing something?

Next, I have 4 xbox 360 controllers (wireless) and 1 xbox elite controller (wired/wireless), in linux they all show up fine, but in windows the fifth one (whichever order I plug them in) doesn't show up.
I tried setting the SDL_XINPUT_ENABLED=0 in windows env vars to try and switch to directinput but it doesn't seem to be working with the 5th. I'm not entirely sure I've done it right as I'm assuming it shouldnt list them as Xinput devices if xinput is disabled:

Windows:
Capture.PNG
Capture.PNG (10.27 KiB) Viewed 4101 times
Ubuntu:
Capture.PNG
Capture.PNG (10.27 KiB) Viewed 4101 times
Cheers!

Re: A few questions about controllers

Posted: Tue Mar 20, 2018 4:35 am
by zorg
There are 3 types of IDs for controllers;
- An instance ID returned as the second return value from getID;
- The ID returned as the first return value from getID;
- A Globally Unique ID returned from getGUID.

Instance IDs change if you unplug/replug in the controller.
IDs only change when you restart the game.
GUIDs don't change, but they are/may be different per-OS.

I'm not exactly certain which one corresponds to the controller ID listings people like to post all the time, and i'm not sure which one is visible in your screenshots, but the "...if i unplug one and plug in another, the new one gets the ID of the first." thing seems a bit fishy.

Re: A few questions about controllers

Posted: Tue Mar 20, 2018 5:00 am
by kraftman
Ahh, forgot to post my code:

Code: Select all

function love.draw()
    world:Draw()
    
    local joysticks = love.joystick.getJoysticks()
    for i, joystick in ipairs(joysticks) do
        love.graphics.print(joystick:getName(), 10, i * 20)
        love.graphics.print(joystick:getID(), 150, i * 20)

    end 
end
So it's the first id, which shouldnt change?

EDIT:
Apparently a restart has fixed the second issue, I've now got all 5 recognised but now they arent gamepads and only have 5 axis!