RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    Analog joystick in RetroPie with MCP3008 ADC

    Scheduled Pinned Locked Moved Help and Support
    analog joystickmcp3008uinputspi
    1 Posts 1 Posters 1.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      dduong16
      last edited by

      Hello,

      I'm trying to build a Super Pi Boy-like system using a RPi3, RetroPie (emulation), Retrogame (basic GPIO buttons), and an MCP3008 ADC with an analog joystick instead of a D-pad with tactile buttons. I'm trying to get analog-like controls if possible (e.g., 45deg would simulate pressing both UP and RIGHT), but if I have to settle for UP is UP, that's fine. I understand that the joysticks output 0-1023, with around 511.5 being centered for both X any Y axes. I also understand that most emulators only have directional buttons, but I prefer the feel of a joystick instead of a D-pad. Though the RPi3 can handle PSX and N64 games, so maybe I can leverage your guys' help to implement full analog controls.

      I've been following some tutorials on how to enable SPI and Python-SPI wrapper on the RPi, and I can get values. However, I have two questions on where to go from here. Note that I'm only as familiar with linux syntax and programs (like nano) as I have been getting through setting this up, so any specific commands, code, or pseudocode would be helpful.

      (1) How do I get the digitized SPI signal from the joystick to correspond to a keyboard press (e.g., <100 UP = 'W', <100 UP && >923 RIGHT = 'W'+'D' with WASD configuration)
      (2) How do I get this to run on boot, since it loads into emulationstation on startup?

      I have also found the Python uinput library, which seems like it could work. However, with my inexperience with Python, I don't know how to incorporate this. Also, please let me know of any solutions that would work in conjunction with RetroGame (my basic A, B, X, Y, L, R GPIO game buttons).

      Pi Model or other hardware: RPi3 Model B
      Power Supply used: Phone charger now, transitioning to PowerBoost with Li battery
      RetroPie Version Used: 4.2
      Built From: Pre made SD Image on RetroPie website - retropie-4.2-rpi2_rpi3.img
      USB Devices connected: Generic 104 Keyboard for now
      Controller used: GPIO buttons with PSP joystick and MCP3008
      Guide used: RaspberryPi Spy, Adafruit

      1 Reply Last reply Reply Quote 0
      • First post
        Last post

      Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

      Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.