Rotary encoder to act as directional buttons for games

Post Reply
Ewhizz
Posts: 2
Joined: Mon Apr 25, 2022 6:24 pm
languages_spoken: english
ODROIDs: DIY odroid go
Has thanked: 0
Been thanked: 0
Contact:

Rotary encoder to act as directional buttons for games

Post by Ewhizz »

Hi!

I am just wondering if anyone knew whether its possible to program a rotary encoder to be used as a controller input for Odroid-go emulators like Gameboy, NES, etc.

If anyone could point me in the right direction in terms of editing the controller code for the emulators on an Odroid go device I would greatly appreciate it!!

Thanks very much :)

User avatar
odroid
Site Admin
Posts: 39117
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 2513 times
Been thanked: 1382 times
Contact:

Re: Rotary encoder to act as directional buttons for games

Post by odroid »

Just curious,
Which games do you want to play with a rotary encoder?

Ewhizz
Posts: 2
Joined: Mon Apr 25, 2022 6:24 pm
languages_spoken: english
ODROIDs: DIY odroid go
Has thanked: 0
Been thanked: 0
Contact:

Re: Rotary encoder to act as directional buttons for games

Post by Ewhizz »

Outrun for example would be cool with rotary controls, or any simple racing game for that matter

User avatar
odroid
Site Admin
Posts: 39117
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 2513 times
Been thanked: 1382 times
Contact:

Re: Rotary encoder to act as directional buttons for games

Post by odroid »

I see.
But I have no idea how to push the encoder events to the emulator input handlers either.

User avatar
mctom
Posts: 1594
Joined: Wed Nov 11, 2020 4:44 am
languages_spoken: english, polish
ODROIDs: OGA, XU4, C2, M1
Location: Gdansk, Poland
Has thanked: 185 times
Been thanked: 199 times
Contact:

Re: Rotary encoder to act as directional buttons for games

Post by mctom »

Probably you'd want to emulate taps of left and right arrows as you turn an encoder knob. It's tricky because encoders do not send pulses, but 2-bit gray code waveforms. Thanks to this, the receiver knows which way the encoder is turned.
Whatever reads these waveforms will have to emulate pulses of some credible length in 10-100ms range, which might be tricky. You don't want to just add sleep() to that procedure and hope for the best...

I would probably build hardware that converts encoder waveforms into pulses and wire it parallel to left and right buttons. Hardware is always the solution. ;)
Punk ain't no religious cult, punk means thinking for yourself!

Maintainer of PiStackMon

crashoverride
Posts: 5660
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 537 times
Contact:

Re: Rotary encoder to act as directional buttons for games

Post by crashoverride »

Ewhizz wrote:
Mon Apr 25, 2022 6:32 pm
If anyone could point me in the right direction in terms of editing the controller code for the emulators on an Odroid go device I would greatly appreciate it!!
For the official build, all the emulators use the same API for input.
https://github.com/OtherCrashOverride/g ... id_input.c

Custom controllers can be implemented by replacing the code here:
https://github.com/OtherCrashOverride/g ... .c#L36-L85

Note that since there are no shared libraries on ESP32, each emulator will need to be recompiled.

Post Reply

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 1 guest