If I start the SNESpad object with:
SNESpad nintendo = SNESpad();
it'll not work (the returned number is always 0b1111111111111111).
But if I change the code to:
SNESpad nintendo = SNESpad(2, 3, 4);
and change some parameters of some delayMicroseconds in the SNESpad.cpp, it'll work correctly. It occurs on version SNESpad_1.2.zip.
I think the actual implementation have a lot of overhead (for example, strobe(), shiftin() functions etc.) and probably we can create a class with a just-one flat function (+ the constructor) that does the job.
Based on http://www.gamesx.com/controldata/snesdat.htm description of the SNES controller I've created a function called getSNESbuttons that does the work right (please see the times in this page so you can see that your implementation have some timing errors). The sketch attached uses my function as an example. If we change this function to be a class, probably we should change the times on delayMicroseconds because of the overhead in calling an object's method.
- snes.pde 1.2KB
Comment #1
Posted on Nov 8, 2010 by Massive BearIf I have access to this repository I can maintain the SNESpad library.
Comment #2
Posted on Nov 8, 2010 by Grumpy ElephantThe code that you posed is all new and has a different interface. It seems like it would make more sense to just create a different project for your library, than to wipe this one out and start it again. The issue with using the constructor without pin numbers is the same as issue #2 - I think I'm going to just change the documentation to say that you need to specify the pin numbers and call it fixed. :) This timing problem that you have is something else, though. It's strange that it's worked for others using the timing that's in the library - I used an actual nintendo game pad (don't have it anymore).. shouldn't matter I would think but I wonder if that's the difference between your setup and others who aren't having a timing issue?
Comment #3
Posted on Nov 13, 2010 by Grumpy ElephantI've uploaded a new version 1.3, that gets rid of the default constructor. If you end up going back to this library instead of your own and find that the timing is off, let us know - the library has worked for others so I'm interested to know why the timing didn't work for you.
Status: Fixed
Labels:
Type-Defect
Priority-Medium