Rotary encoder as arcade spinner

What would be the simplest way to use a rotary encoder ( i got the one from RGB Encoder Breakout ) to control a spinner based arcade game? Convert to a key, or mouse are the easiest ways i can think of to control RetroPie based emulators, but Not exactly sure how to do that, even with the examples in the IOE-Python library. I can’t imagine it would be much different if directly wired to gpio ports (of which i have none left, thus the IO expander breakout).

I’m not a master, more of a hack, but i’m willing to learn if pointed in the right direction…

any suggestions?

Well, it would be much of a difference if directly wired to a gpio port, because you could add the following lines to your /boot/config.txt:

dtoverlay=rotary-encoder,pin_a=17,pin_b=27,relative_axis=1
dtoverlay=gpio-key,gpio=22,keycode=28,label="PUSH"

This would directly generate events that you could process with python module evdev.

So the way to go is to catch the interrupt generated by the expander library and then generate the events yourself (assuming that your game already has the logic in place to react to key or mouse-events). You can find evdev with all it’s documentation here: evdev · PyPI

But on the other hand, it might be simpler to react directly once you have an interrupt (see rotary.py example in the library). The example just sets some colors, but you could call any other method directly.