From c1e1955a4b7586011b6c4263b1cf4ed552ea5dea Mon Sep 17 00:00:00 2001 From: shoaib11120 Date: Wed, 26 Jan 2022 16:51:13 +0530 Subject: [PATCH] Setup for linux --- stardew-access/ModEntry.cs | 31 +++++++++++++++++++------------ stardew-access/ScreenReader.cs | 4 ++++ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/stardew-access/ModEntry.cs b/stardew-access/ModEntry.cs index 87a98e9..224fcf6 100644 --- a/stardew-access/ModEntry.cs +++ b/stardew-access/ModEntry.cs @@ -5,6 +5,7 @@ using StardewValley; using HarmonyLib; using stardew_access.Patches; using AutoHotkey.Interop; +using System.Runtime.InteropServices; namespace stardew_access { @@ -38,18 +39,8 @@ namespace stardew_access Game1.options.setGamepadMode("force_on"); // Initialize AutoHotKey - try - { - ahk = AutoHotkeyEngine.Instance; - ahk.ExecRaw("[::\nSend {LButton}"); - ahk.ExecRaw("^Enter::\nSend {LButton}"); - ahk.ExecRaw("]::\nSend {RButton}"); - ahk.ExecRaw("+Enter::\nSend {RButton}"); - } - catch (Exception e) - { - monitor.Log($"Unable to initialize AutoHotKey:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); - } + if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + InitializeAutoHotKey(); screenReader = new ScreenReader(); screenReader.InitializeScreenReader(); @@ -148,5 +139,21 @@ namespace stardew_access monitor.Log($"{Game1.player.controller.pathToEndPoint==null}", LogLevel.Debug); // true if path not found }*/ } + + private void InitializeAutoHotKey() + { + try + { + ahk = AutoHotkeyEngine.Instance; + ahk.ExecRaw("[::\nSend {LButton}"); + ahk.ExecRaw("^Enter::\nSend {LButton}"); + ahk.ExecRaw("]::\nSend {RButton}"); + ahk.ExecRaw("+Enter::\nSend {RButton}"); + } + catch (Exception e) + { + monitor.Log($"Unable to initialize AutoHotKey:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); + } + } } } \ No newline at end of file diff --git a/stardew-access/ScreenReader.cs b/stardew-access/ScreenReader.cs index 76e04ba..c5f351d 100644 --- a/stardew-access/ScreenReader.cs +++ b/stardew-access/ScreenReader.cs @@ -1,5 +1,6 @@ using AccessibleOutput; using StardewModdingAPI; +using System.Runtime.InteropServices; namespace stardew_access { @@ -11,6 +12,9 @@ namespace stardew_access /// Initializes the screen reader. public void InitializeScreenReader() { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + return; + NvdaOutput? nvdaOutput = null; JawsOutput? jawsOutput = null; SapiOutput? sapiOutput = null;