Uncategorized

How Can Rpi Interface The I2C Nintendo NES Game Controller with WII Remote?

How Can Rpi Interface The I2C Nintendo NES Game Controller with WII Remote?

Ask QuestionAsked 12 days agoActive todayViewed 52 times1

so I bought this NES controller thinking I would be dealing with a 5-pin shift register but found that it was connected to a WIImote connector that appears to use I2C.

NES controller

I am trying to read its output with my raspberry pi 3 model B. Is there a library or something I could use? Any other ideas?pi-3i2cshareedit  follow  close 3flagedited 8 mins agotlfong013,27733 gold badges77 silver badges2121 bronze badgesasked Aug 4 at 19:59matkiller3331133 bronze badges

  • Ah yes, new nes are i2c. try google for a library by the Arduino guys or write your own. – tlfong01 Aug 5 at 0:41   
  • (1) I googled but found not much NinTendDo I2C stuff around. So I decided to do some DIY learning. Now I am drafting an answer. It will be a “live” and “crowd” answer, in the sense that I would welcome readers (the crowd) to comment, suggest, and brainstorm, to expand and improve my answer. (2) About myself: I know quite a lot about I2C, but don’t know nothing about NinTenDo toys, because I never own any. – tlfong01 Aug 5 at 3:08   
  • pls give me the link to your wiimote. Many thanks. – tlfong01 Aug 5 at 3:26   
  • 1I do not have a wiimote to which it connects, however here is the link to the controller I bought: [link] (amazon.ca/DOORGA-Nintendo-Classic-Wired-Controller/dp/…) @tlfong01 – matkiller333 Aug 5 at 5:17 
  • I am confused. The first sentence of your question goes: “I bought this NES controller, …, found that it was connected to a WIImote connector that appears to use I2C .”. The picture follows seems to show the PCB of “this NES controller“. What I am asking is the link to “thsi NES controller” Or have I misunderstood something? – tlfong01 Aug 5 at 5:38   
  • And perhaps I am misunderstanding many things because as I said in my 2nd comment, I don’t know nothing about NinTenDo stuff, I don’t even know there is another thing called “nunchuk” which is an “attachment” to Wiimote, but sometimes it is also called a “controller”. 😦 – tlfong01 Aug 5 at 7:11   
  • 1So the link I sent is the link to “this NES controller”, it has a plug that typically connects to a Wiimote, the same that other attachments for the Wii have (ex. Nunchuk). The NES controller is not a standard attachment to the Wii but simply uses the same plug. So I do not have, nor need a WiiMote for this project to work, as I am solely trying to read the output of the NES controller. Hope this clarifies it better – matkiller333 Aug 5 at 15:02
  • Thnak you for your clarification. As I said, I didn’t know nothing about NinTendo. It is only after I skimmed so many wiki’s and blogs then I have now go a fuzzy picture. didn’t know nothing about NinTendo. It is only after I skimmed so many wiki’s and blogs then I have now go a fuzzy picture. It is laughable that I actually didn’t know what NES stands for, I casually thought it is a general term, but then I know it is like DS which is not at all a general term, but there are many implications when you use the jargons DS, NES etc. / to continue,… – tlfong01 Aug 6 at 1:59   
  • Similarly I didn’t know exactly what is a “home console”, though I can guess what is a handheld console, because I know the term “hand held game”. I know very well the term “computer game”, because I have been playing computer game for 20 years, with Windows PC and keyboard only. Actually I have never seen a real XBOX, so I don’t know it is a console or controller. I once thought about buying a NinTando DS. But then DS game were expensive. Now I am thinking about getting a NS to play Animal Crossing, but then the package price is over HK$2,000! – tlfong01 Aug 6 at 2:07   
  • There is another thing I found confusing. You said the following: “I bought this NES controller thinking I would be dealing with a 5-pin shift register but found that it was connected to a WIImote connector that appears to use I2C”. Question: By 5-pin shift register, do you actually mean a hardware, round 5 pin connector, and NOT 5 software registers? – tlfong01 Aug 6 at 3:03    

add a commentstart a bounty

3 Answers

ActiveOldestVotes0

Question

How can Rpi talk I2C to NintenDo Controllers?

wii i2c
nunchuk 1

/ to continue, …


Answer

