A few questions about controllers

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
kraftman
Party member
Posts: 277
Joined: Sat May 14, 2011 10:18 am

A few questions about controllers

Post 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 4092 times
Ubuntu:
Capture.PNG
Capture.PNG (10.27 KiB) Viewed 4092 times
Cheers!
Attachments
29389176_10159945097580276_6903006579277168640_n.png
29389176_10159945097580276_6903006579277168640_n.png (5.18 KiB) Viewed 4092 times
User avatar
zorg
Party member
Posts: 3441
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: A few questions about controllers

Post 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.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
kraftman
Party member
Posts: 277
Joined: Sat May 14, 2011 10:18 am

Re: A few questions about controllers

Post 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!
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 21 guests