Another suggestion:
Since I already drew this on a piece of paper, I decided to share it, in case you find something useful. Basically, you attach two ratchet cogs on the shaft, one under the other, so that the upper one locks to the rotation of the shaft when the shaft spins counter-clockwise, and the lower one locks to the rotation of the shaft when the shaft spins clockwise (kind of like the cogs of a bicycle or those ratchet wrenches that were mentioned already). Then you have these two additional (regular) cogs, cog 1 spun by upper ratchet cog and cog 2 spun by the lower ratchet cog. The non-interacting ends of cogs 1 and 2 end up in the same plane. The weird stopper on the third picture is in order to restrict the inertial motion of the bar, because since one cog is locked to the rotaion of the shaft, the other is free and can gain extra angular momentum from the movemnt of the bar. All these things of course could be modified to make this more stable, I just drew the overall principle.
![enter image description here](https://i.sstatic.net/wR2gq.jpg)
Previous attempt:
I could suggest this:
![enter image description here](https://i.sstatic.net/sn96w.png)
I don't know if it helps you. You have three main parameters to consider: the radius of the shaft $R$, the radius of the disc on the left $r$, the two teeth (or levers?) attached to the disc on the left of length $x$, both folding in only one direction, the fixed tooth on the shaft of length $x$. I drew only one fixed tooth on the shaft, but one can add several, in order to capture rotations that may not complete one full turn. I guess it depends on the sensitivity, what amplitude of a rotation you want to capture.
There is a condition on these parameters, i.e. they have to satisfy some inequality to make sure the teeth attached to the disc on the left can fold enough so that they do not interact with each other. Now, if you, for example, pick the parameters so that they satisfy a specific geometric equation that I can propose, then I think the mechanism should work (from geometric restriction point of view). The triangle $AOP$ at the bottom of the picture should have edge-lengths satisfying the law of cosines with respect to angle $\angle \, OAP = \alpha$:
$$(R+x)^2 = (R+r+x)^2 + (r+x)^2 - 2 (R+r+x) (r+x)\cos(\alpha)$$
Next, if you pick the geometry of $AOP$ so that the smaller isosceles triangle on the left so that its edge-lengths are $r,\, r, \, x$ and angle $\alpha$, then:
$$x^2 = 2\,r^2 - 2\, r^2 \cos(\alpha)$$
If you solve the second equation for $\cos(\alpha)$ and plug the expression into the first one, you get the equation
$$(R+x)^2 = (R+r+x)^2 + (r+x)^2 - 2(R+r+x) (r+x) \, \frac{2r^2 - x^2}{2r^2}$$
or if you multiply by $r^2$ both sides of the equation:
$$r^2(R+x)^2 = r^2(R+r+x)^2 + r^2(r+x)^2 - (R+r+x) (r+x) (2r^2 - x^2)$$
So I think that if you solve this numerically for either $x$, if you have $r$ predetermined, or for $r$ if $x$ is predetermined, it looks like this will make that the mechanism work. Of course, this is one possible quick suggestion, one could try to analyze the geometry a bit more carefully, for a more optimal solution. But maybe it is not necessary.
Old stuff.
As a starting point, I can suggest something like this:
![enter image description here](https://i.sstatic.net/Yfi8V.png)
We are in a plane perpendicular to your rotating shaft. The intersection of the shaft with the perpendicular plane of the picture is the circle with center $O$ on the right, where $O$ is the point of intersection of the shaft's axis of rotation and the plane. Assume we can place a belt on the shaft that can transfer the rotation onto a planar disc (or cog?), depicted on the picture as the left circle with center $A$. Assume you have attached some kind of a joint firmly to the left disc at point $P$, so $P$ rotates with the disc, driven by the rotation of the shaft, and $|AP|=R$ is the radius of the disc on the left.
Select points $B$ and $C$ firmly fixed so that:
$$B \,\, \text{ such that } \,\, |AB| > 2\, |AP| = 2\, R $$
$$C \,\, \text{ such that } \,\, C \text{ lies on the segment } AB \,\, \text{ and } \,\, |BC| = |AP| = R $$
Place two bars $PD$ and $BD$ connected with a circular joint $D$ and $PD$ is connected to the disc with a circular joint at $P$ (kind of like a wheel of a vintage train engine, so that the bar $PD$ can freely go over the disc, without clashing with it). Moreover
$$|BD| = |BC| = |AP| = R \,\, \text{ and } \,\, |PD| = |AB|$$ which means that when $P$ rotates with the disc, point $D$'s trajectory is a circle of radius $R = |AP| $ centered at $B$, because throughout the circular motion of $P$, the quadrilateral $ABDP$ is always a parallelogram.
Next, attach two bars $CE$ and $CF$, connected with a circular joint at $C$, such that $|CE| = |CF|$. Also, add the four bars $DE, \, DF, \, EQ, \, FQ$ such that
$$|DE| = |DF|=|EQ| =|FQ|$$, all points of connection being circular joints.
The mechanism $CDEFQ$ is constructed so that point $D$ moves along a circle of radius $R = |AP|$, centered at $B$ and passing through the point $C$. At the same time, the mechanism performs geometric inversion with respect to the circle centered at point $C$ and having radius $|CE|^2 - |ED|^2$, so that point $D$ is mapped to point $Q$. Since point $D$ moves along a circle that passes through the center $C$, the inverse image $Q$ of point $D$ must move along a straight line, which is the dashed vertical line drawn on the picture.