It comes down to this, usually there is what is known as a mixer table in the firmware that defines motor layout, some have very comprehensive tables covering a multitude of possible configurations, others very basic that only cover the common +, X, Y, etc. The mixer tells the flight controller...