diff --git a/mod.json b/mod.json index a4586dc..fb32a09 100644 --- a/mod.json +++ b/mod.json @@ -1,9 +1,9 @@ { - "geode": "4.0.0", + "geode": "4.2.0", "gd": { "win": "2.2074" }, - "version": "v1.3.0", + "version": "v1.3.1", "id": "syzzi.click_between_frames", "name": "Click Between Frames", "developer": "syzzi", @@ -108,7 +108,8 @@ }, "resources": { "files": [ - "resources/linux-input.exe.so" + "resources/linux-input.exe.so", + "resources/freebsd-input.exe.so" ] } } \ No newline at end of file diff --git a/resources/freebsd-input.exe.so b/resources/freebsd-input.exe.so new file mode 100644 index 0000000..1c3a893 Binary files /dev/null and b/resources/freebsd-input.exe.so differ diff --git a/src/linux/Makefile b/src/linux/Makefile index 941e588..465ff33 100644 --- a/src/linux/Makefile +++ b/src/linux/Makefile @@ -4,11 +4,22 @@ ### /usr/bin/winemaker -iws2_32 -ievdev . --single-target linux-input +ifeq ($(shell uname),FreeBSD) +# pkg install libepoll-shim libevdev +CXXFLAGS=-I/usr/local/include/libepoll-shim +LDFLAGS=-lepoll-shim +OS=freebsd + +else +OS=linux +endif + + SRCDIR = . SUBDIRS = DLLS = LIBS = -EXES = linux-input +EXES = $(OS)-input @@ -28,7 +39,7 @@ LIBRARIES = ### linux-input sources and settings -linux_input_MODULE = linux-input +linux_input_MODULE = $(OS)-input linux_input_C_SRCS = linux_input_CXX_SRCS = linux-input.cpp linux_input_RC_SRCS = @@ -107,6 +118,6 @@ $(EXTRASUBDIRS:%=%/__clean__): dummy DEFLIB = $(LIBRARY_PATH) $(LIBRARIES) $(DLL_PATH) $(DLL_IMPORTS:%=-l%) $(linux_input_MODULE): $(linux_input_OBJS) - $(CXX) $(linux_input_LDFLAGS) -o $@ $(linux_input_OBJS) $(linux_input_LIBRARY_PATH) $(linux_input_DLL_PATH) $(DEFLIB) $(linux_input_DLLS:%=-l%) $(linux_input_LIBRARIES:%=-l%) + $(CXX) $(linux_input_LDFLAGS) $(LDFLAGS) -o $@ $(linux_input_OBJS) $(linux_input_LIBRARY_PATH) $(linux_input_DLL_PATH) $(DEFLIB) $(linux_input_DLLS:%=-l%) $(linux_input_LIBRARIES:%=-l%) diff --git a/src/main.cpp b/src/main.cpp index d6ff042..95f1d58 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -565,12 +565,14 @@ HANDLE gdMutex; std::string sys = sysname; log::info("Wine {}", sys); - if (sys == "Linux") Mod::get()->setSavedValue("you-must-be-on-linux-to-change-this", true); - if (sys == "Linux" && Mod::get()->getSettingValue("wine-workaround")) { // background raw keyboard input doesn't work in Wine - linuxNative = true; + const bool isLinux = sys == "Linux" || sys == "FreeBSD"; // FreeBSD isn't actually linux but it can run linux executables + + if (isLinux) Mod::get()->setSavedValue("you-must-be-on-linux-to-change-this", true); + if (isLinux && Mod::get()->getSettingValue("wine-workaround")) { // background raw keyboard input doesn't work in Wine + linuxNative = true; log::info("Linux native"); - hSharedMem = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(LinuxInputEvent[BUFFER_SIZE]), "LinuxSharedMemory"); + hSharedMem = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(LinuxInputEvent[BUFFER_SIZE]), "LinuxSharedMemory"); if (hSharedMem == NULL) { log::error("Failed to create file mapping: {}", GetLastError()); return; @@ -578,10 +580,10 @@ HANDLE gdMutex; pBuf = MapViewOfFile(hSharedMem, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(LinuxInputEvent[BUFFER_SIZE])); if (pBuf == NULL) { - log::error("Failed to map view of file: {}", GetLastError()); + log::error("Failed to map view of file: {}", GetLastError()); CloseHandle(hSharedMem); - return; - } + return; + } hMutex = CreateMutex(NULL, FALSE, "CBFLinuxMutex"); if (hMutex == NULL) { @@ -609,7 +611,13 @@ HANDLE gdMutex; si.cb = sizeof(si); ZeroMemory(&pi, sizeof(pi)); - std::string path = CCFileUtils::get()->fullPathForFilename("linux-input.exe.so"_spr, true); + const char* inputlib = "linux-input.exe.so"_spr; + // Workaround because linux version fails to load (newer glibc than in provided rocky linux 9 + something else, lazy to discover) + // Anyway faster version + if (sys == "FreeBSD") + inputlib = "freebsd-input.exe.so"_spr; + + std::string path = CCFileUtils::get()->fullPathForFilename(inputlib, true); if (!CreateProcess(path.c_str(), NULL, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi)) { log::error("Failed to launch Linux input program: {}", GetLastError()); @@ -624,4 +632,4 @@ HANDLE gdMutex; if (!linuxNative) { std::thread(inputThread).detach(); } -} \ No newline at end of file +}