19 thoughts on “Analog/Digital I2C Gamepad on RetroPie

  • April 17, 2018 at 10:41 am

    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.

    • April 17, 2018 at 12:14 pm

      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.

      • April 17, 2018 at 3:19 pm

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

      • December 25, 2020 at 8:23 pm

        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.


        • February 10, 2022 at 8:45 pm

          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.

  • January 27, 2019 at 6:18 pm

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

  • February 5, 2022 at 1:28 am

    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!

    • February 5, 2022 at 4:44 pm

      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.

      • February 9, 2022 at 2:08 am

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

        • February 10, 2022 at 8:46 pm

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

  • March 7, 2022 at 4:18 pm

    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?

    • March 14, 2022 at 1:45 am

      I checked everything again, and it all works fine. The issue is probably with your module.

      • March 14, 2022 at 5:54 pm

        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 😊

        • March 14, 2022 at 9:25 pm

          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.

          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

          • March 16, 2022 at 8:11 pm

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

  • March 16, 2022 at 4:31 pm

    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