Detecting a physical midi controller's input & output

Have a look here at this thread, where I just added some more info. In short, you can distinguish between 2 devices of the same model with MidiDeviceInfo::identifier , but not in any persistent way:

But that said, I’d point out that on macOS anyways, you can rename your MIDI devices in the Audio MIDI Setup app, and give different names to different devices of the same model, and that unique naming will be persistent.