summaryrefslogtreecommitdiff
path: root/platform/windows
diff options
context:
space:
mode:
Diffstat (limited to 'platform/windows')
-rw-r--r--platform/windows/crash_handler_windows.cpp4
-rw-r--r--platform/windows/crash_handler_windows.h4
-rw-r--r--platform/windows/detect.py12
-rw-r--r--platform/windows/display_server_windows.cpp147
-rw-r--r--platform/windows/display_server_windows.h12
-rw-r--r--platform/windows/export/export.cpp4
-rw-r--r--platform/windows/export/export.h4
-rw-r--r--platform/windows/export/export_plugin.cpp34
-rw-r--r--platform/windows/export/export_plugin.h4
-rw-r--r--platform/windows/gl_manager_windows.cpp11
-rw-r--r--platform/windows/gl_manager_windows.h4
-rw-r--r--platform/windows/godot_windows.cpp4
-rw-r--r--platform/windows/joypad_windows.cpp40
-rw-r--r--platform/windows/joypad_windows.h4
-rw-r--r--platform/windows/key_mapping_windows.cpp542
-rw-r--r--platform/windows/key_mapping_windows.h8
-rw-r--r--platform/windows/lang_table.h4
-rw-r--r--platform/windows/os_windows.cpp40
-rw-r--r--platform/windows/os_windows.h5
-rw-r--r--platform/windows/platform_config.h4
-rw-r--r--platform/windows/vulkan_context_win.cpp4
-rw-r--r--platform/windows/vulkan_context_win.h4
-rw-r--r--platform/windows/windows_terminal_logger.cpp6
-rw-r--r--platform/windows/windows_terminal_logger.h8
24 files changed, 473 insertions, 440 deletions
diff --git a/platform/windows/crash_handler_windows.cpp b/platform/windows/crash_handler_windows.cpp
index 1b4dae207f..71e9d9acbd 100644
--- a/platform/windows/crash_handler_windows.cpp
+++ b/platform/windows/crash_handler_windows.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
diff --git a/platform/windows/crash_handler_windows.h b/platform/windows/crash_handler_windows.h
index 5cdc6d3e05..ec8de3ffab 100644
--- a/platform/windows/crash_handler_windows.h
+++ b/platform/windows/crash_handler_windows.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
diff --git a/platform/windows/detect.py b/platform/windows/detect.py
index 22fbbeb74f..e9ecc99ef5 100644
--- a/platform/windows/detect.py
+++ b/platform/windows/detect.py
@@ -206,6 +206,8 @@ def configure_msvc(env, manual_msvc_config):
elif env["target"] == "debug":
env.AppendUnique(CCFLAGS=["/Zi", "/FS", "/Od", "/EHsc"])
+ # Allow big objects. Only needed for debug, see MinGW branch for rationale.
+ env.AppendUnique(CCFLAGS=["/bigobj"])
env.Append(LINKFLAGS=["/DEBUG"])
if env["debug_symbols"]:
@@ -226,9 +228,9 @@ def configure_msvc(env, manual_msvc_config):
env.AppendUnique(CCFLAGS=["/MD"])
env.AppendUnique(CCFLAGS=["/Gd", "/GR", "/nologo"])
- # Force to use Unicode encoding
- env.AppendUnique(CCFLAGS=["/utf-8"])
+ env.AppendUnique(CCFLAGS=["/utf-8"]) # Force to use Unicode encoding.
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.Prepend(CPPPATH=[os.getenv("WindowsSdkDir") + "/Include"])
@@ -306,7 +308,7 @@ def configure_msvc(env, manual_msvc_config):
# Sanitizers
if env["use_asan"]:
- env.extra_suffix += ".s"
+ env.extra_suffix += ".san"
env.Append(LINKFLAGS=["/INFERASANLIBS"])
env.Append(CCFLAGS=["/fsanitize=address"])
@@ -358,6 +360,10 @@ def configure_mingw(env):
elif env["target"] == "debug":
env.Append(CCFLAGS=["-g3"])
+ # Allow big objects. It's supposed not to have drawbacks but seems to break
+ # GCC LTO, so enabling for debug builds only (which are not built with LTO
+ # and are the only ones with too big objects).
+ env.Append(CCFLAGS=["-Wa,-mbig-obj"])
if env["windows_subsystem"] == "gui":
env.Append(LINKFLAGS=["-Wl,--subsystem,windows"])
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp
index e2c9951692..ca2b68371c 100644
--- a/platform/windows/display_server_windows.cpp
+++ b/platform/windows/display_server_windows.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
@@ -42,6 +42,11 @@
#include "drivers/gles3/rasterizer_gles3.h"
#endif
+#if defined(__GNUC__)
+// Workaround GCC warning from -Wcast-function-type.
+#define GetProcAddress (void *)GetProcAddress
+#endif
+
static String format_error_message(DWORD id) {
LPWSTR messageBuffer = nullptr;
size_t size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
@@ -54,6 +59,15 @@ static String format_error_message(DWORD id) {
return msg;
}
+static void track_mouse_leave_event(HWND hWnd) {
+ TRACKMOUSEEVENT tme;
+ tme.cbSize = sizeof(TRACKMOUSEEVENT);
+ tme.dwFlags = TME_LEAVE;
+ tme.hwndTrack = hWnd;
+ tme.dwHoverTime = HOVER_DEFAULT;
+ TrackMouseEvent(&tme);
+}
+
bool DisplayServerWindows::has_feature(Feature p_feature) const {
switch (p_feature) {
case FEATURE_SUBWINDOWS:
@@ -533,12 +547,12 @@ void DisplayServerWindows::delete_sub_window(WindowID p_window) {
}
#ifdef VULKAN_ENABLED
- if (rendering_driver == "vulkan") {
+ if (context_vulkan) {
context_vulkan->window_destroy(p_window);
}
#endif
#ifdef GLES3_ENABLED
- if (rendering_driver == "opengl3") {
+ if (gl_manager) {
gl_manager->window_destroy(p_window);
}
#endif
@@ -823,12 +837,12 @@ void DisplayServerWindows::window_set_size(const Size2i p_size, WindowID p_windo
wd.height = h;
#if defined(VULKAN_ENABLED)
- if (rendering_driver == "vulkan") {
+ if (context_vulkan) {
context_vulkan->window_resize(p_window, w, h);
}
#endif
#if defined(GLES3_ENABLED)
- if (rendering_driver == "opengl3") {
+ if (gl_manager) {
gl_manager->window_resize(p_window, w, h);
}
#endif
@@ -1199,8 +1213,11 @@ void DisplayServerWindows::console_set_visible(bool p_enabled) {
if (console_visible == p_enabled) {
return;
}
- ShowWindow(GetConsoleWindow(), p_enabled ? SW_SHOW : SW_HIDE);
- console_visible = p_enabled;
+ if (!((OS_Windows *)OS::get_singleton())->_is_win11_terminal()) {
+ // GetConsoleWindow is not supported by the Windows Terminal.
+ ShowWindow(GetConsoleWindow(), p_enabled ? SW_SHOW : SW_HIDE);
+ console_visible = p_enabled;
+ }
}
bool DisplayServerWindows::is_console_visible() const {
@@ -1495,13 +1512,13 @@ String DisplayServerWindows::keyboard_get_layout_language(int p_index) const {
}
Key DisplayServerWindows::keyboard_get_keycode_from_physical(Key p_keycode) const {
- unsigned int modifiers = p_keycode & KEY_MODIFIER_MASK;
- Key keycode_no_mod = (Key)(p_keycode & KEY_CODE_MASK);
+ Key modifiers = p_keycode & KeyModifierMask::MODIFIER_MASK;
+ Key keycode_no_mod = (Key)(p_keycode & KeyModifierMask::CODE_MASK);
- if (keycode_no_mod == KEY_PRINT ||
- keycode_no_mod == KEY_KP_ADD ||
- keycode_no_mod == KEY_KP_5 ||
- (keycode_no_mod >= KEY_0 && keycode_no_mod <= KEY_9)) {
+ if (keycode_no_mod == Key::PRINT ||
+ keycode_no_mod == Key::KP_ADD ||
+ keycode_no_mod == Key::KP_5 ||
+ (keycode_no_mod >= Key::KEY_0 && keycode_no_mod <= Key::KEY_9)) {
return p_keycode;
}
@@ -1521,10 +1538,10 @@ Key DisplayServerWindows::keyboard_get_keycode_from_physical(Key p_keycode) cons
// we limit these to ASCII to fix some layouts, including Arabic ones
if (char_code >= 32 && char_code <= 127) {
// Godot uses 'braces' instead of 'brackets'
- if (char_code == KEY_BRACKETLEFT || char_code == KEY_BRACKETRIGHT) {
+ if (char_code == (unsigned int)Key::BRACKETLEFT || char_code == (unsigned int)Key::BRACKETRIGHT) {
char_code += 32;
}
- return (Key)(char_code | modifiers);
+ return (Key)(char_code | (unsigned int)modifiers);
}
return (Key)(KeyMappingWindows::get_keysym(vk) | modifiers);
@@ -1560,7 +1577,7 @@ String DisplayServerWindows::keyboard_get_layout_name(int p_index) const {
GetKeyboardLayoutList(layout_count, layouts);
String ret = _get_full_layout_name_from_registry(layouts[p_index]); // Try reading full name from Windows registry, fallback to locale name if failed (e.g. on Wine).
- if (ret == String()) {
+ if (ret.is_empty()) {
WCHAR buf[LOCALE_NAME_MAX_LENGTH];
memset(buf, 0, LOCALE_NAME_MAX_LENGTH * sizeof(WCHAR));
LCIDToLocaleName(MAKELCID(LOWORD(layouts[p_index]), SORT_DEFAULT), buf, LOCALE_NAME_MAX_LENGTH, 0);
@@ -1968,6 +1985,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
// Run a timer to prevent event catching warning if the focused window is closing.
windows[window_id].focus_timer_id = SetTimer(windows[window_id].hWnd, 2, USER_TIMER_MINIMUM, (TIMERPROC) nullptr);
}
+ if (wParam != WA_INACTIVE) {
+ track_mouse_leave_event(hWnd);
+ }
return 0; // Return to the message loop.
} break;
case WM_GETMINMAXINFO: {
@@ -2252,12 +2272,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
outside = false;
// Once-off notification, must call again.
- TRACKMOUSEEVENT tme;
- tme.cbSize = sizeof(TRACKMOUSEEVENT);
- tme.dwFlags = TME_LEAVE;
- tme.hwndTrack = hWnd;
- tme.dwHoverTime = HOVER_DEFAULT;
- TrackMouseEvent(&tme);
+ track_mouse_leave_event(hWnd);
}
// Don't calculate relative mouse movement if we don't have focus in CAPTURED mode.
@@ -2358,12 +2373,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
outside = false;
// Once-off notification, must call again.
- TRACKMOUSEEVENT tme;
- tme.cbSize = sizeof(TRACKMOUSEEVENT);
- tme.dwFlags = TME_LEAVE;
- tme.hwndTrack = hWnd;
- tme.dwHoverTime = HOVER_DEFAULT;
- TrackMouseEvent(&tme);
+ track_mouse_leave_event(hWnd);
}
// Don't calculate relative mouse movement if we don't have focus in CAPTURED mode.
@@ -2461,41 +2471,41 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
switch (uMsg) {
case WM_LBUTTONDOWN: {
mb->set_pressed(true);
- mb->set_button_index(MOUSE_BUTTON_LEFT);
+ mb->set_button_index(MouseButton::LEFT);
} break;
case WM_LBUTTONUP: {
mb->set_pressed(false);
- mb->set_button_index(MOUSE_BUTTON_LEFT);
+ mb->set_button_index(MouseButton::LEFT);
} break;
case WM_MBUTTONDOWN: {
mb->set_pressed(true);
- mb->set_button_index(MOUSE_BUTTON_MIDDLE);
+ mb->set_button_index(MouseButton::MIDDLE);
} break;
case WM_MBUTTONUP: {
mb->set_pressed(false);
- mb->set_button_index(MOUSE_BUTTON_MIDDLE);
+ mb->set_button_index(MouseButton::MIDDLE);
} break;
case WM_RBUTTONDOWN: {
mb->set_pressed(true);
- mb->set_button_index(MOUSE_BUTTON_RIGHT);
+ mb->set_button_index(MouseButton::RIGHT);
} break;
case WM_RBUTTONUP: {
mb->set_pressed(false);
- mb->set_button_index(MOUSE_BUTTON_RIGHT);
+ mb->set_button_index(MouseButton::RIGHT);
} break;
case WM_LBUTTONDBLCLK: {
mb->set_pressed(true);
- mb->set_button_index(MOUSE_BUTTON_LEFT);
+ mb->set_button_index(MouseButton::LEFT);
mb->set_double_click(true);
} break;
case WM_RBUTTONDBLCLK: {
mb->set_pressed(true);
- mb->set_button_index(MOUSE_BUTTON_RIGHT);
+ mb->set_button_index(MouseButton::RIGHT);
mb->set_double_click(true);
} break;
case WM_MBUTTONDBLCLK: {
mb->set_pressed(true);
- mb->set_button_index(MOUSE_BUTTON_MIDDLE);
+ mb->set_button_index(MouseButton::MIDDLE);
mb->set_double_click(true);
} break;
case WM_MOUSEWHEEL: {
@@ -2506,9 +2516,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
if (motion > 0) {
- mb->set_button_index(MOUSE_BUTTON_WHEEL_UP);
+ mb->set_button_index(MouseButton::WHEEL_UP);
} else {
- mb->set_button_index(MOUSE_BUTTON_WHEEL_DOWN);
+ mb->set_button_index(MouseButton::WHEEL_DOWN);
}
mb->set_factor(fabs((double)motion / (double)WHEEL_DELTA));
} break;
@@ -2520,34 +2530,34 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
if (motion < 0) {
- mb->set_button_index(MOUSE_BUTTON_WHEEL_LEFT);
+ mb->set_button_index(MouseButton::WHEEL_LEFT);
} else {
- mb->set_button_index(MOUSE_BUTTON_WHEEL_RIGHT);
+ mb->set_button_index(MouseButton::WHEEL_RIGHT);
}
mb->set_factor(fabs((double)motion / (double)WHEEL_DELTA));
} break;
case WM_XBUTTONDOWN: {
mb->set_pressed(true);
if (HIWORD(wParam) == XBUTTON1) {
- mb->set_button_index(MOUSE_BUTTON_XBUTTON1);
+ mb->set_button_index(MouseButton::MB_XBUTTON1);
} else {
- mb->set_button_index(MOUSE_BUTTON_XBUTTON2);
+ mb->set_button_index(MouseButton::MB_XBUTTON2);
}
} break;
case WM_XBUTTONUP: {
mb->set_pressed(false);
if (HIWORD(wParam) == XBUTTON1) {
- mb->set_button_index(MOUSE_BUTTON_XBUTTON1);
+ mb->set_button_index(MouseButton::MB_XBUTTON1);
} else {
- mb->set_button_index(MOUSE_BUTTON_XBUTTON2);
+ mb->set_button_index(MouseButton::MB_XBUTTON2);
}
} break;
case WM_XBUTTONDBLCLK: {
mb->set_pressed(true);
if (HIWORD(wParam) == XBUTTON1) {
- mb->set_button_index(MOUSE_BUTTON_XBUTTON1);
+ mb->set_button_index(MouseButton::MB_XBUTTON1);
} else {
- mb->set_button_index(MOUSE_BUTTON_XBUTTON2);
+ mb->set_button_index(MouseButton::MB_XBUTTON2);
}
mb->set_double_click(true);
} break;
@@ -2561,9 +2571,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
mb->set_alt_pressed(alt_mem);
// mb->is_alt_pressed()=(wParam&MK_MENU)!=0;
if (mb->is_pressed()) {
- last_button_state |= MouseButton(1 << (mb->get_button_index() - 1));
+ last_button_state |= mouse_button_to_mask(mb->get_button_index());
} else {
- last_button_state &= (MouseButton) ~(1 << (mb->get_button_index() - 1));
+ last_button_state &= ~mouse_button_to_mask(mb->get_button_index());
}
mb->set_button_mask(last_button_state);
@@ -2599,11 +2609,11 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
mb->set_global_position(mb->get_position());
Input::get_singleton()->parse_input_event(mb);
- if (mb->is_pressed() && mb->get_button_index() > 3 && mb->get_button_index() < 8) {
+ if (mb->is_pressed() && mb->get_button_index() >= MouseButton::WHEEL_UP && mb->get_button_index() <= MouseButton::WHEEL_RIGHT) {
// Send release for mouse wheel.
Ref<InputEventMouseButton> mbd = mb->duplicate();
mbd->set_window_id(window_id);
- last_button_state &= (MouseButton) ~(1 << (mbd->get_button_index() - 1));
+ last_button_state &= ~mouse_button_to_mask(mbd->get_button_index());
mbd->set_button_mask(last_button_state);
mbd->set_pressed(false);
Input::get_singleton()->parse_input_event(mbd);
@@ -2638,7 +2648,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
windows[window_id].height = window_h;
#if defined(VULKAN_ENABLED)
- if ((rendering_driver == "vulkan") && window_created) {
+ if (context_vulkan && window_created) {
context_vulkan->window_resize(window_id, windows[window_id].width, windows[window_id].height);
}
#endif
@@ -2953,7 +2963,7 @@ void DisplayServerWindows::_process_key_events() {
if ((ke.lParam & (1 << 24)) && (ke.wParam == VK_RETURN)) {
// Special case for Numpad Enter key.
- k->set_keycode(KEY_KP_ENTER);
+ k->set_keycode(Key::KP_ENTER);
} else {
k->set_keycode((Key)KeyMappingWindows::get_keysym(ke.wParam));
}
@@ -3100,7 +3110,7 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode,
}
#ifdef VULKAN_ENABLED
- if (rendering_driver == "vulkan") {
+ if (context_vulkan) {
if (context_vulkan->window_create(id, p_vsync_mode, wd.hWnd, hInstance, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top) == -1) {
memdelete(context_vulkan);
context_vulkan = nullptr;
@@ -3111,21 +3121,13 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode,
#endif
#ifdef GLES3_ENABLED
- if (rendering_driver == "opengl3") {
+ if (gl_manager) {
Error err = gl_manager->window_create(id, wd.hWnd, hInstance, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top);
ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Failed to create an OpenGL window.");
}
#endif
RegisterTouchWindow(wd.hWnd, 0);
-
- TRACKMOUSEEVENT tme;
- tme.cbSize = sizeof(TRACKMOUSEEVENT);
- tme.dwFlags = TME_LEAVE;
- tme.hwndTrack = wd.hWnd;
- tme.dwHoverTime = HOVER_DEFAULT;
- TrackMouseEvent(&tme);
-
DragAcceptFiles(wd.hWnd, true);
if ((tablet_get_current_driver() == "wintab") && wintab_available) {
@@ -3450,7 +3452,7 @@ DisplayServerWindows::~DisplayServerWindows() {
if (windows.has(MAIN_WINDOW_ID)) {
#ifdef VULKAN_ENABLED
- if (rendering_driver == "vulkan") {
+ if (context_vulkan) {
context_vulkan->window_destroy(MAIN_WINDOW_ID);
}
#endif
@@ -3462,14 +3464,15 @@ DisplayServerWindows::~DisplayServerWindows() {
}
#if defined(VULKAN_ENABLED)
- if (rendering_driver == "vulkan") {
- if (rendering_device_vulkan) {
- rendering_device_vulkan->finalize();
- memdelete(rendering_device_vulkan);
- }
+ if (rendering_device_vulkan) {
+ rendering_device_vulkan->finalize();
+ memdelete(rendering_device_vulkan);
+ rendering_device_vulkan = nullptr;
+ }
- if (context_vulkan)
- memdelete(context_vulkan);
+ if (context_vulkan) {
+ memdelete(context_vulkan);
+ context_vulkan = nullptr;
}
#endif
diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h
index 8e2c346d5b..409335b41c 100644
--- a/platform/windows/display_server_windows.h
+++ b/platform/windows/display_server_windows.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
@@ -305,12 +305,12 @@ class DisplayServerWindows : public DisplayServer {
Point2i center;
#if defined(GLES3_ENABLED)
- GLManager_Windows *gl_manager;
+ GLManager_Windows *gl_manager = nullptr;
#endif
#if defined(VULKAN_ENABLED)
- VulkanContextWindows *context_vulkan;
- RenderingDeviceVulkan *rendering_device_vulkan;
+ VulkanContextWindows *context_vulkan = nullptr;
+ RenderingDeviceVulkan *rendering_device_vulkan = nullptr;
#endif
Map<int, Vector2> touch_state;
@@ -410,7 +410,7 @@ class DisplayServerWindows : public DisplayServer {
bool shift_mem = false;
bool control_mem = false;
bool meta_mem = false;
- MouseButton last_button_state = MOUSE_BUTTON_NONE;
+ MouseButton last_button_state = MouseButton::NONE;
bool use_raw_input = false;
bool drop_events = false;
bool in_dispatch_input_event = false;
diff --git a/platform/windows/export/export.cpp b/platform/windows/export/export.cpp
index 4ff42f3f62..17a24c08bf 100644
--- a/platform/windows/export/export.cpp
+++ b/platform/windows/export/export.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
diff --git a/platform/windows/export/export.h b/platform/windows/export/export.h
index 110e1439e2..09399f2bee 100644
--- a/platform/windows/export/export.h
+++ b/platform/windows/export/export.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
diff --git a/platform/windows/export/export_plugin.cpp b/platform/windows/export/export_plugin.cpp
index 165e86c066..02b2d026b5 100644
--- a/platform/windows/export/export_plugin.cpp
+++ b/platform/windows/export/export_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
@@ -82,7 +82,7 @@ void EditorExportPlatformWindows::get_export_options(List<ExportOption> *r_optio
void EditorExportPlatformWindows::_rcedit_add_data(const Ref<EditorExportPreset> &p_preset, const String &p_path) {
String rcedit_path = EditorSettings::get_singleton()->get("export/windows/rcedit");
- if (rcedit_path == String()) {
+ if (rcedit_path.is_empty()) {
return;
}
@@ -95,12 +95,12 @@ void EditorExportPlatformWindows::_rcedit_add_data(const Ref<EditorExportPreset>
// On non-Windows we need WINE to run rcedit
String wine_path = EditorSettings::get_singleton()->get("export/windows/wine");
- if (wine_path != String() && !FileAccess::exists(wine_path)) {
+ if (!wine_path.is_empty() && !FileAccess::exists(wine_path)) {
ERR_PRINT("Could not find wine executable at " + wine_path + ", no icon or app information data will be included.");
return;
}
- if (wine_path == String()) {
+ if (wine_path.is_empty()) {
wine_path = "wine"; // try to run wine from PATH
}
#endif
@@ -117,39 +117,39 @@ void EditorExportPlatformWindows::_rcedit_add_data(const Ref<EditorExportPreset>
List<String> args;
args.push_back(p_path);
- if (icon_path != String()) {
+ if (!icon_path.is_empty()) {
args.push_back("--set-icon");
args.push_back(icon_path);
}
- if (file_verion != String()) {
+ if (!file_verion.is_empty()) {
args.push_back("--set-file-version");
args.push_back(file_verion);
}
- if (product_version != String()) {
+ if (!product_version.is_empty()) {
args.push_back("--set-product-version");
args.push_back(product_version);
}
- if (company_name != String()) {
+ if (!company_name.is_empty()) {
args.push_back("--set-version-string");
args.push_back("CompanyName");
args.push_back(company_name);
}
- if (product_name != String()) {
+ if (!product_name.is_empty()) {
args.push_back("--set-version-string");
args.push_back("ProductName");
args.push_back(product_name);
}
- if (file_description != String()) {
+ if (!file_description.is_empty()) {
args.push_back("--set-version-string");
args.push_back("FileDescription");
args.push_back(file_description);
}
- if (copyright != String()) {
+ if (!copyright.is_empty()) {
args.push_back("--set-version-string");
args.push_back("LegalCopyright");
args.push_back(copyright);
}
- if (trademarks != String()) {
+ if (!trademarks.is_empty()) {
args.push_back("--set-version-string");
args.push_back("LegalTrademarks");
args.push_back(trademarks);
@@ -169,20 +169,20 @@ Error EditorExportPlatformWindows::_code_sign(const Ref<EditorExportPreset> &p_p
#ifdef WINDOWS_ENABLED
String signtool_path = EditorSettings::get_singleton()->get("export/windows/signtool");
- if (signtool_path != String() && !FileAccess::exists(signtool_path)) {
+ if (!signtool_path.is_empty() && !FileAccess::exists(signtool_path)) {
ERR_PRINT("Could not find signtool executable at " + signtool_path + ", aborting.");
return ERR_FILE_NOT_FOUND;
}
- if (signtool_path == String()) {
+ if (signtool_path.is_empty()) {
signtool_path = "signtool"; // try to run signtool from PATH
}
#else
String signtool_path = EditorSettings::get_singleton()->get("export/windows/osslsigncode");
- if (signtool_path != String() && !FileAccess::exists(signtool_path)) {
+ if (!signtool_path.is_empty() && !FileAccess::exists(signtool_path)) {
ERR_PRINT("Could not find osslsigncode executable at " + signtool_path + ", aborting.");
return ERR_FILE_NOT_FOUND;
}
- if (signtool_path == String()) {
+ if (signtool_path.is_empty()) {
signtool_path = "osslsigncode"; // try to run signtool from PATH
}
#endif
diff --git a/platform/windows/export/export_plugin.h b/platform/windows/export/export_plugin.h
index 11d3826410..4ec9342cdf 100644
--- a/platform/windows/export/export_plugin.h
+++ b/platform/windows/export/export_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
diff --git a/platform/windows/gl_manager_windows.cpp b/platform/windows/gl_manager_windows.cpp
index 98205d6282..74b5f48502 100644
--- a/platform/windows/gl_manager_windows.cpp
+++ b/platform/windows/gl_manager_windows.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
@@ -77,7 +77,7 @@ int GLManager_Windows::_find_or_create_display(GLWindow &win) {
if (err != OK) {
// not good
// delete the _display?
- _displays.remove(new_display_id);
+ _displays.remove_at(new_display_id);
return -1;
}
@@ -193,13 +193,10 @@ Error GLManager_Windows::window_create(DisplayServer::WindowID p_window_id, HWND
if (win.gldisplay_id == -1) {
// release DC?
- _windows.remove(_windows.size() - 1);
+ _windows.remove_at(_windows.size() - 1);
return FAILED;
}
- // the display could be invalid .. check NYI
- GLDisplay &gl_display = _displays[win.gldisplay_id];
-
// make current
window_make_current(_windows.size() - 1);
diff --git a/platform/windows/gl_manager_windows.h b/platform/windows/gl_manager_windows.h
index 9733a57420..6423c54855 100644
--- a/platform/windows/gl_manager_windows.h
+++ b/platform/windows/gl_manager_windows.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
diff --git a/platform/windows/godot_windows.cpp b/platform/windows/godot_windows.cpp
index 22e2e5f7e5..7819ab9a32 100644
--- a/platform/windows/godot_windows.cpp
+++ b/platform/windows/godot_windows.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp
index 94da63e49d..8b6081d606 100644
--- a/platform/windows/joypad_windows.cpp
+++ b/platform/windows/joypad_windows.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
@@ -97,11 +97,13 @@ bool JoypadWindows::have_device(const GUID &p_guid) {
// adapted from SDL2, works a lot better than the MSDN version
bool JoypadWindows::is_xinput_device(const GUID *p_guid) {
- static GUID IID_ValveStreamingGamepad = { MAKELONG(0x28DE, 0x11FF), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } };
+ static GUID IID_ValveStreamingGamepad = { MAKELONG(0x28DE, 0x11FF), 0x28DE, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } };
static GUID IID_X360WiredGamepad = { MAKELONG(0x045E, 0x02A1), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } };
static GUID IID_X360WirelessGamepad = { MAKELONG(0x045E, 0x028E), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } };
- if (p_guid == &IID_ValveStreamingGamepad || p_guid == &IID_X360WiredGamepad || p_guid == &IID_X360WirelessGamepad)
+ if (memcmp(p_guid, &IID_ValveStreamingGamepad, sizeof(*p_guid)) == 0 ||
+ memcmp(p_guid, &IID_X360WiredGamepad, sizeof(*p_guid)) == 0 ||
+ memcmp(p_guid, &IID_X360WirelessGamepad, sizeof(*p_guid)) == 0)
return true;
PRAWINPUTDEVICELIST dev_list = nullptr;
@@ -334,12 +336,12 @@ void JoypadWindows::process_joypads() {
button_mask = button_mask * 2;
}
- input->joy_axis(joy.id, JOY_AXIS_LEFT_X, axis_correct(joy.state.Gamepad.sThumbLX, true));
- input->joy_axis(joy.id, JOY_AXIS_LEFT_Y, axis_correct(joy.state.Gamepad.sThumbLY, true, false, true));
- input->joy_axis(joy.id, JOY_AXIS_RIGHT_X, axis_correct(joy.state.Gamepad.sThumbRX, true));
- input->joy_axis(joy.id, JOY_AXIS_RIGHT_Y, axis_correct(joy.state.Gamepad.sThumbRY, true, false, true));
- input->joy_axis(joy.id, JOY_AXIS_TRIGGER_LEFT, axis_correct(joy.state.Gamepad.bLeftTrigger, true, true));
- input->joy_axis(joy.id, JOY_AXIS_TRIGGER_RIGHT, axis_correct(joy.state.Gamepad.bRightTrigger, true, true));
+ input->joy_axis(joy.id, JoyAxis::LEFT_X, axis_correct(joy.state.Gamepad.sThumbLX, true));
+ input->joy_axis(joy.id, JoyAxis::LEFT_Y, axis_correct(joy.state.Gamepad.sThumbLY, true, false, true));
+ input->joy_axis(joy.id, JoyAxis::RIGHT_X, axis_correct(joy.state.Gamepad.sThumbRX, true));
+ input->joy_axis(joy.id, JoyAxis::RIGHT_Y, axis_correct(joy.state.Gamepad.sThumbRY, true, false, true));
+ input->joy_axis(joy.id, JoyAxis::TRIGGER_LEFT, axis_correct(joy.state.Gamepad.bLeftTrigger, true, true));
+ input->joy_axis(joy.id, JoyAxis::TRIGGER_RIGHT, axis_correct(joy.state.Gamepad.bRightTrigger, true, true));
joy.last_packet = joy.state.dwPacketNumber;
}
uint64_t timestamp = input->get_joy_vibration_timestamp(joy.id);
@@ -417,31 +419,31 @@ void JoypadWindows::post_hat(int p_device, DWORD p_dpad) {
// BOOL POVCentered = (LOWORD(dwPOV) == 0xFFFF);"
// https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ee416628(v%3Dvs.85)#remarks
if (LOWORD(p_dpad) == 0xFFFF) {
- dpad_val = (HatMask)HatMask::HAT_MASK_CENTER;
+ dpad_val = (HatMask)HatMask::CENTER;
}
if (p_dpad == 0) {
- dpad_val = (HatMask)HatMask::HAT_MASK_UP;
+ dpad_val = (HatMask)HatMask::UP;
} else if (p_dpad == 4500) {
- dpad_val = (HatMask)(HatMask::HAT_MASK_UP | HatMask::HAT_MASK_RIGHT);
+ dpad_val = (HatMask)(HatMask::UP | HatMask::RIGHT);
} else if (p_dpad == 9000) {
- dpad_val = (HatMask)HatMask::HAT_MASK_RIGHT;
+ dpad_val = (HatMask)HatMask::RIGHT;
} else if (p_dpad == 13500) {
- dpad_val = (HatMask)(HatMask::HAT_MASK_RIGHT | HatMask::HAT_MASK_DOWN);
+ dpad_val = (HatMask)(HatMask::RIGHT | HatMask::DOWN);
} else if (p_dpad == 18000) {
- dpad_val = (HatMask)HatMask::HAT_MASK_DOWN;
+ dpad_val = (HatMask)HatMask::DOWN;
} else if (p_dpad == 22500) {
- dpad_val = (HatMask)(HatMask::HAT_MASK_DOWN | HatMask::HAT_MASK_LEFT);
+ dpad_val = (HatMask)(HatMask::DOWN | HatMask::LEFT);
} else if (p_dpad == 27000) {
- dpad_val = (HatMask)HatMask::HAT_MASK_LEFT;
+ dpad_val = (HatMask)HatMask::LEFT;
} else if (p_dpad == 31500) {
- dpad_val = (HatMask)(HatMask::HAT_MASK_LEFT | HatMask::HAT_MASK_UP);
+ dpad_val = (HatMask)(HatMask::LEFT | HatMask::UP);
}
input->joy_hat(p_device, dpad_val);
};
diff --git a/platform/windows/joypad_windows.h b/platform/windows/joypad_windows.h
index 757fb54fb3..4faefe932f 100644
--- a/platform/windows/joypad_windows.h
+++ b/platform/windows/joypad_windows.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
diff --git a/platform/windows/key_mapping_windows.cpp b/platform/windows/key_mapping_windows.cpp
index b9cf8151fc..938a777de6 100644
--- a/platform/windows/key_mapping_windows.cpp
+++ b/platform/windows/key_mapping_windows.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
@@ -33,200 +33,200 @@
#include <stdio.h>
struct _WinTranslatePair {
- unsigned int keysym;
+ Key keysym;
unsigned int keycode;
};
static _WinTranslatePair _vk_to_keycode[] = {
- { KEY_BACKSPACE, VK_BACK }, // (0x08) // backspace
- { KEY_TAB, VK_TAB }, //(0x09)
+ { Key::BACKSPACE, VK_BACK }, // (0x08) // backspace
+ { Key::TAB, VK_TAB }, //(0x09)
//VK_CLEAR (0x0C)
- { KEY_ENTER, VK_RETURN }, //(0x0D)
+ { Key::ENTER, VK_RETURN }, //(0x0D)
- { KEY_SHIFT, VK_SHIFT }, //(0x10)
+ { Key::SHIFT, VK_SHIFT }, //(0x10)
- { KEY_CTRL, VK_CONTROL }, //(0x11)
+ { Key::CTRL, VK_CONTROL }, //(0x11)
- { KEY_ALT, VK_MENU }, //(0x12)
+ { Key::ALT, VK_MENU }, //(0x12)
- { KEY_PAUSE, VK_PAUSE }, //(0x13)
+ { Key::PAUSE, VK_PAUSE }, //(0x13)
- { KEY_CAPSLOCK, VK_CAPITAL }, //(0x14)
+ { Key::CAPSLOCK, VK_CAPITAL }, //(0x14)
- { KEY_ESCAPE, VK_ESCAPE }, //(0x1B)
+ { Key::ESCAPE, VK_ESCAPE }, //(0x1B)
- { KEY_SPACE, VK_SPACE }, //(0x20)
+ { Key::SPACE, VK_SPACE }, //(0x20)
- { KEY_PAGEUP, VK_PRIOR }, //(0x21)
+ { Key::PAGEUP, VK_PRIOR }, //(0x21)
- { KEY_PAGEDOWN, VK_NEXT }, //(0x22)
+ { Key::PAGEDOWN, VK_NEXT }, //(0x22)
- { KEY_END, VK_END }, //(0x23)
+ { Key::END, VK_END }, //(0x23)
- { KEY_HOME, VK_HOME }, //(0x24)
+ { Key::HOME, VK_HOME }, //(0x24)
- { KEY_LEFT, VK_LEFT }, //(0x25)
+ { Key::LEFT, VK_LEFT }, //(0x25)
- { KEY_UP, VK_UP }, //(0x26)
+ { Key::UP, VK_UP }, //(0x26)
- { KEY_RIGHT, VK_RIGHT }, //(0x27)
+ { Key::RIGHT, VK_RIGHT }, //(0x27)
- { KEY_DOWN, VK_DOWN }, // (0x28)
+ { Key::DOWN, VK_DOWN }, // (0x28)
//VK_SELECT (0x29)
- { KEY_PRINT, VK_PRINT }, // (0x2A)
+ { Key::PRINT, VK_PRINT }, // (0x2A)
//VK_EXECUTE (0x2B)
- { KEY_PRINT, VK_SNAPSHOT }, // (0x2C)
-
- { KEY_INSERT, VK_INSERT }, // (0x2D)
-
- { KEY_DELETE, VK_DELETE }, // (0x2E)
-
- { KEY_HELP, VK_HELP }, // (0x2F)
-
- { KEY_0, (0x30) }, ////0 key
- { KEY_1, (0x31) }, ////1 key
- { KEY_2, (0x32) }, ////2 key
- { KEY_3, (0x33) }, ////3 key
- { KEY_4, (0x34) }, ////4 key
- { KEY_5, (0x35) }, ////5 key
- { KEY_6, (0x36) }, ////6 key
- { KEY_7, (0x37) }, ////7 key
- { KEY_8, (0x38) }, ////8 key
- { KEY_9, (0x39) }, ////9 key
- { KEY_A, (0x41) }, ////A key
- { KEY_B, (0x42) }, ////B key
- { KEY_C, (0x43) }, ////C key
- { KEY_D, (0x44) }, ////D key
- { KEY_E, (0x45) }, ////E key
- { KEY_F, (0x46) }, ////F key
- { KEY_G, (0x47) }, ////G key
- { KEY_H, (0x48) }, ////H key
- { KEY_I, (0x49) }, ////I key
- { KEY_J, (0x4A) }, ////J key
- { KEY_K, (0x4B) }, ////K key
- { KEY_L, (0x4C) }, ////L key
- { KEY_M, (0x4D) }, ////M key
- { KEY_N, (0x4E) }, ////N key
- { KEY_O, (0x4F) }, ////O key
- { KEY_P, (0x50) }, ////P key
- { KEY_Q, (0x51) }, ////Q key
- { KEY_R, (0x52) }, ////R key
- { KEY_S, (0x53) }, ////S key
- { KEY_T, (0x54) }, ////T key
- { KEY_U, (0x55) }, ////U key
- { KEY_V, (0x56) }, ////V key
- { KEY_W, (0x57) }, ////W key
- { KEY_X, (0x58) }, ////X key
- { KEY_Y, (0x59) }, ////Y key
- { KEY_Z, (0x5A) }, ////Z key
-
- { KEY_MASK_META, VK_LWIN }, //(0x5B)
- { KEY_MASK_META, VK_RWIN }, //(0x5C)
- { KEY_MENU, VK_APPS }, //(0x5D)
- { KEY_STANDBY, VK_SLEEP }, //(0x5F)
- { KEY_KP_0, VK_NUMPAD0 }, //(0x60)
- { KEY_KP_1, VK_NUMPAD1 }, //(0x61)
- { KEY_KP_2, VK_NUMPAD2 }, //(0x62)
- { KEY_KP_3, VK_NUMPAD3 }, //(0x63)
- { KEY_KP_4, VK_NUMPAD4 }, //(0x64)
- { KEY_KP_5, VK_NUMPAD5 }, //(0x65)
- { KEY_KP_6, VK_NUMPAD6 }, //(0x66)
- { KEY_KP_7, VK_NUMPAD7 }, //(0x67)
- { KEY_KP_8, VK_NUMPAD8 }, //(0x68)
- { KEY_KP_9, VK_NUMPAD9 }, //(0x69)
- { KEY_KP_MULTIPLY, VK_MULTIPLY }, // (0x6A)
- { KEY_KP_ADD, VK_ADD }, // (0x6B)
+ { Key::PRINT, VK_SNAPSHOT }, // (0x2C)
+
+ { Key::INSERT, VK_INSERT }, // (0x2D)
+
+ { Key::KEY_DELETE, VK_DELETE }, // (0x2E)
+
+ { Key::HELP, VK_HELP }, // (0x2F)
+
+ { Key::KEY_0, (0x30) }, ////0 key
+ { Key::KEY_1, (0x31) }, ////1 key
+ { Key::KEY_2, (0x32) }, ////2 key
+ { Key::KEY_3, (0x33) }, ////3 key
+ { Key::KEY_4, (0x34) }, ////4 key
+ { Key::KEY_5, (0x35) }, ////5 key
+ { Key::KEY_6, (0x36) }, ////6 key
+ { Key::KEY_7, (0x37) }, ////7 key
+ { Key::KEY_8, (0x38) }, ////8 key
+ { Key::KEY_9, (0x39) }, ////9 key
+ { Key::A, (0x41) }, ////A key
+ { Key::B, (0x42) }, ////B key
+ { Key::C, (0x43) }, ////C key
+ { Key::D, (0x44) }, ////D key
+ { Key::E, (0x45) }, ////E key
+ { Key::F, (0x46) }, ////F key
+ { Key::G, (0x47) }, ////G key
+ { Key::H, (0x48) }, ////H key
+ { Key::I, (0x49) }, ////I key
+ { Key::J, (0x4A) }, ////J key
+ { Key::K, (0x4B) }, ////K key
+ { Key::L, (0x4C) }, ////L key
+ { Key::M, (0x4D) }, ////M key
+ { Key::N, (0x4E) }, ////N key
+ { Key::O, (0x4F) }, ////O key
+ { Key::P, (0x50) }, ////P key
+ { Key::Q, (0x51) }, ////Q key
+ { Key::R, (0x52) }, ////R key
+ { Key::S, (0x53) }, ////S key
+ { Key::T, (0x54) }, ////T key
+ { Key::U, (0x55) }, ////U key
+ { Key::V, (0x56) }, ////V key
+ { Key::W, (0x57) }, ////W key
+ { Key::X, (0x58) }, ////X key
+ { Key::Y, (0x59) }, ////Y key
+ { Key::Z, (0x5A) }, ////Z key
+
+ { (Key)KeyModifierMask::META, VK_LWIN }, //(0x5B)
+ { (Key)KeyModifierMask::META, VK_RWIN }, //(0x5C)
+ { Key::MENU, VK_APPS }, //(0x5D)
+ { Key::STANDBY, VK_SLEEP }, //(0x5F)
+ { Key::KP_0, VK_NUMPAD0 }, //(0x60)
+ { Key::KP_1, VK_NUMPAD1 }, //(0x61)
+ { Key::KP_2, VK_NUMPAD2 }, //(0x62)
+ { Key::KP_3, VK_NUMPAD3 }, //(0x63)
+ { Key::KP_4, VK_NUMPAD4 }, //(0x64)
+ { Key::KP_5, VK_NUMPAD5 }, //(0x65)
+ { Key::KP_6, VK_NUMPAD6 }, //(0x66)
+ { Key::KP_7, VK_NUMPAD7 }, //(0x67)
+ { Key::KP_8, VK_NUMPAD8 }, //(0x68)
+ { Key::KP_9, VK_NUMPAD9 }, //(0x69)
+ { Key::KP_MULTIPLY, VK_MULTIPLY }, // (0x6A)
+ { Key::KP_ADD, VK_ADD }, // (0x6B)
//VK_SEPARATOR (0x6C)
- { KEY_KP_SUBTRACT, VK_SUBTRACT }, // (0x6D)
- { KEY_KP_PERIOD, VK_DECIMAL }, // (0x6E)
- { KEY_KP_DIVIDE, VK_DIVIDE }, // (0x6F)
- { KEY_F1, VK_F1 }, // (0x70)
- { KEY_F2, VK_F2 }, // (0x71)
- { KEY_F3, VK_F3 }, // (0x72)
- { KEY_F4, VK_F4 }, // (0x73)
- { KEY_F5, VK_F5 }, // (0x74)
- { KEY_F6, VK_F6 }, // (0x75)
- { KEY_F7, VK_F7 }, // (0x76)
- { KEY_F8, VK_F8 }, // (0x77)
- { KEY_F9, VK_F9 }, // (0x78)
- { KEY_F10, VK_F10 }, // (0x79)
- { KEY_F11, VK_F11 }, // (0x7A)
- { KEY_F12, VK_F12 }, // (0x7B)
- { KEY_F13, VK_F13 }, // (0x7C)
- { KEY_F14, VK_F14 }, // (0x7D)
- { KEY_F15, VK_F15 }, // (0x7E)
- { KEY_F16, VK_F16 }, // (0x7F)
- { KEY_NUMLOCK, VK_NUMLOCK }, // (0x90)
- { KEY_SCROLLLOCK, VK_SCROLL }, // (0x91)
- { KEY_SHIFT, VK_LSHIFT }, // (0xA0)
- { KEY_SHIFT, VK_RSHIFT }, // (0xA1)
- { KEY_CTRL, VK_LCONTROL }, // (0xA2)
- { KEY_CTRL, VK_RCONTROL }, // (0xA3)
- { KEY_MENU, VK_LMENU }, // (0xA4)
- { KEY_MENU, VK_RMENU }, // (0xA5)
+ { Key::KP_SUBTRACT, VK_SUBTRACT }, // (0x6D)
+ { Key::KP_PERIOD, VK_DECIMAL }, // (0x6E)
+ { Key::KP_DIVIDE, VK_DIVIDE }, // (0x6F)
+ { Key::F1, VK_F1 }, // (0x70)
+ { Key::F2, VK_F2 }, // (0x71)
+ { Key::F3, VK_F3 }, // (0x72)
+ { Key::F4, VK_F4 }, // (0x73)
+ { Key::F5, VK_F5 }, // (0x74)
+ { Key::F6, VK_F6 }, // (0x75)
+ { Key::F7, VK_F7 }, // (0x76)
+ { Key::F8, VK_F8 }, // (0x77)
+ { Key::F9, VK_F9 }, // (0x78)
+ { Key::F10, VK_F10 }, // (0x79)
+ { Key::F11, VK_F11 }, // (0x7A)
+ { Key::F12, VK_F12 }, // (0x7B)
+ { Key::F13, VK_F13 }, // (0x7C)
+ { Key::F14, VK_F14 }, // (0x7D)
+ { Key::F15, VK_F15 }, // (0x7E)
+ { Key::F16, VK_F16 }, // (0x7F)
+ { Key::NUMLOCK, VK_NUMLOCK }, // (0x90)
+ { Key::SCROLLLOCK, VK_SCROLL }, // (0x91)
+ { Key::SHIFT, VK_LSHIFT }, // (0xA0)
+ { Key::SHIFT, VK_RSHIFT }, // (0xA1)
+ { Key::CTRL, VK_LCONTROL }, // (0xA2)
+ { Key::CTRL, VK_RCONTROL }, // (0xA3)
+ { Key::MENU, VK_LMENU }, // (0xA4)
+ { Key::MENU, VK_RMENU }, // (0xA5)
- { KEY_BACK, VK_BROWSER_BACK }, // (0xA6)
+ { Key::BACK, VK_BROWSER_BACK }, // (0xA6)
- { KEY_FORWARD, VK_BROWSER_FORWARD }, // (0xA7)
+ { Key::FORWARD, VK_BROWSER_FORWARD }, // (0xA7)
- { KEY_REFRESH, VK_BROWSER_REFRESH }, // (0xA8)
+ { Key::REFRESH, VK_BROWSER_REFRESH }, // (0xA8)
- { KEY_STOP, VK_BROWSER_STOP }, // (0xA9)
+ { Key::STOP, VK_BROWSER_STOP }, // (0xA9)
- { KEY_SEARCH, VK_BROWSER_SEARCH }, // (0xAA)
+ { Key::SEARCH, VK_BROWSER_SEARCH }, // (0xAA)
- { KEY_FAVORITES, VK_BROWSER_FAVORITES }, // (0xAB)
+ { Key::FAVORITES, VK_BROWSER_FAVORITES }, // (0xAB)
- { KEY_HOMEPAGE, VK_BROWSER_HOME }, // (0xAC)
+ { Key::HOMEPAGE, VK_BROWSER_HOME }, // (0xAC)
- { KEY_VOLUMEMUTE, VK_VOLUME_MUTE }, // (0xAD)
+ { Key::VOLUMEMUTE, VK_VOLUME_MUTE }, // (0xAD)
- { KEY_VOLUMEDOWN, VK_VOLUME_DOWN }, // (0xAE)
+ { Key::VOLUMEDOWN, VK_VOLUME_DOWN }, // (0xAE)
- { KEY_VOLUMEUP, VK_VOLUME_UP }, // (0xAF)
+ { Key::VOLUMEUP, VK_VOLUME_UP }, // (0xAF)
- { KEY_MEDIANEXT, VK_MEDIA_NEXT_TRACK }, // (0xB0)
+ { Key::MEDIANEXT, VK_MEDIA_NEXT_TRACK }, // (0xB0)
- { KEY_MEDIAPREVIOUS, VK_MEDIA_PREV_TRACK }, // (0xB1)
+ { Key::MEDIAPREVIOUS, VK_MEDIA_PREV_TRACK }, // (0xB1)
- { KEY_MEDIASTOP, VK_MEDIA_STOP }, // (0xB2)
+ { Key::MEDIASTOP, VK_MEDIA_STOP }, // (0xB2)
//VK_MEDIA_PLAY_PAUSE (0xB3)
- { KEY_LAUNCHMAIL, VK_LAUNCH_MAIL }, // (0xB4)
+ { Key::LAUNCHMAIL, VK_LAUNCH_MAIL }, // (0xB4)
- { KEY_LAUNCHMEDIA, VK_LAUNCH_MEDIA_SELECT }, // (0xB5)
+ { Key::LAUNCHMEDIA, VK_LAUNCH_MEDIA_SELECT }, // (0xB5)
- { KEY_LAUNCH0, VK_LAUNCH_APP1 }, // (0xB6)
+ { Key::LAUNCH0, VK_LAUNCH_APP1 }, // (0xB6)
- { KEY_LAUNCH1, VK_LAUNCH_APP2 }, // (0xB7)
+ { Key::LAUNCH1, VK_LAUNCH_APP2 }, // (0xB7)
- { KEY_SEMICOLON, VK_OEM_1 }, // (0xBA)
+ { Key::SEMICOLON, VK_OEM_1 }, // (0xBA)
- { KEY_EQUAL, VK_OEM_PLUS }, // (0xBB) // Windows 2000/XP: For any country/region, the '+' key
- { KEY_COMMA, VK_OEM_COMMA }, // (0xBC) // Windows 2000/XP: For any country/region, the ',' key
- { KEY_MINUS, VK_OEM_MINUS }, // (0xBD) // Windows 2000/XP: For any country/region, the '-' key
- { KEY_PERIOD, VK_OEM_PERIOD }, // (0xBE) // Windows 2000/XP: For any country/region, the '.' key
- { KEY_SLASH, VK_OEM_2 }, // (0xBF) //Windows 2000/XP: For the US standard keyboard, the '/?' key
+ { Key::EQUAL, VK_OEM_PLUS }, // (0xBB) // Windows 2000/XP: For any country/region, the '+' key
+ { Key::COMMA, VK_OEM_COMMA }, // (0xBC) // Windows 2000/XP: For any country/region, the ',' key
+ { Key::MINUS, VK_OEM_MINUS }, // (0xBD) // Windows 2000/XP: For any country/region, the '-' key
+ { Key::PERIOD, VK_OEM_PERIOD }, // (0xBE) // Windows 2000/XP: For any country/region, the '.' key
+ { Key::SLASH, VK_OEM_2 }, // (0xBF) //Windows 2000/XP: For the US standard keyboard, the '/?' key
- { KEY_QUOTELEFT, VK_OEM_3 }, // (0xC0)
- { KEY_BRACELEFT, VK_OEM_4 }, // (0xDB)
- { KEY_BACKSLASH, VK_OEM_5 }, // (0xDC)
- { KEY_BRACERIGHT, VK_OEM_6 }, // (0xDD)
- { KEY_APOSTROPHE, VK_OEM_7 }, // (0xDE)
+ { Key::QUOTELEFT, VK_OEM_3 }, // (0xC0)
+ { Key::BRACELEFT, VK_OEM_4 }, // (0xDB)
+ { Key::BACKSLASH, VK_OEM_5 }, // (0xDC)
+ { Key::BRACERIGHT, VK_OEM_6 }, // (0xDD)
+ { Key::APOSTROPHE, VK_OEM_7 }, // (0xDE)
/*
{VK_OEM_8 (0xDF)
{VK_OEM_102 (0xE2) // Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard
*/
- //{ KEY_PLAY, VK_PLAY},// (0xFA)
+ //{ Key::PLAY, VK_PLAY},// (0xFA)
- { KEY_UNKNOWN, 0 }
+ { Key::UNKNOWN, 0 }
};
/*
@@ -237,104 +237,104 @@ VK_OEM_CLEAR (0xFE)
*/
static _WinTranslatePair _scancode_to_keycode[] = {
- { KEY_ESCAPE, 0x01 },
- { KEY_1, 0x02 },
- { KEY_2, 0x03 },
- { KEY_3, 0x04 },
- { KEY_4, 0x05 },
- { KEY_5, 0x06 },
- { KEY_6, 0x07 },
- { KEY_7, 0x08 },
- { KEY_8, 0x09 },
- { KEY_9, 0x0A },
- { KEY_0, 0x0B },
- { KEY_MINUS, 0x0C },
- { KEY_EQUAL, 0x0D },
- { KEY_BACKSPACE, 0x0E },
- { KEY_TAB, 0x0F },
- { KEY_Q, 0x10 },
- { KEY_W, 0x11 },
- { KEY_E, 0x12 },
- { KEY_R, 0x13 },
- { KEY_T, 0x14 },
- { KEY_Y, 0x15 },
- { KEY_U, 0x16 },
- { KEY_I, 0x17 },
- { KEY_O, 0x18 },
- { KEY_P, 0x19 },
- { KEY_BRACELEFT, 0x1A },
- { KEY_BRACERIGHT, 0x1B },
- { KEY_ENTER, 0x1C },
- { KEY_CTRL, 0x1D },
- { KEY_A, 0x1E },
- { KEY_S, 0x1F },
- { KEY_D, 0x20 },
- { KEY_F, 0x21 },
- { KEY_G, 0x22 },
- { KEY_H, 0x23 },
- { KEY_J, 0x24 },
- { KEY_K, 0x25 },
- { KEY_L, 0x26 },
- { KEY_SEMICOLON, 0x27 },
- { KEY_APOSTROPHE, 0x28 },
- { KEY_QUOTELEFT, 0x29 },
- { KEY_SHIFT, 0x2A },
- { KEY_BACKSLASH, 0x2B },
- { KEY_Z, 0x2C },
- { KEY_X, 0x2D },
- { KEY_C, 0x2E },
- { KEY_V, 0x2F },
- { KEY_B, 0x30 },
- { KEY_N, 0x31 },
- { KEY_M, 0x32 },
- { KEY_COMMA, 0x33 },
- { KEY_PERIOD, 0x34 },
- { KEY_SLASH, 0x35 },
- { KEY_SHIFT, 0x36 },
- { KEY_PRINT, 0x37 },
- { KEY_ALT, 0x38 },
- { KEY_SPACE, 0x39 },
- { KEY_CAPSLOCK, 0x3A },
- { KEY_F1, 0x3B },
- { KEY_F2, 0x3C },
- { KEY_F3, 0x3D },
- { KEY_F4, 0x3E },
- { KEY_F5, 0x3F },
- { KEY_F6, 0x40 },
- { KEY_F7, 0x41 },
- { KEY_F8, 0x42 },
- { KEY_F9, 0x43 },
- { KEY_F10, 0x44 },
- { KEY_NUMLOCK, 0x45 },
- { KEY_SCROLLLOCK, 0x46 },
- { KEY_HOME, 0x47 },
- { KEY_UP, 0x48 },
- { KEY_PAGEUP, 0x49 },
- { KEY_KP_SUBTRACT, 0x4A },
- { KEY_LEFT, 0x4B },
- { KEY_KP_5, 0x4C },
- { KEY_RIGHT, 0x4D },
- { KEY_KP_ADD, 0x4E },
- { KEY_END, 0x4F },
- { KEY_DOWN, 0x50 },
- { KEY_PAGEDOWN, 0x51 },
- { KEY_INSERT, 0x52 },
- { KEY_DELETE, 0x53 },
- //{ KEY_???, 0x56 }, //NON US BACKSLASH
- { KEY_F11, 0x57 },
- { KEY_F12, 0x58 },
- { KEY_META, 0x5B },
- { KEY_META, 0x5C },
- { KEY_MENU, 0x5D },
- { KEY_F13, 0x64 },
- { KEY_F14, 0x65 },
- { KEY_F15, 0x66 },
- { KEY_F16, 0x67 },
- { KEY_UNKNOWN, 0 }
+ { Key::ESCAPE, 0x01 },
+ { Key::KEY_1, 0x02 },
+ { Key::KEY_2, 0x03 },
+ { Key::KEY_3, 0x04 },
+ { Key::KEY_4, 0x05 },
+ { Key::KEY_5, 0x06 },
+ { Key::KEY_6, 0x07 },
+ { Key::KEY_7, 0x08 },
+ { Key::KEY_8, 0x09 },
+ { Key::KEY_9, 0x0A },
+ { Key::KEY_0, 0x0B },
+ { Key::MINUS, 0x0C },
+ { Key::EQUAL, 0x0D },
+ { Key::BACKSPACE, 0x0E },
+ { Key::TAB, 0x0F },
+ { Key::Q, 0x10 },
+ { Key::W, 0x11 },
+ { Key::E, 0x12 },
+ { Key::R, 0x13 },
+ { Key::T, 0x14 },
+ { Key::Y, 0x15 },
+ { Key::U, 0x16 },
+ { Key::I, 0x17 },
+ { Key::O, 0x18 },
+ { Key::P, 0x19 },
+ { Key::BRACELEFT, 0x1A },
+ { Key::BRACERIGHT, 0x1B },
+ { Key::ENTER, 0x1C },
+ { Key::CTRL, 0x1D },
+ { Key::A, 0x1E },
+ { Key::S, 0x1F },
+ { Key::D, 0x20 },
+ { Key::F, 0x21 },
+ { Key::G, 0x22 },
+ { Key::H, 0x23 },
+ { Key::J, 0x24 },
+ { Key::K, 0x25 },
+ { Key::L, 0x26 },
+ { Key::SEMICOLON, 0x27 },
+ { Key::APOSTROPHE, 0x28 },
+ { Key::QUOTELEFT, 0x29 },
+ { Key::SHIFT, 0x2A },
+ { Key::BACKSLASH, 0x2B },
+ { Key::Z, 0x2C },
+ { Key::X, 0x2D },
+ { Key::C, 0x2E },
+ { Key::V, 0x2F },
+ { Key::B, 0x30 },
+ { Key::N, 0x31 },
+ { Key::M, 0x32 },
+ { Key::COMMA, 0x33 },
+ { Key::PERIOD, 0x34 },
+ { Key::SLASH, 0x35 },
+ { Key::SHIFT, 0x36 },
+ { Key::PRINT, 0x37 },
+ { Key::ALT, 0x38 },
+ { Key::SPACE, 0x39 },
+ { Key::CAPSLOCK, 0x3A },
+ { Key::F1, 0x3B },
+ { Key::F2, 0x3C },
+ { Key::F3, 0x3D },
+ { Key::F4, 0x3E },
+ { Key::F5, 0x3F },
+ { Key::F6, 0x40 },
+ { Key::F7, 0x41 },
+ { Key::F8, 0x42 },
+ { Key::F9, 0x43 },
+ { Key::F10, 0x44 },
+ { Key::NUMLOCK, 0x45 },
+ { Key::SCROLLLOCK, 0x46 },
+ { Key::HOME, 0x47 },
+ { Key::UP, 0x48 },
+ { Key::PAGEUP, 0x49 },
+ { Key::KP_SUBTRACT, 0x4A },
+ { Key::LEFT, 0x4B },
+ { Key::KP_5, 0x4C },
+ { Key::RIGHT, 0x4D },
+ { Key::KP_ADD, 0x4E },
+ { Key::END, 0x4F },
+ { Key::DOWN, 0x50 },
+ { Key::PAGEDOWN, 0x51 },
+ { Key::INSERT, 0x52 },
+ { Key::KEY_DELETE, 0x53 },
+ //{ Key::???, 0x56 }, //NON US BACKSLASH
+ { Key::F11, 0x57 },
+ { Key::F12, 0x58 },
+ { Key::META, 0x5B },
+ { Key::META, 0x5C },
+ { Key::MENU, 0x5D },
+ { Key::F13, 0x64 },
+ { Key::F14, 0x65 },
+ { Key::F15, 0x66 },
+ { Key::F16, 0x67 },
+ { Key::UNKNOWN, 0 }
};
-unsigned int KeyMappingWindows::get_keysym(unsigned int p_code) {
- for (int i = 0; _vk_to_keycode[i].keysym != KEY_UNKNOWN; i++) {
+Key KeyMappingWindows::get_keysym(unsigned int p_code) {
+ for (int i = 0; _vk_to_keycode[i].keysym != Key::UNKNOWN; i++) {
if (_vk_to_keycode[i].keycode == p_code) {
//printf("outcode: %x\n",_vk_to_keycode[i].keysym);
@@ -342,11 +342,11 @@ unsigned int KeyMappingWindows::get_keysym(unsigned int p_code) {
}
}
- return KEY_UNKNOWN;
+ return Key::UNKNOWN;
}
unsigned int KeyMappingWindows::get_scancode(Key p_keycode) {
- for (int i = 0; _scancode_to_keycode[i].keysym != KEY_UNKNOWN; i++) {
+ for (int i = 0; _scancode_to_keycode[i].keysym != Key::UNKNOWN; i++) {
if (_scancode_to_keycode[i].keysym == p_keycode) {
return _scancode_to_keycode[i].keycode;
}
@@ -355,9 +355,9 @@ unsigned int KeyMappingWindows::get_scancode(Key p_keycode) {
return 0;
}
-unsigned int KeyMappingWindows::get_scansym(unsigned int p_code, bool p_extended) {
- unsigned int keycode = KEY_UNKNOWN;
- for (int i = 0; _scancode_to_keycode[i].keysym != KEY_UNKNOWN; i++) {
+Key KeyMappingWindows::get_scansym(unsigned int p_code, bool p_extended) {
+ Key keycode = Key::UNKNOWN;
+ for (int i = 0; _scancode_to_keycode[i].keysym != Key::UNKNOWN; i++) {
if (_scancode_to_keycode[i].keycode == p_code) {
keycode = _scancode_to_keycode[i].keysym;
break;
@@ -366,55 +366,55 @@ unsigned int KeyMappingWindows::get_scansym(unsigned int p_code, bool p_extended
if (p_extended) {
switch (keycode) {
- case KEY_ENTER: {
- keycode = KEY_KP_ENTER;
+ case Key::ENTER: {
+ keycode = Key::KP_ENTER;
} break;
- case KEY_SLASH: {
- keycode = KEY_KP_DIVIDE;
+ case Key::SLASH: {
+ keycode = Key::KP_DIVIDE;
} break;
- case KEY_CAPSLOCK: {
- keycode = KEY_KP_ADD;
+ case Key::CAPSLOCK: {
+ keycode = Key::KP_ADD;
} break;
default:
break;
}
} else {
switch (keycode) {
- case KEY_NUMLOCK: {
- keycode = KEY_PAUSE;
+ case Key::NUMLOCK: {
+ keycode = Key::PAUSE;
} break;
- case KEY_HOME: {
- keycode = KEY_KP_7;
+ case Key::HOME: {
+ keycode = Key::KP_7;
} break;
- case KEY_UP: {
- keycode = KEY_KP_8;
+ case Key::UP: {
+ keycode = Key::KP_8;
} break;
- case KEY_PAGEUP: {
- keycode = KEY_KP_9;
+ case Key::PAGEUP: {
+ keycode = Key::KP_9;
} break;
- case KEY_LEFT: {
- keycode = KEY_KP_4;
+ case Key::LEFT: {
+ keycode = Key::KP_4;
} break;
- case KEY_RIGHT: {
- keycode = KEY_KP_6;
+ case Key::RIGHT: {
+ keycode = Key::KP_6;
} break;
- case KEY_END: {
- keycode = KEY_KP_1;
+ case Key::END: {
+ keycode = Key::KP_1;
} break;
- case KEY_DOWN: {
- keycode = KEY_KP_2;
+ case Key::DOWN: {
+ keycode = Key::KP_2;
} break;
- case KEY_PAGEDOWN: {
- keycode = KEY_KP_3;
+ case Key::PAGEDOWN: {
+ keycode = Key::KP_3;
} break;
- case KEY_INSERT: {
- keycode = KEY_KP_0;
+ case Key::INSERT: {
+ keycode = Key::KP_0;
} break;
- case KEY_DELETE: {
- keycode = KEY_KP_PERIOD;
+ case Key::KEY_DELETE: {
+ keycode = Key::KP_PERIOD;
} break;
- case KEY_PRINT: {
- keycode = KEY_KP_MULTIPLY;
+ case Key::PRINT: {
+ keycode = Key::KP_MULTIPLY;
} break;
default:
break;
diff --git a/platform/windows/key_mapping_windows.h b/platform/windows/key_mapping_windows.h
index d056e88f06..393432fa39 100644
--- a/platform/windows/key_mapping_windows.h
+++ b/platform/windows/key_mapping_windows.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
@@ -41,9 +41,9 @@ class KeyMappingWindows {
KeyMappingWindows() {}
public:
- static unsigned int get_keysym(unsigned int p_code);
+ static Key get_keysym(unsigned int p_code);
static unsigned int get_scancode(Key p_keycode);
- static unsigned int get_scansym(unsigned int p_code, bool p_extended);
+ static Key get_scansym(unsigned int p_code, bool p_extended);
static bool is_extended_key(unsigned int p_code);
};
diff --git a/platform/windows/lang_table.h b/platform/windows/lang_table.h
index 51583cc11e..5b022853e8 100644
--- a/platform/windows/lang_table.h
+++ b/platform/windows/lang_table.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 2c21390d73..8477746001 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
@@ -447,7 +447,12 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments,
ZeroMemory(&pi.pi, sizeof(pi.pi));
LPSTARTUPINFOW si_w = (LPSTARTUPINFOW)&pi.si;
- int ret = CreateProcessW(nullptr, (LPWSTR)(command.utf16().ptrw()), nullptr, nullptr, false, NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW, nullptr, nullptr, si_w, &pi.pi);
+ DWORD dwCreationFlags = NORMAL_PRIORITY_CLASS;
+#ifndef DEBUG_ENABLED
+ dwCreationFlags |= CREATE_NO_WINDOW;
+#endif
+
+ int ret = CreateProcessW(nullptr, (LPWSTR)(command.utf16().ptrw()), nullptr, nullptr, false, dwCreationFlags, nullptr, nullptr, si_w, &pi.pi);
ERR_FAIL_COND_V_MSG(ret == 0, ERR_CANT_FORK, "Could not create child process: " + command);
WaitForSingleObject(pi.pi.hProcess, INFINITE);
@@ -462,6 +467,16 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments,
return OK;
};
+bool OS_Windows::_is_win11_terminal() const {
+ HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
+ DWORD dwMode = 0;
+ if (GetConsoleMode(hStdOut, &dwMode)) {
+ return ((dwMode & ENABLE_VIRTUAL_TERMINAL_PROCESSING) == ENABLE_VIRTUAL_TERMINAL_PROCESSING);
+ } else {
+ return false;
+ }
+}
+
Error OS_Windows::create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id) {
String path = p_path.replace("/", "\\");
String command = _quote_command_line_argument(path);
@@ -475,7 +490,16 @@ Error OS_Windows::create_process(const String &p_path, const List<String> &p_arg
ZeroMemory(&pi.pi, sizeof(pi.pi));
LPSTARTUPINFOW si_w = (LPSTARTUPINFOW)&pi.si;
- int ret = CreateProcessW(nullptr, (LPWSTR)(command.utf16().ptrw()), nullptr, nullptr, false, NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW, nullptr, nullptr, si_w, &pi.pi);
+ DWORD dwCreationFlags = NORMAL_PRIORITY_CLASS;
+#ifndef DEBUG_ENABLED
+ dwCreationFlags |= CREATE_NO_WINDOW;
+#endif
+ if (p_path == get_executable_path() && GetConsoleWindow() != nullptr && _is_win11_terminal()) {
+ // Open a new terminal as a workaround for Windows Terminal bug.
+ dwCreationFlags |= CREATE_NEW_CONSOLE;
+ }
+
+ int ret = CreateProcessW(nullptr, (LPWSTR)(command.utf16().ptrw()), nullptr, nullptr, false, dwCreationFlags, nullptr, nullptr, si_w, &pi.pi);
ERR_FAIL_COND_V_MSG(ret == 0, ERR_CANT_FORK, "Could not create child process: " + command);
ProcessID pid = pi.pi.dwProcessId;
@@ -596,7 +620,7 @@ String OS_Windows::get_locale() const {
wl++;
}
- if (neutral != "")
+ if (!neutral.is_empty())
return String(neutral).replace("-", "_");
return "en";
@@ -747,11 +771,11 @@ String OS_Windows::get_system_dir(SystemDir p_dir, bool p_shared_storage) const
String OS_Windows::get_user_data_dir() const {
String appname = get_safe_dir_name(ProjectSettings::get_singleton()->get("application/config/name"));
- if (appname != "") {
+ if (!appname.is_empty()) {
bool use_custom_dir = ProjectSettings::get_singleton()->get("application/config/use_custom_user_dir");
if (use_custom_dir) {
String custom_dir = get_safe_dir_name(ProjectSettings::get_singleton()->get("application/config/custom_user_dir_name"), true);
- if (custom_dir == "") {
+ if (custom_dir.is_empty()) {
custom_dir = appname;
}
return get_data_path().plus_file(custom_dir).replace("\\", "/");
@@ -760,7 +784,7 @@ String OS_Windows::get_user_data_dir() const {
}
}
- return ProjectSettings::get_singleton()->get_resource_path();
+ return get_data_path().plus_file(get_godot_dir_name()).plus_file("app_userdata").plus_file("[unnamed project]");
}
String OS_Windows::get_unique_id() const {
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index 1342d95575..4e61f3be7e 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
@@ -157,6 +157,7 @@ public:
void run();
+ bool _is_win11_terminal() const;
virtual bool _check_internal_feature_support(const String &p_feature) override;
virtual void disable_crash_handler() override;
diff --git a/platform/windows/platform_config.h b/platform/windows/platform_config.h
index dace0f86af..8e80f8cacb 100644
--- a/platform/windows/platform_config.h
+++ b/platform/windows/platform_config.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
diff --git a/platform/windows/vulkan_context_win.cpp b/platform/windows/vulkan_context_win.cpp
index db5e6466be..07c41395fb 100644
--- a/platform/windows/vulkan_context_win.cpp
+++ b/platform/windows/vulkan_context_win.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
diff --git a/platform/windows/vulkan_context_win.h b/platform/windows/vulkan_context_win.h
index 61e66b8ae0..e68f0125ca 100644
--- a/platform/windows/vulkan_context_win.h
+++ b/platform/windows/vulkan_context_win.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
diff --git a/platform/windows/windows_terminal_logger.cpp b/platform/windows/windows_terminal_logger.cpp
index e54a61fdfd..0d5f0e617c 100644
--- a/platform/windows/windows_terminal_logger.cpp
+++ b/platform/windows/windows_terminal_logger.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
@@ -71,7 +71,7 @@ void WindowsTerminalLogger::logv(const char *p_format, va_list p_list, bool p_er
#endif
}
-void WindowsTerminalLogger::log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type) {
+void WindowsTerminalLogger::log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify, ErrorType p_type) {
if (!should_log(true)) {
return;
}
diff --git a/platform/windows/windows_terminal_logger.h b/platform/windows/windows_terminal_logger.h
index aacfe5869e..1045f12201 100644
--- a/platform/windows/windows_terminal_logger.h
+++ b/platform/windows/windows_terminal_logger.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
@@ -37,8 +37,8 @@
class WindowsTerminalLogger : public StdLogger {
public:
- virtual void logv(const char *p_format, va_list p_list, bool p_err);
- virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type = ERR_ERROR);
+ virtual void logv(const char *p_format, va_list p_list, bool p_err) override;
+ virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify = false, ErrorType p_type = ERR_ERROR) override;
virtual ~WindowsTerminalLogger();
};