Skip to content

Comments

Completely refactored to work with new PSMoveAPI Library#15

Open
MattGrayYes wants to merge 6 commits intoJonty:masterfrom
MattGrayYes:master
Open

Completely refactored to work with new PSMoveAPI Library#15
MattGrayYes wants to merge 6 commits intoJonty:masterfrom
MattGrayYes:master

Conversation

@MattGrayYes
Copy link

Oust has been entirely refactored to use the "new" PSMoveAPI v4, and has been tested on Raspberry Pi OS Lite (64-bit, based on Debian Trixie)

Before merging, you may want to edit line 132 of README.md, as the git clone url is hardcoded to my repo.

New features

  • Paired controllers are remembered. No need to pair before every game.
  • When a controller is waiting in the lobby to play, the orb glows a dim orange to show that it's connected and behaving.
  • PS button now turns off a controller when it's in the lobby.
  • SELECT button still turns off a controller when it's in the lobby.
  • CIRCLE button still shows battery status.
  • START button still starts game early.
  • If you use a Raspberry Pi 3B (omg such modern technology!) the bluetooth is inbuilt so you don't need a dongle!

Refactoring

Highlights

  • Original bluetooth hacks no longer needed
  • New bluetooth hacks added
    • Installation step changes bluetooth HID bonding setting ClassicBondedOnly=false to allow PSMove to pair
    • Oust runs rfkill bluetooth unblock on startup to allow bluetooth connections
      • These appear to be soft-blocked by default
  • New pairing process not accessible via python
    • v4 API spins off pairing into a new helper binary psmove
    • Oust now runs psmove pair as a subprocess once a controller is connected via USB
  • New pairing process remembers controllers at a system level, so pairing no longer needed each time
  • Now uses SystemD to run Oust on boot and in the background

Vibecoding

The refactoring was done using VSCode Copilot with Claude Sonnet 4.5. Claude's summary:

  • Complete rewrite using PSMoveAPI class inheritance: Code now extends psmoveapi.PSMoveAPI base class with lifecycle callbacks (on_connect, on_update, on_disconnect)
  • Removed manual polling loops: The old polling-based architecture has been replaced with callback-based event handling
  • Modern colour API: Now uses psmoveapi.RGB() objects instead of raw RGB tuples
  • Simplified game state management: Using flags (in_lobby, in_game, in_countdown) instead of the old state machine
  • Root privilege check: Added upfront validation that the script is running as root

Uses new PSMoveAPI v4
Uses SystemD to run on boot
New API doesn't require original bluetooth hacks
Remembers controllers so pairing not needed every time
Orbs now glow orange when connected to the game lobby so they don't look broken
Updated installation instructions for Raspberry Pi.
@Jonty
Copy link
Owner

Jonty commented Nov 30, 2025

This is so hilariously vibecoded. I'll try and detangle this into something I can merge.

Brief notes for anyone without context.as to why this is:

  • Paired controllers we're already remembered at the system level.
  • I am not at all convinced the original bluetooth hacks are not needed, because they only matter when you have a large number of controllers.
  • The inbuilt bluetooth on the pi is garbage, and external dongles substantially improve performance in RF heavy environments, as well as allowing >7 players.
  • This seems to have patched the original game and added an oust2 variant.

The new event-driven API looks great though, and it seems psmoveapi is now easily installable, so that's great.

The "turn off" button is specifically not the PS button because when a game is left running without supervision players would always press that to turn the controller on and try to join a game in progress, and would instead turn it off and confuse things even further.

@MattGrayYes
Copy link
Author

The changing the code was LLM, but the decisions were mostly me.

My context:

Paired controllers we're already remembered at the system level.

  • Ooh, when I've played in the past i thought they had to be paired every time. I didnt specifically change anything to remember bluetooth devices, I just noticed it when testing.
    • But it was always hard to tell if something was connected, which is why I added the dim orange glow.

I am not at all convinced the original bluetooth hacks are not needed, because they only matter when you have a large number of controllers.

  • OK cool, as I understood it, the bluetooth hack shell script was required for bluetooth to work at all. and it sat there not doing anything when I ran it so figured it was an old OS / Old hardware issue.

The inbuilt bluetooth on the pi is garbage, and external dongles substantially improve performance in RF heavy environments, as well as allowing >7 players.

  • Nice to know the inbuilt bluetooth is shite. Didn't realise. I thought the dongle was because the old Pis didnt have bluetooth rather than because of that. I can get a dongle and see if it uses that one, or add an install step if needed to disable onboard bt.

This seems to have patched the original game and added an oust2 variant.

  • oust2 was me making changes in a separate file so i could reference the original, and then I moved the new variant into oust and deleted oust2.
  • I never code with anyone else so noone ever sees my methods until I rarely pull request lol

The "turn off" button is specifically not the PS button because when a game is left running without supervision players would always press that to turn the controller on and try to join a game in progress, and would instead turn it off and confuse things even further.

  • I added the PS to turn off because I've been in many games where someone has left, but no-one is able to start the game because no-one can work out how to turn the unused controller off.
    • Having only ever played this in the dark I've never even seen the start/select buttons and IMO select to turn off isn't intuitive.
    • Thanks to the dim orange glow in the lobby, I'm thinking it should be reasonably straightforward to work out the controller state
      • Game not running: PS turns on / off the controller. When the controller turns on and connects, The orb glows orange to say its ready to join the game
      • Game running: PS turns on unsed controllers. Orb stays dark until the game ends, then glows orange to say its ready to join the game.
        • PS does nothing to controllers in the game

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants