I've been looking for a way to use my PS3 gamepad on Windows (I'd like to use it while being plugged in via USB-wire, not interested in bluetooth-mode), since I find this pad to be the best for me. For years now there's been this tool called MotionInJoy, but it's a terrible, advertising-and-who-knows-what-else-ridden piece of shit and so I'd rather not install that, if I can avoid it. I know there's another tool called "Better DS3", which can be installed in addition to MotionInJoy, but still, that's not a perfect solution.
Turns out there is something better: A user on the PCSX2 forums wrote the tool "XInput wrapper for DS3" and it works great. Here's the thread, it contains a step-by-step guide.
(note that you have to install the "latest version" first and then install the "latest update". Just installing the latter won't work.
For the PS4 pad, there are several tools out there, but this one here seems to be good and the developer is good at responding to requests/problems (see forum here).
On to the Linux side (using Ubuntu 14.04, kernel 3.13.0-32-generic):
The PS4 controller worked out of the box (again, only interested in wired operation, not wireless), just plugged it in and I was able to use it in Steam and Snes9x.
The PS3 controller should work out of the box, but it currently doesn't due to this bug in the 3.13 Ubuntu kernel. Once it's fixed, it should work again (without the need for any tools, such as this one). Also, found some good troubleshooting tips here.