summaryrefslogtreecommitdiff
path: root/platform/uwp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2017-03-05 16:44:50 +0100
committerRémi Verschelde <rverschelde@gmail.com>2017-03-05 16:44:50 +0100
commit5dbf1809c6e3e905b94b8764e99491e608122261 (patch)
tree5e5a5360db15d86d59ec8c6e4f7eb511388c5a9a /platform/uwp
parent45438e9918d421b244bfd7776a30e67dc7f2d3e3 (diff)
A Whole New World (clang-format edition)
I can show you the code Pretty, with proper whitespace Tell me, coder, now when did You last write readable code? I can open your eyes Make you see your bad indent Force you to respect the style The core devs agreed upon A whole new world A new fantastic code format A de facto standard With some sugar Enforced with clang-format A whole new world A dazzling style we all dreamed of And when we read it through It's crystal clear That now we're in a whole new world of code
Diffstat (limited to 'platform/uwp')
-rw-r--r--platform/uwp/app.cpp281
-rw-r--r--platform/uwp/export/export.cpp31
-rw-r--r--platform/uwp/gl_context_egl.cpp84
-rw-r--r--platform/uwp/gl_context_egl.h11
-rw-r--r--platform/uwp/joypad_uwp.cpp36
-rw-r--r--platform/uwp/joypad_uwp.h11
-rw-r--r--platform/uwp/os_uwp.cpp313
-rw-r--r--platform/uwp/os_uwp.h116
-rw-r--r--platform/uwp/thread_uwp.cpp15
-rw-r--r--platform/uwp/thread_uwp.h11
10 files changed, 397 insertions, 512 deletions
diff --git a/platform/uwp/app.cpp b/platform/uwp/app.cpp
index 0bae148c6b..35b25b1de5 100644
--- a/platform/uwp/app.cpp
+++ b/platform/uwp/app.cpp
@@ -32,10 +32,10 @@
#include "app.h"
-#include "main/main.h"
#include "core/os/dir_access.h"
#include "core/os/file_access.h"
#include "core/os/keyboard.h"
+#include "main/main.h"
#include "platform/windows/key_mapping_win.h"
@@ -56,126 +56,113 @@ using namespace Microsoft::WRL;
using namespace GodotUWP;
// Helper to convert a length in device-independent pixels (DIPs) to a length in physical pixels.
-inline float ConvertDipsToPixels(float dips, float dpi)
-{
- static const float dipsPerInch = 96.0f;
- return floor(dips * dpi / dipsPerInch + 0.5f); // Round to nearest integer.
+inline float ConvertDipsToPixels(float dips, float dpi) {
+ static const float dipsPerInch = 96.0f;
+ return floor(dips * dpi / dipsPerInch + 0.5f); // Round to nearest integer.
}
// Implementation of the IFrameworkViewSource interface, necessary to run our app.
-ref class GodotUWPViewSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
-{
+ref class GodotUWPViewSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource {
public:
- virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView()
- {
- return ref new App();
- }
+ virtual Windows::ApplicationModel::Core::IFrameworkView ^ CreateView() {
+ return ref new App();
+ }
};
// The main function creates an IFrameworkViewSource for our app, and runs the app.
-[Platform::MTAThread]
-int main(Platform::Array<Platform::String^>^)
-{
- auto godotApplicationSource = ref new GodotUWPViewSource();
- CoreApplication::Run(godotApplicationSource);
- return 0;
+[Platform::MTAThread] int main(Platform::Array<Platform::String ^> ^) {
+ auto godotApplicationSource = ref new GodotUWPViewSource();
+ CoreApplication::Run(godotApplicationSource);
+ return 0;
}
-App::App() :
- mWindowClosed(false),
- mWindowVisible(true),
- mWindowWidth(0),
- mWindowHeight(0),
- mEglDisplay(EGL_NO_DISPLAY),
- mEglContext(EGL_NO_CONTEXT),
- mEglSurface(EGL_NO_SURFACE),
- number_of_contacts(0)
-{
+App::App()
+ : mWindowClosed(false),
+ mWindowVisible(true),
+ mWindowWidth(0),
+ mWindowHeight(0),
+ mEglDisplay(EGL_NO_DISPLAY),
+ mEglContext(EGL_NO_CONTEXT),
+ mEglSurface(EGL_NO_SURFACE),
+ number_of_contacts(0) {
}
// The first method called when the IFrameworkView is being created.
-void App::Initialize(CoreApplicationView^ applicationView)
-{
- // Register event handlers for app lifecycle. This example includes Activated, so that we
- // can make the CoreWindow active and start rendering on the window.
- applicationView->Activated +=
- ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &App::OnActivated);
+void App::Initialize(CoreApplicationView ^ applicationView) {
+ // Register event handlers for app lifecycle. This example includes Activated, so that we
+ // can make the CoreWindow active and start rendering on the window.
+ applicationView->Activated +=
+ ref new TypedEventHandler<CoreApplicationView ^, IActivatedEventArgs ^>(this, &App::OnActivated);
- // Logic for other event handlers could go here.
- // Information about the Suspending and Resuming event handlers can be found here:
- // http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh994930.aspx
+ // Logic for other event handlers could go here.
+ // Information about the Suspending and Resuming event handlers can be found here:
+ // http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh994930.aspx
os = new OSUWP;
-
}
// Called when the CoreWindow object is created (or re-created).
-void App::SetWindow(CoreWindow^ p_window)
-{
+void App::SetWindow(CoreWindow ^ p_window) {
window = p_window;
- window->VisibilityChanged +=
- ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &App::OnVisibilityChanged);
+ window->VisibilityChanged +=
+ ref new TypedEventHandler<CoreWindow ^, VisibilityChangedEventArgs ^>(this, &App::OnVisibilityChanged);
- window->Closed +=
- ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &App::OnWindowClosed);
+ window->Closed +=
+ ref new TypedEventHandler<CoreWindow ^, CoreWindowEventArgs ^>(this, &App::OnWindowClosed);
- window->SizeChanged +=
- ref new TypedEventHandler<CoreWindow^, WindowSizeChangedEventArgs^>(this, &App::OnWindowSizeChanged);
+ window->SizeChanged +=
+ ref new TypedEventHandler<CoreWindow ^, WindowSizeChangedEventArgs ^>(this, &App::OnWindowSizeChanged);
#if !(WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
- // Disable all pointer visual feedback for better performance when touching.
- // This is not supported on Windows Phone applications.
- auto pointerVisualizationSettings = PointerVisualizationSettings::GetForCurrentView();
- pointerVisualizationSettings->IsContactFeedbackEnabled = false;
- pointerVisualizationSettings->IsBarrelButtonFeedbackEnabled = false;
+ // Disable all pointer visual feedback for better performance when touching.
+ // This is not supported on Windows Phone applications.
+ auto pointerVisualizationSettings = PointerVisualizationSettings::GetForCurrentView();
+ pointerVisualizationSettings->IsContactFeedbackEnabled = false;
+ pointerVisualizationSettings->IsBarrelButtonFeedbackEnabled = false;
#endif
-
window->PointerPressed +=
- ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &App::OnPointerPressed);
+ ref new TypedEventHandler<CoreWindow ^, PointerEventArgs ^>(this, &App::OnPointerPressed);
window->PointerMoved +=
- ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &App::OnPointerMoved);
+ ref new TypedEventHandler<CoreWindow ^, PointerEventArgs ^>(this, &App::OnPointerMoved);
window->PointerReleased +=
- ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &App::OnPointerReleased);
+ ref new TypedEventHandler<CoreWindow ^, PointerEventArgs ^>(this, &App::OnPointerReleased);
window->PointerWheelChanged +=
- ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &App::OnPointerWheelChanged);
+ ref new TypedEventHandler<CoreWindow ^, PointerEventArgs ^>(this, &App::OnPointerWheelChanged);
mouseChangedNotifier = SignalNotifier::AttachToEvent(L"os_mouse_mode_changed", ref new SignalHandler(
- this, &App::OnMouseModeChanged
- ));
+ this, &App::OnMouseModeChanged));
mouseChangedNotifier->Enable();
window->CharacterReceived +=
- ref new TypedEventHandler<CoreWindow^, CharacterReceivedEventArgs^>(this, &App::OnCharacterReceived);
+ ref new TypedEventHandler<CoreWindow ^, CharacterReceivedEventArgs ^>(this, &App::OnCharacterReceived);
window->KeyDown +=
- ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &App::OnKeyDown);
+ ref new TypedEventHandler<CoreWindow ^, KeyEventArgs ^>(this, &App::OnKeyDown);
window->KeyUp +=
- ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &App::OnKeyUp);
-
+ ref new TypedEventHandler<CoreWindow ^, KeyEventArgs ^>(this, &App::OnKeyUp);
unsigned int argc;
- char** argv = get_command_line(&argc);
+ char **argv = get_command_line(&argc);
Main::setup("uwp", argc, argv, false);
// The CoreWindow has been created, so EGL can be initialized.
- ContextEGL* context = memnew(ContextEGL(window));
+ ContextEGL *context = memnew(ContextEGL(window));
os->set_gl_context(context);
UpdateWindowSize(Size(window->Bounds.Width, window->Bounds.Height));
Main::setup2();
}
-static int _get_button(Windows::UI::Input::PointerPoint ^pt) {
+static int _get_button(Windows::UI::Input::PointerPoint ^ pt) {
using namespace Windows::UI::Input;
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
return BUTTON_LEFT;
#else
- switch (pt->Properties->PointerUpdateKind)
- {
+ switch (pt->Properties->PointerUpdateKind) {
case PointerUpdateKind::LeftButtonPressed:
case PointerUpdateKind::LeftButtonReleased:
return BUTTON_LEFT;
@@ -204,7 +191,7 @@ static int _get_button(Windows::UI::Input::PointerPoint ^pt) {
return 0;
};
-static bool _is_touch(Windows::UI::Input::PointerPoint ^pointerPoint) {
+static bool _is_touch(Windows::UI::Input::PointerPoint ^ pointerPoint) {
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
return true;
#else
@@ -219,20 +206,18 @@ static bool _is_touch(Windows::UI::Input::PointerPoint ^pointerPoint) {
#endif
}
-
-static Windows::Foundation::Point _get_pixel_position(CoreWindow^ window, Windows::Foundation::Point rawPosition, OS* os) {
+static Windows::Foundation::Point _get_pixel_position(CoreWindow ^ window, Windows::Foundation::Point rawPosition, OS *os) {
Windows::Foundation::Point outputPosition;
- // Compute coordinates normalized from 0..1.
- // If the coordinates need to be sized to the SDL window,
- // we'll do that after.
- #if 1 || WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
+// Compute coordinates normalized from 0..1.
+// If the coordinates need to be sized to the SDL window,
+// we'll do that after.
+#if 1 || WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
outputPosition.X = rawPosition.X / window->Bounds.Width;
outputPosition.Y = rawPosition.Y / window->Bounds.Height;
- #else
- switch (DisplayProperties::CurrentOrientation)
- {
+#else
+ switch (DisplayProperties::CurrentOrientation) {
case DisplayOrientations::Portrait:
outputPosition.X = rawPosition.X / window->Bounds.Width;
outputPosition.Y = rawPosition.Y / window->Bounds.Height;
@@ -252,7 +237,7 @@ static Windows::Foundation::Point _get_pixel_position(CoreWindow^ window, Window
default:
break;
}
- #endif
+#endif
OS::VideoMode vm = os->get_video_mode();
outputPosition.X *= vm.width;
@@ -266,9 +251,9 @@ static int _get_finger(uint32_t p_touch_id) {
return p_touch_id % 31; // for now
};
-void App::pointer_event(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args, bool p_pressed, bool p_is_wheel) {
+void App::pointer_event(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args, bool p_pressed, bool p_is_wheel) {
- Windows::UI::Input::PointerPoint ^point = args->CurrentPoint;
+ Windows::UI::Input::PointerPoint ^ point = args->CurrentPoint;
Windows::Foundation::Point pos = _get_pixel_position(window, point->Position, os);
int but = _get_button(point);
if (_is_touch(point)) {
@@ -314,56 +299,51 @@ void App::pointer_event(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core
os->input_event(event);
};
-
-void App::OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args) {
+void App::OnPointerPressed(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) {
number_of_contacts++;
pointer_event(sender, args, true);
};
-
-void App::OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args) {
+void App::OnPointerReleased(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) {
number_of_contacts--;
pointer_event(sender, args, false);
};
-void App::OnPointerWheelChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args) {
+void App::OnPointerWheelChanged(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) {
pointer_event(sender, args, true, true);
}
-void App::OnMouseModeChanged(Windows::System::Threading::Core::SignalNotifier^ signalNotifier, bool timedOut) {
+void App::OnMouseModeChanged(Windows::System::Threading::Core::SignalNotifier ^ signalNotifier, bool timedOut) {
OS::MouseMode mode = os->get_mouse_mode();
- SignalNotifier^ notifier = mouseChangedNotifier;
+ SignalNotifier ^ notifier = mouseChangedNotifier;
window->Dispatcher->RunAsync(
- CoreDispatcherPriority::High,
- ref new DispatchedHandler(
- [mode, notifier, this]() {
- if (mode == OS::MOUSE_MODE_CAPTURED) {
+ CoreDispatcherPriority::High,
+ ref new DispatchedHandler(
+ [mode, notifier, this]() {
+ if (mode == OS::MOUSE_MODE_CAPTURED) {
- this->MouseMovedToken = MouseDevice::GetForCurrentView()->MouseMoved +=
- ref new TypedEventHandler<MouseDevice^, MouseEventArgs^>(this, &App::OnMouseMoved);
+ this->MouseMovedToken = MouseDevice::GetForCurrentView()->MouseMoved +=
+ ref new TypedEventHandler<MouseDevice ^, MouseEventArgs ^>(this, &App::OnMouseMoved);
- } else {
+ } else {
- MouseDevice::GetForCurrentView()->MouseMoved -= MouseMovedToken;
+ MouseDevice::GetForCurrentView()->MouseMoved -= MouseMovedToken;
+ }
- }
-
- notifier->Enable();
- }));
+ notifier->Enable();
+ }));
ResetEvent(os->mouse_mode_changed);
-
-
}
-void App::OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args) {
+void App::OnPointerMoved(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) {
- Windows::UI::Input::PointerPoint ^point = args->CurrentPoint;
+ Windows::UI::Input::PointerPoint ^ point = args->CurrentPoint;
Windows::Foundation::Point pos = _get_pixel_position(window, point->Position, os);
if (point->IsInContact && _is_touch(point)) {
@@ -400,7 +380,6 @@ void App::OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Cor
last_mouse_pos = pos;
os->input_event(event);
-
}
void App::OnMouseMoved(MouseDevice ^ mouse_device, MouseEventArgs ^ args) {
@@ -428,8 +407,7 @@ void App::OnMouseMoved(MouseDevice ^ mouse_device, MouseEventArgs ^ args) {
os->input_event(event);
}
-void App::key_event(Windows::UI::Core::CoreWindow^ sender, bool p_pressed, Windows::UI::Core::KeyEventArgs^ key_args, Windows::UI::Core::CharacterReceivedEventArgs^ char_args)
-{
+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;
@@ -442,9 +420,9 @@ void App::key_event(Windows::UI::Core::CoreWindow^ sender, bool p_pressed, Windo
ke.mod_state = mod;
ke.pressed = p_pressed;
-
+
if (key_args != nullptr) {
-
+
ke.type = OSUWP::KeyEvent::MessageType::KEY_EVENT_MESSAGE;
ke.unicode = 0;
ke.scancode = KeyMappingWindows::get_keysym((unsigned int)key_args->VirtualKey);
@@ -459,92 +437,78 @@ void App::key_event(Windows::UI::Core::CoreWindow^ sender, bool p_pressed, Windo
}
os->queue_key_event(ke);
-
}
-void App::OnKeyDown(CoreWindow^ sender, KeyEventArgs^ args)
-{
+void App::OnKeyDown(CoreWindow ^ sender, KeyEventArgs ^ args) {
key_event(sender, true, args);
}
-void App::OnKeyUp(CoreWindow^ sender, KeyEventArgs^ args)
-{
+void App::OnKeyUp(CoreWindow ^ sender, KeyEventArgs ^ args) {
key_event(sender, false, args);
}
-void App::OnCharacterReceived(CoreWindow^ sender, CharacterReceivedEventArgs^ args)
-{
+void App::OnCharacterReceived(CoreWindow ^ sender, CharacterReceivedEventArgs ^ args) {
key_event(sender, true, nullptr, args);
}
-
// Initializes scene resources
-void App::Load(Platform::String^ entryPoint)
-{
-
+void App::Load(Platform::String ^ entryPoint) {
}
// This method is called after the window becomes active.
-void App::Run()
-{
+void App::Run() {
if (Main::start())
os->run();
}
// Terminate events do not cause Uninitialize to be called. It will be called if your IFrameworkView
// class is torn down while the app is in the foreground.
-void App::Uninitialize()
-{
+void App::Uninitialize() {
Main::cleanup();
delete os;
}
// Application lifecycle event handler.
-void App::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)
-{
- // Run() won't start until the CoreWindow is activated.
- CoreWindow::GetForCurrentThread()->Activate();
+void App::OnActivated(CoreApplicationView ^ applicationView, IActivatedEventArgs ^ args) {
+ // Run() won't start until the CoreWindow is activated.
+ CoreWindow::GetForCurrentThread()->Activate();
}
// Window event handlers.
-void App::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
-{
- mWindowVisible = args->Visible;
+void App::OnVisibilityChanged(CoreWindow ^ sender, VisibilityChangedEventArgs ^ args) {
+ mWindowVisible = args->Visible;
}
-void App::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
-{
- mWindowClosed = true;
+void App::OnWindowClosed(CoreWindow ^ sender, CoreWindowEventArgs ^ args) {
+ mWindowClosed = true;
}
-void App::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args)
-{
+void App::OnWindowSizeChanged(CoreWindow ^ sender, WindowSizeChangedEventArgs ^ args) {
#if (WINAPI_FAMILY == WINAPI_FAMILY_PC_APP)
- // On Windows 8.1, apps are resized when they are snapped alongside other apps, or when the device is rotated.
- // The default framebuffer will be automatically resized when either of these occur.
- // In particular, on a 90 degree rotation, the default framebuffer's width and height will switch.
- UpdateWindowSize(args->Size);
+ // On Windows 8.1, apps are resized when they are snapped alongside other apps, or when the device is rotated.
+ // The default framebuffer will be automatically resized when either of these occur.
+ // In particular, on a 90 degree rotation, the default framebuffer's width and height will switch.
+ UpdateWindowSize(args->Size);
#else if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
- // On Windows Phone 8.1, the window size changes when the device is rotated.
- // The default framebuffer will not be automatically resized when this occurs.
- // It is therefore up to the app to handle rotation-specific logic in its rendering code.
+ // On Windows Phone 8.1, the window size changes when the device is rotated.
+ // The default framebuffer will not be automatically resized when this occurs.
+ // It is therefore up to the app to handle rotation-specific logic in its rendering code.
//os->screen_size_changed();
UpdateWindowSize(args->Size);
#endif
}
-void App::UpdateWindowSize(Size size)
-{
+void App::UpdateWindowSize(Size size) {
float dpi;
#if (WINAPI_FAMILY == WINAPI_FAMILY_PC_APP)
- DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView();
+ DisplayInformation ^ currentDisplayInformation = DisplayInformation::GetForCurrentView();
dpi = currentDisplayInformation->LogicalDpi;
#else if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
dpi = DisplayProperties::LogicalDpi;
#endif
Size pixelSize(ConvertDipsToPixels(size.Width, dpi), ConvertDipsToPixels(size.Height, dpi));
- mWindowWidth = static_cast<GLsizei>(pixelSize.Width);
- mWindowHeight = static_cast<GLsizei>(pixelSize.Height);
+ mWindowWidth = static_cast<GLsizei>(pixelSize.Width);
+ mWindowHeight = static_cast<GLsizei>(pixelSize.Height);
OS::VideoMode vm;
vm.width = mWindowWidth;
@@ -554,12 +518,12 @@ void App::UpdateWindowSize(Size size)
os->set_video_mode(vm);
}
-char** App::get_command_line(unsigned int* out_argc) {
+char **App::get_command_line(unsigned int *out_argc) {
- static char* fail_cl[] = { "-path", "game", NULL };
+ static char *fail_cl[] = { "-path", "game", NULL };
*out_argc = 2;
- FILE* f = _wfopen(L"__cl__.cl", L"rb");
+ FILE *f = _wfopen(L"__cl__.cl", L"rb");
if (f == NULL) {
@@ -573,12 +537,12 @@ char** App::get_command_line(unsigned int* out_argc) {
uint8_t len[4];
int r = fread(len, sizeof(uint8_t), 4, f);
- Platform::Collections::Vector<Platform::String^> cl;
+ Platform::Collections::Vector<Platform::String ^> cl;
if (r < 4) {
fclose(f);
wprintf(L"Wrong cmdline length.");
- return(fail_cl);
+ return (fail_cl);
}
int argc = READ_LE_4(len);
@@ -590,7 +554,7 @@ char** App::get_command_line(unsigned int* out_argc) {
if (r < 4) {
fclose(f);
wprintf(L"Wrong cmdline param length.");
- return(fail_cl);
+ return (fail_cl);
}
int strlen = READ_LE_4(len);
@@ -598,17 +562,17 @@ char** App::get_command_line(unsigned int* out_argc) {
if (strlen > CMD_MAX_LEN) {
fclose(f);
wprintf(L"Wrong command length.");
- return(fail_cl);
+ return (fail_cl);
}
- char* arg = new char[strlen + 1];
+ char *arg = new char[strlen + 1];
r = fread(arg, sizeof(char), strlen, f);
arg[strlen] = '\0';
if (r == strlen) {
int warg_size = MultiByteToWideChar(CP_UTF8, 0, arg, -1, NULL, 0);
- wchar_t* warg = new wchar_t[warg_size];
+ wchar_t *warg = new wchar_t[warg_size];
MultiByteToWideChar(CP_UTF8, 0, arg, -1, warg, warg_size);
@@ -619,7 +583,7 @@ char** App::get_command_line(unsigned int* out_argc) {
delete[] arg;
fclose(f);
wprintf(L"Error reading command.");
- return(fail_cl);
+ return (fail_cl);
}
}
@@ -628,17 +592,16 @@ char** App::get_command_line(unsigned int* out_argc) {
fclose(f);
- char** ret = new char*[cl.Size + 1];
+ char **ret = new char *[cl.Size + 1];
for (int i = 0; i < cl.Size; i++) {
int arg_size = WideCharToMultiByte(CP_UTF8, 0, cl.GetAt(i)->Data(), -1, NULL, 0, NULL, NULL);
- char* arg = new char[arg_size];
+ char *arg = new char[arg_size];
WideCharToMultiByte(CP_UTF8, 0, cl.GetAt(i)->Data(), -1, arg, arg_size, NULL, NULL);
ret[i] = arg;
-
}
ret[cl.Size] = NULL;
*out_argc = cl.Size;
diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp
index 52a22a1942..a9b26056fc 100644
--- a/platform/uwp/export/export.cpp
+++ b/platform/uwp/export/export.cpp
@@ -66,21 +66,21 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*************************************************************************/
#if 0
-#include "version.h"
#include "export.h"
-#include "object.h"
+#include "bind/core_bind.h"
#include "editor/editor_import_export.h"
#include "editor/editor_node.h"
-#include "platform/uwp/logo.h"
-#include "os/file_access.h"
-#include "io/zip.h"
-#include "io/unzip.h"
-#include "io/zip_io.h"
-#include "io/sha256.h"
-#include "io/base64.h"
-#include "bind/core_bind.h"
#include "global_config.h"
+#include "io/base64.h"
#include "io/marshalls.h"
+#include "io/sha256.h"
+#include "io/unzip.h"
+#include "io/zip.h"
+#include "io/zip_io.h"
+#include "object.h"
+#include "os/file_access.h"
+#include "platform/uwp/logo.h"
+#include "version.h"
#include <zlib.h>
@@ -120,14 +120,14 @@ static const char* uwp_device_capabilites[] = {
};
#ifdef OPENSSL_ENABLED
-#include <openssl/bio.h>
#include <openssl/asn1.h>
-#include <openssl/pkcs7.h>
-#include <openssl/pkcs12.h>
-#include <openssl/err.h>
#include <openssl/asn1t.h>
-#include <openssl/x509.h>
+#include <openssl/bio.h>
+#include <openssl/err.h>
#include <openssl/ossl_typ.h>
+#include <openssl/pkcs12.h>
+#include <openssl/pkcs7.h>
+#include <openssl/x509.h>
namespace asn1 {
// https://msdn.microsoft.com/en-us/gg463180.aspx
@@ -2391,4 +2391,3 @@ void register_uwp_exporter() {
EditorImportExport::get_singleton()->add_export_platform(exporter);
#endif
}
-
diff --git a/platform/uwp/gl_context_egl.cpp b/platform/uwp/gl_context_egl.cpp
index c9c03db8a1..6c9efc26b4 100644
--- a/platform/uwp/gl_context_egl.cpp
+++ b/platform/uwp/gl_context_egl.cpp
@@ -62,8 +62,7 @@ void ContextEGL::reset() {
void ContextEGL::swap_buffers() {
- if (eglSwapBuffers(mEglDisplay, mEglSurface) != EGL_TRUE)
- {
+ if (eglSwapBuffers(mEglDisplay, mEglSurface) != EGL_TRUE) {
cleanup();
window = CoreWindow::GetForCurrentThread();
@@ -102,69 +101,61 @@ Error ContextEGL::initialize() {
try {
const EGLint displayAttributes[] =
- {
- /*EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
+ {
+ /*EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, 9,
EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, 3,
EGL_NONE,*/
- // These are the default display attributes, used to request ANGLE's D3D11 renderer.
- // eglInitialize will only succeed with these attributes if the hardware supports D3D11 Feature Level 10_0+.
- EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
-
- // EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER is an optimization that can have large performance benefits on mobile devices.
- // Its syntax is subject to change, though. Please update your Visual Studio templates if you experience compilation issues with it.
- //EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE,
-
- // EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE is an option that enables ANGLE to automatically call
- // the IDXGIDevice3::Trim method on behalf of the application when it gets suspended.
- // Calling IDXGIDevice3::Trim when an application is suspended is a Windows Store application certification requirement.
- EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE,
- EGL_NONE,
- };
+ // These are the default display attributes, used to request ANGLE's D3D11 renderer.
+ // eglInitialize will only succeed with these attributes if the hardware supports D3D11 Feature Level 10_0+.
+ EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
+
+ // EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER is an optimization that can have large performance benefits on mobile devices.
+ // Its syntax is subject to change, though. Please update your Visual Studio templates if you experience compilation issues with it.
+ //EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE,
+
+ // EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE is an option that enables ANGLE to automatically call
+ // the IDXGIDevice3::Trim method on behalf of the application when it gets suspended.
+ // Calling IDXGIDevice3::Trim when an application is suspended is a Windows Store application certification requirement.
+ EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE,
+ EGL_NONE,
+ };
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT = reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>(eglGetProcAddress("eglGetPlatformDisplayEXT"));
- if (!eglGetPlatformDisplayEXT)
- {
+ if (!eglGetPlatformDisplayEXT) {
throw Exception::CreateException(E_FAIL, L"Failed to get function eglGetPlatformDisplayEXT");
}
display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, displayAttributes);
- if (display == EGL_NO_DISPLAY)
- {
+ if (display == EGL_NO_DISPLAY) {
throw Exception::CreateException(E_FAIL, L"Failed to get default EGL display");
}
- if (eglInitialize(display, &majorVersion, &minorVersion) == EGL_FALSE)
- {
+ if (eglInitialize(display, &majorVersion, &minorVersion) == EGL_FALSE) {
throw Exception::CreateException(E_FAIL, L"Failed to initialize EGL");
}
- if (eglGetConfigs(display, NULL, 0, &numConfigs) == EGL_FALSE)
- {
+ if (eglGetConfigs(display, NULL, 0, &numConfigs) == EGL_FALSE) {
throw Exception::CreateException(E_FAIL, L"Failed to get EGLConfig count");
}
- if (eglChooseConfig(display, configAttribList, &config, 1, &numConfigs) == EGL_FALSE)
- {
+ if (eglChooseConfig(display, configAttribList, &config, 1, &numConfigs) == EGL_FALSE) {
throw Exception::CreateException(E_FAIL, L"Failed to choose first EGLConfig count");
}
- surface = eglCreateWindowSurface(display, config, reinterpret_cast<IInspectable*>(window), surfaceAttribList);
- if (surface == EGL_NO_SURFACE)
- {
+ surface = eglCreateWindowSurface(display, config, reinterpret_cast<IInspectable *>(window), surfaceAttribList);
+ if (surface == EGL_NO_SURFACE) {
throw Exception::CreateException(E_FAIL, L"Failed to create EGL fullscreen surface");
}
context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs);
- if (context == EGL_NO_CONTEXT)
- {
+ if (context == EGL_NO_CONTEXT) {
throw Exception::CreateException(E_FAIL, L"Failed to create EGL context");
}
- if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE)
- {
+ if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) {
throw Exception::CreateException(E_FAIL, L"Failed to make fullscreen EGLSurface current");
}
} catch (...) {
@@ -175,38 +166,34 @@ Error ContextEGL::initialize() {
mEglSurface = surface;
mEglContext = context;
- eglQuerySurface(display,surface,EGL_WIDTH,&width);
- eglQuerySurface(display,surface,EGL_HEIGHT,&height);
+ eglQuerySurface(display, surface, EGL_WIDTH, &width);
+ eglQuerySurface(display, surface, EGL_HEIGHT, &height);
return OK;
};
void ContextEGL::cleanup() {
- if (mEglDisplay != EGL_NO_DISPLAY && mEglSurface != EGL_NO_SURFACE)
- {
+ if (mEglDisplay != EGL_NO_DISPLAY && mEglSurface != EGL_NO_SURFACE) {
eglDestroySurface(mEglDisplay, mEglSurface);
mEglSurface = EGL_NO_SURFACE;
}
- if (mEglDisplay != EGL_NO_DISPLAY && mEglContext != EGL_NO_CONTEXT)
- {
+ if (mEglDisplay != EGL_NO_DISPLAY && mEglContext != EGL_NO_CONTEXT) {
eglDestroyContext(mEglDisplay, mEglContext);
mEglContext = EGL_NO_CONTEXT;
}
- if (mEglDisplay != EGL_NO_DISPLAY)
- {
+ if (mEglDisplay != EGL_NO_DISPLAY) {
eglTerminate(mEglDisplay);
mEglDisplay = EGL_NO_DISPLAY;
}
};
-ContextEGL::ContextEGL(CoreWindow^ p_window) :
- mEglDisplay(EGL_NO_DISPLAY),
- mEglContext(EGL_NO_CONTEXT),
- mEglSurface(EGL_NO_SURFACE)
- {
+ContextEGL::ContextEGL(CoreWindow ^ p_window)
+ : mEglDisplay(EGL_NO_DISPLAY),
+ mEglContext(EGL_NO_CONTEXT),
+ mEglSurface(EGL_NO_SURFACE) {
window = p_window;
};
@@ -215,4 +202,3 @@ ContextEGL::~ContextEGL() {
cleanup();
};
-
diff --git a/platform/uwp/gl_context_egl.h b/platform/uwp/gl_context_egl.h
index 858eaa6d12..c397c1206b 100644
--- a/platform/uwp/gl_context_egl.h
+++ b/platform/uwp/gl_context_egl.h
@@ -31,16 +31,16 @@
#include <wrl.h>
-#include "os/os.h"
#include "EGL/egl.h"
-#include "error_list.h"
#include "drivers/gl_context/context_gl.h"
+#include "error_list.h"
+#include "os/os.h"
using namespace Windows::UI::Core;
class ContextEGL : public ContextGL {
- CoreWindow^ window;
+ CoreWindow ^ window;
EGLDisplay mEglDisplay;
EGLContext mEglContext;
@@ -52,7 +52,6 @@ class ContextEGL : public ContextGL {
bool vsync;
public:
-
virtual void release_current();
virtual void make_current();
@@ -69,10 +68,8 @@ public:
void cleanup();
- ContextEGL(CoreWindow^ p_window);
+ ContextEGL(CoreWindow ^ p_window);
~ContextEGL();
-
};
#endif
-
diff --git a/platform/uwp/joypad_uwp.cpp b/platform/uwp/joypad_uwp.cpp
index 7f0837d7be..dd57ed94ae 100644
--- a/platform/uwp/joypad_uwp.cpp
+++ b/platform/uwp/joypad_uwp.cpp
@@ -35,9 +35,9 @@ using namespace Windows::Foundation;
void JoypadUWP::register_events() {
Gamepad::GamepadAdded +=
- ref new EventHandler<Gamepad^>(this, &JoypadUWP::OnGamepadAdded);
+ ref new EventHandler<Gamepad ^>(this, &JoypadUWP::OnGamepadAdded);
Gamepad::GamepadRemoved +=
- ref new EventHandler<Gamepad^>(this, &JoypadUWP::OnGamepadRemoved);
+ ref new EventHandler<Gamepad ^>(this, &JoypadUWP::OnGamepadRemoved);
}
uint32_t JoypadUWP::process_controllers(uint32_t p_last_id) {
@@ -48,26 +48,26 @@ uint32_t JoypadUWP::process_controllers(uint32_t p_last_id) {
switch (controllers[i].type) {
- case ControllerType::GAMEPAD_CONTROLLER: {
+ case ControllerType::GAMEPAD_CONTROLLER: {
- GamepadReading reading = ((Gamepad^)controllers[i].controller_reference)->GetCurrentReading();
+ GamepadReading reading = ((Gamepad ^)controllers[i].controller_reference)->GetCurrentReading();
- int button_mask = (int)GamepadButtons::Menu;
- for (int j = 0; j < 14; j++) {
+ int button_mask = (int)GamepadButtons::Menu;
+ for (int j = 0; j < 14; j++) {
- p_last_id = input->joy_button(p_last_id, controllers[i].id, j,(int)reading.Buttons & button_mask);
- button_mask *= 2;
- }
+ p_last_id = input->joy_button(p_last_id, controllers[i].id, j, (int)reading.Buttons & button_mask);
+ button_mask *= 2;
+ }
- p_last_id = input->joy_axis(p_last_id, controllers[i].id, JOY_AXIS_0, axis_correct(reading.LeftThumbstickX));
- p_last_id = input->joy_axis(p_last_id, controllers[i].id, JOY_AXIS_1, axis_correct(reading.LeftThumbstickY, true));
- p_last_id = input->joy_axis(p_last_id, controllers[i].id, JOY_AXIS_2, axis_correct(reading.RightThumbstickX));
- p_last_id = input->joy_axis(p_last_id, controllers[i].id, JOY_AXIS_3, axis_correct(reading.RightThumbstickY, true));
- p_last_id = input->joy_axis(p_last_id, controllers[i].id, JOY_AXIS_4, axis_correct(reading.LeftTrigger, false, true));
- p_last_id = input->joy_axis(p_last_id, controllers[i].id, JOY_AXIS_5, axis_correct(reading.RightTrigger, false, true));
+ p_last_id = input->joy_axis(p_last_id, controllers[i].id, JOY_AXIS_0, axis_correct(reading.LeftThumbstickX));
+ p_last_id = input->joy_axis(p_last_id, controllers[i].id, JOY_AXIS_1, axis_correct(reading.LeftThumbstickY, true));
+ p_last_id = input->joy_axis(p_last_id, controllers[i].id, JOY_AXIS_2, axis_correct(reading.RightThumbstickX));
+ p_last_id = input->joy_axis(p_last_id, controllers[i].id, JOY_AXIS_3, axis_correct(reading.RightThumbstickY, true));
+ p_last_id = input->joy_axis(p_last_id, controllers[i].id, JOY_AXIS_4, axis_correct(reading.LeftTrigger, false, true));
+ p_last_id = input->joy_axis(p_last_id, controllers[i].id, JOY_AXIS_5, axis_correct(reading.RightTrigger, false, true));
- break;
- }
+ break;
+ }
}
}
@@ -80,7 +80,7 @@ JoypadUWP::JoypadUWP() {
controllers[i].id = i;
}
-JoypadUWP::JoypadUWP(InputDefault * p_input) {
+JoypadUWP::JoypadUWP(InputDefault *p_input) {
input = p_input;
diff --git a/platform/uwp/joypad_uwp.h b/platform/uwp/joypad_uwp.h
index 5d81ac44c0..e5a961e70e 100644
--- a/platform/uwp/joypad_uwp.h
+++ b/platform/uwp/joypad_uwp.h
@@ -41,10 +41,9 @@ internal:
/* clang-format on */
JoypadUWP();
- JoypadUWP(InputDefault* p_input);
+ JoypadUWP(InputDefault *p_input);
private:
-
enum {
MAX_CONTROLLERS = 4,
};
@@ -57,7 +56,7 @@ private:
struct ControllerDevice {
- Windows::Gaming::Input::IGameController^ controller_reference;
+ Windows::Gaming::Input::IGameController ^ controller_reference;
int id;
bool connected;
@@ -72,10 +71,10 @@ private:
ControllerDevice controllers[MAX_CONTROLLERS];
- InputDefault* input;
+ InputDefault *input;
- void OnGamepadAdded(Platform::Object^ sender, Windows::Gaming::Input::Gamepad^ value);
- void OnGamepadRemoved(Platform::Object^ sender, Windows::Gaming::Input::Gamepad^ value);
+ void OnGamepadAdded(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value);
+ void OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value);
InputDefault::JoyAxis axis_correct(double p_val, bool p_negate = false, bool p_trigger = false) const;
};
diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp
index eb62164fd5..19ed2b57a3 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -26,28 +26,28 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "drivers/gles2/rasterizer_gles2.h"
#include "os_uwp.h"
-#include "os/memory_pool_dynamic_static.h"
-#include "thread_uwp.h"
-#include "drivers/windows/semaphore_windows.h"
+#include "drivers/gles2/rasterizer_gles2.h"
+#include "drivers/windows/dir_access_windows.h"
+#include "drivers/windows/file_access_windows.h"
#include "drivers/windows/mutex_windows.h"
+#include "drivers/windows/semaphore_windows.h"
#include "main/main.h"
-#include "drivers/windows/file_access_windows.h"
-#include "drivers/windows/dir_access_windows.h"
-#include "servers/visual/visual_server_raster.h"
+#include "os/memory_pool_dynamic_static.h"
#include "servers/audio_server.h"
+#include "servers/visual/visual_server_raster.h"
+#include "thread_uwp.h"
//#include "servers/visual/visual_server_wrap_mt.h"
-#include "os/memory_pool_dynamic_prealloc.h"
+#include "drivers/unix/ip_unix.h"
#include "global_config.h"
#include "io/marshalls.h"
+#include "os/memory_pool_dynamic_prealloc.h"
#include "platform/windows/packet_peer_udp_winsock.h"
#include "platform/windows/stream_peer_winsock.h"
#include "platform/windows/tcp_server_winsock.h"
-#include "drivers/unix/ip_unix.h"
-#include <wrl.h>
#include <ppltasks.h>
+#include <wrl.h>
using namespace Windows::ApplicationModel::Core;
using namespace Windows::ApplicationModel::Activation;
@@ -63,12 +63,11 @@ using namespace Windows::Devices::Sensors;
using namespace Windows::ApplicationModel::DataTransfer;
using namespace concurrency;
-
int OSUWP::get_video_driver_count() const {
return 1;
}
-const char * OSUWP::get_video_driver_name(int p_driver) const {
+const char *OSUWP::get_video_driver_name(int p_driver) const {
return "GLES2";
}
@@ -91,7 +90,7 @@ void OSUWP::set_window_size(const Size2 p_size) {
new_size.Width = p_size.width;
new_size.Height = p_size.height;
- ApplicationView^ view = ApplicationView::GetForCurrentView();
+ ApplicationView ^ view = ApplicationView::GetForCurrentView();
if (view->TryResizeView(new_size)) {
@@ -102,7 +101,7 @@ void OSUWP::set_window_size(const Size2 p_size) {
void OSUWP::set_window_fullscreen(bool p_enabled) {
- ApplicationView^ view = ApplicationView::GetForCurrentView();
+ ApplicationView ^ view = ApplicationView::GetForCurrentView();
video_mode.fullscreen = view->IsFullScreenMode;
@@ -117,7 +116,6 @@ void OSUWP::set_window_fullscreen(bool p_enabled) {
view->ExitFullScreenMode();
video_mode.fullscreen = false;
-
}
}
@@ -143,20 +141,19 @@ int OSUWP::get_audio_driver_count() const {
return AudioDriverManager::get_driver_count();
}
-const char * OSUWP::get_audio_driver_name(int p_driver) const {
+const char *OSUWP::get_audio_driver_name(int p_driver) const {
- AudioDriver* driver = AudioDriverManager::get_driver(p_driver);
- ERR_FAIL_COND_V( !driver, "" );
+ AudioDriver *driver = AudioDriverManager::get_driver(p_driver);
+ ERR_FAIL_COND_V(!driver, "");
return AudioDriverManager::get_driver(p_driver)->get_name();
}
-static MemoryPoolStatic *mempool_static=NULL;
-static MemoryPoolDynamic *mempool_dynamic=NULL;
+static MemoryPoolStatic *mempool_static = NULL;
+static MemoryPoolDynamic *mempool_dynamic = NULL;
void OSUWP::initialize_core() {
-
- last_button_state=0;
+ last_button_state = 0;
//RedirectIOToConsole();
@@ -181,16 +178,16 @@ void OSUWP::initialize_core() {
mempool_static = new MemoryPoolStaticMalloc;
#if 1
- mempool_dynamic = memnew( MemoryPoolDynamicStatic );
+ mempool_dynamic = memnew(MemoryPoolDynamicStatic);
#else
-#define DYNPOOL_SIZE 4*1024*1024
- void * buffer = malloc( DYNPOOL_SIZE );
- mempool_dynamic = memnew( MemoryPoolDynamicPrealloc(buffer,DYNPOOL_SIZE) );
+#define DYNPOOL_SIZE 4 * 1024 * 1024
+ void *buffer = malloc(DYNPOOL_SIZE);
+ mempool_dynamic = memnew(MemoryPoolDynamicPrealloc(buffer, DYNPOOL_SIZE));
#endif
- // We need to know how often the clock is updated
- if( !QueryPerformanceFrequency((LARGE_INTEGER *)&ticks_per_second) )
+ // We need to know how often the clock is updated
+ if (!QueryPerformanceFrequency((LARGE_INTEGER *)&ticks_per_second))
ticks_per_second = 1000;
// If timeAtGameStart is 0 then we get the time since
// the start of the computer when we call GetGameTime()
@@ -199,7 +196,7 @@ void OSUWP::initialize_core() {
IP_Unix::make_default();
- cursor_shape=CURSOR_ARROW;
+ cursor_shape = CURSOR_ARROW;
}
bool OSUWP::can_draw() const {
@@ -207,8 +204,7 @@ bool OSUWP::can_draw() const {
return !minimized;
};
-
-void OSUWP::set_gl_context(ContextEGL* p_context) {
+void OSUWP::set_gl_context(ContextEGL *p_context) {
gl_context = p_context;
};
@@ -218,10 +214,10 @@ void OSUWP::screen_size_changed() {
gl_context->reset();
};
-void OSUWP::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver) {
+void OSUWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
- main_loop=NULL;
- outside=true;
+ main_loop = NULL;
+ outside = true;
gl_context->initialize();
VideoMode vm;
@@ -229,7 +225,7 @@ void OSUWP::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio
vm.height = gl_context->get_window_height();
vm.resizable = false;
- ApplicationView^ view = ApplicationView::GetForCurrentView();
+ ApplicationView ^ view = ApplicationView::GetForCurrentView();
vm.fullscreen = view->IsFullScreenMode;
view->SetDesiredBoundsMode(ApplicationViewBoundsMode::UseVisible);
@@ -262,48 +258,47 @@ void OSUWP::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio
set_video_mode(vm);
gl_context->make_current();
- rasterizer = memnew( RasterizerGLES2 );
+ rasterizer = memnew(RasterizerGLES2);
- visual_server = memnew( VisualServerRaster(rasterizer) );
- if (get_render_thread_mode()!=RENDER_THREAD_UNSAFE) {
+ visual_server = memnew(VisualServerRaster(rasterizer));
+ if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
- visual_server =memnew(VisualServerWrapMT(visual_server,get_render_thread_mode()==RENDER_SEPARATE_THREAD));
+ visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD));
}
//
- physics_server = memnew( PhysicsServerSW );
+ physics_server = memnew(PhysicsServerSW);
physics_server->init();
- physics_2d_server = memnew( Physics2DServerSW );
+ physics_2d_server = memnew(Physics2DServerSW);
physics_2d_server->init();
visual_server->init();
- input = memnew( InputDefault );
+ input = memnew(InputDefault);
joypad = ref new JoypadUWP(input);
joypad->register_events();
AudioDriverManager::get_driver(p_audio_driver)->set_singleton();
- if (AudioDriverManager::get_driver(p_audio_driver)->init()!=OK) {
+ if (AudioDriverManager::get_driver(p_audio_driver)->init() != OK) {
ERR_PRINT("Initializing audio failed.");
}
- power_manager = memnew ( PowerWinRT );
+ power_manager = memnew(PowerWinRT);
managed_object->update_clipboard();
- Clipboard::ContentChanged += ref new EventHandler<Platform::Object^>(managed_object, &ManagedType::on_clipboard_changed);
+ Clipboard::ContentChanged += ref new EventHandler<Platform::Object ^>(managed_object, &ManagedType::on_clipboard_changed);
accelerometer = Accelerometer::GetDefault();
if (accelerometer != nullptr) {
// 60 FPS
accelerometer->ReportInterval = (1.0f / 60.0f) * 1000;
accelerometer->ReadingChanged +=
- ref new TypedEventHandler<Accelerometer^, AccelerometerReadingChangedEventArgs^>
- (managed_object, &ManagedType::on_accelerometer_reading_changed);
+ ref new TypedEventHandler<Accelerometer ^, AccelerometerReadingChangedEventArgs ^>(managed_object, &ManagedType::on_accelerometer_reading_changed);
}
magnetometer = Magnetometer::GetDefault();
@@ -311,8 +306,7 @@ void OSUWP::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio
// 60 FPS
magnetometer->ReportInterval = (1.0f / 60.0f) * 1000;
magnetometer->ReadingChanged +=
- ref new TypedEventHandler<Magnetometer^, MagnetometerReadingChangedEventArgs^>
- (managed_object, &ManagedType::on_magnetometer_reading_changed);
+ ref new TypedEventHandler<Magnetometer ^, MagnetometerReadingChangedEventArgs ^>(managed_object, &ManagedType::on_magnetometer_reading_changed);
}
gyrometer = Gyrometer::GetDefault();
@@ -320,8 +314,7 @@ void OSUWP::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio
// 60 FPS
gyrometer->ReportInterval = (1.0f / 60.0f) * 1000;
gyrometer->ReadingChanged +=
- ref new TypedEventHandler<Gyrometer^, GyrometerReadingChangedEventArgs^>
- (managed_object, &ManagedType::on_gyroscope_reading_changed);
+ ref new TypedEventHandler<Gyrometer ^, GyrometerReadingChangedEventArgs ^>(managed_object, &ManagedType::on_gyroscope_reading_changed);
}
_ensure_data_dir();
@@ -330,14 +323,13 @@ void OSUWP::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio
display_request->RequestActive();
set_keep_screen_on(GLOBAL_DEF("display/keep_screen_on", true));
-
}
-void OSUWP::set_clipboard(const String& p_text) {
+void OSUWP::set_clipboard(const String &p_text) {
- DataPackage^ clip = ref new DataPackage();
+ DataPackage ^ clip = ref new DataPackage();
clip->RequestedOperation = DataPackageOperation::Copy;
- clip->SetText(ref new Platform::String((const wchar_t*)p_text.c_str()));
+ clip->SetText(ref new Platform::String((const wchar_t *)p_text.c_str()));
Clipboard::SetContent(clip);
};
@@ -350,14 +342,13 @@ String OSUWP::get_clipboard() const {
return "";
};
-
void OSUWP::input_event(InputEvent &p_event) {
p_event.ID = ++last_id;
input->parse_input_event(p_event);
- if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed && p_event.mouse_button.button_index>3) {
+ if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed && p_event.mouse_button.button_index > 3) {
//send release for mouse wheel
p_event.mouse_button.pressed = false;
@@ -370,21 +361,21 @@ void OSUWP::delete_main_loop() {
if (main_loop)
memdelete(main_loop);
- main_loop=NULL;
+ main_loop = NULL;
}
-void OSUWP::set_main_loop( MainLoop * p_main_loop ) {
+void OSUWP::set_main_loop(MainLoop *p_main_loop) {
input->set_main_loop(p_main_loop);
- main_loop=p_main_loop;
+ main_loop = p_main_loop;
}
void OSUWP::finalize() {
- if(main_loop)
+ if (main_loop)
memdelete(main_loop);
- main_loop=NULL;
+ main_loop = NULL;
visual_server->finish();
memdelete(visual_server);
@@ -410,60 +401,57 @@ void OSUWP::finalize() {
memdelete(physics_2d_server);
joypad = nullptr;
-
}
void OSUWP::finalize_core() {
if (mempool_dynamic)
- memdelete( mempool_dynamic );
+ memdelete(mempool_dynamic);
delete mempool_static;
-
}
-void OSUWP::vprint(const char* p_format, va_list p_list, bool p_stderr) {
+void OSUWP::vprint(const char *p_format, va_list p_list, bool p_stderr) {
- char buf[16384+1];
- int len = vsnprintf(buf,16384,p_format,p_list);
- if (len<=0)
+ char buf[16384 + 1];
+ int len = vsnprintf(buf, 16384, p_format, p_list);
+ if (len <= 0)
return;
- buf[len]=0;
+ buf[len] = 0;
-
- int wlen = MultiByteToWideChar(CP_UTF8,0,buf,len,NULL,0);
- if (wlen<0)
+ int wlen = MultiByteToWideChar(CP_UTF8, 0, buf, len, NULL, 0);
+ if (wlen < 0)
return;
- wchar_t *wbuf = (wchar_t*)malloc((len+1)*sizeof(wchar_t));
- MultiByteToWideChar(CP_UTF8,0,buf,len,wbuf,wlen);
- wbuf[wlen]=0;
+ wchar_t *wbuf = (wchar_t *)malloc((len + 1) * sizeof(wchar_t));
+ MultiByteToWideChar(CP_UTF8, 0, buf, len, wbuf, wlen);
+ wbuf[wlen] = 0;
if (p_stderr)
- fwprintf(stderr,L"%s",wbuf);
+ fwprintf(stderr, L"%s", wbuf);
else
- wprintf(L"%s",wbuf);
+ wprintf(L"%s", wbuf);
free(wbuf);
fflush(stdout);
};
-void OSUWP::alert(const String& p_alert,const String& p_title) {
+void OSUWP::alert(const String &p_alert, const String &p_title) {
- Platform::String^ alert = ref new Platform::String(p_alert.c_str());
- Platform::String^ title = ref new Platform::String(p_title.c_str());
+ Platform::String ^ alert = ref new Platform::String(p_alert.c_str());
+ Platform::String ^ title = ref new Platform::String(p_title.c_str());
- MessageDialog^ msg = ref new MessageDialog(alert, title);
+ MessageDialog ^ msg = ref new MessageDialog(alert, title);
- UICommand^ close = ref new UICommand("Close", ref new UICommandInvokedHandler(managed_object, &OSUWP::ManagedType::alert_close));
+ UICommand ^ close = ref new UICommand("Close", ref new UICommandInvokedHandler(managed_object, &OSUWP::ManagedType::alert_close));
msg->Commands->Append(close);
msg->DefaultCommandIndex = 0;
-
+
managed_object->alert_close_handle = true;
msg->ShowAsync();
}
-void OSUWP::ManagedType::alert_close(IUICommand^ command) {
+void OSUWP::ManagedType::alert_close(IUICommand ^ command) {
alert_close_handle = false;
}
@@ -475,12 +463,11 @@ void OSUWP::ManagedType::on_clipboard_changed(Platform::Object ^ sender, Platfor
void OSUWP::ManagedType::update_clipboard() {
- DataPackageView^ data = Clipboard::GetContent();
+ DataPackageView ^ data = Clipboard::GetContent();
if (data->Contains(StandardDataFormats::Text)) {
- create_task(data->GetTextAsync()).then(
- [this](Platform::String^ clipboard_content) {
+ create_task(data->GetTextAsync()).then([this](Platform::String ^ clipboard_content) {
this->clipboard = clipboard_content;
});
@@ -488,36 +475,33 @@ void OSUWP::ManagedType::update_clipboard() {
}
void OSUWP::ManagedType::on_accelerometer_reading_changed(Accelerometer ^ sender, AccelerometerReadingChangedEventArgs ^ args) {
-
- AccelerometerReading^ reading = args->Reading;
+
+ AccelerometerReading ^ reading = args->Reading;
os->input->set_accelerometer(Vector3(
- reading->AccelerationX,
- reading->AccelerationY,
- reading->AccelerationZ
- ));
+ reading->AccelerationX,
+ reading->AccelerationY,
+ reading->AccelerationZ));
}
void OSUWP::ManagedType::on_magnetometer_reading_changed(Magnetometer ^ sender, MagnetometerReadingChangedEventArgs ^ args) {
- MagnetometerReading^ reading = args->Reading;
+ MagnetometerReading ^ reading = args->Reading;
os->input->set_magnetometer(Vector3(
- reading->MagneticFieldX,
- reading->MagneticFieldY,
- reading->MagneticFieldZ
- ));
+ reading->MagneticFieldX,
+ reading->MagneticFieldY,
+ reading->MagneticFieldZ));
}
void OSUWP::ManagedType::on_gyroscope_reading_changed(Gyrometer ^ sender, GyrometerReadingChangedEventArgs ^ args) {
- GyrometerReading^ reading = args->Reading;
+ GyrometerReading ^ reading = args->Reading;
os->input->set_magnetometer(Vector3(
- reading->AngularVelocityX,
- reading->AngularVelocityY,
- reading->AngularVelocityZ
- ));
+ reading->AngularVelocityX,
+ reading->AngularVelocityY,
+ reading->AngularVelocityZ));
}
void OSUWP::set_mouse_mode(MouseMode p_mode) {
@@ -529,7 +513,6 @@ void OSUWP::set_mouse_mode(MouseMode p_mode) {
} else {
CoreWindow::GetForCurrentThread()->ReleasePointerCapture();
-
}
if (p_mode == MouseMode::MOUSE_MODE_CAPTURED || p_mode == MouseMode::MOUSE_MODE_HIDDEN) {
@@ -546,13 +529,11 @@ void OSUWP::set_mouse_mode(MouseMode p_mode) {
SetEvent(mouse_mode_changed);
}
-OSUWP::MouseMode OSUWP::get_mouse_mode() const{
+OSUWP::MouseMode OSUWP::get_mouse_mode() const {
return mouse_mode;
}
-
-
Point2 OSUWP::get_mouse_pos() const {
return Point2(old_x, old_y);
@@ -563,11 +544,10 @@ int OSUWP::get_mouse_button_state() const {
return last_button_state;
}
-void OSUWP::set_window_title(const String& p_title) {
-
+void OSUWP::set_window_title(const String &p_title) {
}
-void OSUWP::set_video_mode(const VideoMode& p_video_mode,int p_screen) {
+void OSUWP::set_video_mode(const VideoMode &p_video_mode, int p_screen) {
video_mode = p_video_mode;
}
@@ -575,20 +555,18 @@ OS::VideoMode OSUWP::get_video_mode(int p_screen) const {
return video_mode;
}
-void OSUWP::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const {
-
-
+void OSUWP::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) const {
}
-void OSUWP::print_error(const char* p_function, const char* p_file, int p_line, const char* p_code, const char* p_rationale, ErrorType p_type) {
+void OSUWP::print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type) {
- const char* err_details;
+ const char *err_details;
if (p_rationale && p_rationale[0])
err_details = p_rationale;
else
err_details = p_code;
- switch(p_type) {
+ switch (p_type) {
case ERR_ERROR:
print("ERROR: %s: %s\n", p_function, err_details);
print(" At: %s:%i\n", p_file, p_line);
@@ -604,7 +582,6 @@ void OSUWP::print_error(const char* p_function, const char* p_file, int p_line,
}
}
-
String OSUWP::get_name() {
return "UWP";
@@ -619,11 +596,11 @@ OS::Date OSUWP::get_date(bool utc) const {
GetLocalTime(&systemtime);
Date date;
- date.day=systemtime.wDay;
- date.month=Month(systemtime.wMonth);
- date.weekday=Weekday(systemtime.wDayOfWeek);
- date.year=systemtime.wYear;
- date.dst=false;
+ date.day = systemtime.wDay;
+ date.month = Month(systemtime.wMonth);
+ date.weekday = Weekday(systemtime.wDayOfWeek);
+ date.year = systemtime.wYear;
+ date.dst = false;
return date;
}
OS::Time OSUWP::get_time(bool utc) const {
@@ -635,9 +612,9 @@ OS::Time OSUWP::get_time(bool utc) const {
GetLocalTime(&systemtime);
Time time;
- time.hour=systemtime.wHour;
- time.min=systemtime.wMinute;
- time.sec=systemtime.wSecond;
+ time.hour = systemtime.wHour;
+ time.min = systemtime.wMinute;
+ time.sec = systemtime.wSecond;
return time;
}
@@ -677,7 +654,7 @@ uint64_t OSUWP::get_unix_time() const {
FILETIME fep;
SystemTimeToFileTime(&ep, &fep);
- return (*(uint64_t*)&ft - *(uint64_t*)&fep) / 10000000;
+ return (*(uint64_t *)&ft - *(uint64_t *)&fep) / 10000000;
};
void OSUWP::delay_usec(uint32_t p_usec) const {
@@ -686,7 +663,6 @@ void OSUWP::delay_usec(uint32_t p_usec) const {
// no Sleep()
WaitForSingleObjectEx(GetCurrentThread(), msec, false);
-
}
uint64_t OSUWP::get_ticks_usec() const {
@@ -702,15 +678,13 @@ uint64_t OSUWP::get_ticks_usec() const {
return time;
}
-
void OSUWP::process_events() {
last_id = joypad->process_controllers(last_id);
process_key_events();
}
-void OSUWP::process_key_events()
-{
+void OSUWP::process_key_events() {
for (int i = 0; i < key_event_pos; i++) {
@@ -725,13 +699,11 @@ void OSUWP::process_key_events()
iev.key.pressed = kev.pressed;
input_event(iev);
-
}
key_event_pos = 0;
}
-void OSUWP::queue_key_event(KeyEvent & p_event)
-{
+void OSUWP::queue_key_event(KeyEvent &p_event) {
// This merges Char events with the previous Key event, so
// the unicode can be retrieved without sending duplicate events.
if (p_event.type == KeyEvent::MessageType::CHAR_EVENT_MESSAGE && key_event_pos > 0) {
@@ -780,17 +752,17 @@ void OSUWP::set_cursor_shape(CursorShape p_shape) {
cursor_shape = p_shape;
}
-Error OSUWP::execute(const String& p_path, const List<String>& p_arguments,bool p_blocking,ProcessID *r_child_id,String* r_pipe,int *r_exitcode) {
+Error OSUWP::execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode) {
return FAILED;
};
-Error OSUWP::kill(const ProcessID& p_pid) {
+Error OSUWP::kill(const ProcessID &p_pid) {
return FAILED;
};
-Error OSUWP::set_cwd(const String& p_cwd) {
+Error OSUWP::set_cwd(const String &p_cwd) {
return FAILED;
}
@@ -800,17 +772,15 @@ String OSUWP::get_executable_path() const {
return "";
}
-void OSUWP::set_icon(const Image& p_icon) {
-
+void OSUWP::set_icon(const Image &p_icon) {
}
-
-bool OSUWP::has_environment(const String& p_var) const {
+bool OSUWP::has_environment(const String &p_var) const {
return false;
};
-String OSUWP::get_environment(const String& p_var) const {
+String OSUWP::get_environment(const String &p_var) const {
return "";
};
@@ -820,9 +790,7 @@ String OSUWP::get_stdin_string(bool p_block) {
return String();
}
-
void OSUWP::move_window_to_foreground() {
-
}
Error OSUWP::shell_open(String p_uri) {
@@ -830,13 +798,12 @@ Error OSUWP::shell_open(String p_uri) {
return FAILED;
}
-
String OSUWP::get_locale() const {
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP // this should work on phone 8.1, but it doesn't
return "en";
#else
- Platform::String ^language = Windows::Globalization::Language::CurrentInputMethodLanguageTag;
+ Platform::String ^ language = Windows::Globalization::Language::CurrentInputMethodLanguageTag;
return String(language->Data()).replace("-", "_");
#endif
}
@@ -858,7 +825,7 @@ void OSUWP::swap_buffers() {
bool OSUWP::has_touchscreen_ui_hint() const {
- TouchCapabilities^ tc = ref new TouchCapabilities();
+ TouchCapabilities ^ tc = ref new TouchCapabilities();
return tc->TouchPresent != 0 || UIViewSettings::GetForCurrentView()->UserInteractionMode == UserInteractionMode::Touch;
}
@@ -867,19 +834,18 @@ bool OSUWP::has_virtual_keyboard() const {
return UIViewSettings::GetForCurrentView()->UserInteractionMode == UserInteractionMode::Touch;
}
-void OSUWP::show_virtual_keyboard(const String & p_existing_text, const Rect2 & p_screen_rect) {
+void OSUWP::show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect) {
- InputPane^ pane = InputPane::GetForCurrentView();
+ InputPane ^ pane = InputPane::GetForCurrentView();
pane->TryShow();
}
void OSUWP::hide_virtual_keyboard() {
- InputPane^ pane = InputPane::GetForCurrentView();
+ InputPane ^ pane = InputPane::GetForCurrentView();
pane->TryHide();
}
-
void OSUWP::run() {
if (!main_loop)
@@ -887,35 +853,31 @@ void OSUWP::run() {
main_loop->init();
- uint64_t last_ticks=get_ticks_usec();
+ uint64_t last_ticks = get_ticks_usec();
- int frames=0;
- uint64_t frame=0;
+ int frames = 0;
+ uint64_t frame = 0;
while (!force_quit) {
CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
if (managed_object->alert_close_handle) continue;
process_events(); // get rid of pending events
- if (Main::iteration()==true)
+ if (Main::iteration() == true)
break;
};
main_loop->finish();
-
}
-
-
MainLoop *OSUWP::get_main_loop() const {
return main_loop;
}
-
String OSUWP::get_data_dir() const {
- Windows::Storage::StorageFolder ^data_folder = Windows::Storage::ApplicationData::Current->LocalFolder;
+ Windows::Storage::StorageFolder ^ data_folder = Windows::Storage::ApplicationData::Current->LocalFolder;
return String(data_folder->Path->Data()).replace("\\", "/");
}
@@ -932,24 +894,23 @@ int OSWinrt::get_power_percent_left() {
return power_manager->get_power_percent_left();
}
-
OSUWP::OSUWP() {
- key_event_pos=0;
- force_quit=false;
- alt_mem=false;
- gr_mem=false;
- shift_mem=false;
- control_mem=false;
- meta_mem=false;
+ key_event_pos = 0;
+ force_quit = false;
+ alt_mem = false;
+ gr_mem = false;
+ shift_mem = false;
+ control_mem = false;
+ meta_mem = false;
minimized = false;
- pressrc=0;
- old_invalid=true;
- last_id=0;
- mouse_mode=MOUSE_MODE_VISIBLE;
+ pressrc = 0;
+ old_invalid = true;
+ last_id = 0;
+ mouse_mode = MOUSE_MODE_VISIBLE;
#ifdef STDOUT_FILE
- stdo=fopen("stdout.txt","wb");
+ stdo = fopen("stdout.txt", "wb");
#endif
gl_context = NULL;
@@ -964,12 +925,8 @@ OSUWP::OSUWP() {
AudioDriverManager::add_driver(&audio_driver);
}
-
-OSUWP::~OSUWP()
-{
+OSUWP::~OSUWP() {
#ifdef STDOUT_FILE
fclose(stdo);
#endif
}
-
-
diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h
index 72cc8a7854..ebbb8af39c 100644
--- a/platform/uwp/os_uwp.h
+++ b/platform/uwp/os_uwp.h
@@ -29,26 +29,25 @@
#ifndef OSUWP_H
#define OSUWP_H
-#include "os/input.h"
-#include "os/os.h"
-#include "servers/visual_server.h"
-#include "servers/visual/rasterizer.h"
-#include "servers/physics/physics_server_sw.h"
-#include "servers/audio_server.h"
-#include "servers/physics_2d/physics_2d_server_sw.h"
-#include "drivers/xaudio2/audio_driver_xaudio2.h"
-#include "gl_context_egl.h"
#include "core/math/math_2d.h"
#include "core/ustring.h"
-#include "main/input_default.h"
+#include "drivers/xaudio2/audio_driver_xaudio2.h"
+#include "gl_context_egl.h"
#include "joypad_uwp.h"
+#include "main/input_default.h"
+#include "os/input.h"
+#include "os/os.h"
#include "power_winrt.h"
+#include "servers/audio_server.h"
+#include "servers/physics/physics_server_sw.h"
+#include "servers/physics_2d/physics_2d_server_sw.h"
+#include "servers/visual/rasterizer.h"
+#include "servers/visual_server.h"
-#include <windows.h>
-#include <io.h>
#include <fcntl.h>
+#include <io.h>
#include <stdio.h>
-
+#include <windows.h>
/**
@author Juan Linietsky <reduzio@gmail.com>
@@ -56,11 +55,9 @@
class OSUWP : public OS {
public:
-
struct KeyEvent {
- enum MessageType
- {
+ enum MessageType {
KEY_EVENT_MESSAGE,
CHAR_EVENT_MESSAGE
};
@@ -72,16 +69,14 @@ public:
unsigned int unicode;
bool echo;
CorePhysicalKeyStatus status;
-
};
private:
-
enum {
JOYPADS_MAX = 8,
JOY_AXIS_COUNT = 6,
MAX_JOY_AXIS = 32768, // I've no idea
- KEY_EVENT_BUFFER_SIZE=512
+ KEY_EVENT_BUFFER_SIZE = 512
};
FILE *stdo;
@@ -89,14 +84,13 @@ private:
KeyEvent key_event_buffer[KEY_EVENT_BUFFER_SIZE];
int key_event_pos;
-
uint64_t ticks_start;
uint64_t ticks_per_second;
bool minimized;
bool old_invalid;
bool outside;
- int old_x,old_y;
+ int old_x, old_y;
Point2i center;
unsigned int last_id;
VisualServer *visual_server;
@@ -105,7 +99,7 @@ private:
Physics2DServer *physics_2d_server;
int pressrc;
- ContextEGL* gl_context;
+ ContextEGL *gl_context;
VideoMode video_mode;
@@ -128,52 +122,52 @@ private:
InputDefault *input;
- JoypadUWP^ joypad;
+ JoypadUWP ^ joypad;
- Windows::System::Display::DisplayRequest^ display_request;
+ Windows::System::Display::DisplayRequest ^ display_request;
void _post_dpad(DWORD p_dpad, int p_device, bool p_pressed);
- void _drag_event(int idx,UINT uMsg, WPARAM wParam, LPARAM lParam);
- void _touch_event(int idx, UINT uMsg, WPARAM wParam, LPARAM lParam);
+ void _drag_event(int idx, UINT uMsg, WPARAM wParam, LPARAM lParam);
+ void _touch_event(int idx, UINT uMsg, WPARAM wParam, LPARAM lParam);
ref class ManagedType {
public:
property bool alert_close_handle;
- property Platform::String^ clipboard;
- void alert_close(Windows::UI::Popups::IUICommand^ command);
- void on_clipboard_changed(Platform::Object^ sender, Platform::Object^ ev);
+ property Platform::String ^ clipboard;
+ void alert_close(Windows::UI::Popups::IUICommand ^ command);
+ void on_clipboard_changed(Platform::Object ^ sender, Platform::Object ^ ev);
void update_clipboard();
- void on_accelerometer_reading_changed(Windows::Devices::Sensors::Accelerometer^ sender, Windows::Devices::Sensors::AccelerometerReadingChangedEventArgs^ args);
- void on_magnetometer_reading_changed(Windows::Devices::Sensors::Magnetometer^ sender, Windows::Devices::Sensors::MagnetometerReadingChangedEventArgs^ args);
- void on_gyroscope_reading_changed(Windows::Devices::Sensors::Gyrometer^ sender, Windows::Devices::Sensors::GyrometerReadingChangedEventArgs^ args);
+ void on_accelerometer_reading_changed(Windows::Devices::Sensors::Accelerometer ^ sender, Windows::Devices::Sensors::AccelerometerReadingChangedEventArgs ^ args);
+ void on_magnetometer_reading_changed(Windows::Devices::Sensors::Magnetometer ^ sender, Windows::Devices::Sensors::MagnetometerReadingChangedEventArgs ^ args);
+ void on_gyroscope_reading_changed(Windows::Devices::Sensors::Gyrometer ^ sender, Windows::Devices::Sensors::GyrometerReadingChangedEventArgs ^ args);
- /** clang-format breaks this, it does not understand this token. */
- /* clang-format off */
+ /** clang-format breaks this, it does not understand this token. */
+ /* clang-format off */
internal:
ManagedType() { alert_close_handle = false; }
property OSUWP* os;
- /* clang-format on */
+ /* clang-format on */
};
- ManagedType^ managed_object;
- Windows::Devices::Sensors::Accelerometer^ accelerometer;
- Windows::Devices::Sensors::Magnetometer^ magnetometer;
- Windows::Devices::Sensors::Gyrometer^ gyrometer;
+ ManagedType ^ managed_object;
+ Windows::Devices::Sensors::Accelerometer ^ accelerometer;
+ Windows::Devices::Sensors::Magnetometer ^ magnetometer;
+ Windows::Devices::Sensors::Gyrometer ^ gyrometer;
// functions used by main to initialize/deintialize the OS
protected:
virtual int get_video_driver_count() const;
- virtual const char * get_video_driver_name(int p_driver) const;
+ virtual const char *get_video_driver_name(int p_driver) const;
virtual VideoMode get_default_video_mode() const;
virtual int get_audio_driver_count() const;
- virtual const char * get_audio_driver_name(int p_driver) const;
+ virtual const char *get_audio_driver_name(int p_driver) const;
virtual void initialize_core();
- virtual void initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver);
+ virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
- virtual void set_main_loop( MainLoop * p_main_loop );
+ virtual void set_main_loop(MainLoop *p_main_loop);
virtual void delete_main_loop();
virtual void finalize();
@@ -184,14 +178,13 @@ protected:
void process_key_events();
public:
-
// Event to send to the app wrapper
HANDLE mouse_mode_changed;
- void print_error(const char* p_function,const char* p_file,int p_line,const char *p_code,const char*p_rationale,ErrorType p_type);
+ void print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type);
- virtual void vprint(const char *p_format, va_list p_list, bool p_stderr=false);
- virtual void alert(const String& p_alert,const String& p_title="ALERT!");
+ virtual void vprint(const char *p_format, va_list p_list, bool p_stderr = false);
+ virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
String get_stdin_string(bool p_block);
void set_mouse_mode(MouseMode p_mode);
@@ -199,11 +192,11 @@ public:
virtual Point2 get_mouse_pos() const;
virtual int get_mouse_button_state() const;
- virtual void set_window_title(const String& p_title);
+ virtual void set_window_title(const String &p_title);
- virtual void set_video_mode(const VideoMode& p_video_mode,int p_screen=0);
- virtual VideoMode get_video_mode(int p_screen=0) const;
- virtual void get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen=0) const;
+ virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0);
+ virtual VideoMode get_video_mode(int p_screen = 0) const;
+ virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const;
virtual Size2 get_window_size() const;
virtual void set_window_size(const Size2 p_size);
virtual void set_window_fullscreen(bool p_enabled);
@@ -220,22 +213,22 @@ public:
virtual uint64_t get_unix_time() const;
virtual bool can_draw() const;
- virtual Error set_cwd(const String& p_cwd);
+ virtual Error set_cwd(const String &p_cwd);
virtual void delay_usec(uint32_t p_usec) const;
virtual uint64_t get_ticks_usec() const;
- virtual Error execute(const String& p_path, const List<String>& p_arguments,bool p_blocking,ProcessID *r_child_id=NULL,String* r_pipe=NULL,int *r_exitcode=NULL);
- virtual Error kill(const ProcessID& p_pid);
+ virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL);
+ virtual Error kill(const ProcessID &p_pid);
- virtual bool has_environment(const String& p_var) const;
- virtual String get_environment(const String& p_var) const;
+ virtual bool has_environment(const String &p_var) const;
+ virtual String get_environment(const String &p_var) const;
- virtual void set_clipboard(const String& p_text);
+ virtual void set_clipboard(const String &p_text);
virtual String get_clipboard() const;
void set_cursor_shape(CursorShape p_shape);
- void set_icon(const Image& p_icon);
+ void set_icon(const Image &p_icon);
virtual String get_executable_path() const;
@@ -244,7 +237,7 @@ public:
virtual void move_window_to_foreground();
virtual String get_data_dir() const;
- void set_gl_context(ContextEGL* p_context);
+ void set_gl_context(ContextEGL *p_context);
void screen_size_changed();
virtual void release_rendering_thread();
@@ -254,7 +247,7 @@ public:
virtual bool has_touchscreen_ui_hint() const;
virtual bool has_virtual_keyboard() const;
- virtual void show_virtual_keyboard(const String& p_existing_text, const Rect2& p_screen_rect = Rect2());
+ virtual void show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2());
virtual void hide_virtual_keyboard();
virtual Error shell_open(String p_uri);
@@ -264,7 +257,7 @@ public:
virtual bool get_swap_ok_cancel() { return true; }
void input_event(InputEvent &p_event);
-
+
virtual PowerState get_power_state();
virtual int get_power_seconds_left();
virtual int get_power_percent_left();
@@ -273,7 +266,6 @@ public:
OSUWP();
~OSUWP();
-
};
#endif
diff --git a/platform/uwp/thread_uwp.cpp b/platform/uwp/thread_uwp.cpp
index 4008a1eeb0..ff079be375 100644
--- a/platform/uwp/thread_uwp.cpp
+++ b/platform/uwp/thread_uwp.cpp
@@ -30,10 +30,9 @@
#include "os/memory.h"
-Thread* ThreadUWP::create_func_uwp(ThreadCreateCallback p_callback,void *p_user,const Settings&) {
-
- ThreadUWP* thread = memnew(ThreadUWP);
+Thread *ThreadUWP::create_func_uwp(ThreadCreateCallback p_callback, void *p_user, const Settings &) {
+ ThreadUWP *thread = memnew(ThreadUWP);
std::thread new_thread(p_callback, p_user);
std::swap(thread->thread, new_thread);
@@ -46,13 +45,12 @@ Thread::ID ThreadUWP::get_thread_ID_func_uwp() {
return std::hash<std::thread::id>()(std::this_thread::get_id());
};
-void ThreadUWP::wait_to_finish_func_uwp(Thread* p_thread) {
+void ThreadUWP::wait_to_finish_func_uwp(Thread *p_thread) {
- ThreadUWP *tp=static_cast<ThreadUWP*>(p_thread);
+ ThreadUWP *tp = static_cast<ThreadUWP *>(p_thread);
tp->thread.join();
};
-
Thread::ID ThreadUWP::get_ID() const {
return std::hash<std::thread::id>()(thread.get_id());
@@ -64,11 +62,10 @@ void ThreadUWP::make_default() {
wait_to_finish_func = wait_to_finish_func_uwp;
};
-ThreadUWP::ThreadUWP() {
+ThreadUWP::ThreadUWP(){
};
-ThreadUWP::~ThreadUWP() {
+ThreadUWP::~ThreadUWP(){
};
-
diff --git a/platform/uwp/thread_uwp.h b/platform/uwp/thread_uwp.h
index 06c19c0139..b4e67c8b5c 100644
--- a/platform/uwp/thread_uwp.h
+++ b/platform/uwp/thread_uwp.h
@@ -39,25 +39,20 @@ class ThreadUWP : public Thread {
std::thread thread;
- static Thread* create_func_uwp(ThreadCreateCallback p_callback,void *,const Settings&);
+ static Thread *create_func_uwp(ThreadCreateCallback p_callback, void *, const Settings &);
static ID get_thread_ID_func_uwp();
- static void wait_to_finish_func_uwp(Thread* p_thread);
+ static void wait_to_finish_func_uwp(Thread *p_thread);
ThreadUWP();
-public:
-
+public:
virtual ID get_ID() const;
static void make_default();
-
~ThreadUWP();
-
};
-
#endif
#endif
-