19 thoughts on “Analog/Digital I2C Gamepad on RetroPie

  • April 17, 2018 at 10:41 am
    Permalink

    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.

    • April 17, 2018 at 12:14 pm
      Permalink

      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
        Permalink

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

      • December 25, 2020 at 8:23 pm
        Permalink

        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.

        • February 10, 2022 at 8:45 pm
          Permalink

          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
    Permalink

    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
    Permalink

    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
      Permalink

      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
        Permalink

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

        • February 10, 2022 at 8:46 pm
          Permalink

          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
    Permalink

    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
      Permalink

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

      • March 14, 2022 at 5:54 pm
        Permalink

        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
          Permalink

          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

          • March 16, 2022 at 8:11 pm
            Permalink

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

  • March 16, 2022 at 4:31 pm
    Permalink

    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