The RetroPie SDL fork is at https://github.com/RetroPie/SDL-mirror, for the Raspberry PI it uses the rpi-3 branch. In your case I'd try first an updated xpad driver and making sure the device is in Xinput mode. The xpad driver used by RetroPie is at github.com/paroj/xpad.