The easiest way to do this is from within the emulator menu itself. It’s much quicker than messing around with .cfg files etc.
Play a game – I would usually go for something NES/SNES/Megadrive related (not MAME or the other ports).
Access the emulator menu (usually you press F1) and then you can go to the settings etc. Choose input and then assign the relevant buttons on your control pad.
However, I found it sometimes problematic accessing the menu by pressing F1. I managed to fix this by editing the relevant .cfg file and changing the hotkey to F2. I could then access the menu by holding F2 then pressing F1.
Check out this post here: https://www.petrockblock.com/forums/topic/how-to-setup-a-controller-in-2-2/#post-13105 as this should help.