Find joystick Id

Hi, I’m using SimConnect_MapInputEventToClientEvent to map joystick press to a sim event, however the problem I have I can’t seems to use the joystick name and instead need to use joystick id which windows keep changing when I plug/unplug devices and sometimes even random.

Does anybody know how I can find a joystick id by device name or use device name instead of joystick id? Please see below is the example of the mapping command.

hr = SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, “joystick:0:button:1”, BUTTON_PRESS);