mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-12-04 15:52:35 -08:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
827e2ceef8 | ||
|
|
ae4391bff1 | ||
|
|
be76cd1b6f | ||
|
|
884424c7b4 | ||
|
|
e0d3224393 |
No files matched your search
@@ -96,6 +96,7 @@
|
||||
expat
|
||||
libayatana-appindicator
|
||||
libusb1
|
||||
libudev-zero
|
||||
])
|
||||
++ lib.optionals pkgs.stdenv.isDarwin [
|
||||
pkgs.darwin.apple_sdk.frameworks.Security
|
||||
|
||||
@@ -191,7 +191,7 @@ fn main() -> Result<()> {
|
||||
)
|
||||
.title("SlimeVR")
|
||||
.inner_size(1289.0, 709.0)
|
||||
.min_inner_size(393.0, 667.0)
|
||||
.min_inner_size(util::MIN_WINDOW_SIZE_WIDTH, util::MIN_WINDOW_SIZE_HEIGHT)
|
||||
.resizable(true)
|
||||
.visible(true)
|
||||
.decorations(false)
|
||||
|
||||
@@ -4,6 +4,8 @@ use color_eyre::Result;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tauri::{LogicalSize, Monitor, PhysicalPosition, PhysicalSize, Window};
|
||||
|
||||
use crate::util;
|
||||
|
||||
static STATE_FILENAME: &str = ".window-state.json";
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Default)]
|
||||
@@ -73,7 +75,11 @@ impl WindowState {
|
||||
window.unmaximize()?;
|
||||
}
|
||||
|
||||
window.set_size(LogicalSize::new(self.width, self.height))?;
|
||||
if self.width > util::MIN_WINDOW_SIZE_WIDTH
|
||||
&& self.height > util::MIN_WINDOW_SIZE_HEIGHT
|
||||
{
|
||||
window.set_size(LogicalSize::new(self.width, self.height))?;
|
||||
}
|
||||
|
||||
let pos = PhysicalPosition::new(self.x, self.y);
|
||||
for monitor in window.available_monitors()? {
|
||||
|
||||
@@ -28,6 +28,8 @@ pub static POSSIBLE_TITLES: &[&str] = &[
|
||||
"never gonna let you down",
|
||||
"uwu sowwy",
|
||||
];
|
||||
pub const MIN_WINDOW_SIZE_WIDTH: f64 = 393.0;
|
||||
pub const MIN_WINDOW_SIZE_HEIGHT: f64 = 667.0;
|
||||
|
||||
shadow!(build);
|
||||
// Tauri has a way to return the package.json version, but it's not a constant...
|
||||
|
||||
@@ -187,6 +187,9 @@ class BVHFileStream : PoseDataStream {
|
||||
val positionScale = bvhSettings.positionScale
|
||||
writer
|
||||
.write("${rootPos.x * positionScale} ${rootPos.y * positionScale} ${rootPos.z * positionScale}")
|
||||
|
||||
// Add spacing
|
||||
writer.write(" ")
|
||||
writeBoneHierarchyRotation(rootBone, null)
|
||||
|
||||
writer.newLine()
|
||||
|
||||
@@ -46,7 +46,9 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
||||
emptyList()
|
||||
}
|
||||
private val parser = UDPProtocolParser()
|
||||
private val rcvBuffer = ByteArray(512)
|
||||
|
||||
// 1500 is a common network MTU. 1472 is the maximum size of a UDP packet (1500 - 20 for IPv4 header - 8 for UDP header)
|
||||
private val rcvBuffer = ByteArray(1500 - 20 - 8)
|
||||
private val bb = ByteBuffer.wrap(rcvBuffer).order(ByteOrder.BIG_ENDIAN)
|
||||
|
||||
// Gets initialized in this.run()
|
||||
@@ -319,6 +321,9 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
||||
tracker = connection?.getTracker(packet.sensorId)
|
||||
if (tracker == null) return
|
||||
tracker.setRotation(rot)
|
||||
if (packet is UDPPacket23RotationAndAcceleration) {
|
||||
tracker.setAcceleration(packet.acceleration)
|
||||
}
|
||||
tracker.dataTick()
|
||||
}
|
||||
|
||||
|
||||
@@ -329,6 +329,27 @@ class UDPPacket22FeatureFlags(
|
||||
}
|
||||
}
|
||||
|
||||
data class UDPPacket23RotationAndAcceleration(
|
||||
override var rotation: Quaternion = Quaternion.IDENTITY,
|
||||
var acceleration: Vector3 = Vector3.NULL,
|
||||
) : UDPPacket(23),
|
||||
RotationPacket {
|
||||
override var sensorId: Int = 0
|
||||
override fun readData(buf: ByteBuffer) {
|
||||
// s16 s16 s16 s16 s16 s16 s16
|
||||
// qX qY qZ qW aX aY aZ
|
||||
sensorId = buf.get().toInt() and 0xFF
|
||||
val scaleR = 1 / (1 shl 15).toFloat() // Q15: 1 is represented as 0x7FFF and -1 as 0x8000
|
||||
val x = buf.short * scaleR
|
||||
val y = buf.short * scaleR
|
||||
val z = buf.short * scaleR
|
||||
val w = buf.short * scaleR
|
||||
rotation = Quaternion(w, x, y, z).unit()
|
||||
val scaleA = 1 / (1 shl 7).toFloat() // The same as the HID scale
|
||||
acceleration = Vector3(buf.short * scaleA, buf.short * scaleA, buf.short * scaleA)
|
||||
}
|
||||
}
|
||||
|
||||
data class UDPPacket200ProtocolChange(
|
||||
var targetProtocol: Int = 0,
|
||||
var targetProtocolVersion: Int = 0,
|
||||
|
||||
@@ -127,6 +127,7 @@ class UDPProtocolParser {
|
||||
const val PACKET_TEMPERATURE = 20
|
||||
const val PACKET_USER_ACTION = 21
|
||||
const val PACKET_FEATURE_FLAGS = 22
|
||||
const val PACKET_ROTATION_AND_ACCELERATION = 23
|
||||
const val PACKET_BUNDLE = 100
|
||||
const val PACKET_PROTOCOL_CHANGE = 200
|
||||
private val HANDSHAKE_BUFFER = ByteArray(64)
|
||||
|
||||
@@ -59,7 +59,7 @@ dependencies {
|
||||
implementation("net.java.dev.jna:jna:5.+")
|
||||
implementation("net.java.dev.jna:jna-platform:5.+")
|
||||
implementation("com.fazecast:jSerialComm:2.10.2")
|
||||
implementation("org.hid4java:hid4java:0.7.0")
|
||||
implementation("org.hid4java:hid4java:0.8.0")
|
||||
}
|
||||
|
||||
tasks.shadowJar {
|
||||
|
||||
+8
-3
@@ -32,7 +32,7 @@ class TrackersHID(name: String, private val trackersConsumer: Consumer<Tracker>)
|
||||
private val hidServices: HidServices
|
||||
|
||||
init {
|
||||
hidServicesSpecification.isAutoStart = false
|
||||
hidServicesSpecification.setAutoStart(false)
|
||||
hidServices = HidManager.getHidServices(hidServicesSpecification)
|
||||
hidServices.addHidServicesListener(this)
|
||||
val dataReadThread = Thread(dataReadRunnable)
|
||||
@@ -43,7 +43,7 @@ class TrackersHID(name: String, private val trackersConsumer: Consumer<Tracker>)
|
||||
|
||||
private fun checkConfigureDevice(hidDevice: HidDevice) {
|
||||
if (hidDevice.vendorId == 0x2FE3 && hidDevice.productId == 0x5652) { // TODO: Use correct ids
|
||||
if (!hidDevice.isOpen) {
|
||||
if (hidDevice.isClosed) {
|
||||
check(hidDevice.open()) { "Unable to open device" }
|
||||
}
|
||||
// TODO: Configure the device here
|
||||
@@ -164,7 +164,7 @@ class TrackersHID(name: String, private val trackersConsumer: Consumer<Tracker>)
|
||||
var devicesPresent = false
|
||||
for ((hidDevice, deviceList) in devicesByHID) {
|
||||
val dataReceived: Array<Byte> = try {
|
||||
hidDevice.read(80, 1) // Read up to 80 bytes, timeout 1ms
|
||||
hidDevice.read(80, 0) // Read up to 80 bytes
|
||||
} catch (e: NegativeArraySizeException) {
|
||||
continue // Skip devices with read error (Maybe disconnected)
|
||||
}
|
||||
@@ -174,6 +174,7 @@ class TrackersHID(name: String, private val trackersConsumer: Consumer<Tracker>)
|
||||
// TODO: make this less bad
|
||||
if (dataReceived.size % 20 != 0) {
|
||||
LogManager.info("[TrackerServer] Malformed HID packet, ignoring")
|
||||
continue // Don't continue with this data
|
||||
}
|
||||
val packetCount = dataReceived.size / 20
|
||||
var i = 0
|
||||
@@ -243,6 +244,10 @@ class TrackersHID(name: String, private val trackersConsumer: Consumer<Tracker>)
|
||||
// TODO:
|
||||
}
|
||||
|
||||
override fun hidDataReceived(p0: HidServicesEvent?) {
|
||||
// Seems to have issues with the size of data returned
|
||||
}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Change between IMU axes and OpenGL/SteamVR axes
|
||||
|
||||
Reference in new issue
Block a user