diff options
Diffstat (limited to 'platform/windows')
-rw-r--r-- | platform/windows/SCsub | 11 | ||||
-rw-r--r-- | platform/windows/context_gl_windows.cpp (renamed from platform/windows/context_gl_win.cpp) | 24 | ||||
-rw-r--r-- | platform/windows/context_gl_windows.h (renamed from platform/windows/context_gl_win.h) | 25 | ||||
-rw-r--r-- | platform/windows/crash_handler_windows.cpp (renamed from platform/windows/crash_handler_win.cpp) | 7 | ||||
-rw-r--r-- | platform/windows/crash_handler_windows.h (renamed from platform/windows/crash_handler_win.h) | 8 | ||||
-rw-r--r-- | platform/windows/ctxgl_procaddr.cpp | 188 | ||||
-rw-r--r-- | platform/windows/ctxgl_procaddr.h | 39 | ||||
-rw-r--r-- | platform/windows/detect.py | 36 | ||||
-rw-r--r-- | platform/windows/export/export.cpp | 4 | ||||
-rw-r--r-- | platform/windows/godot.natvis | 147 | ||||
-rw-r--r-- | platform/windows/godot_windows.cpp (renamed from platform/windows/godot_win.cpp) | 3 | ||||
-rw-r--r-- | platform/windows/joypad_windows.cpp (renamed from platform/windows/joypad.cpp) | 4 | ||||
-rw-r--r-- | platform/windows/joypad_windows.h (renamed from platform/windows/joypad.h) | 9 | ||||
-rw-r--r-- | platform/windows/key_mapping_windows.cpp (renamed from platform/windows/key_mapping_win.cpp) | 4 | ||||
-rw-r--r-- | platform/windows/key_mapping_windows.h (renamed from platform/windows/key_mapping_win.h) | 4 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 145 | ||||
-rw-r--r-- | platform/windows/os_windows.h | 27 | ||||
-rw-r--r-- | platform/windows/power_windows.h | 6 |
18 files changed, 276 insertions, 415 deletions
diff --git a/platform/windows/SCsub b/platform/windows/SCsub index e07d373c4b..892d734734 100644 --- a/platform/windows/SCsub +++ b/platform/windows/SCsub @@ -7,13 +7,12 @@ from platform_methods import run_in_subprocess import platform_windows_builders common_win = [ - "godot_win.cpp", - "context_gl_win.cpp", - "crash_handler_win.cpp", + "godot_windows.cpp", + "context_gl_windows.cpp", + "crash_handler_windows.cpp", "os_windows.cpp", - "ctxgl_procaddr.cpp", - "key_mapping_win.cpp", - "joypad.cpp", + "key_mapping_windows.cpp", + "joypad_windows.cpp", "power_windows.cpp", "windows_terminal_logger.cpp" ] diff --git a/platform/windows/context_gl_win.cpp b/platform/windows/context_gl_windows.cpp index 9d267c699f..e715999378 100644 --- a/platform/windows/context_gl_win.cpp +++ b/platform/windows/context_gl_windows.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* context_gl_win.cpp */ +/* context_gl_windows.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -32,7 +32,7 @@ // Author: Juan Linietsky <reduzio@gmail.com>, (C) 2008 -#include "context_gl_win.h" +#include "context_gl_windows.h" #define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 #define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 @@ -43,32 +43,32 @@ typedef HGLRC(APIENTRY *PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC, HGLRC, const int *); -void ContextGL_Win::release_current() { +void ContextGL_Windows::release_current() { wglMakeCurrent(hDC, NULL); } -void ContextGL_Win::make_current() { +void ContextGL_Windows::make_current() { wglMakeCurrent(hDC, hRC); } -int ContextGL_Win::get_window_width() { +int ContextGL_Windows::get_window_width() { return OS::get_singleton()->get_video_mode().width; } -int ContextGL_Win::get_window_height() { +int ContextGL_Windows::get_window_height() { return OS::get_singleton()->get_video_mode().height; } -void ContextGL_Win::swap_buffers() { +void ContextGL_Windows::swap_buffers() { SwapBuffers(hDC); } -void ContextGL_Win::set_use_vsync(bool p_use) { +void ContextGL_Windows::set_use_vsync(bool p_use) { if (wglSwapIntervalEXT) { wglSwapIntervalEXT(p_use ? 1 : 0); @@ -76,14 +76,14 @@ void ContextGL_Win::set_use_vsync(bool p_use) { use_vsync = p_use; } -bool ContextGL_Win::is_using_vsync() const { +bool ContextGL_Windows::is_using_vsync() const { return use_vsync; } #define _WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 -Error ContextGL_Win::initialize() { +Error ContextGL_Windows::initialize() { static PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor @@ -172,14 +172,14 @@ Error ContextGL_Win::initialize() { return OK; } -ContextGL_Win::ContextGL_Win(HWND hwnd, bool p_opengl_3_context) { +ContextGL_Windows::ContextGL_Windows(HWND hwnd, bool p_opengl_3_context) { opengl_3_context = p_opengl_3_context; hWnd = hwnd; use_vsync = false; } -ContextGL_Win::~ContextGL_Win() { +ContextGL_Windows::~ContextGL_Windows() { } #endif diff --git a/platform/windows/context_gl_win.h b/platform/windows/context_gl_windows.h index 3076bbb1e8..d23fba50e1 100644 --- a/platform/windows/context_gl_win.h +++ b/platform/windows/context_gl_windows.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* context_gl_win.h */ +/* context_gl_windows.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -37,13 +37,12 @@ #include "core/error_list.h" #include "core/os/os.h" -#include "drivers/gl_context/context_gl.h" #include <windows.h> typedef bool(APIENTRY *PFNWGLSWAPINTERVALEXTPROC)(int interval); -class ContextGL_Win : public ContextGL { +class ContextGL_Windows { HDC hDC; HGLRC hRC; @@ -55,21 +54,21 @@ class ContextGL_Win : public ContextGL { PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT; public: - virtual void release_current(); + void release_current(); - virtual void make_current(); + void make_current(); - virtual int get_window_width(); - virtual int get_window_height(); - virtual void swap_buffers(); + int get_window_width(); + int get_window_height(); + void swap_buffers(); - virtual Error initialize(); + Error initialize(); - virtual void set_use_vsync(bool p_use); - virtual bool is_using_vsync() const; + void set_use_vsync(bool p_use); + bool is_using_vsync() const; - ContextGL_Win(HWND hwnd, bool p_opengl_3_context); - virtual ~ContextGL_Win(); + ContextGL_Windows(HWND hwnd, bool p_opengl_3_context); + ~ContextGL_Windows(); }; #endif diff --git a/platform/windows/crash_handler_win.cpp b/platform/windows/crash_handler_windows.cpp index 1d93c6d8dd..4006c4c60e 100644 --- a/platform/windows/crash_handler_win.cpp +++ b/platform/windows/crash_handler_windows.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* crash_handler_win.cpp */ +/* crash_handler_windows.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,9 +28,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ +#include "crash_handler_windows.h" + +#include "core/os/os.h" #include "core/project_settings.h" #include "main/main.h" -#include "os_windows.h" #ifdef CRASH_HANDLER_EXCEPTION @@ -39,6 +41,7 @@ #include <psapi.h> #include <algorithm> #include <iterator> +#include <vector> #pragma comment(lib, "psapi.lib") #pragma comment(lib, "dbghelp.lib") diff --git a/platform/windows/crash_handler_win.h b/platform/windows/crash_handler_windows.h index 016612a00e..eba72beb7e 100644 --- a/platform/windows/crash_handler_win.h +++ b/platform/windows/crash_handler_windows.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* crash_handler_win.h */ +/* crash_handler_windows.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef CRASH_HANDLER_WIN_H -#define CRASH_HANDLER_WIN_H +#ifndef CRASH_HANDLER_WINDOWS_H +#define CRASH_HANDLER_WINDOWS_H #include <windows.h> @@ -54,4 +54,4 @@ public: ~CrashHandler(); }; -#endif +#endif // CRASH_HANDLER_WINDOWS_H diff --git a/platform/windows/ctxgl_procaddr.cpp b/platform/windows/ctxgl_procaddr.cpp deleted file mode 100644 index ecff8f7a4d..0000000000 --- a/platform/windows/ctxgl_procaddr.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/*************************************************************************/ -/* ctxgl_procaddr.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifdef OPENGL_ENABLED -#include "ctxgl_procaddr.h" -#include <GL/gl.h> -#include <stdio.h> - -static PROC _gl_procs[] = { - (PROC)glCullFace, - (PROC)glFrontFace, - (PROC)glHint, - (PROC)glLineWidth, - (PROC)glPointSize, - (PROC)glPolygonMode, - (PROC)glScissor, - (PROC)glTexParameterf, - (PROC)glTexParameterfv, - (PROC)glTexParameteri, - (PROC)glTexParameteriv, - (PROC)glTexImage1D, - (PROC)glTexImage2D, - (PROC)glDrawBuffer, - (PROC)glClear, - (PROC)glClearColor, - (PROC)glClearStencil, - (PROC)glClearDepth, - (PROC)glStencilMask, - (PROC)glColorMask, - (PROC)glDepthMask, - (PROC)glDisable, - (PROC)glEnable, - (PROC)glFinish, - (PROC)glFlush, - (PROC)glBlendFunc, - (PROC)glLogicOp, - (PROC)glStencilFunc, - (PROC)glStencilOp, - (PROC)glDepthFunc, - (PROC)glPixelStoref, - (PROC)glPixelStorei, - (PROC)glReadBuffer, - (PROC)glReadPixels, - (PROC)glGetBooleanv, - (PROC)glGetDoublev, - (PROC)glGetError, - (PROC)glGetFloatv, - (PROC)glGetIntegerv, - (PROC)glGetString, - (PROC)glGetTexImage, - (PROC)glGetTexParameterfv, - (PROC)glGetTexParameteriv, - (PROC)glGetTexLevelParameterfv, - (PROC)glGetTexLevelParameteriv, - (PROC)glIsEnabled, - (PROC)glDepthRange, - (PROC)glViewport, - /* not detected in ATI */ - (PROC)glDrawArrays, - (PROC)glDrawElements, - (PROC)glGetPointerv, - (PROC)glPolygonOffset, - (PROC)glCopyTexImage1D, - (PROC)glCopyTexImage2D, - (PROC)glCopyTexSubImage1D, - (PROC)glCopyTexSubImage2D, - (PROC)glTexSubImage1D, - (PROC)glTexSubImage2D, - (PROC)glBindTexture, - (PROC)glDeleteTextures, - (PROC)glGenTextures, - (PROC)glIsTexture, - - 0 -}; - -static const char *_gl_proc_names[] = { - "glCullFace", - "glFrontFace", - "glHint", - "glLineWidth", - "glPointSize", - "glPolygonMode", - "glScissor", - "glTexParameterf", - "glTexParameterfv", - "glTexParameteri", - "glTexParameteriv", - "glTexImage1D", - "glTexImage2D", - "glDrawBuffer", - "glClear", - "glClearColor", - "glClearStencil", - "glClearDepth", - "glStencilMask", - "glColorMask", - "glDepthMask", - "glDisable", - "glEnable", - "glFinish", - "glFlush", - "glBlendFunc", - "glLogicOp", - "glStencilFunc", - "glStencilOp", - "glDepthFunc", - "glPixelStoref", - "glPixelStorei", - "glReadBuffer", - "glReadPixels", - "glGetBooleanv", - "glGetDoublev", - "glGetError", - "glGetFloatv", - "glGetIntegerv", - "glGetString", - "glGetTexImage", - "glGetTexParameterfv", - "glGetTexParameteriv", - "glGetTexLevelParameterfv", - "glGetTexLevelParameteriv", - "glIsEnabled", - "glDepthRange", - "glViewport", - /* not detected in ati */ - "glDrawArrays", - "glDrawElements", - "glGetPointerv", - "glPolygonOffset", - "glCopyTexImage1D", - "glCopyTexImage2D", - "glCopyTexSubImage1D", - "glCopyTexSubImage2D", - "glTexSubImage1D", - "glTexSubImage2D", - "glBindTexture", - "glDeleteTextures", - "glGenTextures", - "glIsTexture", - - 0 -}; - -PROC get_gl_proc_address(const char *p_address) { - - PROC proc = wglGetProcAddress((const CHAR *)p_address); - if (!proc) { - - int i = 0; - while (_gl_procs[i]) { - - if (strcmp(p_address, _gl_proc_names[i]) == 0) { - return _gl_procs[i]; - } - i++; - } - } - return proc; -} -#endif diff --git a/platform/windows/ctxgl_procaddr.h b/platform/windows/ctxgl_procaddr.h deleted file mode 100644 index cc40804ae6..0000000000 --- a/platform/windows/ctxgl_procaddr.h +++ /dev/null @@ -1,39 +0,0 @@ -/*************************************************************************/ -/* ctxgl_procaddr.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef CTXGL_PROCADDR_H -#define CTXGL_PROCADDR_H - -#ifdef OPENGL_ENABLED -#include <windows.h> - -PROC get_gl_proc_address(const char *p_address); -#endif -#endif // CTXGL_PROCADDR_H diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 0662bc2edc..4b4b507499 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -1,6 +1,5 @@ import methods import os -import sys def is_active(): @@ -197,16 +196,18 @@ def configure_msvc(env, manual_msvc_config): ## Compile/link flags env.AppendUnique(CCFLAGS=['/MT', '/Gd', '/GR', '/nologo']) + if int(env['MSVC_VERSION'].split('.')[0]) >= 14: #vs2015 and later + env.AppendUnique(CCFLAGS=['/utf-8']) env.AppendUnique(CXXFLAGS=['/TP']) # assume all sources are C++ if manual_msvc_config: # should be automatic if SCons found it if os.getenv("WindowsSdkDir") is not None: - env.Append(CPPPATH=[os.getenv("WindowsSdkDir") + "/Include"]) + env.Prepend(CPPPATH=[os.getenv("WindowsSdkDir") + "/Include"]) else: print("Missing environment variable: WindowsSdkDir") env.AppendUnique(CPPDEFINES = ['WINDOWS_ENABLED', 'OPENGL_ENABLED', - 'RTAUDIO_ENABLED', 'WASAPI_ENABLED', - 'WINMIDI_ENABLED', 'TYPED_METHOD_BIND', + 'WASAPI_ENABLED', 'WINMIDI_ENABLED', + 'TYPED_METHOD_BIND', 'WIN32', 'MSVC', 'WINVER=%s' % env["target_win_version"], '_WIN32_WINNT=%s' % env["target_win_version"]]) @@ -238,7 +239,7 @@ def configure_msvc(env, manual_msvc_config): env.AppendUnique(LINKFLAGS=['/LTCG']) if manual_msvc_config: - env.Append(CPPPATH=[p for p in os.getenv("INCLUDE").split(";")]) + env.Prepend(CPPPATH=[p for p in os.getenv("INCLUDE").split(";")]) env.Append(LIBPATH=[p for p in os.getenv("LIB").split(";")]) # Incremental linking fix @@ -272,7 +273,8 @@ def configure_mingw(env): env.Prepend(CCFLAGS=['-g2']) elif (env["target"] == "release_debug"): - env.Append(CCFLAGS=['-O2', '-DDEBUG_ENABLED']) + env.Append(CCFLAGS=['-O2']) + env.Append(CPPFLAGS=['-DDEBUG_ENABLED']) if (env["debug_symbols"] == "yes"): env.Prepend(CCFLAGS=['-g1']) if (env["debug_symbols"] == "full"): @@ -283,7 +285,8 @@ def configure_mingw(env): env.Prepend(CCFLAGS=['-Os']) elif (env["target"] == "debug"): - env.Append(CCFLAGS=['-g3', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) + env.Append(CCFLAGS=['-g3']) + env.Append(CPPFLAGS=['-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) ## Compiler configuration @@ -324,12 +327,13 @@ def configure_mingw(env): ## Compile flags - env.Append(CCFLAGS=['-DWINDOWS_ENABLED', '-mwindows']) - env.Append(CCFLAGS=['-DOPENGL_ENABLED']) - env.Append(CCFLAGS=['-DRTAUDIO_ENABLED']) - env.Append(CCFLAGS=['-DWASAPI_ENABLED']) - env.Append(CCFLAGS=['-DWINVER=%s' % env['target_win_version'], '-D_WIN32_WINNT=%s' % env['target_win_version']]) - env.Append(LIBS=['mingw32', 'opengl32', 'dsound', 'ole32', 'd3d9', 'winmm', 'gdi32', 'iphlpapi', 'shlwapi', 'wsock32', 'ws2_32', 'kernel32', 'oleaut32', 'dinput8', 'dxguid', 'ksuser', 'imm32', 'bcrypt','avrt']) + env.Append(CCFLAGS=['-mwindows']) + env.Append(CPPFLAGS=['-DWINDOWS_ENABLED']) + env.Append(CPPFLAGS=['-DOPENGL_ENABLED']) + env.Append(CPPFLAGS=['-DWASAPI_ENABLED']) + env.Append(CPPFLAGS=['-DWINMIDI_ENABLED']) + env.Append(CPPFLAGS=['-DWINVER=%s' % env['target_win_version'], '-D_WIN32_WINNT=%s' % env['target_win_version']]) + env.Append(LIBS=['mingw32', 'opengl32', 'dsound', 'ole32', 'd3d9', 'winmm', 'gdi32', 'iphlpapi', 'shlwapi', 'wsock32', 'ws2_32', 'kernel32', 'oleaut32', 'dinput8', 'dxguid', 'ksuser', 'imm32', 'bcrypt', 'avrt', 'uuid']) env.Append(CPPFLAGS=['-DMINGW_ENABLED']) @@ -338,7 +342,7 @@ def configure_mingw(env): def configure(env): # At this point the env has been set up with basic tools/compilers. - env.Append(CPPPATH=['#platform/windows']) + env.Prepend(CPPPATH=['#platform/windows']) print("Configuring for Windows: target=%s, bits=%s" % (env['target'], env['bits'])) @@ -347,12 +351,12 @@ def configure(env): env['ENV']['TMP'] = os.environ['TMP'] # First figure out which compiler, version, and target arch we're using - if os.getenv("VCINSTALLDIR"): + if os.getenv("VCINSTALLDIR") and not env["use_mingw"]: # Manual setup of MSVC setup_msvc_manual(env) env.msvc = True manual_msvc_config = True - elif env.get('MSVC_VERSION', ''): + elif env.get('MSVC_VERSION', '') and not env["use_mingw"]: setup_msvc_auto(env) env.msvc = True manual_msvc_config = False diff --git a/platform/windows/export/export.cpp b/platform/windows/export/export.cpp index ca2f71ca18..141ab96370 100644 --- a/platform/windows/export/export.cpp +++ b/platform/windows/export/export.cpp @@ -73,7 +73,7 @@ Error EditorExportPlatformWindows::export_project(const Ref<EditorExportPreset> } #endif - String icon_path = p_preset->get("application/icon"); + String icon_path = ProjectSettings::get_singleton()->globalize_path(p_preset->get("application/icon")); String file_verion = p_preset->get("application/file_version"); String product_version = p_preset->get("application/product_version"); String company_name = p_preset->get("application/company_name"); @@ -137,7 +137,7 @@ Error EditorExportPlatformWindows::export_project(const Ref<EditorExportPreset> void EditorExportPlatformWindows::get_export_options(List<ExportOption> *r_options) { EditorExportPlatformPC::get_export_options(r_options); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/icon", PROPERTY_HINT_GLOBAL_FILE, "*.ico"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/icon", PROPERTY_HINT_FILE, "*.ico"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/file_version"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/product_version"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/company_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Company Name"), "")); diff --git a/platform/windows/godot.natvis b/platform/windows/godot.natvis index 01963035a1..55c83c3f3c 100644 --- a/platform/windows/godot.natvis +++ b/platform/windows/godot.natvis @@ -2,92 +2,109 @@ <AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010"> <Type Name="Vector<*>"> <Expand> - <Item Name="size">(_cowdata && _cowdata->_ptr) ? (((const unsigned int *)(_cowdata->_ptr))[-1]) : 0</Item> + <Item Name="[size]">_cowdata._ptr ? (((const unsigned int *)(_cowdata._ptr))[-1]) : 0</Item> <ArrayItems> - <Size>(_cowdata && _cowdata->_ptr) ? (((const unsigned int *)(_cowdata->_ptr))[-1]) : 0</Size> - <ValuePointer>(_cowdata) ? (_cowdata->_ptr) : 0</ValuePointer> + <Size>_cowdata._ptr ? (((const unsigned int *)(_cowdata._ptr))[-1]) : 0</Size> + <ValuePointer>_cowdata._ptr</ValuePointer> </ArrayItems> </Expand> </Type> <Type Name="PoolVector<*>"> <Expand> - <Item Name="size">alloc ? (alloc->size / sizeof($T1)) : 0</Item> + <Item Name="[size]">alloc ? (alloc->size / sizeof($T1)) : 0</Item> <ArrayItems> <Size>alloc ? (alloc->size / sizeof($T1)) : 0</Size> <ValuePointer>alloc ? (($T1 *)alloc->mem) : 0</ValuePointer> </ArrayItems> </Expand> </Type> + + <Type Name="List<*>"> + <Expand> + <Item Name="[size]">_data ? (_data->size_cache) : 0</Item> + <LinkedListItems> + <Size>_data ? (_data->size_cache) : 0</Size> + <HeadPointer>_data->first</HeadPointer> + <NextPointer>next_ptr</NextPointer> + <ValueNode>value</ValueNode> + </LinkedListItems> + </Expand> + </Type> <Type Name="Variant"> - <DisplayString Condition="this->type == Variant::NIL">nil</DisplayString> - <DisplayString Condition="this->type == Variant::BOOL">{_data._bool}</DisplayString> - <DisplayString Condition="this->type == Variant::INT">{_data._int}</DisplayString> - <DisplayString Condition="this->type == Variant::REAL">{_data._real}</DisplayString> - <DisplayString Condition="this->type == Variant::TRANSFORM2D">{_data._transform2d}</DisplayString> - <DisplayString Condition="this->type == Variant::AABB">{_data._aabb}</DisplayString> - <DisplayString Condition="this->type == Variant::BASIS">{_data._basis}</DisplayString> - <DisplayString Condition="this->type == Variant::TRANSFORM">{_data._transform}</DisplayString> - <DisplayString Condition="this->type == Variant::ARRAY">{*(Array *)_data._mem}</DisplayString> - <DisplayString Condition="this->type == Variant::STRING && ((String *)(&_data._mem[0]))->_cowdata._ptr == 0">""</DisplayString> - <DisplayString Condition="this->type == Variant::STRING && ((String *)(&_data._mem[0]))->_cowdata._ptr != 0">{((String *)(&_data._mem[0]))->_cowdata._ptr,su}</DisplayString> - <DisplayString Condition="this->type == Variant::VECTOR2">{*(Vector2 *)_data._mem}</DisplayString> - <DisplayString Condition="this->type == Variant::RECT2">{*(Rect2 *)_data._mem}</DisplayString> - <DisplayString Condition="this->type == Variant::VECTOR3">{*(Vector3 *)_data._mem}</DisplayString> - <DisplayString Condition="this->type == Variant::PLANE">{*(Plane *)_data._mem}</DisplayString> - <DisplayString Condition="this->type == Variant::QUAT">{*(Quat *)_data._mem}</DisplayString> - <DisplayString Condition="this->type == Variant::COLOR">{*(Color *)_data._mem}</DisplayString> - <DisplayString Condition="this->type == Variant::NODE_PATH">{*(NodePath *)_data._mem}</DisplayString> - <DisplayString Condition="this->type == Variant::_RID">{*(RID *)_data._mem}</DisplayString> - <DisplayString Condition="this->type == Variant::OBJECT">{*(Object *)_data._mem}</DisplayString> - <DisplayString Condition="this->type == Variant::DICTIONARY">{*(Dictionary *)_data._mem}</DisplayString> - <DisplayString Condition="this->type == Variant::ARRAY">{*(Array *)_data._mem}</DisplayString> - <DisplayString Condition="this->type == Variant::POOL_BYTE_ARRAY">{*(PoolByteArray *)_data._mem}</DisplayString> - <DisplayString Condition="this->type == Variant::POOL_INT_ARRAY">{*(PoolIntArray *)_data._mem}</DisplayString> - <DisplayString Condition="this->type == Variant::POOL_REAL_ARRAY">{*(PoolRealArray *)_data._mem}</DisplayString> - <DisplayString Condition="this->type == Variant::POOL_STRING_ARRAY">{*(PoolStringArray *)_data._mem}</DisplayString> - <DisplayString Condition="this->type == Variant::POOL_VECTOR2_ARRAY">{*(PoolVector2Array *)_data._mem}</DisplayString> - <DisplayString Condition="this->type == Variant::POOL_VECTOR3_ARRAY">{*(PoolVector3Array *)_data._mem}</DisplayString> - <DisplayString Condition="this->type == Variant::POOL_COLOR_ARRAY">{*(PoolColorArray *)_data._mem}</DisplayString> - - <StringView Condition="this->type == Variant::STRING && ((String *)(&_data._mem[0]))->_cowdata._ptr != 0">((String *)(&_data._mem[0]))->_cowdata._ptr,su</StringView> + <DisplayString Condition="type == Variant::NIL">nil</DisplayString> + <DisplayString Condition="type == Variant::BOOL">{_data._bool}</DisplayString> + <DisplayString Condition="type == Variant::INT">{_data._int}</DisplayString> + <DisplayString Condition="type == Variant::REAL">{_data._real}</DisplayString> + <DisplayString Condition="type == Variant::TRANSFORM2D">{_data._transform2d}</DisplayString> + <DisplayString Condition="type == Variant::AABB">{_data._aabb}</DisplayString> + <DisplayString Condition="type == Variant::BASIS">{_data._basis}</DisplayString> + <DisplayString Condition="type == Variant::TRANSFORM">{_data._transform}</DisplayString> + <DisplayString Condition="type == Variant::STRING">{*(String *)_data._mem}</DisplayString> + <DisplayString Condition="type == Variant::VECTOR2">{*(Vector2 *)_data._mem}</DisplayString> + <DisplayString Condition="type == Variant::RECT2">{*(Rect2 *)_data._mem}</DisplayString> + <DisplayString Condition="type == Variant::VECTOR3">{*(Vector3 *)_data._mem}</DisplayString> + <DisplayString Condition="type == Variant::PLANE">{*(Plane *)_data._mem}</DisplayString> + <DisplayString Condition="type == Variant::QUAT">{*(Quat *)_data._mem}</DisplayString> + <DisplayString Condition="type == Variant::COLOR">{*(Color *)_data._mem}</DisplayString> + <DisplayString Condition="type == Variant::NODE_PATH">{*(NodePath *)_data._mem}</DisplayString> + <DisplayString Condition="type == Variant::_RID">{*(RID *)_data._mem}</DisplayString> + <DisplayString Condition="type == Variant::OBJECT">{*(Object *)_data._mem}</DisplayString> + <DisplayString Condition="type == Variant::DICTIONARY">{*(Dictionary *)_data._mem}</DisplayString> + <DisplayString Condition="type == Variant::ARRAY">{*(Array *)_data._mem}</DisplayString> + <DisplayString Condition="type == Variant::POOL_BYTE_ARRAY">{*(PoolByteArray *)_data._mem}</DisplayString> + <DisplayString Condition="type == Variant::POOL_INT_ARRAY">{*(PoolIntArray *)_data._mem}</DisplayString> + <DisplayString Condition="type == Variant::POOL_REAL_ARRAY">{*(PoolRealArray *)_data._mem}</DisplayString> + <DisplayString Condition="type == Variant::POOL_STRING_ARRAY">{*(PoolStringArray *)_data._mem}</DisplayString> + <DisplayString Condition="type == Variant::POOL_VECTOR2_ARRAY">{*(PoolVector2Array *)_data._mem}</DisplayString> + <DisplayString Condition="type == Variant::POOL_VECTOR3_ARRAY">{*(PoolVector3Array *)_data._mem}</DisplayString> + <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="this->type == Variant::BOOL">_data._bool</Item> - <Item Name="value" Condition="this->type == Variant::INT">_data._int</Item> - <Item Name="value" Condition="this->type == Variant::REAL">_data._real</Item> - <Item Name="value" Condition="this->type == Variant::TRANSFORM2D">_data._transform2d</Item> - <Item Name="value" Condition="this->type == Variant::AABB">_data._aabb</Item> - <Item Name="value" Condition="this->type == Variant::BASIS">_data._basis</Item> - <Item Name="value" Condition="this->type == Variant::TRANSFORM">_data._transform</Item> - <Item Name="value" Condition="this->type == Variant::ARRAY">*(Array *)_data._mem</Item> - <Item Name="value" Condition="this->type == Variant::STRING">*(String *)_data._mem</Item> - <Item Name="value" Condition="this->type == Variant::VECTOR2">*(Vector2 *)_data._mem</Item> - <Item Name="value" Condition="this->type == Variant::RECT2">*(Rect2 *)_data._mem</Item> - <Item Name="value" Condition="this->type == Variant::VECTOR3">*(Vector3 *)_data._mem</Item> - <Item Name="value" Condition="this->type == Variant::PLANE">*(Plane *)_data._mem</Item> - <Item Name="value" Condition="this->type == Variant::QUAT">*(Quat *)_data._mem</Item> - <Item Name="value" Condition="this->type == Variant::COLOR">*(Color *)_data._mem</Item> - <Item Name="value" Condition="this->type == Variant::NODE_PATH">*(NodePath *)_data._mem</Item> - <Item Name="value" Condition="this->type == Variant::_RID">*(RID *)_data._mem</Item> - <Item Name="value" Condition="this->type == Variant::OBJECT">*(Object *)_data._mem</Item> - <Item Name="value" Condition="this->type == Variant::DICTIONARY">*(Dictionary *)_data._mem</Item> - <Item Name="value" Condition="this->type == Variant::ARRAY">*(Array *)_data._mem</Item> - <Item Name="value" Condition="this->type == Variant::POOL_BYTE_ARRAY">*(PoolByteArray *)_data._mem</Item> - <Item Name="value" Condition="this->type == Variant::POOL_INT_ARRAY">*(PoolIntArray *)_data._mem</Item> - <Item Name="value" Condition="this->type == Variant::POOL_REAL_ARRAY">*(PoolRealArray *)_data._mem</Item> - <Item Name="value" Condition="this->type == Variant::POOL_STRING_ARRAY">*(PoolStringArray *)_data._mem</Item> - <Item Name="value" Condition="this->type == Variant::POOL_VECTOR2_ARRAY">*(PoolVector2Array *)_data._mem</Item> - <Item Name="value" Condition="this->type == Variant::POOL_VECTOR3_ARRAY">*(PoolVector3Array *)_data._mem</Item> - <Item Name="value" Condition="this->type == Variant::POOL_COLOR_ARRAY">*(PoolColorArray *)_data._mem</Item> + <Item Name="[value]" Condition="type == Variant::BOOL">_data._bool</Item> + <Item Name="[value]" Condition="type == Variant::INT">_data._int</Item> + <Item Name="[value]" Condition="type == Variant::REAL">_data._real</Item> + <Item Name="[value]" Condition="type == Variant::TRANSFORM2D">_data._transform2d</Item> + <Item Name="[value]" Condition="type == Variant::AABB">_data._aabb</Item> + <Item Name="[value]" Condition="type == Variant::BASIS">_data._basis</Item> + <Item Name="[value]" Condition="type == Variant::TRANSFORM">_data._transform</Item> + <Item Name="[value]" Condition="type == Variant::STRING">*(String *)_data._mem</Item> + <Item Name="[value]" Condition="type == Variant::VECTOR2">*(Vector2 *)_data._mem</Item> + <Item Name="[value]" Condition="type == Variant::RECT2">*(Rect2 *)_data._mem</Item> + <Item Name="[value]" Condition="type == Variant::VECTOR3">*(Vector3 *)_data._mem</Item> + <Item Name="[value]" Condition="type == Variant::PLANE">*(Plane *)_data._mem</Item> + <Item Name="[value]" Condition="type == Variant::QUAT">*(Quat *)_data._mem</Item> + <Item Name="[value]" Condition="type == Variant::COLOR">*(Color *)_data._mem</Item> + <Item Name="[value]" Condition="type == Variant::NODE_PATH">*(NodePath *)_data._mem</Item> + <Item Name="[value]" Condition="type == Variant::_RID">*(RID *)_data._mem</Item> + <Item Name="[value]" Condition="type == Variant::OBJECT">*(Object *)_data._mem</Item> + <Item Name="[value]" Condition="type == Variant::DICTIONARY">*(Dictionary *)_data._mem</Item> + <Item Name="[value]" Condition="type == Variant::ARRAY">*(Array *)_data._mem</Item> + <Item Name="[value]" Condition="type == Variant::POOL_BYTE_ARRAY">*(PoolByteArray *)_data._mem</Item> + <Item Name="[value]" Condition="type == Variant::POOL_INT_ARRAY">*(PoolIntArray *)_data._mem</Item> + <Item Name="[value]" Condition="type == Variant::POOL_REAL_ARRAY">*(PoolRealArray *)_data._mem</Item> + <Item Name="[value]" Condition="type == Variant::POOL_STRING_ARRAY">*(PoolStringArray *)_data._mem</Item> + <Item Name="[value]" Condition="type == Variant::POOL_VECTOR2_ARRAY">*(PoolVector2Array *)_data._mem</Item> + <Item Name="[value]" Condition="type == Variant::POOL_VECTOR3_ARRAY">*(PoolVector3Array *)_data._mem</Item> + <Item Name="[value]" Condition="type == Variant::POOL_COLOR_ARRAY">*(PoolColorArray *)_data._mem</Item> </Expand> </Type> <Type Name="String"> - <DisplayString Condition="this->_cowdata._ptr == 0">empty</DisplayString> - <DisplayString Condition="this->_cowdata._ptr != 0">{this->_cowdata._ptr,su}</DisplayString> - <StringView Condition="this->_cowdata._ptr != 0">this->_cowdata._ptr,su</StringView> + <DisplayString Condition="_cowdata._ptr == 0">[empty]</DisplayString> + <DisplayString Condition="_cowdata._ptr != 0">{_cowdata._ptr,su}</DisplayString> + <StringView Condition="_cowdata._ptr != 0">_cowdata._ptr,su</StringView> + </Type> + + <Type Name="StringName"> + <DisplayString Condition="_data && _data->cname">{_data->cname}</DisplayString> + <DisplayString Condition="_data && !_data->cname">{_data->name,su}</DisplayString> + <DisplayString Condition="!_data">[empty]</DisplayString> + <StringView Condition="_data && _data->cname">_data->cname</StringView> + <StringView Condition="_data && !_data->cname">_data->name,su</StringView> </Type> <Type Name="Vector2"> diff --git a/platform/windows/godot_win.cpp b/platform/windows/godot_windows.cpp index 0f5065d816..0b52682c7c 100644 --- a/platform/windows/godot_win.cpp +++ b/platform/windows/godot_windows.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* godot_win.cpp */ +/* godot_windows.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -30,6 +30,7 @@ #include "main/main.h" #include "os_windows.h" + #include <locale.h> #include <stdio.h> diff --git a/platform/windows/joypad.cpp b/platform/windows/joypad_windows.cpp index 5fafc7c8c0..5a399cdf90 100644 --- a/platform/windows/joypad.cpp +++ b/platform/windows/joypad_windows.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* joypad.cpp */ +/* joypad_windows.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "joypad.h" +#include "joypad_windows.h" #include <oleauto.h> #include <wbemidl.h> diff --git a/platform/windows/joypad.h b/platform/windows/joypad_windows.h index 3a6c0cef9f..4af5d9bd6a 100644 --- a/platform/windows/joypad.h +++ b/platform/windows/joypad_windows.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* joypad.h */ +/* joypad_windows.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,10 +28,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef JOYPAD_H -#define JOYPAD_H +#ifndef JOYPAD_WINDOWS_H +#define JOYPAD_WINDOWS_H #include "os_windows.h" + #define DIRECTINPUT_VERSION 0x0800 #include <dinput.h> #include <xinput.h> // on unix the file is called "xinput.h", on windows I'm sure it won't mind @@ -145,4 +146,4 @@ private: XInputSetState_t xinput_set_state; }; -#endif +#endif // JOYPAD_WINDOWS_H diff --git a/platform/windows/key_mapping_win.cpp b/platform/windows/key_mapping_windows.cpp index f9b01e5532..01bbb072bb 100644 --- a/platform/windows/key_mapping_win.cpp +++ b/platform/windows/key_mapping_windows.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* key_mapping_win.cpp */ +/* key_mapping_windows.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "key_mapping_win.h" +#include "key_mapping_windows.h" #include <stdio.h> diff --git a/platform/windows/key_mapping_win.h b/platform/windows/key_mapping_windows.h index e4f8a61d04..dbb8c20f1e 100644 --- a/platform/windows/key_mapping_win.h +++ b/platform/windows/key_mapping_windows.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* key_mapping_win.h */ +/* key_mapping_windows.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -45,4 +45,4 @@ public: static unsigned int get_keysym(unsigned int p_code); }; -#endif +#endif // KEY_MAPPING_WINDOWS_H diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 35f9d541ef..0b61770d87 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -43,15 +43,17 @@ #include "drivers/windows/rw_lock_windows.h" #include "drivers/windows/semaphore_windows.h" #include "drivers/windows/thread_windows.h" -#include "joypad.h" +#include "joypad_windows.h" #include "lang_table.h" #include "main/main.h" #include "servers/audio_server.h" #include "servers/visual/visual_server_raster.h" #include "servers/visual/visual_server_wrap_mt.h" #include "windows_terminal_logger.h" -#include <avrt.h> +#include <avrt.h> +#include <direct.h> +#include <knownfolders.h> #include <process.h> #include <regstr.h> #include <shlobj.h> @@ -270,7 +272,7 @@ void OS_Windows::_touch_event(bool p_pressed, float p_x, float p_y, int idx) { event->set_position(Vector2(p_x, p_y)); if (main_loop) { - input->parse_input_event(event); + input->accumulate_input_event(event); } }; @@ -292,11 +294,21 @@ void OS_Windows::_drag_event(float p_x, float p_y, int idx) { event->set_position(Vector2(p_x, p_y)); if (main_loop) - input->parse_input_event(event); + input->accumulate_input_event(event); }; LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + if (drop_events) { + + if (user_proc) { + + return CallWindowProcW(user_proc, hWnd, uMsg, wParam, lParam); + } else { + return DefWindowProcW(hWnd, uMsg, wParam, lParam); + } + }; + switch (uMsg) // Check For Windows Messages { case WM_SETFOCUS: { @@ -334,6 +346,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) control_mem = false; shift_mem = false; } else { // WM_INACTIVE + input->release_pressed_events(); main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT); alt_mem = false; }; @@ -373,8 +386,6 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) outside = true; if (main_loop && mouse_mode != MOUSE_MODE_CAPTURED) main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_EXIT); - if (input) - input->set_mouse_in_window(false); } break; case WM_INPUT: { @@ -447,7 +458,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) } if (window_has_focus && main_loop && mm->get_relative() != Vector2()) - input->parse_input_event(mm); + input->accumulate_input_event(mm); } delete[] lpb; } break; @@ -469,8 +480,6 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if (main_loop && mouse_mode != MOUSE_MODE_CAPTURED) main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_ENTER); - if (input) - input->set_mouse_in_window(true); CursorShape c = cursor_shape; cursor_shape = CURSOR_MAX; @@ -534,7 +543,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) old_x = mm->get_position().x; old_y = mm->get_position().y; if (window_has_focus && main_loop) - input->parse_input_event(mm); + input->accumulate_input_event(mm); } break; case WM_LBUTTONDOWN: @@ -659,7 +668,9 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) mb->set_button_index(BUTTON_XBUTTON2); mb->set_doubleclick(true); } break; - default: { return 0; } + default: { + return 0; + } } mb->set_control((wParam & MK_CONTROL) != 0); @@ -707,14 +718,14 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) mb->set_global_position(mb->get_position()); if (main_loop) { - input->parse_input_event(mb); + input->accumulate_input_event(mb); if (mb->is_pressed() && mb->get_button_index() > 3 && mb->get_button_index() < 8) { //send release for mouse wheel Ref<InputEventMouseButton> mbd = mb->duplicate(); last_button_state &= ~(1 << (mbd->get_button_index() - 1)); mbd->set_button_mask(last_button_state); mbd->set_pressed(false); - input->parse_input_event(mbd); + input->accumulate_input_event(mbd); } } } break; @@ -776,6 +787,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) } break; case WM_ENTERSIZEMOVE: { + input->release_pressed_events(); move_timer_id = SetTimer(hWnd, 1, USER_TIMER_MINIMUM, (TIMERPROC)NULL); } break; case WM_EXITSIZEMOVE: { @@ -977,7 +989,7 @@ void OS_Windows::process_key_events() { if (k->get_unicode() < 32) k->set_unicode(0); - input->parse_input_event(k); + input->accumulate_input_event(k); } //do nothing @@ -1015,7 +1027,7 @@ void OS_Windows::process_key_events() { k->set_echo((ke.uMsg == WM_KEYDOWN && (ke.lParam & (1 << 30)))); - input->parse_input_event(k); + input->accumulate_input_event(k); } break; } @@ -1273,13 +1285,13 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int gl_context = NULL; while (!gl_context) { - gl_context = memnew(ContextGL_Win(hWnd, gles3_context)); + gl_context = memnew(ContextGL_Windows(hWnd, gles3_context)); if (gl_context->initialize() != OK) { memdelete(gl_context); gl_context = NULL; - if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best" || editor) { + if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2") || editor) { if (p_video_driver == VIDEO_DRIVER_GLES2) { gl_initialization_error = true; break; @@ -1301,7 +1313,7 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int RasterizerGLES3::make_current(); break; } else { - if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best" || editor) { + if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2") || editor) { p_video_driver = VIDEO_DRIVER_GLES2; gles3_context = false; continue; @@ -1394,31 +1406,36 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); } + update_real_mouse_position(); + return OK; } void OS_Windows::set_clipboard(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"); + if (!OpenClipboard(hWnd)) { ERR_EXPLAIN("Unable to open clipboard."); ERR_FAIL(); }; EmptyClipboard(); - HGLOBAL mem = GlobalAlloc(GMEM_MOVEABLE, (p_text.length() + 1) * sizeof(CharType)); + HGLOBAL mem = GlobalAlloc(GMEM_MOVEABLE, (text.length() + 1) * sizeof(CharType)); if (mem == NULL) { ERR_EXPLAIN("Unable to allocate memory for clipboard contents."); ERR_FAIL(); }; LPWSTR lptstrCopy = (LPWSTR)GlobalLock(mem); - memcpy(lptstrCopy, p_text.c_str(), (p_text.length() + 1) * sizeof(CharType)); - //memset((lptstrCopy + p_text.length()), 0, sizeof(CharType)); + memcpy(lptstrCopy, text.c_str(), (text.length() + 1) * sizeof(CharType)); GlobalUnlock(mem); SetClipboardData(CF_UNICODETEXT, mem); // set the CF_TEXT version (not needed?) - CharString utf8 = p_text.utf8(); + CharString utf8 = text.utf8(); mem = GlobalAlloc(GMEM_MOVEABLE, utf8.length() + 1); if (mem == NULL) { ERR_EXPLAIN("Unable to allocate memory for clipboard contents."); @@ -1595,6 +1612,19 @@ Point2 OS_Windows::get_mouse_position() const { return Point2(old_x, old_y); } +void OS_Windows::update_real_mouse_position() { + + POINT mouse_pos; + if (GetCursorPos(&mouse_pos) && ScreenToClient(hWnd, &mouse_pos)) { + if (mouse_pos.x > 0 && mouse_pos.y > 0 && mouse_pos.x <= video_mode.width && mouse_pos.y <= video_mode.height) { + old_x = mouse_pos.x; + old_y = mouse_pos.y; + old_invalid = false; + input->set_mouse_position(Point2i(mouse_pos.x, mouse_pos.y)); + } + } +} + int OS_Windows::get_mouse_button_state() const { return last_button_state; @@ -1737,6 +1767,7 @@ void OS_Windows::set_window_position(const Point2 &p_position) { } last_pos = p_position; + update_real_mouse_position(); } Size2 OS_Windows::get_window_size() const { @@ -2137,7 +2168,9 @@ OS::TimeZoneInfo OS_Windows::get_time_zone_info() const { ret.name = info.StandardName; } - ret.bias = info.Bias; + // Bias value returned by GetTimeZoneInformation is inverted of what we expect + // For example on GMT-3 GetTimeZoneInformation return a Bias of 180, so invert the value to get -180 + ret.bias = -info.Bias; return ret; } @@ -2211,7 +2244,9 @@ void OS_Windows::process_events() { MSG msg; - joypad->process_joypads(); + if (!drop_events) { + joypad->process_joypads(); + } while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) { @@ -2219,7 +2254,10 @@ void OS_Windows::process_events() { DispatchMessageW(&msg); } - process_key_events(); + if (!drop_events) { + process_key_events(); + input->flush_accumulated_events(); + } } void OS_Windows::set_cursor_shape(CursorShape p_shape) { @@ -2263,6 +2301,11 @@ void OS_Windows::set_cursor_shape(CursorShape p_shape) { cursor_shape = p_shape; } +OS::CursorShape OS_Windows::get_cursor_shape() const { + + return cursor_shape; +} + void OS_Windows::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) { if (p_cursor.is_valid()) { Ref<Texture> texture = p_cursor; @@ -2423,7 +2466,7 @@ void OS_Windows::GetMaskBitmaps(HBITMAP hSourceBitmap, COLORREF clrTransparent, DeleteDC(hMainDC); } -Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode, bool read_stderr) { +Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex) { if (p_blocking && r_pipe) { @@ -2442,7 +2485,13 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, char buf[65535]; while (fgets(buf, 65535, f)) { + if (p_pipe_mutex) { + p_pipe_mutex->lock(); + } (*r_pipe) += buf; + if (p_pipe_mutex) { + p_pipe_mutex->unlock(); + } } int rv = _pclose(f); @@ -2604,6 +2653,11 @@ String OS_Windows::get_environment(const String &p_var) const { return ""; } +bool OS_Windows::set_environment(const String &p_var, const String &p_value) const { + + return (bool)SetEnvironmentVariableW(p_var.c_str(), p_value.c_str()); +} + String OS_Windows::get_stdin_string(bool p_block) { if (p_block) { @@ -2828,39 +2882,41 @@ String OS_Windows::get_godot_dir_name() const { String OS_Windows::get_system_dir(SystemDir p_dir) const { - int id; + KNOWNFOLDERID id; switch (p_dir) { case SYSTEM_DIR_DESKTOP: { - id = CSIDL_DESKTOPDIRECTORY; + id = FOLDERID_Desktop; } break; case SYSTEM_DIR_DCIM: { - id = CSIDL_MYPICTURES; + id = FOLDERID_Pictures; } break; case SYSTEM_DIR_DOCUMENTS: { - id = CSIDL_PERSONAL; + id = FOLDERID_Documents; } break; case SYSTEM_DIR_DOWNLOADS: { - id = 0x000C; + id = FOLDERID_Downloads; } break; case SYSTEM_DIR_MOVIES: { - id = CSIDL_MYVIDEO; + id = FOLDERID_Videos; } break; case SYSTEM_DIR_MUSIC: { - id = CSIDL_MYMUSIC; + id = FOLDERID_Music; } break; case SYSTEM_DIR_PICTURES: { - id = CSIDL_MYPICTURES; + id = FOLDERID_Pictures; } break; case SYSTEM_DIR_RINGTONES: { - id = CSIDL_MYMUSIC; + id = FOLDERID_Music; } break; } - WCHAR szPath[MAX_PATH]; - HRESULT res = SHGetFolderPathW(NULL, id, NULL, 0, szPath); + PWSTR szPath; + HRESULT res = SHGetKnownFolderPath(id, 0, NULL, &szPath); ERR_FAIL_COND_V(res != S_OK, String()); - return String(szPath); + String path = String(szPath); + CoTaskMemFree(szPath); + return path; } String OS_Windows::get_user_data_dir() const { @@ -2952,7 +3008,7 @@ int OS_Windows::get_power_percent_left() { bool OS_Windows::_check_internal_feature_support(const String &p_feature) { - return p_feature == "pc" || p_feature == "s3tc" || p_feature == "bptc"; + return p_feature == "pc"; } void OS_Windows::disable_crash_handler() { @@ -2963,6 +3019,13 @@ bool OS_Windows::is_disable_crash_handler() const { return crash_handler.is_disabled(); } +void OS_Windows::process_and_drop_events() { + + drop_events = true; + process_events(); + drop_events = false; +} + Error OS_Windows::move_to_trash(const String &p_path) { SHFILEOPSTRUCTW sf; WCHAR *from = new WCHAR[p_path.length() + 2]; @@ -2991,6 +3054,7 @@ Error OS_Windows::move_to_trash(const String &p_path) { OS_Windows::OS_Windows(HINSTANCE _hInstance) { + drop_events = false; key_event_pos = 0; layered_window = false; hBitmap = NULL; @@ -3014,9 +3078,6 @@ OS_Windows::OS_Windows(HINSTANCE _hInstance) { #ifdef WASAPI_ENABLED AudioDriverManager::add_driver(&driver_wasapi); #endif -#ifdef RTAUDIO_ENABLED - AudioDriverManager::add_driver(&driver_rtaudio); -#endif #ifdef XAUDIO2_ENABLED AudioDriverManager::add_driver(&driver_xaudio2); #endif diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 4936a69120..0e0b9bf3f6 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -30,14 +30,17 @@ #ifndef OS_WINDOWS_H #define OS_WINDOWS_H -#include "context_gl_win.h" + +#include "context_gl_windows.h" #include "core/os/input.h" #include "core/os/os.h" #include "core/project_settings.h" -#include "crash_handler_win.h" -#include "drivers/rtaudio/audio_driver_rtaudio.h" +#include "crash_handler_windows.h" +#include "drivers/unix/ip_unix.h" #include "drivers/wasapi/audio_driver_wasapi.h" -#include "drivers/winmidi/win_midi.h" +#include "drivers/winmidi/midi_driver_winmidi.h" +#include "key_mapping_windows.h" +#include "main/input_default.h" #include "power_windows.h" #include "servers/audio_server.h" #include "servers/visual/rasterizer.h" @@ -45,9 +48,6 @@ #ifdef XAUDIO2_ENABLED #include "drivers/xaudio2/audio_driver_xaudio2.h" #endif -#include "drivers/unix/ip_unix.h" -#include "key_mapping_win.h" -#include "main/input_default.h" #include <fcntl.h> #include <io.h> @@ -86,7 +86,7 @@ class OS_Windows : public OS { int old_x, old_y; Point2i center; #if defined(OPENGL_ENABLED) - ContextGL_Win *gl_context; + ContextGL_Windows *gl_context; #endif VisualServer *visual_server; int pressrc; @@ -127,6 +127,7 @@ class OS_Windows : public OS { bool window_has_focus; uint32_t last_button_state; bool use_raw_input; + bool drop_events; HCURSOR cursors[CURSOR_MAX] = { NULL }; CursorShape cursor_shape; @@ -141,9 +142,6 @@ class OS_Windows : public OS { #ifdef WASAPI_ENABLED AudioDriverWASAPI driver_wasapi; #endif -#ifdef RTAUDIO_ENABLED - AudioDriverRtAudio driver_rtaudio; -#endif #ifdef XAUDIO2_ENABLED AudioDriverXAudio2 driver_xaudio2; #endif @@ -200,6 +198,7 @@ public: virtual void warp_mouse_position(const Point2 &p_to); virtual Point2 get_mouse_position() const; + void update_real_mouse_position(); virtual int get_mouse_button_state() const; virtual void set_window_title(const String &p_title); @@ -262,17 +261,19 @@ public: virtual void delay_usec(uint32_t p_usec) const; virtual uint64_t get_ticks_usec() const; - virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false); + virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false, Mutex *p_pipe_mutex = NULL); virtual Error kill(const ProcessID &p_pid); virtual int get_process_id() const; virtual bool has_environment(const String &p_var) const; virtual String get_environment(const String &p_var) const; + virtual bool set_environment(const String &p_var, const String &p_value) const; virtual void set_clipboard(const String &p_text); virtual String get_clipboard() const; void set_cursor_shape(CursorShape p_shape); + CursorShape get_cursor_shape() const; virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot); void GetMaskBitmaps(HBITMAP hSourceBitmap, COLORREF clrTransparent, OUT HBITMAP &hAndMaskBitmap, OUT HBITMAP &hXorMaskBitmap); void set_icon(const Ref<Image> &p_icon); @@ -331,6 +332,8 @@ public: virtual Error move_to_trash(const String &p_path); + virtual void process_and_drop_events(); + OS_Windows(HINSTANCE _hInstance); ~OS_Windows(); }; diff --git a/platform/windows/power_windows.h b/platform/windows/power_windows.h index 4d83d75e00..ef75ce6271 100644 --- a/platform/windows/power_windows.h +++ b/platform/windows/power_windows.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef PLATFORM_WINDOWS_POWER_WINDOWS_H_ -#define PLATFORM_WINDOWS_POWER_WINDOWS_H_ +#ifndef POWER_WINDOWS_H +#define POWER_WINDOWS_H #include "core/os/dir_access.h" #include "core/os/file_access.h" @@ -55,4 +55,4 @@ public: int get_power_percent_left(); }; -#endif /* PLATFORM_WINDOWS_POWER_WINDOWS_H_ */ +#endif // POWER_WINDOWS_H |