summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorGeorge Marques <george@gmarqu.es>2017-05-23 13:50:21 -0300
committerGeorge Marques <george@gmarqu.es>2017-05-23 14:06:24 -0300
commit40613221a4f255bf9115ec8fca8206b2ff222f1b (patch)
treea0c0d7dd943db885d8ad6d0feca2e16b8a480620 /platform
parent9e2b3f0903a74c009825561559d20bfc48062446 (diff)
Fix UWP compilation issues
Also fix VS2017 compilation problems.
Diffstat (limited to 'platform')
-rw-r--r--platform/uwp/app.cpp117
-rw-r--r--platform/uwp/detect.py15
-rw-r--r--platform/uwp/gl_context_egl.cpp2
-rw-r--r--platform/uwp/os_uwp.cpp29
-rw-r--r--platform/uwp/os_uwp.h4
5 files changed, 77 insertions, 90 deletions
diff --git a/platform/uwp/app.cpp b/platform/uwp/app.cpp
index 7c8f09b27b..51aba9b7fd 100644
--- a/platform/uwp/app.cpp
+++ b/platform/uwp/app.cpp
@@ -259,45 +259,48 @@ void App::pointer_event(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Cor
int but = _get_button(point);
if (_is_touch(point)) {
- Ref<InputEvent> event;
- event.type = InputEvent::SCREEN_TOUCH;
- event.device = 0;
- event.screen_touch->is_pressed() = p_pressed;
- event.screen_touch.x = pos.X;
- event.screen_touch.y = pos.Y;
- event.screen_touch.index = _get_finger(point->PointerId);
-
- last_touch_x[event.screen_touch.index] = pos.X;
- last_touch_y[event.screen_touch.index] = pos.Y;
-
- os->input_event(event);
+ Ref<InputEventScreenTouch> screen_touch;
+ screen_touch.instance();
+ screen_touch->set_device(0);
+ screen_touch->set_pressed(p_pressed);
+ screen_touch->set_pos(Vector2(pos.X, pos.Y));
+ screen_touch->set_index(_get_finger(point->PointerId));
+
+ last_touch_x[screen_touch->get_index()] = pos.X;
+ last_touch_y[screen_touch->get_index()] = pos.Y;
+
+ os->input_event(screen_touch);
if (number_of_contacts > 1)
return;
}; // fallthrought of sorts
- Ref<InputEvent> event;
- event.type = InputEvent::MOUSE_BUTTON;
- event.device = 0;
- event->is_pressed() = p_pressed;
- event->get_button_index() = but;
- event->get_pos().x = pos.X;
- event->get_pos().y = pos.Y;
- event.mouse_button.global_x = pos.X;
- event.mouse_button.global_y = pos.Y;
+ Ref<InputEventMouseButton> mouse_button;
+ mouse_button.instance();
+ mouse_button->set_device(0);
+ mouse_button->set_pressed(p_pressed);
+ mouse_button->set_button_index(but);
+ mouse_button->set_pos(Vector2(pos.X, pos.Y));
+ mouse_button->set_global_pos(Vector2(pos.X, pos.Y));
if (p_is_wheel) {
if (point->Properties->MouseWheelDelta > 0) {
- event->get_button_index() = point->Properties->IsHorizontalMouseWheel ? BUTTON_WHEEL_RIGHT : BUTTON_WHEEL_UP;
+ mouse_button->set_button_index(point->Properties->IsHorizontalMouseWheel ? BUTTON_WHEEL_RIGHT : BUTTON_WHEEL_UP);
} else if (point->Properties->MouseWheelDelta < 0) {
- event->get_button_index() = point->Properties->IsHorizontalMouseWheel ? BUTTON_WHEEL_LEFT : BUTTON_WHEEL_DOWN;
+ mouse_button->set_button_index(point->Properties->IsHorizontalMouseWheel ? BUTTON_WHEEL_LEFT : BUTTON_WHEEL_DOWN);
}
}
last_touch_x[31] = pos.X;
last_touch_y[31] = pos.Y;
- os->input_event(event);
+ os->input_event(mouse_button);
+
+ if (p_is_wheel) {
+ // Send release for mouse wheel
+ mouse_button->set_pressed(false);
+ os->input_event(mouse_button);
+ }
};
void App::OnPointerPressed(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) {
@@ -349,16 +352,14 @@ void App::OnPointerMoved(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Co
if (point->IsInContact && _is_touch(point)) {
- InputEvent event;
- event.type = Ref<InputEvent>::SCREEN_DRAG;
- event.device = 0;
- event.screen_drag.x = pos.X;
- event.screen_drag.y = pos.Y;
- event.screen_drag.index = _get_finger(point->PointerId);
- event.screen_drag.relative_x = event.screen_drag.x - last_touch_x[event.screen_drag.index];
- event.screen_drag.relative_y = event.screen_drag.y - last_touch_y[event.screen_drag.index];
+ Ref<InputEventScreenDrag> screen_drag;
+ screen_drag.instance();
+ screen_drag->set_device(0);
+ screen_drag->set_pos(Vector2(pos.X, pos.Y));
+ screen_drag->set_index(_get_finger(point->PointerId));
+ screen_drag->set_relative(Vector2(screen_drag->get_pos().x - last_touch_x[screen_drag->get_index()], screen_drag->get_pos().y - last_touch_y[screen_drag->get_index()]));
- os->input_event(event);
+ os->input_event(screen_drag);
if (number_of_contacts > 1)
return;
@@ -368,19 +369,16 @@ void App::OnPointerMoved(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Co
if (os->get_mouse_mode() == OS::MouseMode::MOUSE_MODE_CAPTURED)
return;
- InputEvent event;
- event.type = Ref<InputEvent>::MOUSE_MOTION;
- event.device = 0;
- event.mouse_motion.x = pos.X;
- event.mouse_motion.y = pos.Y;
- event.mouse_motion.global_x = pos.X;
- event.mouse_motion.global_y = pos.Y;
- event->get_relative().x = pos.X - last_touch_x[31];
- event->get_relative().y = pos.Y - last_touch_y[31];
+ Ref<InputEventMouseMotion> mouse_motion;
+ mouse_motion.instance();
+ mouse_motion->set_device(0);
+ mouse_motion->set_pos(Vector2(pos.X, pos.Y));
+ mouse_motion->set_global_pos(Vector2(pos.X, pos.Y));
+ mouse_motion->set_relative(Vector2(pos.X - last_touch_x[31], pos.Y - last_touch_y[31]));
last_mouse_pos = pos;
- os->input_event(event);
+ os->input_event(mouse_motion);
}
void App::OnMouseMoved(MouseDevice ^ mouse_device, MouseEventArgs ^ args) {
@@ -393,47 +391,40 @@ void App::OnMouseMoved(MouseDevice ^ mouse_device, MouseEventArgs ^ args) {
pos.X = last_mouse_pos.X + args->MouseDelta.X;
pos.Y = last_mouse_pos.Y + args->MouseDelta.Y;
- InputEvent event;
- event.type = Ref<InputEvent>::MOUSE_MOTION;
- event.device = 0;
- event.mouse_motion.x = pos.X;
- event.mouse_motion.y = pos.Y;
- event.mouse_motion.global_x = pos.X;
- event.mouse_motion.global_y = pos.Y;
- event->get_relative().x = args->MouseDelta.X;
- event->get_relative().y = args->MouseDelta.Y;
+ Ref<InputEventMouseMotion> mouse_motion;
+ mouse_motion.instance();
+ mouse_motion->set_device(0);
+ mouse_motion->set_pos(Vector2(pos.X, pos.Y));
+ mouse_motion->set_global_pos(Vector2(pos.X, pos.Y));
+ mouse_motion->set_relative(Vector2(args->MouseDelta.X, args->MouseDelta.Y));
last_mouse_pos = pos;
- os->input_event(event);
+ os->input_event(mouse_motion);
}
void App::key_event(Windows::UI::Core::CoreWindow ^ sender, bool p_pressed, Windows::UI::Core::KeyEventArgs ^ key_args, Windows::UI::Core::CharacterReceivedEventArgs ^ char_args) {
OSUWP::KeyEvent ke;
- InputModifierState mod;
- mod.meta = false;
- mod.command = false;
- mod.control = sender->GetAsyncKeyState(VirtualKey::Control) == CoreVirtualKeyStates::Down;
- mod.alt = sender->GetAsyncKeyState(VirtualKey::Menu) == CoreVirtualKeyStates::Down;
- mod.shift = sender->GetAsyncKeyState(VirtualKey::Shift) == CoreVirtualKeyStates::Down;
- ke.mod_state = mod;
+ ke.control = sender->GetAsyncKeyState(VirtualKey::Control) == CoreVirtualKeyStates::Down;
+ ke.alt = sender->GetAsyncKeyState(VirtualKey::Menu) == CoreVirtualKeyStates::Down;
+ ke.shift = sender->GetAsyncKeyState(VirtualKey::Shift) == CoreVirtualKeyStates::Down;
- ke->is_pressed() = p_pressed;
+ ke.pressed = p_pressed;
if (key_args != nullptr) {
ke.type = OSUWP::KeyEvent::MessageType::KEY_EVENT_MESSAGE;
ke.unicode = 0;
- ke->get_scancode() = KeyMappingWindows::get_keysym((unsigned int)key_args->VirtualKey);
+ ke.scancode = KeyMappingWindows::get_keysym((unsigned int)key_args->VirtualKey);
ke.echo = (!p_pressed && !key_args->KeyStatus.IsKeyReleased) || (p_pressed && key_args->KeyStatus.WasKeyDown);
} else {
ke.type = OSUWP::KeyEvent::MessageType::CHAR_EVENT_MESSAGE;
ke.unicode = char_args->KeyCode;
- ke->get_scancode() = 0;
+ ke.scancode = 0;
ke.echo = (!p_pressed && !char_args->KeyStatus.IsKeyReleased) || (p_pressed && char_args->KeyStatus.WasKeyDown);
}
diff --git a/platform/uwp/detect.py b/platform/uwp/detect.py
index f1e0716241..baff7f9788 100644
--- a/platform/uwp/detect.py
+++ b/platform/uwp/detect.py
@@ -49,6 +49,8 @@ def configure(env):
arch = ""
env['ENV'] = os.environ
+ vc_base_path = os.environ['VCTOOLSINSTALLDIR'] if "VCTOOLSINSTALLDIR" in os.environ else os.environ['VCINSTALLDIR']
+
# ANGLE
angle_root = os.getenv("ANGLE_SRC_PATH")
env.Append(CPPPATH=[angle_root + '/include'])
@@ -65,7 +67,7 @@ def configure(env):
arch = "arm"
env["bits"] = "32"
env.Append(LINKFLAGS=['/MACHINE:ARM'])
- env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store/arm'])
+ env.Append(LIBPATH=[vc_base_path + 'lib/store/arm'])
angle_build_cmd += "ARM"
@@ -92,7 +94,7 @@ def configure(env):
env.Append(CPPFLAGS=['/DPNG_ABORT=abort'])
env.Append(LINKFLAGS=['/MACHINE:X86'])
- env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store'])
+ env.Append(LIBPATH=[vc_base_path + 'lib/store'])
env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_Win32/lib'])
else:
@@ -107,10 +109,9 @@ def configure(env):
env.Append(CPPPATH=['#platform/uwp', '#drivers/windows'])
env.Append(LINKFLAGS=['/MANIFEST:NO', '/NXCOMPAT', '/DYNAMICBASE', '/WINMD', '/APPCONTAINER', '/ERRORREPORT:PROMPT', '/NOLOGO', '/TLBID:1', '/NODEFAULTLIB:"kernel32.lib"', '/NODEFAULTLIB:"ole32.lib"'])
env.Append(CPPFLAGS=['/D', '__WRL_NO_DEFAULT_LIB__', '/D', 'WIN32'])
- env.Append(CPPFLAGS=['/FU', os.environ['VCINSTALLDIR'] + 'lib/store/references/platform.winmd'])
- env.Append(CPPFLAGS=['/AI', os.environ['VCINSTALLDIR'] + 'lib/store/references'])
-
- env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store/references'])
+
+ env.Append(CPPFLAGS=['/AI', vc_base_path + 'lib/store/references'])
+ env.Append(CPPFLAGS=['/AI', vc_base_path + 'lib/x86/store/references'])
if (env["target"] == "release"):
@@ -133,7 +134,7 @@ def configure(env):
env.Append(CCFLAGS=string.split('/FS /MP /GS /wd"4453" /wd"28204" /wd"4291" /Zc:wchar_t /Gm- /fp:precise /D "_UNICODE" /D "UNICODE" /D "WINAPI_FAMILY=WINAPI_FAMILY_APP" /errorReport:prompt /WX- /Zc:forScope /Gd /EHsc /nologo'))
env.Append(CXXFLAGS=string.split('/ZW /FS'))
- env.Append(CCFLAGS=['/AI', os.environ['VCINSTALLDIR'] + '\\vcpackages', '/AI', os.environ['WINDOWSSDKDIR'] + '\\References\\CommonConfiguration\\Neutral'])
+ env.Append(CCFLAGS=['/AI', vc_base_path + '\\vcpackages', '/AI', os.environ['WINDOWSSDKDIR'] + '\\References\\CommonConfiguration\\Neutral'])
env["PROGSUFFIX"] = "." + arch + env["PROGSUFFIX"]
env["OBJSUFFIX"] = "." + arch + env["OBJSUFFIX"]
diff --git a/platform/uwp/gl_context_egl.cpp b/platform/uwp/gl_context_egl.cpp
index d79ce75db5..57c4c5d572 100644
--- a/platform/uwp/gl_context_egl.cpp
+++ b/platform/uwp/gl_context_egl.cpp
@@ -97,7 +97,7 @@ Error ContextEGL::initialize() {
EGLContext context = EGL_NO_CONTEXT;
EGLSurface surface = EGL_NO_SURFACE;
EGLConfig config = nullptr;
- EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE };
+ EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE, EGL_NONE };
try {
diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp
index 47f4b3f3c8..28aaf9161b 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -330,16 +330,9 @@ String OSUWP::get_clipboard() const {
return "";
};
-void OSUWP::input_event(Ref<InputEvent> &p_event) {
+void OSUWP::input_event(const Ref<InputEvent> &p_event) {
input->parse_input_event(p_event);
-
- if (p_event.type == Ref<InputEvent>::MOUSE_BUTTON && p_event->is_pressed() && p_event->get_button_index() > 3) {
-
- //send release for mouse wheel
- p_event->is_pressed() = false;
- input->parse_input_event(p_event);
- }
};
void OSUWP::delete_main_loop() {
@@ -663,16 +656,18 @@ void OSUWP::process_key_events() {
for (int i = 0; i < key_event_pos; i++) {
KeyEvent &kev = key_event_buffer[i];
- Ref<InputEvent> iev;
-
- iev.type = Ref<InputEvent>::KEY;
- iev.key.mod = kev.mod_state;
- iev->is_echo() = kev.echo;
- iev->get_scancode() = kev->get_scancode();
- iev.key.unicode = kev.unicode;
- iev->is_pressed() = kev->is_pressed();
- input_event(iev);
+ Ref<InputEventKey> key_event;
+ key_event.instance();
+ key_event->set_alt(kev.alt);
+ key_event->set_shift(kev.shift);
+ key_event->set_control(kev.control);
+ key_event->set_echo(kev.echo);
+ key_event->set_scancode(kev.scancode);
+ key_event->set_unicode(kev.unicode);
+ key_event->set_pressed(kev.pressed);
+
+ input_event(key_event);
}
key_event_pos = 0;
}
diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h
index d2a51aad4c..45b8eefdee 100644
--- a/platform/uwp/os_uwp.h
+++ b/platform/uwp/os_uwp.h
@@ -63,7 +63,7 @@ public:
CHAR_EVENT_MESSAGE
};
- InputModifierState mod_state;
+ bool alt, shift, control;
MessageType type;
bool pressed;
unsigned int scancode;
@@ -257,7 +257,7 @@ public:
virtual bool get_swap_ok_cancel() { return true; }
- void input_event(Ref<InputEvent> &p_event);
+ void input_event(const Ref<InputEvent> &p_event);
virtual PowerState get_power_state();
virtual int get_power_seconds_left();