summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/android/detect.py10
-rw-r--r--platform/android/display_server_android.cpp4
-rw-r--r--platform/android/vulkan/vulkan_context_android.cpp6
-rw-r--r--platform/iphone/detect.py48
-rw-r--r--platform/iphone/display_server_iphone.h8
-rw-r--r--platform/iphone/display_server_iphone.mm2
-rw-r--r--platform/iphone/keyboard_input_view.mm4
-rw-r--r--platform/iphone/main.m1
-rw-r--r--platform/iphone/os_iphone.mm6
-rw-r--r--platform/iphone/vulkan_context_iphone.mm6
-rw-r--r--platform/javascript/display_server_javascript.cpp2
-rw-r--r--platform/javascript/dom_keys.inc8
-rw-r--r--platform/linuxbsd/detect.py2
-rw-r--r--platform/linuxbsd/display_server_x11.cpp18
-rw-r--r--platform/linuxbsd/key_mapping_x11.cpp16
-rw-r--r--platform/linuxbsd/key_mapping_x11.h4
-rw-r--r--platform/linuxbsd/vulkan_context_x11.cpp6
-rw-r--r--platform/osx/detect.py18
-rw-r--r--platform/osx/display_server_osx.h2
-rw-r--r--platform/osx/display_server_osx.mm30
-rw-r--r--platform/osx/vulkan_context_osx.mm6
-rw-r--r--platform/uwp/os_uwp.cpp2
-rw-r--r--platform/uwp/os_uwp.h2
-rw-r--r--platform/windows/detect.py8
-rw-r--r--platform/windows/display_server_windows.cpp8
-rw-r--r--platform/windows/key_mapping_windows.cpp4
-rw-r--r--platform/windows/vulkan_context_win.cpp6
27 files changed, 114 insertions, 123 deletions
diff --git a/platform/android/detect.py b/platform/android/detect.py
index 1b6af8662e..9be6f33b93 100644
--- a/platform/android/detect.py
+++ b/platform/android/detect.py
@@ -54,6 +54,7 @@ def get_android_ndk_root():
def get_flags():
return [
("tools", False),
+ ("use_volk", False),
]
@@ -367,8 +368,13 @@ def configure(env):
)
env.Prepend(CPPPATH=["#platform/android"])
- env.Append(CPPDEFINES=["ANDROID_ENABLED", "UNIX_ENABLED", "VULKAN_ENABLED", "NO_FCNTL"])
- env.Append(LIBS=["OpenSLES", "EGL", "GLESv2", "vulkan", "android", "log", "z", "dl"])
+ env.Append(CPPDEFINES=["ANDROID_ENABLED", "UNIX_ENABLED", "NO_FCNTL"])
+ env.Append(LIBS=["OpenSLES", "EGL", "GLESv2", "android", "log", "z", "dl"])
+
+ if env["vulkan"]:
+ env.Append(CPPDEFINES=["VULKAN_ENABLED"])
+ if not env["use_volk"]:
+ env.Append(LIBS=["vulkan"])
# Return the project NDK version.
diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp
index af8829324b..d200d024c5 100644
--- a/platform/android/display_server_android.cpp
+++ b/platform/android/display_server_android.cpp
@@ -538,8 +538,8 @@ void DisplayServerAndroid::process_key_event(int p_keycode, int p_scancode, int
meta_mem = p_pressed;
}
- ev->set_keycode(keycode);
- ev->set_physical_keycode(phy_keycode);
+ ev->set_keycode((Key)keycode);
+ ev->set_physical_keycode((Key)phy_keycode);
ev->set_unicode(val);
ev->set_pressed(p_pressed);
diff --git a/platform/android/vulkan/vulkan_context_android.cpp b/platform/android/vulkan/vulkan_context_android.cpp
index a031f3beee..f06a30f3a4 100644
--- a/platform/android/vulkan/vulkan_context_android.cpp
+++ b/platform/android/vulkan/vulkan_context_android.cpp
@@ -30,7 +30,11 @@
#include "vulkan_context_android.h"
-#include <vulkan/vulkan_android.h>
+#ifdef USE_VOLK
+#include <volk.h>
+#else
+#include <vulkan/vulkan.h>
+#endif
const char *VulkanContextAndroid::_get_platform_surface_extension() const {
return VK_KHR_ANDROID_SURFACE_EXTENSION_NAME;
diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py
index cf358e0878..05e24c5003 100644
--- a/platform/iphone/detect.py
+++ b/platform/iphone/detect.py
@@ -28,12 +28,6 @@ def get_opts():
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain",
),
("IPHONESDK", "Path to the iPhone SDK", ""),
- BoolVariable(
- "use_static_mvk",
- "Link MoltenVK statically as Level-0 driver (better portability) or use Vulkan ICD loader (enables"
- " validation layers)",
- False,
- ),
BoolVariable("ios_simulator", "Build for iOS Simulator", False),
BoolVariable("ios_exceptions", "Enable exceptions", False),
("ios_triple", "Triple for ios toolchain", ""),
@@ -43,6 +37,7 @@ def get_opts():
def get_flags():
return [
("tools", False),
+ ("use_volk", False),
]
@@ -111,12 +106,10 @@ def configure(env):
if env["ios_simulator"]:
detect_darwin_sdk_path("iphonesimulator", env)
env.Append(CCFLAGS=["-mios-simulator-version-min=13.0"])
- env.Append(LINKFLAGS=["-mios-simulator-version-min=13.0"])
env.extra_suffix = ".simulator" + env.extra_suffix
else:
detect_darwin_sdk_path("iphone", env)
env.Append(CCFLAGS=["-miphoneos-version-min=11.0"])
- env.Append(LINKFLAGS=["-miphoneos-version-min=11.0"])
if env["arch"] == "x86" or env["arch"] == "x86_64":
env["ENV"]["MACOSX_DEPLOYMENT_TARGET"] = "10.9"
@@ -162,35 +155,6 @@ def configure(env):
# Temp fix for ABS/MAX/MIN macros in iPhone SDK blocking compilation
env.Append(CCFLAGS=["-Wno-ambiguous-macro"])
- ## Link flags
-
- if env["arch"] == "x86" or env["arch"] == "x86_64":
- arch_flag = "i386" if env["arch"] == "x86" else env["arch"]
- env.Append(
- LINKFLAGS=[
- "-arch",
- arch_flag,
- "-isysroot",
- "$IPHONESDK",
- "-Xlinker",
- "-objc_abi_version",
- "-Xlinker",
- "2",
- "-F$IPHONESDK",
- ]
- )
- elif env["arch"] == "arm":
- env.Append(LINKFLAGS=["-arch", "armv7", "-Wl,-dead_strip"])
- if env["arch"] == "arm64":
- env.Append(LINKFLAGS=["-arch", "arm64", "-Wl,-dead_strip"])
-
- env.Append(
- LINKFLAGS=[
- "-isysroot",
- "$IPHONESDK",
- ]
- )
-
env.Prepend(
CPPPATH=[
"$IPHONESDK/usr/include",
@@ -198,14 +162,8 @@ def configure(env):
]
)
- env["ENV"]["CODESIGN_ALLOCATE"] = "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate"
-
env.Prepend(CPPPATH=["#platform/iphone"])
env.Append(CPPDEFINES=["IPHONE_ENABLED", "UNIX_ENABLED", "COREAUDIO_ENABLED"])
- env.Append(CPPDEFINES=["VULKAN_ENABLED"])
- env.Append(LINKFLAGS=["-framework", "IOSurface"])
-
- # Use Static Vulkan for iOS. Dynamic Framework works fine too.
- env.Append(LINKFLAGS=["-framework", "MoltenVK"])
- env["builtin_vulkan"] = False
+ if env["vulkan"]:
+ env.Append(CPPDEFINES=["VULKAN_ENABLED"])
diff --git a/platform/iphone/display_server_iphone.h b/platform/iphone/display_server_iphone.h
index 8ba7a69a4f..5cfcc1765c 100644
--- a/platform/iphone/display_server_iphone.h
+++ b/platform/iphone/display_server_iphone.h
@@ -41,7 +41,11 @@
#include "vulkan_context_iphone.h"
#import <QuartzCore/CAMetalLayer.h>
-#include <vulkan/vulkan_metal.h>
+#ifdef USE_VOLK
+#include <volk.h>
+#else
+#include <vulkan/vulkan.h>
+#endif
#endif
class DisplayServerIPhone : public DisplayServer {
@@ -105,7 +109,7 @@ public:
// MARK: Keyboard
- void key(uint32_t p_key, bool p_pressed);
+ void key(Key p_key, bool p_pressed);
// MARK: Motion
diff --git a/platform/iphone/display_server_iphone.mm b/platform/iphone/display_server_iphone.mm
index b4f0a32027..e18448fb6d 100644
--- a/platform/iphone/display_server_iphone.mm
+++ b/platform/iphone/display_server_iphone.mm
@@ -254,7 +254,7 @@ void DisplayServerIPhone::touches_cancelled(int p_idx) {
// MARK: Keyboard
-void DisplayServerIPhone::key(uint32_t p_key, bool p_pressed) {
+void DisplayServerIPhone::key(Key p_key, bool p_pressed) {
Ref<InputEventKey> ev;
ev.instantiate();
ev->set_echo(false);
diff --git a/platform/iphone/keyboard_input_view.mm b/platform/iphone/keyboard_input_view.mm
index 0e5a98a3e6..e2bd0acff4 100644
--- a/platform/iphone/keyboard_input_view.mm
+++ b/platform/iphone/keyboard_input_view.mm
@@ -138,8 +138,8 @@
break;
}
- DisplayServerIPhone::get_singleton()->key(character, true);
- DisplayServerIPhone::get_singleton()->key(character, false);
+ DisplayServerIPhone::get_singleton()->key((Key)character, true);
+ DisplayServerIPhone::get_singleton()->key((Key)character, false);
}
}
diff --git a/platform/iphone/main.m b/platform/iphone/main.m
index fddd5bd99f..d2c41d4d84 100644
--- a/platform/iphone/main.m
+++ b/platform/iphone/main.m
@@ -32,7 +32,6 @@
#import <UIKit/UIKit.h>
#include <stdio.h>
-#include <vulkan/vulkan.h>
int gargc;
char **gargv;
diff --git a/platform/iphone/os_iphone.mm b/platform/iphone/os_iphone.mm
index a999929cc4..c88d253691 100644
--- a/platform/iphone/os_iphone.mm
+++ b/platform/iphone/os_iphone.mm
@@ -49,7 +49,11 @@
#if defined(VULKAN_ENABLED)
#include "servers/rendering/renderer_rd/renderer_compositor_rd.h"
#import <QuartzCore/CAMetalLayer.h>
-#include <vulkan/vulkan_metal.h>
+#ifdef USE_VOLK
+#include <volk.h>
+#else
+#include <vulkan/vulkan.h>
+#endif
#endif
// Initialization order between compilation units is not guaranteed,
diff --git a/platform/iphone/vulkan_context_iphone.mm b/platform/iphone/vulkan_context_iphone.mm
index 17f2b167b3..5432cdc033 100644
--- a/platform/iphone/vulkan_context_iphone.mm
+++ b/platform/iphone/vulkan_context_iphone.mm
@@ -29,7 +29,11 @@
/*************************************************************************/
#include "vulkan_context_iphone.h"
-#include <vulkan/vulkan_ios.h>
+#ifdef USE_VOLK
+#include <volk.h>
+#else
+#include <vulkan/vulkan.h>
+#endif
const char *VulkanContextIPhone::_get_platform_surface_extension() const {
return VK_MVK_IOS_SURFACE_EXTENSION_NAME;
diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp
index 8df81bb8cc..fda18a5c19 100644
--- a/platform/javascript/display_server_javascript.cpp
+++ b/platform/javascript/display_server_javascript.cpp
@@ -172,7 +172,7 @@ EM_BOOL DisplayServerJavaScript::keyup_callback(int p_event_type, const Emscript
Ref<InputEventKey> ev = setup_key_event(p_event);
ev->set_pressed(false);
Input::get_singleton()->parse_input_event(ev);
- return ev->get_keycode() != KEY_UNKNOWN && ev->get_keycode() != 0;
+ return ev->get_keycode() != KEY_UNKNOWN && ev->get_keycode() != (Key)0;
}
// Mouse
diff --git a/platform/javascript/dom_keys.inc b/platform/javascript/dom_keys.inc
index 69340ff58c..0e62776923 100644
--- a/platform/javascript/dom_keys.inc
+++ b/platform/javascript/dom_keys.inc
@@ -31,7 +31,7 @@
#include "core/os/keyboard.h"
// See https://w3c.github.io/uievents-code/#code-value-tables
-int dom_code2godot_scancode(EM_UTF8 const p_code[32], EM_UTF8 const p_key[32], bool p_physical) {
+Key dom_code2godot_scancode(EM_UTF8 const p_code[32], EM_UTF8 const p_key[32], bool p_physical) {
#define DOM2GODOT(p_str, p_godot_code) \
if (memcmp((const void *)p_str, (void *)p_code, strlen(p_str) + 1) == 0) { \
return KEY_##p_godot_code; \
@@ -79,7 +79,7 @@ int dom_code2godot_scancode(EM_UTF8 const p_code[32], EM_UTF8 const p_key[32], b
if (b0 > 0x60 && b0 < 0x7B) { // Lowercase ASCII.
b0 -= 32;
}
- return b0;
+ return (Key)b0;
}
#define _U_2BYTES_MASK 0xE0
@@ -88,11 +88,11 @@ int dom_code2godot_scancode(EM_UTF8 const p_code[32], EM_UTF8 const p_key[32], b
if (b2 == 0 && (b0 & _U_2BYTES_MASK) == _U_2BYTES) { // 2-bytes utf8, only known latin.
uint32_t key = ((b0 & ~_U_2BYTES_MASK) << 6) | (b1 & 0x3F);
if (key >= 0xA0 && key <= 0xDF) {
- return key;
+ return (Key)key;
}
if (key >= 0xE0 && key <= 0xFF) { // Lowercase known latin.
key -= 0x20;
- return key;
+ return (Key)key;
}
}
#undef _U_2BYTES_MASK
diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py
index eba672ddcb..3e3ed469ed 100644
--- a/platform/linuxbsd/detect.py
+++ b/platform/linuxbsd/detect.py
@@ -384,7 +384,7 @@ def configure(env):
if env["vulkan"]:
env.Append(CPPDEFINES=["VULKAN_ENABLED"])
- if not env["builtin_vulkan"]:
+ if not env["use_volk"]:
env.ParseConfig("pkg-config vulkan --cflags --libs")
if not env["builtin_glslang"]:
# No pkgconfig file for glslang so far
diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp
index 4a32dd9646..5b26b23806 100644
--- a/platform/linuxbsd/display_server_x11.cpp
+++ b/platform/linuxbsd/display_server_x11.cpp
@@ -2207,7 +2207,7 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event,
if (status == XLookupChars) {
bool keypress = xkeyevent->type == KeyPress;
- unsigned int keycode = KeyMappingX11::get_keycode(keysym_keycode);
+ Key keycode = KeyMappingX11::get_keycode(keysym_keycode);
unsigned int physical_keycode = KeyMappingX11::get_scancode(xkeyevent->keycode);
if (keycode >= 'a' && keycode <= 'z') {
@@ -2224,7 +2224,7 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event,
}
if (keycode == 0) {
- keycode = physical_keycode;
+ keycode = (Key)physical_keycode;
}
_get_key_modifier_state(xkeyevent->state, k);
@@ -2236,7 +2236,7 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event,
k->set_keycode(keycode);
- k->set_physical_keycode(physical_keycode);
+ k->set_physical_keycode((Key)physical_keycode);
k->set_echo(false);
@@ -2271,7 +2271,7 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event,
// KeyMappingX11 just translated the X11 keysym to a PIGUI
// keysym, so it works in all platforms the same.
- unsigned int keycode = KeyMappingX11::get_keycode(keysym_keycode);
+ Key keycode = KeyMappingX11::get_keycode(keysym_keycode);
unsigned int physical_keycode = KeyMappingX11::get_scancode(xkeyevent->keycode);
/* Phase 3, obtain a unicode character from the keysym */
@@ -2292,12 +2292,12 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event,
bool keypress = xkeyevent->type == KeyPress;
- if (physical_keycode == 0 && keycode == 0 && unicode == 0) {
+ if (physical_keycode == 0 && keycode == KEY_NONE && unicode == 0) {
return;
}
- if (keycode == 0) {
- keycode = physical_keycode;
+ if (keycode == KEY_NONE) {
+ keycode = (Key)physical_keycode;
}
/* Phase 5, determine modifier mask */
@@ -2360,11 +2360,11 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event,
k->set_pressed(keypress);
if (keycode >= 'a' && keycode <= 'z') {
- keycode -= 'a' - 'A';
+ keycode -= int('a' - 'A');
}
k->set_keycode(keycode);
- k->set_physical_keycode(physical_keycode);
+ k->set_physical_keycode((Key)physical_keycode);
k->set_unicode(unicode);
k->set_echo(p_echo);
diff --git a/platform/linuxbsd/key_mapping_x11.cpp b/platform/linuxbsd/key_mapping_x11.cpp
index 74257a7e61..a1ef28234d 100644
--- a/platform/linuxbsd/key_mapping_x11.cpp
+++ b/platform/linuxbsd/key_mapping_x11.cpp
@@ -34,7 +34,7 @@
struct _XTranslatePair {
KeySym keysym;
- unsigned int keycode;
+ Key keycode;
};
static _XTranslatePair _xkeysym_to_keycode[] = {
@@ -176,7 +176,7 @@ static _XTranslatePair _xkeysym_to_keycode[] = {
{ XF86XK_LaunchC, KEY_LAUNCHE },
{ XF86XK_LaunchD, KEY_LAUNCHF },
- { 0, 0 }
+ { 0, KEY_NONE }
};
struct _TranslatePair {
@@ -309,11 +309,11 @@ unsigned int KeyMappingX11::get_scancode(unsigned int p_code) {
return keycode;
}
-unsigned int KeyMappingX11::get_keycode(KeySym p_keysym) {
+Key KeyMappingX11::get_keycode(KeySym p_keysym) {
// kinda bruteforce.. could optimize.
if (p_keysym < 0x100) { // Latin 1, maps 1-1
- return p_keysym;
+ return (Key)p_keysym;
}
// look for special key
@@ -323,14 +323,14 @@ unsigned int KeyMappingX11::get_keycode(KeySym p_keysym) {
}
}
- return 0;
+ return KEY_NONE;
}
-KeySym KeyMappingX11::get_keysym(unsigned int p_code) {
+KeySym KeyMappingX11::get_keysym(Key p_code) {
// kinda bruteforce.. could optimize.
if (p_code < 0x100) { // Latin 1, maps 1-1
- return p_code;
+ return (KeySym)p_code;
}
// look for special key
@@ -340,7 +340,7 @@ KeySym KeyMappingX11::get_keysym(unsigned int p_code) {
}
}
- return 0;
+ return (KeySym)KEY_NONE;
}
/***** UNICODE CONVERSION ******/
diff --git a/platform/linuxbsd/key_mapping_x11.h b/platform/linuxbsd/key_mapping_x11.h
index 163a8e21db..598db1c45a 100644
--- a/platform/linuxbsd/key_mapping_x11.h
+++ b/platform/linuxbsd/key_mapping_x11.h
@@ -44,9 +44,9 @@ class KeyMappingX11 {
KeyMappingX11() {}
public:
- static unsigned int get_keycode(KeySym p_keysym);
+ static Key get_keycode(KeySym p_keysym);
static unsigned int get_scancode(unsigned int p_code);
- static KeySym get_keysym(unsigned int p_code);
+ static KeySym get_keysym(Key p_code);
static unsigned int get_unicode_from_keysym(KeySym p_keysym);
static KeySym get_keysym_from_unicode(unsigned int p_unicode);
};
diff --git a/platform/linuxbsd/vulkan_context_x11.cpp b/platform/linuxbsd/vulkan_context_x11.cpp
index 88cb00a8a1..ebaef984e0 100644
--- a/platform/linuxbsd/vulkan_context_x11.cpp
+++ b/platform/linuxbsd/vulkan_context_x11.cpp
@@ -29,7 +29,11 @@
/*************************************************************************/
#include "vulkan_context_x11.h"
-#include <vulkan/vulkan_xlib.h>
+#ifdef USE_VOLK
+#include <volk.h>
+#else
+#include <vulkan/vulkan.h>
+#endif
const char *VulkanContextX11::_get_platform_surface_extension() const {
return VK_KHR_XLIB_SURFACE_EXTENSION_NAME;
diff --git a/platform/osx/detect.py b/platform/osx/detect.py
index 2393f2ea10..6b25daf05d 100644
--- a/platform/osx/detect.py
+++ b/platform/osx/detect.py
@@ -25,12 +25,6 @@ def get_opts():
("osxcross_sdk", "OSXCross SDK version", "darwin16"),
("MACOS_SDK_PATH", "Path to the macOS SDK", ""),
("VULKAN_SDK_PATH", "Path to the Vulkan SDK", ""),
- BoolVariable(
- "use_static_mvk",
- "Link MoltenVK statically as Level-0 driver (better portability) or use Vulkan ICD loader (enables"
- " validation layers)",
- False,
- ),
EnumVariable("macports_clang", "Build using Clang from MacPorts", "no", ("no", "5.0", "devel")),
BoolVariable("debug_symbols", "Add debugging symbols to release/release_debug builds", True),
BoolVariable("separate_debug_symbols", "Create a separate file containing debugging symbols", False),
@@ -188,12 +182,10 @@ def configure(env):
)
env.Append(LIBS=["pthread", "z"])
- env.Append(CPPDEFINES=["VULKAN_ENABLED"])
- env.Append(LINKFLAGS=["-framework", "Metal", "-framework", "QuartzCore", "-framework", "IOSurface"])
- if env["use_static_mvk"]:
- env.Append(LINKFLAGS=["-L$VULKAN_SDK_PATH/MoltenVK/MoltenVK.xcframework/macos-arm64_x86_64/", "-lMoltenVK"])
- env["builtin_vulkan"] = False
- elif not env["builtin_vulkan"]:
- env.Append(LIBS=["vulkan"])
+ if env["vulkan"]:
+ env.Append(CPPDEFINES=["VULKAN_ENABLED"])
+ env.Append(LINKFLAGS=["-framework", "Metal", "-framework", "QuartzCore", "-framework", "IOSurface"])
+ if not env["use_volk"]:
+ env.Append(LINKFLAGS=["-L$VULKAN_SDK_PATH/MoltenVK/MoltenVK.xcframework/macos-arm64_x86_64/", "-lMoltenVK"])
# env.Append(CPPDEFINES=['GLES_ENABLED', 'OPENGL_ENABLED'])
diff --git a/platform/osx/display_server_osx.h b/platform/osx/display_server_osx.h
index 6b1b777224..06b14f1c14 100644
--- a/platform/osx/display_server_osx.h
+++ b/platform/osx/display_server_osx.h
@@ -85,7 +85,7 @@ public:
bool pressed = false;
bool echo = false;
bool raw = false;
- uint32_t keycode = 0;
+ Key keycode = KEY_NONE;
uint32_t physical_keycode = 0;
uint32_t unicode = 0;
};
diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm
index 73aa013701..cc8400980a 100644
--- a/platform/osx/display_server_osx.mm
+++ b/platform/osx/display_server_osx.mm
@@ -318,8 +318,16 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) {
}
DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
- _get_mouse_pos(wd, [wd.window_object mouseLocationOutsideOfEventStream]);
- Input::get_singleton()->set_mouse_position(wd.mouse_pos);
+ if (DS_OSX->mouse_mode == DisplayServer::MOUSE_MODE_CAPTURED) {
+ const NSRect contentRect = [wd.window_view frame];
+ NSRect pointInWindowRect = NSMakeRect(contentRect.size.width / 2, contentRect.size.height / 2, 0, 0);
+ NSPoint pointOnScreen = [[wd.window_view window] convertRectToScreen:pointInWindowRect].origin;
+ CGPoint lMouseWarpPos = { pointOnScreen.x, CGDisplayBounds(CGMainDisplayID()).size.height - pointOnScreen.y };
+ CGWarpMouseCursorPosition(lMouseWarpPos);
+ } else {
+ _get_mouse_pos(wd, [wd.window_object mouseLocationOutsideOfEventStream]);
+ Input::get_singleton()->set_mouse_position(wd.mouse_pos);
+ }
DS_OSX->window_focused = true;
DS_OSX->_send_window_event(wd, DisplayServerOSX::WINDOW_EVENT_FOCUS_IN);
@@ -577,7 +585,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
ke.pressed = true;
ke.echo = false;
ke.raw = false; // IME input event
- ke.keycode = 0;
+ ke.keycode = KEY_NONE;
ke.physical_keycode = 0;
ke.unicode = codepoint;
@@ -920,9 +928,9 @@ static bool isNumpadKey(unsigned int key) {
// Translates a OS X keycode to a Godot keycode
//
-static int translateKey(unsigned int key) {
+static Key translateKey(unsigned int key) {
// Keyboard symbol translation table
- static const unsigned int table[128] = {
+ static const Key table[128] = {
/* 00 */ KEY_A,
/* 01 */ KEY_S,
/* 02 */ KEY_D,
@@ -1062,7 +1070,7 @@ static int translateKey(unsigned int key) {
struct _KeyCodeMap {
UniChar kchar;
- int kcode;
+ Key kcode;
};
static const _KeyCodeMap _keycodes[55] = {
@@ -1123,7 +1131,7 @@ static const _KeyCodeMap _keycodes[55] = {
{ '/', KEY_SLASH }
};
-static int remapKey(unsigned int key, unsigned int state) {
+static Key remapKey(unsigned int key, unsigned int state) {
if (isNumpadKey(key)) {
return translateKey(key);
}
@@ -3263,7 +3271,7 @@ void DisplayServerOSX::_process_key_events() {
k->set_pressed(ke.pressed);
k->set_echo(ke.echo);
k->set_keycode(ke.keycode);
- k->set_physical_keycode(ke.physical_keycode);
+ k->set_physical_keycode((Key)ke.physical_keycode);
k->set_unicode(ke.unicode);
_push_input(k);
@@ -3276,8 +3284,8 @@ void DisplayServerOSX::_process_key_events() {
_get_key_modifier_state(ke.osx_state, k);
k->set_pressed(ke.pressed);
k->set_echo(ke.echo);
- k->set_keycode(0);
- k->set_physical_keycode(0);
+ k->set_keycode(KEY_NONE);
+ k->set_physical_keycode(KEY_NONE);
k->set_unicode(ke.unicode);
_push_input(k);
@@ -3290,7 +3298,7 @@ void DisplayServerOSX::_process_key_events() {
k->set_pressed(ke.pressed);
k->set_echo(ke.echo);
k->set_keycode(ke.keycode);
- k->set_physical_keycode(ke.physical_keycode);
+ k->set_physical_keycode((Key)ke.physical_keycode);
if (i + 1 < key_event_pos && key_event_buffer[i + 1].keycode == 0) {
k->set_unicode(key_event_buffer[i + 1].unicode);
diff --git a/platform/osx/vulkan_context_osx.mm b/platform/osx/vulkan_context_osx.mm
index 7e18e177c1..504955149b 100644
--- a/platform/osx/vulkan_context_osx.mm
+++ b/platform/osx/vulkan_context_osx.mm
@@ -29,7 +29,11 @@
/*************************************************************************/
#include "vulkan_context_osx.h"
-#include <vulkan/vulkan_macos.h>
+#ifdef USE_VOLK
+#include <volk.h>
+#else
+#include <vulkan/vulkan.h>
+#endif
const char *VulkanContextOSX::_get_platform_surface_extension() const {
return VK_MVK_MACOS_SURFACE_EXTENSION_NAME;
diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp
index e26e204f5f..6ac5b55156 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -566,7 +566,7 @@ void OS_UWP::process_key_events() {
key_event->set_ctrl_pressed(kev.control);
key_event->set_echo(kev.echo);
key_event->set_keycode(kev.keycode);
- key_event->set_physical_keycode(kev.physical_keycode);
+ key_event->set_physical_keycode((Key)kev.physical_keycode);
key_event->set_unicode(kev.unicode);
key_event->set_pressed(kev.pressed);
diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h
index 3a735889b0..c9b2600c8e 100644
--- a/platform/uwp/os_uwp.h
+++ b/platform/uwp/os_uwp.h
@@ -58,7 +58,7 @@ public:
bool alt = false, shift = false, control = false;
MessageType type = KEY_EVENT_MESSAGE;
bool pressed = false;
- unsigned int keycode = 0;
+ Key keycode = KEY_NONE;
unsigned int physical_keycode = 0;
unsigned int unicode = 0;
bool echo = false;
diff --git a/platform/windows/detect.py b/platform/windows/detect.py
index 287ece1d29..9154f7749e 100644
--- a/platform/windows/detect.py
+++ b/platform/windows/detect.py
@@ -278,10 +278,8 @@ def configure_msvc(env, manual_msvc_config):
]
env.AppendUnique(CPPDEFINES=["VULKAN_ENABLED"])
- if not env["builtin_vulkan"]:
+ if not env["use_volk"]:
LIBS += ["vulkan"]
- else:
- LIBS += ["cfgmgr32"]
# env.AppendUnique(CPPDEFINES = ['OPENGL_ENABLED'])
LIBS += ["opengl32"]
@@ -456,10 +454,8 @@ def configure_mingw(env):
)
env.Append(CPPDEFINES=["VULKAN_ENABLED"])
- if not env["builtin_vulkan"]:
+ if not env["use_volk"]:
env.Append(LIBS=["vulkan"])
- else:
- env.Append(LIBS=["cfgmgr32"])
## TODO !!! Re-enable when OpenGLES Rendering Device is implemented !!!
# env.Append(CPPDEFINES=['OPENGL_ENABLED'])
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp
index 4be95487b8..42a517879b 100644
--- a/platform/windows/display_server_windows.cpp
+++ b/platform/windows/display_server_windows.cpp
@@ -2855,8 +2855,8 @@ void DisplayServerWindows::_process_key_events() {
k->set_ctrl_pressed(ke.control);
k->set_meta_pressed(ke.meta);
k->set_pressed(true);
- k->set_keycode(KeyMappingWindows::get_keysym(ke.wParam));
- k->set_physical_keycode(KeyMappingWindows::get_scansym((ke.lParam >> 16) & 0xFF, ke.lParam & (1 << 24)));
+ k->set_keycode((Key)KeyMappingWindows::get_keysym(ke.wParam));
+ k->set_physical_keycode((Key)(KeyMappingWindows::get_scansym((ke.lParam >> 16) & 0xFF, ke.lParam & (1 << 24))));
k->set_unicode(unicode);
if (k->get_unicode() && gr_mem) {
k->set_alt_pressed(false);
@@ -2888,10 +2888,10 @@ void DisplayServerWindows::_process_key_events() {
// Special case for Numpad Enter key
k->set_keycode(KEY_KP_ENTER);
} else {
- k->set_keycode(KeyMappingWindows::get_keysym(ke.wParam));
+ k->set_keycode((Key)KeyMappingWindows::get_keysym(ke.wParam));
}
- k->set_physical_keycode(KeyMappingWindows::get_scansym((ke.lParam >> 16) & 0xFF, ke.lParam & (1 << 24)));
+ k->set_physical_keycode((Key)(KeyMappingWindows::get_scansym((ke.lParam >> 16) & 0xFF, ke.lParam & (1 << 24))));
if (i + 1 < key_event_pos && key_event_buffer[i + 1].uMsg == WM_CHAR) {
char32_t unicode = key_event_buffer[i + 1].wParam;
diff --git a/platform/windows/key_mapping_windows.cpp b/platform/windows/key_mapping_windows.cpp
index c367c69826..db99d6c122 100644
--- a/platform/windows/key_mapping_windows.cpp
+++ b/platform/windows/key_mapping_windows.cpp
@@ -365,6 +365,8 @@ unsigned int KeyMappingWindows::get_scansym(unsigned int p_code, bool p_extended
case KEY_CAPSLOCK: {
keycode = KEY_KP_ADD;
} break;
+ default:
+ break;
}
} else {
switch (keycode) {
@@ -404,6 +406,8 @@ unsigned int KeyMappingWindows::get_scansym(unsigned int p_code, bool p_extended
case KEY_PRINT: {
keycode = KEY_KP_MULTIPLY;
} break;
+ default:
+ break;
}
}
diff --git a/platform/windows/vulkan_context_win.cpp b/platform/windows/vulkan_context_win.cpp
index 191792b329..d720c7e8fe 100644
--- a/platform/windows/vulkan_context_win.cpp
+++ b/platform/windows/vulkan_context_win.cpp
@@ -29,7 +29,11 @@
/*************************************************************************/
#include "vulkan_context_win.h"
-#include <vulkan/vulkan_win32.h>
+#ifdef USE_VOLK
+#include <volk.h>
+#else
+#include <vulkan/vulkan.h>
+#endif
const char *VulkanContextWindows::_get_platform_surface_extension() const {
return VK_KHR_WIN32_SURFACE_EXTENSION_NAME;