@@ -13,14 +13,16 @@ const __filename = fileURLToPath(import.meta.url);
1313const __dirname = dirname ( __filename ) ;
1414
1515const mainPath = app . isPackaged ? path . dirname ( app . getPath ( "exe" ) ) : __dirname ;
16- const configPath = app . isPackaged ? path . resolve ( mainPath , "config.json" ) : path . resolve ( path . join ( mainPath , ".." ) , "config.json" )
16+ const configPath = app . isPackaged
17+ ? path . resolve ( mainPath , "config.json" )
18+ : path . resolve ( path . join ( mainPath , ".." ) , "config.json" ) ;
1719const dataDebugPath = path . resolve ( mainPath , "debug.txt" ) ;
1820const isMac = process . platform === "darwin" ;
1921// don't mess with this or languages will fail to load cause of how the project is structured, lol
2022// i hate how this is done.
2123const languagesPath = path . resolve (
2224 mainPath ,
23- ( isMac && app . isPackaged ) ? ".." : "" ,
25+ isMac && app . isPackaged ? ".." : "" ,
2426 app . isPackaged ? ( isMac ? "Resources/languages" : "resources/languages" ) : "languages"
2527) ;
2628let mainWindow : BrowserWindow ;
@@ -1233,7 +1235,7 @@ import { EmulatedTracker } from "@slimevr/tracker-emulation";
12331235import { ActivePorts } from "haritorax-interpreter/dist/mode/com" ;
12341236import BetterQuaternion from "quaternion" ;
12351237import { ParsedUrlQueryInput } from "querystring" ;
1236- import Rand from "rand-seed"
1238+ import Rand from "rand-seed" ;
12371239
12381240// For haritorax-interpreter
12391241// Used to handle errors coming from haritorax-interpreter and display them to the user if wanted
@@ -1481,6 +1483,7 @@ function startDeviceListeners() {
14811483 } ) ;
14821484
14831485 let imuErrorCount : { [ key : string ] : number } = { } ;
1486+ let trackerErrorCount : { [ key : string ] : number } = { } ;
14841487 device . on ( "imu" , async ( trackerName : string , rawRotation : Rotation , rawGravity : Gravity ) => {
14851488 if ( ! trackerName || ! rawRotation || ! rawGravity || ! connectedDevices . has ( trackerName ) || isClosing ) return ;
14861489
@@ -1507,18 +1510,24 @@ function startDeviceListeners() {
15071510 const gravity = new Vector ( rawGravity . x , rawGravity . y , rawGravity . z ) ;
15081511
15091512 let tracker = connectedDevices . get ( trackerName ) ;
1510- if ( ! tracker || ! rotation || ! gravity || ! quaternion || ! eulerRadians ) {
1511- error ( `Error processing IMU data for "${ trackerName } ", skipping...` , "tracker" ) ;
1512- log (
1513- `Tracker: ${ JSON . stringify ( tracker ) } , Rotation: ${ JSON . stringify ( rotation ) } , Gravity: ${ JSON . stringify (
1514- gravity
1515- ) } `,
1516- "tracker"
1517- ) ;
1513+ if ( ! tracker ) {
1514+ trackerErrorCount [ trackerName ] = trackerErrorCount [ trackerName ] ? trackerErrorCount [ trackerName ] + 1 : 1 ;
1515+ if ( trackerErrorCount [ trackerName ] > 500 ) {
1516+ error ( `Too many errors processing tracker data for "${ trackerName } ", disconnecting...` , "tracker" ) ;
1517+ device . emit ( "disconnect" , trackerName ) ;
1518+ connectedDevices . delete ( trackerName ) ;
1519+ trackerErrorCount [ trackerName ] = 0 ;
1520+ mainWindow . webContents . send ( "device-error" , trackerName ) ;
1521+ }
1522+ return ;
1523+ }
15181524
1525+ if ( ! rotation || ! gravity || ! quaternion || ! eulerRadians ) {
15191526 // Prevent spam of IMU errors
15201527 imuErrorCount [ trackerName ] = imuErrorCount [ trackerName ] ? imuErrorCount [ trackerName ] + 1 : 1 ;
15211528 if ( imuErrorCount [ trackerName ] > 20 ) {
1529+ error ( `Error processing IMU data for "${ trackerName } ", skipping...` , "tracker" ) ;
1530+ log ( `Rotation: ${ JSON . stringify ( rotation ) } , Gravity: ${ JSON . stringify ( gravity ) } ` , "tracker" ) ;
15221531 error ( `Too many errors processing IMU data for "${ trackerName } ", disconnecting...` , "tracker" ) ;
15231532 device . emit ( "disconnect" , trackerName ) ;
15241533 connectedDevices . delete ( trackerName ) ;
0 commit comments