diff options
Diffstat (limited to 'platform/windows')
-rw-r--r-- | platform/windows/detect.py | 17 | ||||
-rw-r--r-- | platform/windows/display_server_windows.cpp | 36 | ||||
-rw-r--r-- | platform/windows/display_server_windows.h | 1 | ||||
-rw-r--r-- | platform/windows/godot.natvis | 6 | ||||
-rw-r--r-- | platform/windows/godot_windows.cpp | 8 | ||||
-rw-r--r-- | platform/windows/joypad_windows.cpp | 6 | ||||
-rw-r--r-- | platform/windows/platform_config.h | 2 |
7 files changed, 49 insertions, 27 deletions
diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 9f79e92dcb..a9f25fa078 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -128,7 +128,9 @@ def setup_msvc_manual(env): print("Compiled program architecture will be a 32 bit executable. (forcing bits=32).") else: print( - "Failed to manually detect MSVC compiler architecture version... Defaulting to 32bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup, or avoid setting VCINSTALLDIR." + "Failed to manually detect MSVC compiler architecture version... Defaulting to 32bit executable settings" + " (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this" + " build is compiled for. You should check your settings/compilation setup, or avoid setting VCINSTALLDIR." ) @@ -181,7 +183,6 @@ def configure_msvc(env, manual_msvc_config): env.Append(CCFLAGS=["/O2"]) else: # optimize for size env.Append(CCFLAGS=["/O1"]) - env.Append(LINKFLAGS=["/SUBSYSTEM:WINDOWS"]) env.Append(LINKFLAGS=["/ENTRY:mainCRTStartup"]) env.Append(LINKFLAGS=["/OPT:REF"]) @@ -191,15 +192,15 @@ def configure_msvc(env, manual_msvc_config): else: # optimize for size env.Append(CCFLAGS=["/O1"]) env.AppendUnique(CPPDEFINES=["DEBUG_ENABLED"]) - env.Append(LINKFLAGS=["/SUBSYSTEM:CONSOLE"]) env.Append(LINKFLAGS=["/OPT:REF"]) elif env["target"] == "debug": env.AppendUnique(CCFLAGS=["/Z7", "/Od", "/EHsc"]) - env.AppendUnique(CPPDEFINES=["DEBUG_ENABLED", "DEBUG_MEMORY_ENABLED", "D3D_DEBUG_INFO"]) - env.Append(LINKFLAGS=["/SUBSYSTEM:CONSOLE"]) + env.AppendUnique(CPPDEFINES=["DEBUG_ENABLED"]) env.Append(LINKFLAGS=["/DEBUG"]) + env.Append(LINKFLAGS=["/SUBSYSTEM:WINDOWS"]) + if env["debug_symbols"] == "full" or env["debug_symbols"] == "yes": env.AppendUnique(CCFLAGS=["/Z7"]) env.AppendUnique(LINKFLAGS=["/DEBUG"]) @@ -312,8 +313,6 @@ def configure_mingw(env): else: # optimize for size env.Prepend(CCFLAGS=["-Os"]) - env.Append(LINKFLAGS=["-Wl,--subsystem,windows"]) - if env["debug_symbols"] == "yes": env.Prepend(CCFLAGS=["-g1"]) if env["debug_symbols"] == "full": @@ -333,7 +332,9 @@ def configure_mingw(env): elif env["target"] == "debug": env.Append(CCFLAGS=["-g3"]) - env.Append(CPPDEFINES=["DEBUG_ENABLED", "DEBUG_MEMORY_ENABLED"]) + env.Append(CPPDEFINES=["DEBUG_ENABLED"]) + + env.Append(LINKFLAGS=["-Wl,--subsystem,windows"]) ## Compiler configuration diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 0251ffe664..9469e35536 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -170,7 +170,7 @@ void DisplayServerWindows::clipboard_set(const String &p_text) { // Convert LF line endings to CRLF in clipboard content // Otherwise, line endings won't be visible when pasted in other software - String text = p_text.replace("\n", "\r\n"); + String text = p_text.replace("\r\n", "\n").replace("\n", "\r\n"); // avoid \r\r\n if (!OpenClipboard(windows[last_focused_window].hWnd)) { ERR_FAIL_MSG("Unable to open clipboard."); @@ -1131,10 +1131,17 @@ void DisplayServerWindows::window_set_ime_position(const Point2i &p_pos, WindowI void DisplayServerWindows::console_set_visible(bool p_enabled) { _THREAD_SAFE_METHOD_ - if (console_visible == p_enabled) + if (console_visible == p_enabled) { return; - ShowWindow(GetConsoleWindow(), p_enabled ? SW_SHOW : SW_HIDE); - console_visible = p_enabled; + } + if (p_enabled && GetConsoleWindow() == nullptr) { // Open new console if not attached. + own_console = true; + AllocConsole(); + } + if (own_console) { // Note: Do not hide parent console. + ShowWindow(GetConsoleWindow(), p_enabled ? SW_SHOW : SW_HIDE); + console_visible = p_enabled; + } } bool DisplayServerWindows::is_console_visible() const { @@ -2026,8 +2033,8 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA Ref<InputEventMouseMotion> mm; mm.instance(); mm->set_window_id(window_id); - mm->set_control(GetKeyState(VK_CONTROL) != 0); - mm->set_shift(GetKeyState(VK_SHIFT) != 0); + mm->set_control(GetKeyState(VK_CONTROL) < 0); + mm->set_shift(GetKeyState(VK_SHIFT) < 0); mm->set_alt(alt_mem); mm->set_pressure(windows[window_id].last_pressure); @@ -2169,8 +2176,8 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA mm->set_tilt(Vector2((float)pen_info.tiltX / 90, (float)pen_info.tiltY / 90)); } - mm->set_control((wParam & MK_CONTROL) != 0); - mm->set_shift((wParam & MK_SHIFT) != 0); + mm->set_control(GetKeyState(VK_CONTROL) < 0); + mm->set_shift(GetKeyState(VK_SHIFT) < 0); mm->set_alt(alt_mem); mm->set_button_mask(last_button_state); @@ -3015,7 +3022,18 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win shift_mem = false; control_mem = false; meta_mem = false; - console_visible = IsWindowVisible(GetConsoleWindow()); + + if (AttachConsole(ATTACH_PARENT_PROCESS)) { + FILE *_file = nullptr; + freopen_s(&_file, "CONOUT$", "w", stdout); + freopen_s(&_file, "CONOUT$", "w", stderr); + freopen_s(&_file, "CONIN$", "r", stdin); + + printf("\n"); + console_visible = true; + } else { + console_visible = false; + } hInstance = ((OS_Windows *)OS::get_singleton())->get_hinstance(); pressrc = 0; diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h index 725f9697c5..0ad8cd3d07 100644 --- a/platform/windows/display_server_windows.h +++ b/platform/windows/display_server_windows.h @@ -405,6 +405,7 @@ private: bool drop_events = false; bool in_dispatch_input_event = false; bool console_visible = false; + bool own_console = false; WNDCLASSEXW wc; diff --git a/platform/windows/godot.natvis b/platform/windows/godot.natvis index 593557cc69..90f0b55d0a 100644 --- a/platform/windows/godot.natvis +++ b/platform/windows/godot.natvis @@ -19,7 +19,7 @@ </ArrayItems> </Expand> </Type> - + <Type Name="List<*>"> <Expand> <Item Name="[size]">_data ? (_data->size_cache) : 0</Item> @@ -62,7 +62,7 @@ <DisplayString Condition="type == Variant::POOL_COLOR_ARRAY">{*(PoolColorArray *)_data._mem}</DisplayString> <StringView Condition="type == Variant::STRING && ((String *)(_data._mem))->_cowdata._ptr">((String *)(_data._mem))->_cowdata._ptr,su</StringView> - + <Expand> <Item Name="[value]" Condition="type == Variant::BOOL">_data._bool</Item> <Item Name="[value]" Condition="type == Variant::INT">_data._int</Item> @@ -143,7 +143,7 @@ <Item Name="alpha">a</Item> </Expand> </Type> - + <Type Name="Node" Inheritable="false"> <Expand> <Item Name="Object">(Object*)this</Item> diff --git a/platform/windows/godot_windows.cpp b/platform/windows/godot_windows.cpp index 910059a9fc..add559a717 100644 --- a/platform/windows/godot_windows.cpp +++ b/platform/windows/godot_windows.cpp @@ -146,6 +146,8 @@ int widechar_main(int argc, wchar_t **argv) { argv_utf8[i] = wc_to_utf8(argv[i]); } + TEST_MAIN_PARAM_OVERRIDE(argc, argv_utf8) + Error err = Main::setup(argv_utf8[0], argc - 1, &argv_utf8[1]); if (err != OK) { @@ -186,10 +188,12 @@ int _main() { return result; } -int main(int _argc, char **_argv) { +int main(int argc, char **argv) { + // override the arguments for the test handler / if symbol is provided + // TEST_MAIN_OVERRIDE + // _argc and _argv are ignored // we are going to use the WideChar version of them instead - #ifdef CRASH_HANDLER_EXCEPTION __try { return _main(); diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp index 65caee3035..d1454c9096 100644 --- a/platform/windows/joypad_windows.cpp +++ b/platform/windows/joypad_windows.cpp @@ -146,8 +146,8 @@ bool JoypadWindows::setup_dinput_joypad(const DIDEVICEINSTANCE *instance) { if (have_device(instance->guidInstance) || num == -1) return false; - d_joypads[joypad_count] = dinput_gamepad(); - dinput_gamepad *joy = &d_joypads[joypad_count]; + d_joypads[num] = dinput_gamepad(); + dinput_gamepad *joy = &d_joypads[num]; const DWORD devtype = (instance->dwDevType & 0xFF); @@ -171,7 +171,7 @@ bool JoypadWindows::setup_dinput_joypad(const DIDEVICEINSTANCE *instance) { WORD version = 0; sprintf_s(uid, "%04x%04x%04x%04x%04x%04x%04x%04x", type, 0, vendor, 0, product, 0, version, 0); - id_to_change = joypad_count; + id_to_change = num; slider_count = 0; joy->di_joy->SetDataFormat(&c_dfDIJoystick2); diff --git a/platform/windows/platform_config.h b/platform/windows/platform_config.h index 290decac5f..09a16614e0 100644 --- a/platform/windows/platform_config.h +++ b/platform/windows/platform_config.h @@ -29,5 +29,3 @@ /*************************************************************************/ #include <malloc.h> - -#define GLES2_INCLUDE_H "thirdparty/glad/glad/glad.h" |