SNES Controller reading #28
brentward
started this conversation in
Show and tell
Replies: 1 comment 2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I just wanted to share the code I used to read 2 SNES controllers hooked up to port A on the VIA:
https://github.com/brentward/rp6502_hello_world
Please forgive the code messiness, it is just testing code and isn't meant to be production ready; I just wanted to share what I've got so far. This project has assembly that initializes and reads the controllers with an interface into C. The C code reads the controller values and draws on the screen using the d-pad with the B and Y buttons used to cycle through the color options. My son has been having a lot of fun messing around with the computer and he wants me to write a snake style game so that is where I'm going with this. Apparently I didn't push my changes to CMakeLists.txt so the target_sources will have to be modified for it to build.
Hardware wise, two SNES controllers are attached to the GPIO pins on the RP6502 (J1). Both controllers share latch and clock pins which are PA3 (pin 9) and PA5 (pin 13) respectively. The data pins are PA4 (pin 11) and PA6 (pin 15) for controller 1 and 2 respectively. All the pins can be moved around except controller 2 must be higher than controller 1. In order to properly detect detached controllers I used pull up resistors on the data lines, that is a resistor between the data pin and +3.3v which I think were 10k ohm.
When I get a chance to take some pictures of the hardware wiring and the onscreen results I will post them, hopefully by the end of today.
Credit to Michael Steil at https://www.pagetable.com/?p=1365 for the information about the pinout of the SNES controllers, the code to read them, and the information about decoding the data read.
Beta Was this translation helpful? Give feedback.
All reactions