Merge pull request #88 from saile515/fix-input-linux

Fix input not working on Linux
This commit is contained in:
Lion 2024-05-29 11:13:05 +02:00 committed by GitHub
commit cc4e322065
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -15,6 +15,7 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <spawn.h>
#endif #endif
#include <Security/Init.h> #include <Security/Init.h>
@ -90,17 +91,19 @@ void StartGame(std::string Dir){
#elif defined(__linux__) #elif defined(__linux__)
void StartGame(std::string Dir) { void StartGame(std::string Dir) {
int status; int status;
pid_t pid = fork(); std::string filename = (Dir + "/BinLinux/BeamNG.drive.x64");
if (pid >= 0){ char *argv[] = {filename.data(), NULL};
if (pid == 0){ pid_t pid;
execl((Dir + "/BinLinux/BeamNG.drive.x64").c_str(), "", NULL); int result = posix_spawn(&pid, filename.c_str(), NULL, NULL, argv, environ);
} else if (pid > 0){
if (result != 0) {
error("Failed to Launch the game! launcher closing soon");
return;
} else {
waitpid(pid, &status, 0); waitpid(pid, &status, 0);
error("Game Closed! launcher closing soon"); error("Game Closed! launcher closing soon");
} }
} else {
error("Failed to Launch the game! launcher closing soon");
}
std::this_thread::sleep_for(std::chrono::seconds(5)); std::this_thread::sleep_for(std::chrono::seconds(5));
exit(2); exit(2);
} }