Out of the box, a PS3 controller won't simply plug into a PC and go—but with the right software, it absolutely can. A tool called MotionInJoy lets you connect your PS3 controller to your computer and use it across your PC games.
Once you've gathered everything, download MotionInJoy from its official site, install it, and follow the on-screen setup instructions. After that, you're ready to game with your DualShock on PC.