Add cross-platform gamepad rumble via SDL2#860
Open
chiefautism wants to merge 2 commits intobuttplugio:masterfrom
Open
Add cross-platform gamepad rumble via SDL2#860chiefautism wants to merge 2 commits intobuttplugio:masterfrom
chiefautism wants to merge 2 commits intobuttplugio:masterfrom
Conversation
New crate: buttplug_server_hwmgr_sdl_gamepad Adds SDL2-based gamepad haptics as a buttplug device communication manager. Xbox, PlayStation, and Switch controllers appear as XInput-compatible buttplug devices with dual vibration motors (left/right, 65535 steps each). Works on macOS (GCController backend), Windows (XInput/DirectInput), and Linux (evdev) — all from a single SDL2 codebase. Usage: intiface-engine --use-sdl-gamepad --websocket-port 12345 Tested with Xbox Series X controller on macOS via Bluetooth. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Buttplug sends separate write_value calls for each motor (left then right). Without draining, a stop sequence would send rumble(65535, 0, 10000) then rumble(0, 0, 10000) — the first call re-activates vibration before the second can cancel it. Now the SDL worker thread waits 5ms and drains all pending commands before applying, so both motor values arrive as a single set_rumble() call. Also: SDL on macOS requires duration > 0 to override active rumble, so stop now sends rumble(0, 0, 10000) instead of rumble(0, 0, 1). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
|
Member
|
Oh hell yeah. Lemme know what platforms you need tests run on if you don't have them yourself. I've also got xbox/dualsense/pro controllers to test with. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
buttplug_server_hwmgr_sdl_gamepad— cross-platform gamepad haptics via SDL2intiface-engine --use-sdl-gamepadbundledfeature — no system dependency requiredMotivation
buttplug currently supports gamepads only via XInput on Windows. SDL2 provides a single cross-platform API for gamepad rumble that works everywhere, including macOS where XInput is unavailable.
This unlocks game controllers as haptic devices for creative applications — interactive fiction with haptic feedback, biofeedback loops, accessibility tools, and more.
Implementation
SdlGamepadCommunicationManager: scans for controllers via SDL2's GameController API on a dedicated thread (SDL types are !Send)SdlGamepadHardware: wraps a GameController with a worker thread that processes rumble commands, with 5ms drain batching to coalesce per-motor write_value callsTest plan
🤖 Generated with Claude Code