Refined the function to get the number of plugged in controllers.