Rigging mechanical joints

I am trying to rig a mechanical joint like this:

I tried to use track to constraints on multiple bones in combination with limit rotations, copy rotation with limit rotation constraints, and transform constraints, but none of them seemed to do, what I wanted: object one shall rotate together with object two only around the x axis. Object t shall rotate only around its local y axis, and object three shall be able to rotate seperat from the other ones around the x axis. This is the shoulder of some mech, so is has to be controled by a IK chain which starts at the lower arm. Any help is apreciated, I am running out of ideas. Thanks!

Over in this thread…

There was a discussion about a similar arm rig. Wasn’t exactly the same, but DanPro did a great tutorial that should get you going in the right direction.

Thank you, based on this, I got it figured out. I didn´t knew about the limit rotation settings for IK bones. Her is my solution, if anybody is interested/having the same problem:
rig_complete.blend (490 KB)