SNESDev-RPi
SNESDev-RPi copied to clipboard
Improvements
Check out my branch. https://github.com/axle-h/SNESDev-RPi
I haven't made a pull request because I've changed so much. Instead, here's where I think you can improve this.
Performance:
- Assume that the latch and clock signals are tied so only need to run the poll sequences once per frame. Data signals can be read for all controllers fast enough between clock pulses.
- Retain last frame state so that we don't need to write button state to uinput every frame. We can instead only write when state changes.
- Don't need to run all 16 SNES clock pulses. 12 works fine.
- uinput sync is only required once per frame, not per button and no need to write the button press time.
- Button polling doesn't need to be done every frame.
Accuracy:
- The latch pulse should be 12ns. Each clock pulse should be 6ns.
- The clock signal should be held high and pulsed low.
Some general daemon stuff:
- Run as daemon using unistd. Don't rely on daemon tools.
- Log to daemon syslog.
- Provide command line options e.g. verbose, pid-file, debug.
- Don't tie this to your snes gpio adapter, e.g. i'm using your circuit but not connected to same gpios.
- Use an auto build system e.g. CMake instead of building dependencies as part of project.
Improvements
- Button config seems over complicated. Simplify it like what I've done and providing configurable key values is trivial.
Thanks for that - looks great. I will add the enhancements based on your work!
@axle-h does your fork work when using the GPIO adapter ? I installed it hoping it would solve the issues i'm having with my SNES controllers, but i don't know what values i should put in the configuration file, since the pins of the SNES controllers are not directly connected to the Pi GPIOs.
Never mind, i found my answer for revision 2 of the adapter :
- Gamepad 1 GPIO = 27
- Gamepad 2 GPIO = 22
- Clock GPIO = 23
- Latch GPIO = 24
- Button GPIO = 17
It's working but i see you have removed the option to handle different behaviours on 1, 3 or 5 presses on the button. Is there a way to get this option back ? Sorry to ask this question here, but you didn't open the "issues" tab on your Github fork.
Hi, Yeah probably not right place to be talking about a different branch here until/if it gets pulled. Issues can only be created on the original repository unfortunately. Is my email address not visible? I don't know about the adapter - I built my own. Most of the fun of using the Pi is to find your own way anyway!
I took the button press polling thing out as it was a bit over complicated, was difficult to setup from a config file and I didn't need it. It should be relatively easy to implement though. Check out button.c. It's a simple state machine. You just need to add some more states and decide when to switch to them. Maybe add a counter in the button struct and "do stuff" when it hits a particular threshold - I think that's how Florian implemented it. It might be difficult however to add this to the config. Hence why it's not in my branch. Might look at it. Be an excuse to have another dabble with this. Unless you fancy a go?
I'm writing here instead of e-mailing because this may be of some interest to someone using your fork :) I understand your code but i'm not a C dev, so for now i'll keep it like this. Maybe i will try to patch it some day. For the configuration of the button, you don't have to make it fully configurable with a variable amount of programmable key presses. Maybe you could just have something like this :
Buttons {
Button 1 {
Enabled = true
# Tap the button to press this keyboard key
SinglePressKey = "R"
#SinglePressCommand =
# Double tap the button to press this keyboard key
DoublePressKey = "ESC"
#DoublePressCommand =
# Hold the button for 3 seconds to execute this command
LongPressCommand = "shutdown -t 3 -h now"
#LongPressKey =
Gpio = 5
}
# Frequency to poll buttons in Hz
PollFrequency = 2
}
What do you think ?