19 thoughts on “Analog/Digital I2C Gamepad on RetroPie

  • cexher1

    Hello.
    Could it be used in I2C1 port? I want to test it with Pi 3 connecting to gpio and I would like to use this port instead I2C0.

    • Short answer is yes. Long answer is that I’d need to update the tutorial to show how it’s done, and that might take a bit.

      • Ok, I can wait.
        I know that you are too busy assembling PCBs

      • obmai89

        After 3 years have you done it ;D? I am working on a project, and my current setup uses I2C1 (physical pin 3 and 5). Could you please give atleast a crude explanation as to what to do? I really need to get this working.

        Thanks.

        • Lets make it an even 4 years. The driver got some updates and changes, and the new code is on GitHub. I’m updating the guide.

  • facelessloser

    Hi I seam to be missing something. Where do you copy the files to on the SD card?

  • CRISTIANO ANSELMI

    Hi, after sudo python joystick.py & the Pi give me an error on file joystick.py line 50. IO error no file or directory /Sys/class/humon/humon0/device/im4_input. I double checked my wiring and is ok. It seems like my I2C doesn’t communicate. Could you please help me with this? many thanks!

    • This guide is very outdated, and the overlays don’t work the same as they used to. I think I can set some time aside to update it.

      • CRISTIANO ANSELMI

        it will be great! losing my health making it works!
        thanks

        • The code is updated and got some changes to add a GPIO expander. I’ll update the guide shortly.

  • Harold Lane

    Hi! I tried the recent feb22 version of the library. It works perfectly with the mcp23017, and detects 1 out of 4 channels of the ads1015 module. I tried a lot of things including editing gamepad.c and changing number of joysticks to two (that was the last resort). The multiplexing isn’t working as expected. It is totally possible that I’m using an ads1115 but the module looks the same as shown here. Maybe a bug?

      • Harold Lane

        Hi! Thanks for looking into this. I took your advice and checked the package markings. It seems I have an ads1115 (BOGI). I’ll try to tweak your library to see if i can make it work. Please let me know if there is a known workaround. In any case, thanks for the great work, the mcp23017 works perfectly and lets me game a bit on the pi 😊

        • Assuming all the registers operate in the same manner between the chips, it’s possible that only one line needs to be changed. Line 180 in the current driver is where the math happens to convert the reading to a voltage.
          https://github.com/othermod/Analog-Digital-I2C-Gamepad-on-Linux/blob/6d61b0b71c771f5025e07a187659168727490429/gamepad.c#L180

          Try changing this:
          ADCstore[input] = (((ADS1015readBuffer[0] << 8) | ((ADS1015readBuffer[1] & 0xff))) >> 4) * 3;
          To this:
          ADCstore[input] = (((ADS1015readBuffer[0] << 8) | ((ADS1015readBuffer[1] & 0xff)))) * 3;

          I only did a quick reading of the datasheet, and more changes might be needed, but this is a good thing to try first. Try it and recompile the code, and let me know whether it works

          • Harold Lane

            Ummmm which variable do I tweak to set bits 7-5 of the config register?

  • Harold Lane

    Unfortunately that didn’t work. I tried (with and without) changing the calibration values but that didn’t help either. Only one channel responds. Afaik the sampling rate is much lower than the ads1015 (something like 860sps) so that might be a thing (will try continuous mode 2 tonight). I’ve worked with ads1115 once before for an arduino project, but my understanding of bit shift is poor.

Leave a Reply