mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-24 02:51:20 -08:00
Steam (#1763)
Co-authored-by: loucass003 <[email protected]> Co-authored-by: HannahPadd <[email protected]>
This commit is contained in:
26 files changed
+510
-82
No files matched your search
@@ -0,0 +1,6 @@
|
||||
package dev.slimevr
|
||||
|
||||
data class FeatureFlags(
|
||||
var steam: Boolean = false,
|
||||
var skipCheckUdev: Boolean = false,
|
||||
)
|
||||
@@ -57,6 +57,7 @@ const val SLIMEVR_IDENTIFIER = "dev.slimevr.SlimeVR"
|
||||
|
||||
class VRServer @JvmOverloads constructor(
|
||||
bridgeProvider: BridgeProvider = { _, _ -> sequence {} },
|
||||
featureFlagsProvider: (VRServer) -> FeatureFlags = { _ -> FeatureFlags() },
|
||||
serialHandlerProvider: (VRServer) -> SerialHandler = { _ -> SerialHandlerStub() },
|
||||
flashingHandlerProvider: (VRServer) -> SerialFlashingHandler? = { _ -> null },
|
||||
vrcConfigHandlerProvider: (VRServer) -> VRCConfigHandler = { _ -> VRCConfigHandlerStub() },
|
||||
@@ -84,6 +85,9 @@ class VRServer @JvmOverloads constructor(
|
||||
@JvmField
|
||||
val deviceManager: DeviceManager
|
||||
|
||||
// UwU
|
||||
val featureFlags: FeatureFlags = featureFlagsProvider(this)
|
||||
|
||||
@JvmField
|
||||
val bvhRecorder: BVHRecorder
|
||||
|
||||
@@ -127,7 +131,6 @@ class VRServer @JvmOverloads constructor(
|
||||
val serverGuards = ServerGuards()
|
||||
|
||||
init {
|
||||
// UwU
|
||||
deviceManager = DeviceManager(this)
|
||||
serialHandler = serialHandlerProvider(this)
|
||||
serialFlashingHandler = flashingHandlerProvider(this)
|
||||
|
||||
@@ -10,6 +10,7 @@ import dev.slimevr.protocol.datafeed.createTrackerId
|
||||
import dev.slimevr.protocol.rpc.autobone.RPCAutoBoneHandler
|
||||
import dev.slimevr.protocol.rpc.firmware.RPCFirmwareUpdateHandler
|
||||
import dev.slimevr.protocol.rpc.games.vrchat.RPCVRChatHandler
|
||||
import dev.slimevr.protocol.rpc.installinfo.RPCInstallInfoHandler
|
||||
import dev.slimevr.protocol.rpc.reset.RPCResetHandler
|
||||
import dev.slimevr.protocol.rpc.serial.RPCProvisioningHandler
|
||||
import dev.slimevr.protocol.rpc.serial.RPCSerialHandler
|
||||
@@ -52,6 +53,7 @@ class RPCHandler(private val api: ProtocolAPI) : ProtocolHandler<RpcMessageHeade
|
||||
RPCVRChatHandler(this, api)
|
||||
RPCTrackingChecklistHandler(this, api)
|
||||
RPCUserHeightCalibration(this, api)
|
||||
RPCInstallInfoHandler(this, api)
|
||||
|
||||
registerPacketListener(
|
||||
RpcMessage.AssignTrackerRequest,
|
||||
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package dev.slimevr.protocol.rpc.installinfo
|
||||
|
||||
import com.google.flatbuffers.FlatBufferBuilder
|
||||
import dev.slimevr.protocol.GenericConnection
|
||||
import dev.slimevr.protocol.ProtocolAPI
|
||||
import dev.slimevr.protocol.rpc.RPCHandler
|
||||
import io.eiren.util.logging.LogManager
|
||||
import solarxr_protocol.rpc.InstalledInfoResponse.createInstalledInfoResponse
|
||||
import solarxr_protocol.rpc.RpcMessage
|
||||
import solarxr_protocol.rpc.RpcMessageHeader
|
||||
import java.io.IOException
|
||||
|
||||
class RPCInstallInfoHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) {
|
||||
|
||||
init {
|
||||
rpcHandler.registerPacketListener(RpcMessage.InstalledInfoRequest, ::onInstalledInfoRequest)
|
||||
}
|
||||
|
||||
fun onInstalledInfoRequest(conn: GenericConnection, messageHeader: RpcMessageHeader?) {
|
||||
if (api.server.featureFlags.skipCheckUdev) {
|
||||
return
|
||||
}
|
||||
|
||||
val command = if (api.server.featureFlags.steam) {
|
||||
arrayOf("steam-runtime-launch-client", "--alongside-steam", "--", "udevadm", "cat")
|
||||
} else {
|
||||
arrayOf("udevadm", "cat")
|
||||
}
|
||||
val udevResponse = executeShellCommand(*command)
|
||||
|
||||
if (udevResponse == null) {
|
||||
LogManager.warning("Server couldn't verify if udev is installed")
|
||||
return
|
||||
}
|
||||
val response = udevResponse.contains("slime")
|
||||
val fbb = FlatBufferBuilder(1024)
|
||||
val outbound = this.rpcHandler.createRPCMessage(
|
||||
fbb,
|
||||
RpcMessage.InstalledInfoResponse,
|
||||
createInstalledInfoResponse(fbb, response, false),
|
||||
)
|
||||
fbb.finish(outbound)
|
||||
conn.send(fbb.dataBuffer())
|
||||
}
|
||||
}
|
||||
|
||||
private fun executeShellCommand(vararg command: String): String? = try {
|
||||
val process = ProcessBuilder(*command)
|
||||
.redirectErrorStream(true)
|
||||
.start()
|
||||
process.inputStream.bufferedReader().readText().also {
|
||||
process.waitFor()
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
LogManager.warning("Error executing shell command", e)
|
||||
null
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.eiren.util
|
||||
|
||||
import dev.slimevr.SLIMEVR_IDENTIFIER
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
import java.util.*
|
||||
@@ -38,6 +39,12 @@ enum class OperatingSystem(
|
||||
var dir = System.getenv("SLIMEVR_SOCKET_DIR")
|
||||
if (dir != null) return dir
|
||||
if (currentPlatform == LINUX) {
|
||||
val isPressureVessel = System.getenv("PRESSURE_VESSEL_RUNTIME")?.isNotEmpty() == true
|
||||
if (isPressureVessel) {
|
||||
dir = System.getenv("XDG_CONFIG_HOME")?.let { Path(it, SLIMEVR_IDENTIFIER).toString() }
|
||||
?: System.getenv("HOME")?.let { Path(it, ".local", "share", SLIMEVR_IDENTIFIER).toString() }
|
||||
if (dir != null) return dir
|
||||
}
|
||||
dir = System.getenv("XDG_RUNTIME_DIR")
|
||||
if (dir != null) return dir
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user