Piston and wheel mechanism issue

So I found this post:

Which is fantastic, just what I needed, but… It only works in the Y-axis.

Could someone point me in the direction of how to rig such a mechanism that can be rotated in any orientation and still operate correctly?

This is a good piston tutorial.