diff --git a/BetterJoyForCemu/BetterJoy.csproj b/BetterJoyForCemu/BetterJoy.csproj
index 292a02b..22fb2e8 100644
--- a/BetterJoyForCemu/BetterJoy.csproj
+++ b/BetterJoyForCemu/BetterJoy.csproj
@@ -236,7 +236,10 @@
-
+
+ Always
+
+
Always
diff --git a/BetterJoyForCemu/Program.cs b/BetterJoyForCemu/Program.cs
index 67bcd60..24e67e6 100644
--- a/BetterJoyForCemu/Program.cs
+++ b/BetterJoyForCemu/Program.cs
@@ -516,6 +516,10 @@ namespace BetterJoyForCemu {
private static string appGuid = "1bf709e9-c133-41df-933a-c9ff3f664c7b"; // randomly-generated
static void Main(string[] args) {
+
+ // Set the correct DLL for the current OS
+ SetupDlls();
+
using (Mutex mutex = new Mutex(false, "Global\\" + appGuid)) {
if (!mutex.WaitOne(0, false)) {
MessageBox.Show("Instance already running.", "BetterJoy");
@@ -528,5 +532,21 @@ namespace BetterJoyForCemu {
Application.Run(form);
}
}
+
+ static void SetupDlls() {
+ const int LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x00001000;
+ SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
+ AddDllDirectory(Path.Combine(
+ AppDomain.CurrentDomain.BaseDirectory,
+ Environment.Is64BitProcess ? "x64" : "x86"
+ ));
+ }
+
+ // Helper funtions to set the hidapi dll location acording to the system instruction set.
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ static extern bool SetDefaultDllDirectories(int directoryFlags);
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
+ static extern void AddDllDirectory(string lpPathName);
}
}
diff --git a/BetterJoyForCemu/hidapi.dll b/BetterJoyForCemu/hidapi.dll
deleted file mode 100644
index 28c267a..0000000
Binary files a/BetterJoyForCemu/hidapi.dll and /dev/null differ
diff --git a/BetterJoyForCemu/x64/hidapi.dll b/BetterJoyForCemu/x64/hidapi.dll
new file mode 100644
index 0000000..cea5b09
Binary files /dev/null and b/BetterJoyForCemu/x64/hidapi.dll differ
diff --git a/BetterJoyForCemu/x86/hidapi.dll b/BetterJoyForCemu/x86/hidapi.dll
new file mode 100644
index 0000000..9998cca
Binary files /dev/null and b/BetterJoyForCemu/x86/hidapi.dll differ