Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions mod.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -108,7 +108,8 @@
},
"resources": {
"files": [
"resources/linux-input.exe.so"
"resources/linux-input.exe.so",
"resources/freebsd-input.exe.so"
]
}
}
Binary file added resources/freebsd-input.exe.so
Binary file not shown.
17 changes: 14 additions & 3 deletions src/linux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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



Expand All @@ -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 =
Expand Down Expand Up @@ -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%)


26 changes: 17 additions & 9 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,23 +565,25 @@ HANDLE gdMutex;
std::string sys = sysname;
log::info("Wine {}", sys);

if (sys == "Linux") Mod::get()->setSavedValue<bool>("you-must-be-on-linux-to-change-this", true);
if (sys == "Linux" && Mod::get()->getSettingValue<bool>("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<bool>("you-must-be-on-linux-to-change-this", true);
if (isLinux && Mod::get()->getSettingValue<bool>("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;
}

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) {
Expand Down Expand Up @@ -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());
Expand All @@ -624,4 +632,4 @@ HANDLE gdMutex;
if (!linuxNative) {
std::thread(inputThread).detach();
}
}
}