This guide will tell you how to fix Controller Not Working/Not being Detected in Modern Warfare 2.
First of all, you will need to open Steam and click on the library tab at the top of your screen. After that, find COD Modern Warfare, then right-click on the game and go to the properties. You have to select the controller from the left side of your screen and change it from using default settings. You need to set it to Disable Steam Input. It will skip the remapping that Steam does to make it compatible with some games and then it will connect directly to your game.
But in the future, if you change it to Enable Steam Input or to Use Default settings, then this might fix your problem.