Category: Programming

  • davids_pico_gamepad: A Pico W Bluetooth-to-USB Adapter

    The Nintendo 64 is my favourite games console and I have many fond memories of playing it when I was much younger. In the past few years I’ve acquired an N64 with a PixelFX Retro GEM HDMI mod and have been playing using an official Nintendo controller modded with the 8bitdo mod kit (keeping the original stick) and a blueretro adapter.

    One frustration I have with the 8bitdo mod kit is that it’s difficult if not impossible to make it work nicely with a PC running an emulator or a PC port of an N64 game. The controller is somewhat unique and so using anything else feels odd. I wanted to find a solution to use the controller on my PC.

    I looked at a few existing options, but they all had drawbacks:

    • The mod kit only supports rumble in “S” (Switch) mode, but only works nicely without random drivers in “D” (D-input) mode. This is pretty annoying.
    • 8bitdo do sell a USB adapter which can connect to the mod kit (in “S” mode) and present it as an X-input device via USB, which then supports rumble effects. However, there seems to be extreme latency on the rumble effects which detract somewhat from the experience.
    • The blueretro implementation works really well. It uses an ESP32 for bluetooth and talking to the N64. I believe it uses the two cores in the ESP32 to separate the bluetooth and USB communications which help provide great latency. Blueretro would have been a preferred starting point, however it’s written and optimised for the ESP32 for which most development boards don’t contain a USB port that can be used as a USB device.

    The Raspberry Pi Pico W can act as a USB device and also has bluetooth built-in. I decided to see if I could make this do what I want.

    There are two similar projects that I looked at before embarking on creating something new: PicoGamepadConverter and OGX-Mini. I couldn’t get either to work properly for me though I didn’t spend too long trying.

    I ended up starting a new project and experimenting with gemini-cli to write it, having only a small amount of experience with programming bluetooth and less for USB. I found gemini-cli very slow to respond, but over the course of a few nights managed to get something that worked. I’ve pushed it to github as davids_pico_gamepad.

    Currently I can only confirm it works for my niche use case but I’d like to expand it to work with more bluetooth gamepads. I’ve developed it on a Raspberry Pi Pico 2 W but have ordered a Pico (1) W to test with. If you have a Pico W/Pico 2 W and a USB gamepad lying around please give it a go and let me know what works!

  • kerl: Ubuntu 22.04 build dependencies

    On top of what I already had on a relatively newly install 22.04 machine, I needed the following to build Erlang/OTP 26.3.4 with kerl completely without any warnings:

    sudo apt install automake autoconf libncurses5-dev openjdk-21-jdk xsltproc fop unixodbc-dev libwxgtk3.0-gtk3-dev libwxgtk-webview3.0-gtk3-dev

    I already had build-essential and possibly other things. For tab completion I did:

    mkdir -p ~/.local/share/bash-completion/completions/
    curl https://raw.githubusercontent.com/kerl/kerl/master/bash_completion/kerl > ~/.local/share/bash-completion/completions/kerl

    UPDATE:

    For 24.04 I used:

    sudo apt install automake autoconf libncurses-dev openjdk-21-jdk xsltproc fop unixodbc-dev libwxgtk3.2-dev libwxgtk-webview3.2-dev

    UPDATE 2:

    I added an activate line in my .bashrc file. This broke all my man pages because it set MANPATH (which was previously blank) to include the erlang man pages (and nothing else). Adding this before the activate line fixed that (many thanks to this comment):

    if [ -z "${MANPATH+x}" ] || [ -z "$MANPATH" ]; then
       export MANPATH=$(manpath -g)
    fi