mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-22 10:01:19 -08:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa07e4f7be | ||
|
|
9835222762 | ||
|
|
69068bbf17 | ||
|
|
ba02688a82 | ||
|
|
65bdf2fffb | ||
|
|
13ee32c903 | ||
|
|
9748bd77c2 | ||
|
|
d7a286863f | ||
|
|
a1e0cd52d2 | ||
|
|
d1a39dba05 |
No files matched your search
@@ -1,37 +0,0 @@
|
||||
"Area: Continuous Integration":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ".github/**"
|
||||
"Area: Application Protocol":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ["solarxr-protocol"]
|
||||
"Area: AutoBone":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: "server/core/src/main/java/dev/slimevr/autobone/**"
|
||||
"Area: Documentation":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: "**/*.md"
|
||||
"Area: GUI":
|
||||
- all:
|
||||
- changed-files:
|
||||
- all-globs-to-any-file: ["gui/**/*", "!gui/public/i18n/**/*"]
|
||||
"Area: Hardware Protocol":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: "server/core/src/main/java/dev/slimevr/tracking/trackers/udp/**"
|
||||
"Area: Server":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ["server/**", "*gradle*", "gradle/**"]
|
||||
"Area: Skeletal Model":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: "server/core/src/main/java/dev/slimevr/tracking/processor/**"
|
||||
"Area: SteamVR Driver":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: "server/desktop/src/main/java/dev/slimevr/desktop/platform/**"
|
||||
"Area: Translation":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: "gui/public/i18n/**"
|
||||
"Area: VMC":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ["server/core/src/main/java/dev/slimevr/osc/Unity*", "server/core/src/main/java/dev/slimevr/osc/VMC*", "server/core/src/main/java/dev/slimevr/osc/VRM*"]
|
||||
"Area: VRCOSC":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ["server/core/src/main/java/dev/slimevr/osc/VRC*"]
|
||||
@@ -1,22 +0,0 @@
|
||||
# This workflow will triage pull requests and apply a label based on the
|
||||
# paths that are modified in the pull request.
|
||||
#
|
||||
# To use this workflow, you will need to set up a .github/labeler.yml
|
||||
# file with configuration. For more information, see:
|
||||
# https://github.com/actions/labeler
|
||||
|
||||
name: Labeler
|
||||
on: [pull_request_target]
|
||||
|
||||
jobs:
|
||||
label:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- uses: actions/labeler@v6
|
||||
with:
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
+16
-22
@@ -1,21 +1,15 @@
|
||||
import { defineConfig } from 'electron-vite'
|
||||
import { resolve } from 'path'
|
||||
import rendererConfig from './vite.config' // Import your existing React config
|
||||
import { defineConfig } from 'electron-vite';
|
||||
import { resolve } from 'path';
|
||||
import rendererConfig from './vite.config'; // Import your existing React config
|
||||
|
||||
export default defineConfig({
|
||||
main: {
|
||||
build: {
|
||||
rollupOptions: {
|
||||
input: resolve(__dirname, 'electron/main/index.ts'),
|
||||
external: [
|
||||
'pino',
|
||||
'pino-pretty',
|
||||
'pino-roll',
|
||||
'commander',
|
||||
'open'
|
||||
]
|
||||
}
|
||||
}
|
||||
external: ['pino', 'pino-pretty', 'pino-roll', 'commander', 'open'],
|
||||
},
|
||||
},
|
||||
},
|
||||
preload: {
|
||||
build: {
|
||||
@@ -23,12 +17,12 @@ export default defineConfig({
|
||||
input: resolve(__dirname, 'electron/preload/index.ts'),
|
||||
output: {
|
||||
format: 'cjs', // Force CJS for the preload
|
||||
entryFileNames: 'index.js' // Change back to .js
|
||||
}
|
||||
}
|
||||
}
|
||||
entryFileNames: 'index.js', // Change back to .js
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
renderer: {
|
||||
renderer: {
|
||||
...rendererConfig,
|
||||
root: '.',
|
||||
build: {
|
||||
@@ -40,8 +34,8 @@ export default defineConfig({
|
||||
transformMixedEsModules: true,
|
||||
},
|
||||
rollupOptions: {
|
||||
input: resolve(__dirname, 'index.html')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
input: resolve(__dirname, 'index.html'),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
+28
-21
@@ -29,7 +29,6 @@ import {
|
||||
} from './paths';
|
||||
import { initStores } from './store';
|
||||
import { closeLogger, logger } from './logger';
|
||||
|
||||
import { spawn } from 'node:child_process';
|
||||
import { discordPresence } from './presence';
|
||||
import { options } from './cli';
|
||||
@@ -156,8 +155,7 @@ handleIpc(IPC_CHANNELS.STORAGE, async (e, { type, method, key, value }) => {
|
||||
|
||||
handleIpc(IPC_CHANNELS.DISCORD_PRESENCE, async (e, options) => {
|
||||
if (options.enable) {
|
||||
if (!discordPresence.state.ready)
|
||||
await discordPresence.connect();
|
||||
if (!discordPresence.state.ready) await discordPresence.connect();
|
||||
discordPresence.updateActivity(options.activity, options.iconText);
|
||||
} else if (discordPresence.state.ready) {
|
||||
discordPresence.destroy();
|
||||
@@ -193,6 +191,10 @@ handleIpc(IPC_CHANNELS.GET_FOLDER, (e, folder) => {
|
||||
}
|
||||
});
|
||||
|
||||
handleIpc(IPC_CHANNELS.IS_STEAM, () => {
|
||||
return options.steam;
|
||||
});
|
||||
|
||||
const defaultWindowState: {
|
||||
width: number;
|
||||
height: number;
|
||||
@@ -208,11 +210,11 @@ const defaultWindowState: {
|
||||
const windowState = await readFile(getWindowStateFile(), {
|
||||
encoding: 'utf-8',
|
||||
})
|
||||
.then(data => JSON.parse(data))
|
||||
.catch(() => {
|
||||
logger.error('Failed to load window state, using defaults');
|
||||
return defaultWindowState;
|
||||
});
|
||||
.then((data) => JSON.parse(data))
|
||||
.catch(() => {
|
||||
logger.error('Failed to load window state, using defaults');
|
||||
return defaultWindowState;
|
||||
});
|
||||
|
||||
const MIN_WIDTH = 393;
|
||||
const MIN_HEIGHT = 667;
|
||||
@@ -245,7 +247,9 @@ function validateWindowState(state: typeof defaultWindowState) {
|
||||
|
||||
const saveWindowState = async () => {
|
||||
await mkdir(dirname(getWindowStateFile()), { recursive: true });
|
||||
await writeFile(getWindowStateFile(), JSON.stringify(windowState), { encoding: 'utf-8' });
|
||||
await writeFile(getWindowStateFile(), JSON.stringify(windowState), {
|
||||
encoding: 'utf-8',
|
||||
});
|
||||
};
|
||||
|
||||
function createWindow() {
|
||||
@@ -293,10 +297,8 @@ function createWindow() {
|
||||
mainWindow.minimize();
|
||||
break;
|
||||
case 'toggle-maximize':
|
||||
if (mainWindow.isMaximized())
|
||||
mainWindow.unmaximize();
|
||||
else
|
||||
mainWindow.maximize();
|
||||
if (mainWindow.isMaximized()) mainWindow.unmaximize();
|
||||
else mainWindow.maximize();
|
||||
break;
|
||||
}
|
||||
});
|
||||
@@ -403,7 +405,7 @@ const spawnServer = async () => {
|
||||
'SlimeVR',
|
||||
`Couldn't find a compatible Java version, please download Java 17 or higher`
|
||||
);
|
||||
app.quit()
|
||||
app.quit();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -425,7 +427,9 @@ const spawnServer = async () => {
|
||||
? {
|
||||
...process.env,
|
||||
APPDATA: app.getPath('appData'),
|
||||
LOCALAPPDATA: process.env['USERPROFILE'] ? path.join(process.env['USERPROFILE'], 'AppData', 'Local') : undefined,
|
||||
LOCALAPPDATA: process.env['USERPROFILE']
|
||||
? path.join(process.env['USERPROFILE'], 'AppData', 'Local')
|
||||
: undefined,
|
||||
}
|
||||
: undefined,
|
||||
});
|
||||
@@ -447,11 +451,11 @@ const spawnServer = async () => {
|
||||
serverProcess.on('error', (err) => {
|
||||
logger.info({ err }, 'Error launching the java server');
|
||||
if (!isQuitting) app.quit();
|
||||
})
|
||||
});
|
||||
|
||||
serverProcess.on('exit', () => {
|
||||
logger.info('Server process exiting');
|
||||
})
|
||||
});
|
||||
|
||||
const exited = new Promise<void>((resolve) => serverProcess.once('exit', resolve));
|
||||
|
||||
@@ -465,8 +469,7 @@ const spawnServer = async () => {
|
||||
const createFolders = async () => {
|
||||
await mkdir(getServerDataFolder(), { recursive: true });
|
||||
await mkdir(getGuiDataFolder(), { recursive: true });
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
let isQuitting = false;
|
||||
|
||||
@@ -477,7 +480,6 @@ app.whenReady().then(async () => {
|
||||
return net.fetch(pathToFileURL(filePath).toString(), { headers: request.headers });
|
||||
});
|
||||
|
||||
|
||||
try {
|
||||
await createFolders();
|
||||
} catch (err) {
|
||||
@@ -490,7 +492,6 @@ app.whenReady().then(async () => {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
stores = await initStores();
|
||||
checkEnvironmentVariables();
|
||||
const server = await spawnServer();
|
||||
@@ -499,6 +500,12 @@ app.whenReady().then(async () => {
|
||||
|
||||
logger.info('SlimeVR started!');
|
||||
|
||||
process.on('exit', async (code) => {
|
||||
console.log(code);
|
||||
server?.close();
|
||||
await server?.waitForExit();
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
app.quit();
|
||||
});
|
||||
|
||||
@@ -14,7 +14,8 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
||||
close: () => ipcRenderer.invoke(IPC_CHANNELS.WINDOW_ACTIONS, 'close'),
|
||||
hide: () => ipcRenderer.invoke(IPC_CHANNELS.WINDOW_ACTIONS, 'hide'),
|
||||
minimize: () => ipcRenderer.invoke(IPC_CHANNELS.WINDOW_ACTIONS, 'minimize'),
|
||||
toggleMaximize: () => ipcRenderer.invoke(IPC_CHANNELS.WINDOW_ACTIONS, 'toggle-maximize'),
|
||||
toggleMaximize: () =>
|
||||
ipcRenderer.invoke(IPC_CHANNELS.WINDOW_ACTIONS, 'toggle-maximize'),
|
||||
getStorage: async (type) => {
|
||||
return {
|
||||
get: (key) =>
|
||||
@@ -32,10 +33,19 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
||||
setTranslations: () => {},
|
||||
openDialog: (options) => ipcRenderer.invoke(IPC_CHANNELS.OPEN_DIALOG, options),
|
||||
saveDialog: (options) => ipcRenderer.invoke(IPC_CHANNELS.SAVE_DIALOG, options),
|
||||
openConfigFolder: async () => ipcRenderer.invoke(IPC_CHANNELS.OPEN_FILE, await ipcRenderer.invoke(IPC_CHANNELS.GET_FOLDER, 'config')),
|
||||
openLogsFolder: async () => ipcRenderer.invoke(IPC_CHANNELS.OPEN_FILE, await ipcRenderer.invoke(IPC_CHANNELS.GET_FOLDER, 'logs')),
|
||||
openConfigFolder: async () =>
|
||||
ipcRenderer.invoke(
|
||||
IPC_CHANNELS.OPEN_FILE,
|
||||
await ipcRenderer.invoke(IPC_CHANNELS.GET_FOLDER, 'config')
|
||||
),
|
||||
openLogsFolder: async () =>
|
||||
ipcRenderer.invoke(
|
||||
IPC_CHANNELS.OPEN_FILE,
|
||||
await ipcRenderer.invoke(IPC_CHANNELS.GET_FOLDER, 'logs')
|
||||
),
|
||||
openFile: (path) => ipcRenderer.invoke(IPC_CHANNELS.OPEN_FILE, path),
|
||||
ghGet: (req) => ipcRenderer.invoke(IPC_CHANNELS.GH_FETCH, req),
|
||||
setPresence: (options) => ipcRenderer.invoke(IPC_CHANNELS.DISCORD_PRESENCE, options),
|
||||
getInstallDir: () => ipcRenderer.invoke(IPC_CHANNELS.GET_FOLDER, 'exe'),
|
||||
isSteam: () => ipcRenderer.invoke(IPC_CHANNELS.IS_STEAM),
|
||||
} satisfies IElectronAPI);
|
||||
Vendored
+1
@@ -59,6 +59,7 @@ export interface IElectronAPI {
|
||||
ghGet: <T extends GHGet>(options: T) => Promise<GHReturn[T['type']]>;
|
||||
setPresence: (options: DiscordPresence) => void;
|
||||
getInstallDir: () => Promise<string>;
|
||||
isSteam: () => Promise<boolean>;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
@@ -19,7 +19,8 @@ export const IPC_CHANNELS = {
|
||||
OPEN_FILE: 'open-file',
|
||||
GET_FOLDER: 'get-folder',
|
||||
GH_FETCH: 'gh-fetch',
|
||||
DISCORD_PRESENCE: 'discord-presence'
|
||||
DISCORD_PRESENCE: 'discord-presence',
|
||||
IS_STEAM: 'is-steam',
|
||||
} as const;
|
||||
|
||||
export interface IpcInvokeMap {
|
||||
@@ -48,4 +49,5 @@ export interface IpcInvokeMap {
|
||||
options: T
|
||||
) => Promise<GHReturn[T['type']]>;
|
||||
[IPC_CHANNELS.DISCORD_PRESENCE]: (options: DiscordPresence) => void;
|
||||
[IPC_CHANNELS.IS_STEAM]: () => boolean;
|
||||
}
|
||||
@@ -2,11 +2,14 @@ import { ReactNode } from 'react';
|
||||
import { ConfigContextC, loadConfig, useConfigProvider } from '@/hooks/config';
|
||||
import { getSentryOrCompute } from '@/utils/sentry';
|
||||
|
||||
const config = await loadConfig();
|
||||
const [config, isSteam] = await Promise.all([
|
||||
loadConfig(),
|
||||
window.electronAPI.isSteam(),
|
||||
]);
|
||||
|
||||
if (config?.errorTracking !== undefined) {
|
||||
// load sentry ASAP to catch early errors
|
||||
getSentryOrCompute(config.errorTracking ?? false, config.uuid);
|
||||
getSentryOrCompute(config.errorTracking ?? false, config.uuid, isSteam);
|
||||
}
|
||||
|
||||
export function ConfigContextProvider({ children }: { children: ReactNode }) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useEffect } from 'react';
|
||||
import { FieldPath, useForm } from 'react-hook-form';
|
||||
import { useConfig } from '@/hooks/config';
|
||||
import { useWebsocketAPI } from '@/hooks/websocket-api';
|
||||
import { CheckBox } from '@/components/commons/Checkbox';
|
||||
import { useLocalization } from '@fluent/react';
|
||||
|
||||
@@ -28,7 +27,10 @@ export const defaultValues: DeveloperModeWidgetForm = {
|
||||
export function DeveloperModeWidget() {
|
||||
const { l10n } = useLocalization();
|
||||
const { config, setConfig } = useConfig();
|
||||
const { reconnect } = useWebsocketAPI();
|
||||
|
||||
const onSubmit = (formData: DeveloperModeWidgetForm) => {
|
||||
setConfig({ devSettings: formData });
|
||||
};
|
||||
|
||||
const { reset, control, handleSubmit, watch } =
|
||||
useForm<DeveloperModeWidgetForm>({
|
||||
@@ -44,13 +46,6 @@ export function DeveloperModeWidget() {
|
||||
return () => subscription.unsubscribe();
|
||||
}, []);
|
||||
|
||||
const onSubmit = async (formData: DeveloperModeWidgetForm) => {
|
||||
const needReconnect =
|
||||
config?.devSettings?.fastDataFeed !== formData.fastDataFeed;
|
||||
await setConfig({ devSettings: formData });
|
||||
if (needReconnect) reconnect();
|
||||
};
|
||||
|
||||
const makeToggle = ([name, label]: string[], index: number) => (
|
||||
<CheckBox
|
||||
key={index}
|
||||
|
||||
@@ -16,6 +16,8 @@ import { getSentryOrCompute, updateSentryContext } from '@/utils/sentry';
|
||||
import { fetchCurrentFirmwareRelease, FirmwareRelease } from './firmware-update';
|
||||
import { DEFAULT_LOCALE, LangContext } from '@/i18n/config';
|
||||
|
||||
const isSteam = await window.electronAPI.isSteam();
|
||||
|
||||
export interface AppContext {
|
||||
currentFirmwareRelease: FirmwareRelease | null;
|
||||
}
|
||||
@@ -40,7 +42,7 @@ export function useProvideAppContext(): AppContext {
|
||||
startDataFeed.dataFeeds = [dataFeedConfig, bonesDataFeedConfig];
|
||||
sendDataFeedPacket(DataFeedMessage.StartDataFeed, startDataFeed);
|
||||
}
|
||||
}, [isConnected]);
|
||||
}, [isConnected, config?.debug, config?.devSettings?.fastDataFeed]);
|
||||
|
||||
useDataFeedPacket(DataFeedMessage.DataFeedUpdate, (packet: DataFeedUpdateT) => {
|
||||
if (packet.index === 0) {
|
||||
@@ -79,7 +81,7 @@ export function useProvideAppContext(): AppContext {
|
||||
if (config.errorTracking !== undefined) {
|
||||
// Alows for sentry to refresh if user change the setting once the gui
|
||||
// is initialized
|
||||
getSentryOrCompute(config.errorTracking ?? false, config.uuid);
|
||||
getSentryOrCompute(config.errorTracking ?? false, config.uuid, isSteam);
|
||||
}
|
||||
}, [config]);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ export function useDataFeedConfig() {
|
||||
const { config } = useConfig();
|
||||
|
||||
const fastDataFeed = config?.debug && config?.devSettings?.fastDataFeed;
|
||||
const feedMaxTps = fastDataFeed ? 40 : 10;
|
||||
const feedMaxTps = fastDataFeed ? 90 : 10;
|
||||
|
||||
const trackerData = new TrackerDataMaskT();
|
||||
trackerData.position = true;
|
||||
@@ -39,8 +39,13 @@ export function useDataFeedConfig() {
|
||||
}
|
||||
|
||||
export function useBonesDataFeedConfig() {
|
||||
const { config } = useConfig();
|
||||
|
||||
const fastDataFeed = config?.debug && config?.devSettings?.fastDataFeed;
|
||||
const feedMaxTps = fastDataFeed ? 90 : 40;
|
||||
|
||||
const dataFeedConfig = new DataFeedConfigT();
|
||||
dataFeedConfig.boneMask = true;
|
||||
dataFeedConfig.minimumTimeSinceLast = 1000 / 40;
|
||||
dataFeedConfig.minimumTimeSinceLast = 1000 / feedMaxTps;
|
||||
return dataFeedConfig;
|
||||
}
|
||||
+10
-4
@@ -9,7 +9,13 @@ import {
|
||||
} from 'react-router-dom';
|
||||
import { DeviceDataT } from 'solarxr-protocol';
|
||||
|
||||
export function getSentryOrCompute(enabled = false, uuid: string) {
|
||||
export function getSentryOrCompute(enabled = false, uuid: string, isSteam: boolean) {
|
||||
// to be considered prod it needs to be a proper version tag, non-dirty
|
||||
const isProd = import.meta.env.PROD && __GIT_CLEAN__ && __VERSION_TAG__;
|
||||
|
||||
// We disable sentry for non prod environments
|
||||
if (!isProd) enabled = false;
|
||||
|
||||
Sentry.setUser({ id: uuid });
|
||||
|
||||
// if sentry is already initialized - SKIP
|
||||
@@ -44,10 +50,10 @@ export function getSentryOrCompute(enabled = false, uuid: string) {
|
||||
}),
|
||||
],
|
||||
beforeSend: (ev) => (newClient?.getOptions().enabled ? ev : null),
|
||||
environment: import.meta.env.MODE,
|
||||
environment: isSteam ? 'steam' : 'production',
|
||||
release: (__VERSION_TAG__ || __COMMIT_HASH__) + (__GIT_CLEAN__ ? '' : '-dirty'),
|
||||
// Tracing
|
||||
tracesSampleRate: import.meta.env.PROD ? 0.5 : 1.0, // Capture 50% of the transactions
|
||||
tracesSampleRate: 0.5, // Capture 50% of the transactions
|
||||
// Set profilesSampleRate to 1.0 to profile every transaction.
|
||||
// Since profilesSampleRate is relative to tracesSampleRate,
|
||||
// the final profiling rate can be computed as tracesSampleRate * profilesSampleRate
|
||||
@@ -55,7 +61,7 @@ export function getSentryOrCompute(enabled = false, uuid: string) {
|
||||
// results in 25% of transactions being profiled (0.5*0.5=0.25)
|
||||
profilesSampleRate: 0.2,
|
||||
// Session Replay
|
||||
replaysSessionSampleRate: import.meta.env.PROD ? 0.1 : 1.0, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
|
||||
replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
|
||||
replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
|
||||
normalizeDepth: 8,
|
||||
enabled,
|
||||
|
||||
@@ -2,5 +2,5 @@ package dev.slimevr
|
||||
|
||||
data class FeatureFlags(
|
||||
var steam: Boolean = false,
|
||||
var skipCheckUdev: Boolean = false,
|
||||
var skipCheckUdev: Boolean = true,
|
||||
)
|
||||
@@ -5,7 +5,7 @@ data class NetworkInfo(
|
||||
val description: String?,
|
||||
val category: NetworkCategory?,
|
||||
val connectivity: Set<ConnectivityFlags>?,
|
||||
val connected: Boolean?,
|
||||
val connected: Boolean,
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -18,7 +18,7 @@ enum class NetworkCategory(val value: Int) {
|
||||
;
|
||||
|
||||
companion object {
|
||||
fun fromInt(value: Int) = values().find { it.value == value }
|
||||
fun fromInt(value: Int) = entries.find { it.value == value }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ enum class ConnectivityFlags(val value: Int) {
|
||||
fun fromInt(value: Int): Set<ConnectivityFlags> = if (value == 0) {
|
||||
setOf(DISCONNECTED)
|
||||
} else {
|
||||
values().filter { it != DISCONNECTED && (value and it.value) != 0 }.toSet()
|
||||
entries.filter { it != DISCONNECTED && (value and it.value) != 0 }.toSet()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ abstract class NetworkProfileChecker {
|
||||
abstract val publicNetworks: List<NetworkInfo>
|
||||
}
|
||||
|
||||
class NetworkProfileCheckerStub : NetworkProfileChecker() {
|
||||
class StubNetworkProfileChecker : NetworkProfileChecker() {
|
||||
override val isSupported: Boolean
|
||||
get() = false
|
||||
override val publicNetworks: List<NetworkInfo>
|
||||
|
||||
@@ -61,7 +61,7 @@ class VRServer @JvmOverloads constructor(
|
||||
serialHandlerProvider: (VRServer) -> SerialHandler = { _ -> SerialHandlerStub() },
|
||||
flashingHandlerProvider: (VRServer) -> SerialFlashingHandler? = { _ -> null },
|
||||
vrcConfigHandlerProvider: (VRServer) -> VRCConfigHandler = { _ -> VRCConfigHandlerStub() },
|
||||
networkProfileProvider: (VRServer) -> NetworkProfileChecker = { _ -> NetworkProfileCheckerStub() },
|
||||
networkProfileProvider: (VRServer) -> NetworkProfileChecker = { _ -> StubNetworkProfileChecker() },
|
||||
acquireMulticastLock: () -> Any? = { null },
|
||||
@JvmField val configManager: ConfigManager,
|
||||
) : Thread("VRServer") {
|
||||
|
||||
@@ -16,6 +16,7 @@ import dev.slimevr.osc.UnityBone.Companion.getByStringVal
|
||||
import dev.slimevr.tracking.processor.BoneType
|
||||
import dev.slimevr.tracking.processor.HumanPoseManager
|
||||
import dev.slimevr.tracking.trackers.Device
|
||||
import dev.slimevr.tracking.trackers.DeviceOrigin
|
||||
import dev.slimevr.tracking.trackers.Tracker
|
||||
import dev.slimevr.tracking.trackers.TrackerPosition
|
||||
import dev.slimevr.tracking.trackers.TrackerStatus
|
||||
@@ -270,7 +271,7 @@ class VMCHandler(
|
||||
// Create device if it doesn't exist
|
||||
var rot = rotation
|
||||
if (trackerDevice == null) {
|
||||
trackerDevice = server.deviceManager.createDevice("VMC receiver", "1.0", "VMC")
|
||||
trackerDevice = server.deviceManager.createDevice(DeviceOrigin.VMC, "VMC receiver", "1.0", "VMC")
|
||||
server.deviceManager.addDevice(trackerDevice!!)
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.jme3.system.NanoTimer
|
||||
import dev.slimevr.VRServer
|
||||
import dev.slimevr.config.VRCOSCConfig
|
||||
import dev.slimevr.tracking.trackers.Device
|
||||
import dev.slimevr.tracking.trackers.DeviceOrigin
|
||||
import dev.slimevr.tracking.trackers.Tracker
|
||||
import dev.slimevr.tracking.trackers.TrackerPosition
|
||||
import dev.slimevr.tracking.trackers.TrackerStatus
|
||||
@@ -328,7 +329,7 @@ class VRCOSCHandler(
|
||||
// Create device if it doesn't exist
|
||||
if (vrsystemTrackersDevice == null) {
|
||||
// Instantiate OSC Trackers device
|
||||
vrsystemTrackersDevice = server.deviceManager.createDevice("VRC VRSystem", null, "VRChat")
|
||||
vrsystemTrackersDevice = server.deviceManager.createDevice(DeviceOrigin.VRCHAT, "VRC VRSystem", null, "VRChat")
|
||||
server.deviceManager.addDevice(vrsystemTrackersDevice!!)
|
||||
}
|
||||
|
||||
@@ -404,7 +405,7 @@ class VRCOSCHandler(
|
||||
// Receiving OSC Trackers data. This is not from VRChat.
|
||||
if (oscTrackersDevice == null) {
|
||||
// Instantiate OSC Trackers device
|
||||
oscTrackersDevice = server.deviceManager.createDevice("OSC Tracker", null, "OSC Trackers")
|
||||
oscTrackersDevice = server.deviceManager.createDevice(DeviceOrigin.OSC, "OSC Tracker", null, "OSC Trackers")
|
||||
server.deviceManager.addDevice(oscTrackersDevice!!)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,18 @@ import kotlinx.coroutines.launch
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
open class Device(val magSupport: Boolean = false) {
|
||||
enum class DeviceOrigin {
|
||||
HID,
|
||||
UDP,
|
||||
VRCHAT,
|
||||
OSC,
|
||||
VMC,
|
||||
STEAMVR,
|
||||
SOLARXR,
|
||||
WEBSOCKET,
|
||||
}
|
||||
|
||||
open class Device(val origin: DeviceOrigin, val magSupport: Boolean = false) {
|
||||
open val id: Int = nextLocalDeviceId.incrementAndGet()
|
||||
open var name: String? = null
|
||||
open var firmwareVersion: String? = null
|
||||
@@ -26,9 +37,6 @@ open class Device(val magSupport: Boolean = false) {
|
||||
|
||||
open val hardwareIdentifier: String = "Unknown"
|
||||
|
||||
val isOpenVrDevice: Boolean
|
||||
get() = manufacturer == "OpenVR"
|
||||
|
||||
init {
|
||||
CoroutineScope(Job()).launch {
|
||||
// Wait a little for device to get configured
|
||||
|
||||
@@ -5,8 +5,8 @@ import io.eiren.util.collections.FastList
|
||||
|
||||
class DeviceManager(private val server: VRServer) {
|
||||
val devices = FastList<Device>()
|
||||
fun createDevice(name: String?, version: String?, manufacturer: String?): Device {
|
||||
val device = Device()
|
||||
fun createDevice(origin: DeviceOrigin, name: String?, version: String?, manufacturer: String?): Device {
|
||||
val device = Device(origin)
|
||||
device.name = name
|
||||
device.firmwareVersion = version
|
||||
device.manufacturer = manufacturer
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package dev.slimevr.tracking.trackers.hid
|
||||
|
||||
import dev.slimevr.tracking.trackers.Device
|
||||
import dev.slimevr.tracking.trackers.DeviceOrigin
|
||||
import dev.slimevr.tracking.trackers.Tracker
|
||||
import dev.slimevr.tracking.trackers.udp.BoardType
|
||||
import dev.slimevr.tracking.trackers.udp.MCUType
|
||||
|
||||
class HIDDevice(val hidId: Int) : Device() {
|
||||
class HIDDevice(val hidId: Int) : Device(DeviceOrigin.HID) {
|
||||
override var hardwareIdentifier: String = "Unknown"
|
||||
override var boardType: BoardType = BoardType.UNKNOWN
|
||||
override var mcuType: MCUType = MCUType.UNKNOWN
|
||||
|
||||
@@ -3,6 +3,7 @@ package dev.slimevr.tracking.trackers.udp
|
||||
import dev.slimevr.NetworkProtocol
|
||||
import dev.slimevr.VRServer
|
||||
import dev.slimevr.tracking.trackers.Device
|
||||
import dev.slimevr.tracking.trackers.DeviceOrigin
|
||||
import dev.slimevr.tracking.trackers.Tracker
|
||||
import java.net.InetAddress
|
||||
import java.net.SocketAddress
|
||||
@@ -14,7 +15,7 @@ class UDPDevice(
|
||||
override val hardwareIdentifier: String,
|
||||
override val boardType: BoardType = BoardType.UNKNOWN,
|
||||
override val mcuType: MCUType = MCUType.UNKNOWN,
|
||||
) : Device(true) {
|
||||
) : Device(DeviceOrigin.UDP, true) {
|
||||
|
||||
override val id: Int = nextLocalDeviceId.incrementAndGet()
|
||||
|
||||
|
||||
@@ -114,6 +114,7 @@ class UDPProtocolParser {
|
||||
PACKET_TEMPERATURE -> UDPPacket20Temperature()
|
||||
PACKET_USER_ACTION -> UDPPacket21UserAction()
|
||||
PACKET_FEATURE_FLAGS -> UDPPacket22FeatureFlags()
|
||||
PACKET_ROTATION_AND_ACCELERATION -> UDPPacket23RotationAndAcceleration()
|
||||
PACKET_ACK_CONFIG_CHANGE -> UDPPacket24AckConfigChange()
|
||||
PACKET_FLEX_DATA -> UDPPacket26FlexData()
|
||||
PACKET_POSITION -> UDPPacket27Position()
|
||||
|
||||
@@ -6,6 +6,7 @@ import dev.slimevr.VRServer
|
||||
import dev.slimevr.VRServer.Companion.getNextLocalTrackerId
|
||||
import dev.slimevr.VRServer.Companion.instance
|
||||
import dev.slimevr.bridge.Bridge
|
||||
import dev.slimevr.tracking.trackers.DeviceOrigin
|
||||
import dev.slimevr.tracking.trackers.Tracker
|
||||
import dev.slimevr.tracking.trackers.TrackerPosition
|
||||
import dev.slimevr.tracking.trackers.TrackerStatus
|
||||
@@ -63,7 +64,7 @@ class WebSocketVRBridge(
|
||||
if (hmdTracker == null) {
|
||||
// Create HMD for websocket
|
||||
val hmdDevice = server.deviceManager
|
||||
.createDevice("WebSocketVRBridge", null, null)
|
||||
.createDevice(DeviceOrigin.WEBSOCKET, "WebSocketVRBridge", null, null)
|
||||
hmdTracker = Tracker(
|
||||
null,
|
||||
getNextLocalTrackerId(),
|
||||
|
||||
@@ -1,26 +1,31 @@
|
||||
package dev.slimevr.desktop
|
||||
|
||||
import com.sun.jna.Native
|
||||
import com.sun.jna.Pointer
|
||||
import com.sun.jna.platform.win32.COM.COMException
|
||||
import com.sun.jna.platform.win32.COM.COMUtils
|
||||
import com.sun.jna.platform.win32.COM.Dispatch
|
||||
import com.sun.jna.platform.win32.Guid.CLSID
|
||||
import com.sun.jna.platform.win32.Guid.IID
|
||||
import com.sun.jna.platform.win32.IPHlpAPI
|
||||
import com.sun.jna.platform.win32.IPHlpAPI.AF_UNSPEC
|
||||
import com.sun.jna.platform.win32.OaIdl.VARIANT_BOOLByReference
|
||||
import com.sun.jna.platform.win32.Ole32
|
||||
import com.sun.jna.platform.win32.OleAuto
|
||||
import com.sun.jna.platform.win32.WTypes
|
||||
import com.sun.jna.platform.win32.WinDef
|
||||
import com.sun.jna.platform.win32.WinError
|
||||
import com.sun.jna.platform.win32.WinNT
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT
|
||||
import com.sun.jna.ptr.IntByReference
|
||||
import com.sun.jna.ptr.PointerByReference
|
||||
import com.sun.jna.win32.StdCallLibrary
|
||||
import dev.slimevr.ConnectivityFlags
|
||||
import dev.slimevr.NetworkCategory
|
||||
import dev.slimevr.NetworkInfo
|
||||
import dev.slimevr.NetworkProfileChecker
|
||||
import dev.slimevr.VRServer
|
||||
import io.eiren.util.OperatingSystem
|
||||
import java.util.*
|
||||
import kotlin.concurrent.scheduleAtFixedRate
|
||||
import io.eiren.util.logging.LogManager
|
||||
|
||||
/**
|
||||
* @see <a href="https://learn.microsoft.com/en-us/windows/win32/api/netlistmgr/nn-netlistmgr-inetworkconnection">INetworkConnection interface (netlistmgr.h)</a>
|
||||
@@ -234,13 +239,44 @@ constructor() : AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("ktlint:standard:function-naming", "ktlint:standard:class-naming")
|
||||
interface NetIOAPI : IPHlpAPI {
|
||||
enum class MIB_NOTIFICATION_TYPE(val native: Int) {
|
||||
MibParameterNotification(0),
|
||||
MibAddInstance(1),
|
||||
MibDeleteInstance(2),
|
||||
MibInitialNotification(3),
|
||||
;
|
||||
|
||||
companion object {
|
||||
fun fromNative(native: Int) = byNative[native]
|
||||
private val byNative = entries.associateBy { it.native }
|
||||
}
|
||||
}
|
||||
interface IPINTERFACE_CHANGE_CALLBACK : StdCallLibrary.StdCallCallback {
|
||||
fun callback(
|
||||
context: Pointer?,
|
||||
row: Pointer?,
|
||||
/* MIB_NOTIFICATION_TYPE */
|
||||
notificationType: Int,
|
||||
)
|
||||
}
|
||||
|
||||
fun NotifyIpInterfaceChange(family: Int, callback: IPINTERFACE_CHANGE_CALLBACK, context: Pointer?, initialNotification: WinDef.BOOL, notificationHandle: WinNT.HANDLEByReference): Long
|
||||
fun CancelMibChangeNotify2(notificationHandle: WinNT.HANDLE): Long
|
||||
|
||||
companion object {
|
||||
val INSTANCE: NetIOAPI = Native.load("Iphlpapi", NetIOAPI::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
fun enumerateNetworks(): List<NetworkInfo>? {
|
||||
if (OperatingSystem.currentPlatform != OperatingSystem.WINDOWS) {
|
||||
return null
|
||||
}
|
||||
try {
|
||||
COMNetworkManager().use { netmgr ->
|
||||
netmgr.instance.GetNetworkConnections().use { conns ->
|
||||
COMNetworkManager().use { netMgr ->
|
||||
netMgr.instance.GetNetworkConnections().use { conns ->
|
||||
return generateSequence { conns.Next() }
|
||||
.map { conn ->
|
||||
conn.use {
|
||||
@@ -257,14 +293,16 @@ fun enumerateNetworks(): List<NetworkInfo>? {
|
||||
}.toList()
|
||||
}
|
||||
}
|
||||
} catch (err: Exception) {
|
||||
println(err.stackTraceToString())
|
||||
} catch (e: Exception) {
|
||||
LogManager.severe("[DesktopNetworkProfileChecker] Exception when enumerating networks", e)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
class DesktopNetworkProfileChecker(private val server: VRServer) : NetworkProfileChecker() {
|
||||
private val updateTickTimer = Timer("NetworkProfileCheck")
|
||||
class DesktopNetworkProfileChecker :
|
||||
NetworkProfileChecker(),
|
||||
Runnable {
|
||||
private val thread = Thread(this, "DesktopNetworkProfileChecker runner")
|
||||
private var publicNetworksLocal: List<NetworkInfo> = listOf()
|
||||
|
||||
override val isSupported: Boolean
|
||||
@@ -274,11 +312,40 @@ class DesktopNetworkProfileChecker(private val server: VRServer) : NetworkProfil
|
||||
get() = publicNetworksLocal
|
||||
|
||||
init {
|
||||
if (OperatingSystem.currentPlatform == OperatingSystem.WINDOWS) {
|
||||
this.updateTickTimer.scheduleAtFixedRate(0, 3000) {
|
||||
publicNetworksLocal = enumerateNetworks()?.filter { net ->
|
||||
net.connected == true && net.category == NetworkCategory.PUBLIC
|
||||
} ?: listOf()
|
||||
if (isSupported) {
|
||||
thread.start()
|
||||
}
|
||||
}
|
||||
|
||||
override fun run() {
|
||||
val handle = WinNT.HANDLEByReference()
|
||||
val callback = object : NetIOAPI.IPINTERFACE_CHANGE_CALLBACK {
|
||||
override fun callback(
|
||||
context: Pointer?,
|
||||
row: Pointer?,
|
||||
notificationType: Int,
|
||||
) {
|
||||
synchronized(publicNetworksLocal) {
|
||||
publicNetworksLocal = enumerateNetworks()?.filter { net ->
|
||||
net.connected && net.category == NetworkCategory.PUBLIC
|
||||
} ?: listOf()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val ret = NetIOAPI.INSTANCE.NotifyIpInterfaceChange(AF_UNSPEC, callback, null, WinDef.BOOL(true), handle)
|
||||
if (ret != WinError.ERROR_SUCCESS.toLong()) {
|
||||
LogManager.warning("[DesktopNetworkProfileChecker] Error registering network interface change callback, public interface detection will not work: $ret")
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
while (true) Thread.sleep(Long.MAX_VALUE)
|
||||
} catch (_: InterruptedException) {} finally {
|
||||
handle.value?.let {
|
||||
try {
|
||||
NetIOAPI.INSTANCE.CancelMibChangeNotify2(it)
|
||||
} catch (_: Exception) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ fun main(args: Array<String>) {
|
||||
{ _ -> DesktopSerialHandler() },
|
||||
{ _ -> DesktopSerialFlashingHandler() },
|
||||
{ _ -> DesktopVRCConfigHandler() },
|
||||
{ server -> DesktopNetworkProfileChecker(server) },
|
||||
{ _ -> DesktopNetworkProfileChecker() },
|
||||
configManager = configManager,
|
||||
)
|
||||
vrServer.start()
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.sun.jna.platform.win32.Advapi32Util
|
||||
import com.sun.jna.platform.win32.WinNT
|
||||
import com.sun.jna.platform.win32.WinReg
|
||||
import com.sun.jna.ptr.IntByReference
|
||||
import dev.slimevr.desktop.platform.linux.SteamUtils
|
||||
import io.eiren.util.logging.LogManager
|
||||
import java.io.BufferedReader
|
||||
import java.io.FileReader
|
||||
@@ -13,8 +14,6 @@ import java.io.InvalidObjectException
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.Path
|
||||
import kotlin.io.path.exists
|
||||
|
||||
abstract class AbstractRegEdit {
|
||||
abstract fun getQwordValue(path: String, key: String): Double?
|
||||
@@ -72,7 +71,7 @@ class RegEditWindows : AbstractRegEdit() {
|
||||
keysMap[it.key.replace("""_h\d+$""".toRegex(), "")] = it.key
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
LogManager.severe("[VRChatRegEdit] Error reading Values from VRC registry: ${e.message}")
|
||||
LogManager.severe("[VRChatRegEdit] Error reading values from VRC registry: ${e.message}")
|
||||
}
|
||||
return keysMap
|
||||
}
|
||||
@@ -92,11 +91,13 @@ class RegEditWindows : AbstractRegEdit() {
|
||||
}
|
||||
|
||||
class RegEditLinux : AbstractRegEdit() {
|
||||
private val userRegPath: Path? = SteamUtils.findAppLibraryLocation(438100)?.resolve(USER_REG_SUBPATH)
|
||||
|
||||
init {
|
||||
if (USER_REG_PATH == null) {
|
||||
if (userRegPath == null) {
|
||||
LogManager.info("[VRChatRegEdit] Couldn't find any VRChat registry file")
|
||||
} else {
|
||||
LogManager.info("[VRChatRegEdit] Using VRChat registry file: $USER_REG_PATH")
|
||||
LogManager.info("[VRChatRegEdit] Using VRChat registry file: $userRegPath")
|
||||
}
|
||||
}
|
||||
lateinit var registry: Map<String, String>
|
||||
@@ -129,7 +130,7 @@ class RegEditLinux : AbstractRegEdit() {
|
||||
val map = mutableMapOf<String, String>()
|
||||
|
||||
try {
|
||||
BufferedReader(FileReader(USER_REG_PATH?.toFile() ?: return keysMap)).use { reader ->
|
||||
BufferedReader(FileReader(userRegPath?.toFile() ?: return keysMap)).use { reader ->
|
||||
// The reg file uses double backward-slash for paths
|
||||
val actualPath = "[${path.replace("\\", """\\""")}]"
|
||||
while (reader.ready()) {
|
||||
@@ -141,7 +142,7 @@ class RegEditLinux : AbstractRegEdit() {
|
||||
val keyValue = reader.readLine()
|
||||
if (keyValue == "") break
|
||||
|
||||
KEY_VALUE_PATTERN.matchEntire(keyValue)?.let {
|
||||
REG_KEY_VALUE_PATTERN.matchEntire(keyValue)?.let {
|
||||
map[it.groupValues[1]] = it.groupValues[2]
|
||||
keysMap[it.groupValues[1].replace("""_h\d+$""".toRegex(), "")] = it.groupValues[1]
|
||||
}
|
||||
@@ -150,7 +151,7 @@ class RegEditLinux : AbstractRegEdit() {
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
LogManager.severe("[VRChatRegEdit] Error reading Values from VRC registry: ${e.message}")
|
||||
LogManager.severe("[VRChatRegEdit] Error reading values from VRC registry: ${e.message}")
|
||||
}
|
||||
registry = map
|
||||
return keysMap
|
||||
@@ -160,79 +161,9 @@ class RegEditLinux : AbstractRegEdit() {
|
||||
override fun getKeyByPath(hkey: WinReg.HKEY, path: String): Map<String, String> = mutableMapOf<String, String>()
|
||||
|
||||
companion object {
|
||||
private fun findAppLibraryLocation(steamPath: Path, appId: Int): Path? {
|
||||
val keyValueRegex = Regex(""""(\w+)"[ \t]*(?:"(.+)")?""")
|
||||
try {
|
||||
BufferedReader(FileReader(steamPath.resolve("config/libraryfolders.vdf").toFile())).use { reader ->
|
||||
var depth = 0
|
||||
var currentLibraryPath: Path? = null
|
||||
|
||||
while (reader.ready()) {
|
||||
val line = reader.readLine().trim()
|
||||
if (line == "{") {
|
||||
depth += 1
|
||||
continue
|
||||
}
|
||||
if (line == "}") {
|
||||
depth -= 1
|
||||
continue
|
||||
}
|
||||
|
||||
keyValueRegex.matchEntire(line)?.let {
|
||||
val key = it.groupValues[1]
|
||||
val value = it.groupValues[2]
|
||||
|
||||
when (depth) {
|
||||
0 -> {
|
||||
require(key == "libraryfolders") { "root key must be libraryfolders" }
|
||||
}
|
||||
|
||||
1 -> {
|
||||
// start of a library node
|
||||
}
|
||||
|
||||
2 -> {
|
||||
// in a library node
|
||||
if (key == "path") {
|
||||
currentLibraryPath = Path(value)
|
||||
} else if (key == "apps") {
|
||||
// start of apps node
|
||||
require(currentLibraryPath != null) { "path must come before apps in node" }
|
||||
}
|
||||
}
|
||||
|
||||
3 -> {
|
||||
// in apps node
|
||||
val curAppId = try {
|
||||
key.toInt()
|
||||
} catch (_: NumberFormatException) {
|
||||
null
|
||||
}
|
||||
if (curAppId != null && curAppId == appId) {
|
||||
assert(currentLibraryPath != null)
|
||||
return currentLibraryPath
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LogManager.warning("[VRChatRegEdit] Couldn't find library folder for appid $appId")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
LogManager.severe("[VRChatRegEdit] Error parsing Steam libraryfolders", e)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
const val USER_REG_SUBPATH = "steamapps/compatdata/438100/pfx/user.reg"
|
||||
val STEAM_PATH = System.getenv("HOME")?.let { home ->
|
||||
Path(home, ".steam", "root").takeIf { it.exists() }
|
||||
?: Path(home, ".steam", "debian-installation").takeIf { it.exists() }
|
||||
?: Path(home, ".var", "app", "com.valvesoftware.Steam", "data", "Steam").takeIf { it.exists() }
|
||||
}
|
||||
val USER_REG_PATH: Path? = if (STEAM_PATH != null) findAppLibraryLocation(STEAM_PATH, 438100)?.resolve(USER_REG_SUBPATH) else null
|
||||
|
||||
val KEY_VALUE_PATTERN = Regex(""""(.+)"=(.+)""")
|
||||
val REG_KEY_VALUE_PATTERN = Regex(""""(.+)"=(.+)""")
|
||||
|
||||
val HEX_FORMAT = HexFormat {
|
||||
upperCase = false
|
||||
|
||||
@@ -3,14 +3,31 @@ package dev.slimevr.desktop.install.drivers
|
||||
import io.eiren.util.logging.LogManager
|
||||
import java.io.IOException
|
||||
|
||||
fun executeShellCommand(vararg command: String): String? = try {
|
||||
fun executeShellCommand(vararg command: String): Pair<Int, String>? = try {
|
||||
val process = ProcessBuilder(*command)
|
||||
.redirectErrorStream(true)
|
||||
.start()
|
||||
process.inputStream.bufferedReader().readText().also {
|
||||
process.waitFor()
|
||||
}
|
||||
|
||||
process.waitFor()
|
||||
Pair(process.exitValue(), process.inputStream.bufferedReader().readText())
|
||||
} catch (e: IOException) {
|
||||
LogManager.warning("Error executing shell command", e)
|
||||
null
|
||||
}
|
||||
|
||||
// vrpathreg returns 1 if the driver is present
|
||||
fun shouldInstallDriver(exitCode: Int): Boolean = exitCode == 1
|
||||
|
||||
// get a descriptive reason why we're skipping driver installation
|
||||
// Exit codes from vrpathreg output:
|
||||
// 0 : Success
|
||||
// 1 : ( finddriver only ) Driver not present
|
||||
// 2 : ( finddriver only ) Error, driver installed more than once
|
||||
// -1 : Configuration or permission problem
|
||||
// -2 : Argument problem
|
||||
fun getDriverInstallSkipReason(exitCode: Int): String = when (exitCode) {
|
||||
0 -> "driver already installed"
|
||||
2 -> "driver installed more than once"
|
||||
-1 -> "SteamVR is misconfigured"
|
||||
else -> "unknown reason ($exitCode)"
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
package dev.slimevr.desktop.install.drivers
|
||||
|
||||
import dev.slimevr.desktop.featureFlags
|
||||
import dev.slimevr.desktop.platform.linux.SteamUtils
|
||||
import io.eiren.util.logging.LogManager
|
||||
|
||||
class Linux {
|
||||
|
||||
val path: String = System.getProperty("user.dir")
|
||||
|
||||
fun updateLinux() {
|
||||
@@ -12,21 +11,29 @@ class Linux {
|
||||
}
|
||||
|
||||
fun updateLinuxSteamVRDriver() {
|
||||
val pathRegPath = "${System.getProperty("user.home")}/.steam/steam/steamapps/common/SteamVR/bin/vrpathreg.sh"
|
||||
val vrPathRegContents = executeShellCommand(pathRegPath)
|
||||
if (vrPathRegContents == null) {
|
||||
LogManager.warning("SteamVR driver installation failed")
|
||||
return
|
||||
}
|
||||
if (vrPathRegContents.contains("slimevr")) {
|
||||
LogManager.info("SteamVR driver is already installed")
|
||||
val steamVRLocation = SteamUtils.findAppLibraryLocation(250820)?.resolve("steamapps/common/SteamVR") ?: run {
|
||||
LogManager.warning("SteamVR driver installation failed: couldn't find SteamVR")
|
||||
return
|
||||
}
|
||||
|
||||
executeShellCommand(pathRegPath, "adddriver", "$path/$LINUX_STEAM_DRIVER_DIRECTORY")
|
||||
val pathRegPath = "$steamVRLocation/bin/vrpathreg.sh"
|
||||
val (findExitCode, _) = executeShellCommand(pathRegPath, "finddriver", "slimevr") ?: run {
|
||||
LogManager.warning("SteamVR driver installation failed: couldn't run vrpathreg finddriver")
|
||||
return
|
||||
}
|
||||
|
||||
if (executeShellCommand(pathRegPath)?.contains("slimevr") != true) {
|
||||
LogManager.warning("Failed to install SteamVR driver")
|
||||
if (!shouldInstallDriver(findExitCode)) {
|
||||
LogManager.info("Skipping SteamVR driver installation: ${getDriverInstallSkipReason(findExitCode)}")
|
||||
return
|
||||
}
|
||||
|
||||
val (addExitCode, _) = executeShellCommand(pathRegPath, "adddriver", "$path/$LINUX_STEAM_DRIVER_DIRECTORY") ?: run {
|
||||
LogManager.warning("SteamVR driver installation failed: couldn't run vrpathreg adddriver")
|
||||
return
|
||||
}
|
||||
|
||||
if (addExitCode != 0) {
|
||||
LogManager.warning("SteamVR driver installation failed: vrpathreg exited with code $addExitCode")
|
||||
return
|
||||
}
|
||||
LogManager.info("SteamVR driver successfully installed")
|
||||
|
||||
@@ -3,9 +3,10 @@ package dev.slimevr.desktop.install.drivers
|
||||
import com.sun.jna.platform.win32.WinReg
|
||||
import dev.slimevr.desktop.games.vrchat.RegEditWindows
|
||||
import io.eiren.util.logging.LogManager
|
||||
import kotlin.io.path.Path
|
||||
import kotlin.io.path.exists
|
||||
|
||||
class Windows {
|
||||
|
||||
val path: String = System.getProperty("user.dir")
|
||||
|
||||
fun updateWindows() {
|
||||
@@ -14,28 +15,36 @@ class Windows {
|
||||
|
||||
fun steamVRDriver() {
|
||||
val regEdit = RegEditWindows()
|
||||
val regQuery = regEdit.getKeyByPath(WinReg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 250820")
|
||||
val steamVRLocation = regQuery["InstallLocation"]
|
||||
if (steamVRLocation == null || !steamVRLocation.contains("SteamVR")) {
|
||||
LogManager.warning("Can't find SteamVR, unable to install SteamVR driver")
|
||||
val steamVRLocation = regEdit.getKeyByPath(WinReg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 250820")["InstallLocation"]
|
||||
if (steamVRLocation == null || !steamVRLocation.endsWith("SteamVR")) {
|
||||
LogManager.warning("SteamVR driver installation failed: couldn't find SteamVR")
|
||||
return
|
||||
}
|
||||
|
||||
val pathRegPath = "${steamVRLocation}\\bin\\win64\\vrpathreg.exe"
|
||||
val vrPathRegContents = executeShellCommand(pathRegPath, "finddriver", "slimevr")
|
||||
if (vrPathRegContents == null) {
|
||||
LogManager.warning("Error installing SteamVR driver")
|
||||
return
|
||||
}
|
||||
if (vrPathRegContents.contains("slimevr")) {
|
||||
LogManager.info("SteamVR driver is already installed")
|
||||
if (Path(steamVRLocation, "drivers", "slimevr").exists()) {
|
||||
LogManager.warning("Skipping SteamVR driver installation: driver is in SteamVR drivers folder")
|
||||
LogManager.warning("If you would like the SteamVR driver to automatically update, please uninstall the other version of SlimeVR")
|
||||
return
|
||||
}
|
||||
|
||||
executeShellCommand(pathRegPath, "adddriver", "${path}\\${WINDOWS_STEAMVR_DRIVER_DIRECTORY}")
|
||||
val pathRegPath = "$steamVRLocation\\bin\\win64\\vrpathreg.exe"
|
||||
val (findExitCode, _) = executeShellCommand(pathRegPath, "finddriver", "slimevr") ?: run {
|
||||
LogManager.warning("SteamVR driver installation failed: couldn't run vrpathreg finddriver")
|
||||
return
|
||||
}
|
||||
|
||||
if (executeShellCommand(pathRegPath, "finddriver", "slimevr")?.contains("slimevr") != true) {
|
||||
LogManager.warning("Failed to install SlimeVR driver")
|
||||
if (!shouldInstallDriver(findExitCode)) {
|
||||
LogManager.info("Skipping SteamVR driver installation: ${getDriverInstallSkipReason(findExitCode)}")
|
||||
return
|
||||
}
|
||||
|
||||
val (addExitCode, _) = executeShellCommand(pathRegPath, "adddriver", "$path\\$WINDOWS_STEAMVR_DRIVER_DIRECTORY") ?: run {
|
||||
LogManager.warning("SteamVR driver installation failed: couldn't run vrpathreg adddriver")
|
||||
return
|
||||
}
|
||||
|
||||
if (addExitCode != 0) {
|
||||
LogManager.warning("SteamVR driver installation failed: vrpathreg exited with code $addExitCode")
|
||||
return
|
||||
}
|
||||
LogManager.info("SteamVR driver successfully installed")
|
||||
|
||||
@@ -8,6 +8,7 @@ import dev.slimevr.bridge.ISteamVRBridge
|
||||
import dev.slimevr.config.BridgeConfig
|
||||
import dev.slimevr.desktop.platform.ProtobufMessages.*
|
||||
import dev.slimevr.protocol.rpc.settings.RPCSettingsHandler
|
||||
import dev.slimevr.tracking.trackers.DeviceOrigin
|
||||
import dev.slimevr.tracking.trackers.Tracker
|
||||
import dev.slimevr.tracking.trackers.TrackerPosition
|
||||
import dev.slimevr.tracking.trackers.TrackerPosition.Companion.getByTrackerRole
|
||||
@@ -140,61 +141,33 @@ abstract class SteamVRBridge(
|
||||
if (!config.automaticSharedTrackersToggling || server.getPauseTracking()) return false
|
||||
|
||||
val skeleton = instance.humanPoseManager.skeleton
|
||||
val isWaistSteamVr = skeleton.hipTracker?.device?.isOpenVrDevice == true ||
|
||||
skeleton.waistTracker?.device?.isOpenVrDevice == true
|
||||
// Enable waist if skeleton has an spine tracker
|
||||
changeShareSettings(TrackerRole.WAIST, skeleton.hasSpineTracker && !isWaistSteamVr)
|
||||
|
||||
// hasChest if waist and/or hip is on, and chest and/or upper chest is also on
|
||||
val hasChest = skeleton.upperChestTracker != null || skeleton.chestTracker != null
|
||||
val isChestSteamVr = skeleton.upperChestTracker?.device?.isOpenVrDevice == true ||
|
||||
skeleton.chestTracker?.device?.isOpenVrDevice == true
|
||||
changeShareSettings(
|
||||
TrackerRole.CHEST,
|
||||
hasChest && !isChestSteamVr,
|
||||
)
|
||||
|
||||
// hasFeet if lower and/or upper leg tracker is on
|
||||
val hasLeftFoot =
|
||||
(skeleton.leftUpperLegTracker != null || skeleton.leftLowerLegTracker != null)
|
||||
val isLeftFootSteamVr =
|
||||
skeleton.leftLowerLegTracker?.device?.isOpenVrDevice == true ||
|
||||
skeleton.leftFootTracker?.device?.isOpenVrDevice == true
|
||||
|
||||
val hasRightFoot =
|
||||
(skeleton.rightUpperLegTracker != null || skeleton.rightLowerLegTracker != null)
|
||||
val isRightFootSteamVr =
|
||||
skeleton.rightLowerLegTracker?.device?.isOpenVrDevice == true ||
|
||||
skeleton.rightFootTracker?.device?.isOpenVrDevice == true
|
||||
changeShareSettings(
|
||||
TrackerRole.LEFT_FOOT,
|
||||
hasLeftFoot && !isLeftFootSteamVr,
|
||||
)
|
||||
changeShareSettings(
|
||||
TrackerRole.RIGHT_FOOT,
|
||||
hasRightFoot && !isRightFootSteamVr,
|
||||
)
|
||||
|
||||
// hasKnees is just hasFeet
|
||||
val isLeftKneeSteamVr = skeleton.leftUpperLegTracker?.device?.isOpenVrDevice == true
|
||||
|
||||
val isRightKneeSteamVr = skeleton.rightUpperLegTracker?.device?.isOpenVrDevice == true
|
||||
changeShareSettings(TrackerRole.LEFT_KNEE, hasLeftFoot && !isLeftKneeSteamVr)
|
||||
changeShareSettings(TrackerRole.RIGHT_KNEE, hasRightFoot && !isRightKneeSteamVr)
|
||||
|
||||
// hasElbows if an upper arm or a lower arm tracker is on
|
||||
val hasLeftElbow = skeleton.hasLeftArmTracker
|
||||
val isLeftElbowSteamVr = skeleton.leftUpperArmTracker?.device?.isOpenVrDevice == true ||
|
||||
skeleton.leftLowerArmTracker?.device?.isOpenVrDevice == true
|
||||
|
||||
val hasRightElbow = skeleton.hasRightArmTracker
|
||||
val isRightElbowSteamVr = skeleton.rightUpperArmTracker?.device?.isOpenVrDevice == true ||
|
||||
skeleton.rightLowerArmTracker?.device?.isOpenVrDevice == true
|
||||
changeShareSettings(TrackerRole.LEFT_ELBOW, hasLeftElbow && !isLeftElbowSteamVr)
|
||||
changeShareSettings(TrackerRole.RIGHT_ELBOW, hasRightElbow && !isRightElbowSteamVr)
|
||||
|
||||
// Hands aren't touched as they will override the controller's tracking
|
||||
// Return true to say that trackers were successfully toggled automatically
|
||||
val roleToTrackers = mapOf(
|
||||
TrackerRole.CHEST to setOf(skeleton.upperChestTracker, skeleton.chestTracker),
|
||||
TrackerRole.LEFT_ELBOW to setOf(skeleton.leftUpperArmTracker),
|
||||
TrackerRole.RIGHT_ELBOW to setOf(skeleton.rightUpperArmTracker),
|
||||
TrackerRole.WAIST to setOf(skeleton.waistTracker, skeleton.hipTracker),
|
||||
TrackerRole.LEFT_KNEE to setOf(skeleton.leftUpperLegTracker),
|
||||
TrackerRole.RIGHT_KNEE to setOf(skeleton.rightUpperLegTracker),
|
||||
TrackerRole.LEFT_FOOT to setOf(skeleton.leftLowerLegTracker, skeleton.leftFootTracker),
|
||||
TrackerRole.RIGHT_FOOT to setOf(skeleton.rightLowerLegTracker, skeleton.rightFootTracker),
|
||||
)
|
||||
|
||||
for ((role, trackers) in roleToTrackers) {
|
||||
val shouldShare = if (role == TrackerRole.WAIST) {
|
||||
// Waist is special, it should be enabled if there is any tracker on the spine,
|
||||
// but ignored if the waist or hip tracker is from us
|
||||
skeleton.hasSpineTracker &&
|
||||
!trackers.any {
|
||||
it?.device?.origin == DeviceOrigin.STEAMVR
|
||||
}
|
||||
} else {
|
||||
trackers.any {
|
||||
it != null && it.device?.origin != DeviceOrigin.STEAMVR
|
||||
}
|
||||
}
|
||||
changeShareSettings(role, shouldShare)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -228,6 +201,7 @@ abstract class SteamVRBridge(
|
||||
override fun createNewTracker(trackerAdded: TrackerAdded): Tracker {
|
||||
val device = instance.deviceManager
|
||||
.createDevice(
|
||||
DeviceOrigin.STEAMVR,
|
||||
trackerAdded.trackerName,
|
||||
null,
|
||||
trackerAdded.manufacturer.ifEmpty { "OpenVR" },
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package dev.slimevr.desktop.platform.linux
|
||||
|
||||
import io.eiren.util.logging.LogManager
|
||||
import java.io.BufferedReader
|
||||
import java.io.FileReader
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.Path
|
||||
import kotlin.io.path.exists
|
||||
|
||||
class SteamUtils {
|
||||
companion object {
|
||||
val STEAM_PATH = System.getenv("HOME")?.let { home ->
|
||||
Path(home, ".steam", "root").takeIf { it.exists() }
|
||||
?: Path(home, ".steam", "debian-installation").takeIf { it.exists() }
|
||||
?: Path(home, ".var", "app", "com.valvesoftware.Steam", "data", "Steam").takeIf { it.exists() }
|
||||
}
|
||||
val VDF_KEY_VALUES_PATTERN = Regex(""""(\w+)"[ \t]*(?:"(.+)")?""")
|
||||
|
||||
fun findAppLibraryLocation(appId: Int): Path? {
|
||||
if (STEAM_PATH == null) return null
|
||||
|
||||
try {
|
||||
BufferedReader(FileReader(STEAM_PATH.resolve("config/libraryfolders.vdf").toFile())).use { reader ->
|
||||
var depth = 0
|
||||
var currentLibraryPath: Path? = null
|
||||
|
||||
while (reader.ready()) {
|
||||
val line = reader.readLine().trim()
|
||||
if (line == "{") {
|
||||
depth += 1
|
||||
continue
|
||||
}
|
||||
if (line == "}") {
|
||||
depth -= 1
|
||||
continue
|
||||
}
|
||||
|
||||
VDF_KEY_VALUES_PATTERN.matchEntire(line)?.let {
|
||||
val key = it.groupValues[1]
|
||||
val value = it.groupValues[2]
|
||||
|
||||
when (depth) {
|
||||
0 -> {
|
||||
require(key == "libraryfolders") { "root key must be libraryfolders" }
|
||||
}
|
||||
|
||||
1 -> {
|
||||
// start of a library node
|
||||
}
|
||||
|
||||
2 -> {
|
||||
// in a library node
|
||||
if (key == "path") {
|
||||
currentLibraryPath = Path(value)
|
||||
} else if (key == "apps") {
|
||||
// start of apps node
|
||||
require(currentLibraryPath != null) { "path must come before apps in node" }
|
||||
}
|
||||
}
|
||||
|
||||
3 -> {
|
||||
// in apps node
|
||||
val curAppId = try {
|
||||
key.toInt()
|
||||
} catch (_: NumberFormatException) {
|
||||
null
|
||||
}
|
||||
if (curAppId != null && curAppId == appId) {
|
||||
check(currentLibraryPath != null) { "path must come before apps in node" }
|
||||
return currentLibraryPath
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LogManager.warning("[RegEdit] Couldn't find library folder for appid $appId")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
LogManager.severe("[RegEdit] Error parsing Steam libraryfolders", e)
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user