diff --git a/src/launcher.cpp b/src/launcher.cpp index 85ebe9c..eea59f4 100644 --- a/src/launcher.cpp +++ b/src/launcher.cpp @@ -6,21 +6,59 @@ #include #include +#include +#include +#include +#include + +// Bind and activate the framebuffer console on selected platforms. +#define BIND_CONSOLE \ + defined(PLATFORM_A320) || defined(PLATFORM_GCW0) + +#if BIND_CONSOLE +#include +#endif + using namespace std; -Launcher::Launcher(vector const& commandLine) +Launcher::Launcher(vector const& commandLine, bool consoleApp) : commandLine(commandLine) + , consoleApp(consoleApp) { } -Launcher::Launcher(vector && commandLine) +Launcher::Launcher(vector && commandLine, bool consoleApp) : commandLine(commandLine) + , consoleApp(consoleApp) { } void Launcher::exec() { + if (consoleApp) { +#if BIND_CONSOLE + /* Enable the framebuffer console */ + char c = '1'; + int fd = open("/sys/devices/virtual/vtconsole/vtcon1/bind", O_WRONLY); + if (fd < 0) { + WARNING("Unable to open fbcon handle\n"); + } else { + write(fd, &c, 1); + close(fd); + } + + fd = open("/dev/tty1", O_RDWR); + if (fd < 0) { + WARNING("Unable to open tty1 handle\n"); + } else { + if (ioctl(fd, VT_ACTIVATE, 1) < 0) + WARNING("Unable to activate tty1\n"); + close(fd); + } +#endif + } + vector args; args.reserve(commandLine.size() + 1); for (auto arg : commandLine) { diff --git a/src/launcher.h b/src/launcher.h index 0c99b28..a875aa2 100644 --- a/src/launcher.h +++ b/src/launcher.h @@ -8,13 +8,16 @@ class Launcher { public: - Launcher(std::vector const& commandLine); - Launcher(std::vector && commandLine); + Launcher(std::vector const& commandLine, + bool consoleApp = true); + Launcher(std::vector && commandLine, + bool consoleApp = true); void exec(); private: std::vector commandLine; + bool consoleApp; }; #endif // LAUNCHER_H diff --git a/src/linkapp.cpp b/src/linkapp.cpp index 3979c9b..d19c5ed 100644 --- a/src/linkapp.cpp +++ b/src/linkapp.cpp @@ -43,14 +43,6 @@ #include #include -// Bind and activate the framebuffer console on selected platforms. -#define BIND_CONSOLE \ - defined(PLATFORM_A320) || defined(PLATFORM_GCW0) - -#if BIND_CONSOLE -#include -#endif - #ifdef HAVE_LIBOPK #include #endif @@ -578,29 +570,6 @@ void LinkApp::launch(const string &selectedFile) { #endif gmenu2x->quit(); - if (consoleApp) { -#if BIND_CONSOLE - /* Enable the framebuffer console */ - char c = '1'; - int fd = open("/sys/devices/virtual/vtconsole/vtcon1/bind", O_WRONLY); - if (fd < 0) { - WARNING("Unable to open fbcon handle\n"); - } else { - write(fd, &c, 1); - close(fd); - } - - fd = open("/dev/tty1", O_RDWR); - if (fd < 0) { - WARNING("Unable to open tty1 handle\n"); - } else { - if (ioctl(fd, VT_ACTIVATE, 1) < 0) - WARNING("Unable to activate tty1\n"); - close(fd); - } -#endif - } - vector commandLine; if (isOpk()) { #ifdef HAVE_LIBOPK @@ -613,7 +582,7 @@ void LinkApp::launch(const string &selectedFile) { commandLine = { "/bin/sh", "-c", exec + " " + params }; } - Launcher launcher(move(commandLine)); + Launcher launcher(move(commandLine), consoleApp); launcher.exec(); //if execution continues then something went wrong and as we already called SDL_Quit we cannot continue