From cee400a4c654e3ae377dec6cc50b9eadee92855f Mon Sep 17 00:00:00 2001 From: Carl Andersson Date: Sun, 26 Dec 2021 21:48:52 +0100 Subject: [PATCH] Simplify OS & error checks --- src/main/java/dev/slimevr/gui/Keybinding.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/main/java/dev/slimevr/gui/Keybinding.java b/src/main/java/dev/slimevr/gui/Keybinding.java index 45c019f95..7d5e3aea5 100644 --- a/src/main/java/dev/slimevr/gui/Keybinding.java +++ b/src/main/java/dev/slimevr/gui/Keybinding.java @@ -1,12 +1,10 @@ package dev.slimevr.gui; -import java.util.Locale; - import com.melloware.jintellitype.HotkeyListener; import com.melloware.jintellitype.JIntellitype; -import com.melloware.jintellitype.JIntellitypeException; import dev.slimevr.VRServer; +import io.eiren.util.OperatingSystem; import io.eiren.util.ann.AWTThread; import io.eiren.util.logging.LogManager; @@ -19,14 +17,8 @@ public class Keybinding implements HotkeyListener { public Keybinding(VRServer server) { this.server = server; - try { - String osName = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH); - if(!osName.contains("windows")) { - LogManager.log.info("[Keybinding] Currently only supported on Windows. Keybindings will be disabled."); - return; - } - } catch (SecurityException e) { - LogManager.log.info("[Keybinding] Can't check operating system name. Keybindings will be disabled."); + if (OperatingSystem.getCurrentPlatform() == OperatingSystem.WINDOWS) { + LogManager.log.info("[Keybinding] Currently only supported on Windows. Keybindings will be disabled."); return; } @@ -50,7 +42,7 @@ public class Keybinding implements HotkeyListener { JIntellitype.getInstance().registerHotKey(QUICK_RESET, quickResetBinding); LogManager.log.info("[Keybinding] Bound quick reset to " + quickResetBinding); } - } catch(JIntellitypeException | ExceptionInInitializerError | UnsatisfiedLinkError e) { + } catch(Throwable e) { LogManager.log.info("[Keybinding] JIntellitype initialization failed. Keybindings will be disabled. Try restarting your computer."); } }