Skip to content

Instantly share code, notes, and snippets.

@sclark39
Created August 6, 2019 13:55
Show Gist options
  • Save sclark39/2513efde634349f69da34a19c8a1cb26 to your computer and use it in GitHub Desktop.
Save sclark39/2513efde634349f69da34a19c8a1cb26 to your computer and use it in GitHub Desktop.
Run to fix phantom controllers showing up in Oculus after low battery events
const fs = require( 'fs' )
console.log( `Make sure OVRService has been stopped and Oculus is closed before running this!` )
let filename = process.env.LOCALAPPDATA + '\\Oculus\\DeviceCache.json';
console.log( `Opening ${filename}.` )
let file = fs.readFileSync( filename, {encoding: 'utf8'} )
let json = JSON.parse(file)
console.log( `Looking for phantom controllers.` )
let count = 0;
for ( let i = json.devices.length; i-- > 0; )
{
let device = json.devices[i]
if ( device.subtype === "rlcon" || device.subtype === "llcon" )
{
if ( device.firmware.version === '' )
{
count++
json.devices.splice(i,1)
}
}
}
if ( 0 < count )
{
console.log( `Found ${count} bad devices to remove.` )
console.log( 'Cleaning DeviceCache.json' )
fs.writeFileSync( filename, JSON.stringify( json ) )
}
else
{
console.log( `No bad devices found.` )
}
console.log( `Done.` )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment