1

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?

11
  • Ah yes, new nes are i2c. try google for a library by the Arduino guys or write your own.
    – tlfong01
    Aug 5, 2020 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, 2020 at 3:08
  • pls give me the link to your wiimote. Many thanks.
    – tlfong01
    Aug 5, 2020 at 3:26
  • 1
    I 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 Aug 5, 2020 at 5:17
  • 1
    So 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 Aug 5, 2020 at 15:02

3 Answers 3

1

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.

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

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
0

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

(23) Using a Wii Nunchuck to control Raspberry Pi Python Turtle - Jason Barnett, TutsPlus, 2014jun13

/ to continue, ...


Appendices

Appendix A - NinTenDo Wii Nunchuk I2C Interface

wii i2c 1

wii i2c 2

/ to continue, ...


End of answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.