[Base] Change behavior of has_console_attached().
[Base] Change has_console_attached() so that it no longer proves true if Xenia is launched from a Windows Terminal.
This commit is contained in:
parent
44bfba4b0e
commit
be1a666066
|
@ -38,11 +38,29 @@ bool has_console_attached_ = true;
|
||||||
|
|
||||||
bool has_console_attached() { return has_console_attached_; }
|
bool has_console_attached() { return has_console_attached_; }
|
||||||
|
|
||||||
|
bool has_shell_environment_variable() {
|
||||||
|
size_t size = 0;
|
||||||
|
// Check if SHELL exists
|
||||||
|
// If it doesn't, then we are in a Windows Terminal
|
||||||
|
auto error = getenv_s(&size, nullptr, 0, "SHELL");
|
||||||
|
if (error) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return !!size;
|
||||||
|
}
|
||||||
|
|
||||||
void AttachConsole() {
|
void AttachConsole() {
|
||||||
if (!cvars::enable_console) {
|
if (!cvars::enable_console) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool has_console = ::AttachConsole(ATTACH_PARENT_PROCESS) == TRUE;
|
||||||
|
if (!has_console || !has_shell_environment_variable()) {
|
||||||
|
// We weren't launched from a console, so just return.
|
||||||
|
has_console_attached_ = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
AllocConsole();
|
AllocConsole();
|
||||||
|
|
||||||
has_console_attached_ = true;
|
has_console_attached_ = true;
|
||||||
|
|
Loading…
Reference in New Issue