r/jailbreakdevelopers • u/Douugr • 1h ago
Release [Release] Open-source libretro frontends for iOS 8 with BTstack input
I've been reviving an iPad 3 (iOS 8.4.1, armv7) and ended up writing two small libretro frontends for it, since current RetroArch builds no longer target iOS 8. Sharing some of the implementation details in case they're useful to anyone else building for legacy 32-bit devices, and I'd love feedback.
**What it is**
- MD16: Genesis Plus GX core (Mega Drive / Master System / Game Gear)
- SNES16: Snes9x 2005 core
- Both are plain Obj-C apps (no RetroArch), installed in /Applications so they can use BTstack.
**Toolchain**
- Xcode 13.4.1 on a modern Mac, `-arch armv7 -miphoneos-version-min=8.0`, signed with `ldid -S`
- Cores built from pinned libretro commits and linked statically
**Bluetooth input (BTstack 1.1)**
- BTstack's client lib schedules on `CFRunLoopGetCurrent()`. Running it on the main thread caused multi-second input delays and dropped links whenever the UI was busy, so it now runs on a dedicated NSThread with its own run loop, and callbacks are dispatched to the main thread.
- Sniff mode is disabled on the HID link (`hci_write_link_policy_settings(handle, 0x0001)`), which removed the periodic latency spikes.
- On the iPad 3, BTstack never reaches the working state with Wi-Fi off (shared BT/Wi-Fi chip), so the app detects that and warns the user.
- Button mapping is learned from raw HID reports: the app picks the report bytes that changed most during each press, detects hat switches, and saves the mapping per controller address. Tested with an 8BitDo Pro 2.
**Video / audio / latency**
- RGB565 framebuffer uploaded to a GLES2 texture, GLKView at contentScaleFactor 1 (the Retina scale was a big cost on the A5X)
- Frame pacing is driven by the audio queue level: skip a frame when there's more than ~4 frames buffered, run an extra one when there's less than 2.
- Optional 1-frame run-ahead (serialize, run a muted frame with video disabled, unserialize). It auto-pauses if frames come in late. Genesis Plus GX fits comfortably; Snes9x 2005 is borderline on the A5X, so it's off by default there.
- The on-screen controller was originally one full-screen transparent overlay, and compositing it caused stutter. Splitting it into small subviews (one per button group) fixed it.
**Other bits**
- Built-in HTTP server (BSD sockets) for uploading files from a desktop browser over Wi-Fi
- IPS/BPS patcher in C, applied at load time (with CRC checks for BPS)
- Save-state slots plus autosave
**Distribution**
Cydia repo hosted on GitHub Pages; packages are built with `dpkg-deb` and indexed with `dpkg-scanpackages`. Depends on `ch.ringwald.btstack` and limits firmware to `>= 8.0, << 11.0`.
Repo: https://douugr.github.io/repo/
Source: github.com/douugr/md16 and github.com/douugr/snes16
I've only tested on an iPad 3. I'm especially interested in reports from other armv7 devices (4S, iPad 2, iPad mini 1), and in whether anyone knows a cleaner way to get BTstack working with Wi-Fi off on these chips.