-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
618 additions
and
891 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
Panel-Tester/src/main/kotlin/dev/slimevr/OperatingSystem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package dev.slimevr | ||
|
||
import java.io.File | ||
import java.util.* | ||
|
||
enum class OperatingSystem( | ||
val systemName: String, | ||
private val aliases: Array<String?> | ||
) { | ||
|
||
LINUX("linux", arrayOf("linux", "unix")), | ||
WINDOWS("windows", arrayOf("win")), | ||
OSX("osx", arrayOf("mac")), | ||
UNKNOWN("unknown", arrayOfNulls(0)); | ||
|
||
companion object { | ||
|
||
private var currentPlatform: OperatingSystem? = null | ||
|
||
fun getJavaExecutable(forceConsole: Boolean): String { | ||
val separator = System.getProperty("file.separator") | ||
val path = System.getProperty("java.home") + separator + "bin" + separator | ||
if (getCurrentPlatform() == WINDOWS) { | ||
if (!forceConsole && File(path + "javaw.exe").isFile) | ||
return path + "javaw.exe" | ||
return path + "java.exe" | ||
} | ||
return path + "java" | ||
} | ||
|
||
@OptIn(ExperimentalStdlibApi::class) | ||
fun getCurrentPlatform(): OperatingSystem? { | ||
if (currentPlatform != null) return currentPlatform | ||
val osName = System.getProperty("os.name").lowercase(Locale.getDefault()) | ||
for (os in OperatingSystem.values()) { | ||
for (alias in os.aliases) { | ||
if (osName.contains(alias!!)) return os.also { | ||
currentPlatform = it | ||
} | ||
} | ||
} | ||
return UNKNOWN | ||
} | ||
|
||
val tempDirectory: String | ||
get() { | ||
if (currentPlatform == LINUX) { | ||
val tmp = System.getenv("XDG_RUNTIME_DIR") | ||
if (tmp != null) return tmp | ||
} | ||
return System.getProperty("java.io.tmpdir") | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...in/dev/slimevr/testing/USBDmesgWatcher.kt → ...v/slimevr/hardware/usb/USBDmesgWatcher.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package dev.slimevr.testing | ||
package dev.slimevr.hardware.usb | ||
|
||
import java.util.logging.Logger | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...n/kotlin/dev/slimevr/testing/USBNotify.kt → ...lin/dev/slimevr/hardware/usb/USBNotify.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package dev.slimevr.testing | ||
package dev.slimevr.hardware.usb | ||
|
||
interface USBNotify { | ||
|
||
|
24 changes: 24 additions & 0 deletions
24
Panel-Tester/src/main/kotlin/dev/slimevr/hardware/usb/USBSerialWatcher.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package dev.slimevr.hardware.usb | ||
|
||
import com.fazecast.jSerialComm.SerialPort | ||
import dev.slimevr.hardware.serial.SerialManager | ||
import java.util.logging.Logger | ||
|
||
class USBSerialWatcher( | ||
private val notifyUSB: USBNotify, | ||
private val serialManager: SerialManager | ||
): Thread("USB Serial watcher") { | ||
|
||
val logger: Logger = Logger.getLogger("USBSerialWatcher") | ||
|
||
override fun run() { | ||
while(true) { | ||
val newPorts = serialManager.findNewPorts() | ||
if(newPorts.isNotEmpty()) { | ||
for(port in newPorts) | ||
notifyUSB.setUSB(port.portLocation, port.systemPortName) | ||
} | ||
sleep(1000) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.