I googled but could not find any Rpi python library for I2C Wiimote. I only find the BootLin’s Wii I2c spec.

The Wiimote I2C protocol is pretty standard (Appendix A). So it should be easy to
talk I2C with it.

Ref 9, 10 are DIY project to make fun with Wiimote and should be useful for the OP.

/ to continue, …


References

(1) Game Controller – Wikipedia

(2) Nintendo controllers list – Wikipedia

(3) Nintendo Wii Remote (nunchuck) – Wikipedia

(4) Nintendo I2C Wiimote/Extension Controllers

(5) Nintendo I2C Wiimote/Extension Controllers/Classic Controller

(6) Pynput, a python library to control and monitor input devices (Sorry, No Nintendo!)

(7) Amazon WiiMote Catalog

(8) AliExpress Wii Remote Catalog

(9) Do-it-yourself project to use a Wii remote controller

(10) Fun with Wiimote

(11) I2C for Wii WiiChuck Nunchuck Adapter shield Module Board for Arduino

(12) NinTenDo Wii Nunchuk I2C Interface

(13) NinTenDo NunChuk

(14) Nintendo Switch – Wikipedia

(15) Nintendo Video Game Home and Handheld (Portable) Consoles – Wikipedia

(16) Animal Crossing – Wikipedia

(17) Animal Crossing: New Horizons – Wikipedia

(18) Nintendo Entertainment System – Wikipedia

(19) Wii Remote Teardown and Analysis (ADXL330) – 2016

(20) Video Games in South Korea (Lineage II, NCsoft 2003)

(21) The Best Nintendo Switch Controllers of 2020

(22) Using a Wii Nunchuck to control Raspberry Pi Python Turtle – AdaFruit 2014jun20

/ to continue, …


Appendices

Appendix A – NinTenDo Wii Nunchuk I2C Interface

wii i2c 1
wii i2c 2

/ to continue, …


End of answershareeditdeleteflagedited 51 secs agoanswered Aug 5 at 3:19tlfong013,27733 gold badges77 silver badges2121 bronze badgesadd a comment0

All right, so a few days and a lot of reading about i2c later, I came up with a simple code to read the basic inputs of the NES controller. Thanks to Andyroo for the starting place.

For anybody interested here’s the code:

import time
from smbus import SMBus

address = 0x52

class nes:

    def __init__(self,delay = 0.05):
        i2c_bus = 1
        self.delay = delay
        self.bus = SMBus(i2c_bus)
        time.sleep(1)
        self.bus.write_byte_data(address,0x40,0x00)

    def raw(self):
        time.sleep(self.delay)
        data = self.bus.read_i2c_block_data(address, 0, 6)
        time.sleep(self.delay)
        return data

    def read(self, key = 0, name = ""):
        data = self.raw()
        a = data[4]
        b = data[5]
        if a == 255 and b == 255:
            key = 0
            name = "none"
        elif a == 255 and b == 254:
            key = 1
            name = "up_arrow"
        elif a == 191 and b == 255:
            key = 2
            name = "down_arrow"
        elif a == 255 and b == 253:
            key = 3
            name = ("left_arrow")
        elif a == 127 and b == 255:
            key = 4
            name = ("right_arrow")
        elif a == 239 and b == 255:
            key = 5
            name = ("select")
        elif a == 251 and b == 255:
            key = 6
            name = ("start")
        elif a == 255 and b == 191:
            key = 7
            name = ("b")
        elif a == 255 and b == 239:
            key = 8
            name = ("a")
        elif a == 63 and b == 252:
            key = 9
            name = ("full_arrow")
        else:
            key = 100
            name = ("unregistered")
        return key, name

shareedit  follow  flag answered Aug 8 at 21:20matkiller3331133 bronze badgesadd a comment1

The wiimote controller connected via Bluetooth to the console whereas the nunchuck used I2C to connect.

If it is the nunchuck interface then the Python routines from Boeeerb on Github is a good place to start else look at the Python module pynput to handle the feed.

As for your board – I’ve no idea what it will output but I would go back to the supplier and ask.shareedit  follow  flag answered Aug 5 at 0:51Andyroo2,99233 silver badges1919 bronze badges

  • 1Thanks, I’ll look into the nunchuck interface and come back if I can write one that works for the NES controller – matkiller333 Aug 5 at 5:37

add a comment

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.