How does lutro handle button settings?

Love retroarch and the idea behind lutro, so I have been reading some source files to see how things works over there. I found the lutro-bobble to be quite educative so far, but there’s one thing I don’t understand, it probably has to do with the way that retroarch handles input devices.

I see that in input.lua there’s a bunch of BTN_* constants, does retroarch just assign them to different controllers as they are configured?

Maybe my question seems incomprehensible due to ignorance, I’m quite happy to clarify further.

Lutro follows mainly the LOVE 0.9.0 API when it comes to joypads. Not that we prefer it over the newest way of handling joypads, but LOVE is just moving faster than us.

What you’re looking at in input.lua is a small abstraction layer that I used to be able to run this demo in both lutro and recent love versions.

The way retroarch works, at least in Lutro, is that 4 joypads are considered plugged all the time.

The BTN_ constants you see at the top of input.lua are just a copy of the constants you will find there https://github.com/libretro/libretro-common/blob/master/include/libretro.h#L319-L371 in the libretro header.

So if you want to check if player 1 pressed button START, you would do isDown(1, BTN_START). And if you want to check if player 2 pressed START, you would do isDown(2, BTN_START).

1 Like

Oh, I see!

So the way that libretro handles the gamepad abstraction is similar to the way that the input.lua file does it, iterating over values on an array? Is there any way to manually check for connected controllers or is it better to only scan for the desired amount of players when needed?