diff --git a/projects/VS2017.UWP/raylib.App.UWP/App.cpp b/projects/VS2017.UWP/raylib.App.UWP/App.cpp deleted file mode 100644 index d2a369d6..00000000 --- a/projects/VS2017.UWP/raylib.App.UWP/App.cpp +++ /dev/null @@ -1,574 +0,0 @@ -#include "pch.h" -#include "app.h" - -#include - -#include -#include -#include - -#include -#include - -using namespace Windows::ApplicationModel::Core; -using namespace Windows::ApplicationModel::Activation; -using namespace Windows::UI::Core; -using namespace Windows::UI::Input; -using namespace Windows::Devices::Input; -using namespace Windows::Foundation; -using namespace Windows::Foundation::Collections; -using namespace Windows::Gaming::Input; -using namespace Windows::Graphics::Display; -using namespace Microsoft::WRL; -using namespace Platform; - -using namespace raylibUWP; - -// Stand-ins for "core.c" variables -#define MAX_GAMEPADS 4 // Max number of gamepads supported -#define MAX_GAMEPAD_BUTTONS 32 // Max bumber of buttons supported (per gamepad) -#define MAX_GAMEPAD_AXIS 8 // Max number of axis supported (per gamepad) - -// Gamepad bindings struct -struct GamepadBinding -{ - Gamepad^ Gamepad = nullptr; - bool Ready = false; -}; - -// Global variables -static int posX = 100; -static int posY = 100; -static int gTime = 0; -static bool mouseLocked = false; -static GamepadBinding gGamepadBindings[MAX_GAMEPADS]; - -// The main function creates an IFrameworkViewSource for our app, and runs the app -[Platform::MTAThread] -int main(Platform::Array^) -{ - auto appSource = ref new AppSource(); - CoreApplication::Run(appSource); - return 0; -} - -// App implementation -App::App() -{ - // Currently, UWP ignores flags... You must implement flag functionality yourself - SetConfigFlags(0); -} - -void App::Initialize(Windows::ApplicationModel::Core::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(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 - - CoreApplication::Suspending += ref new Windows::Foundation::EventHandler(this, &App::OnSuspending); - CoreApplication::Resuming += ref new EventHandler(this, &App::OnResuming); - - // Store the app data directory - auto dataPath = Windows::Storage::ApplicationData::Current->LocalFolder->Path; - std::wstring dataPathW(dataPath->Begin()); - static std::string dataPathA(dataPathW.begin(), dataPathW.end()); - UWPSetDataPath(dataPathA.c_str()); -} - -void App::SetWindow(Windows::UI::Core::CoreWindow^ window) -{ - // Hook window events - window->SizeChanged += ref new TypedEventHandler(this, &App::OnWindowSizeChanged); - window->VisibilityChanged += ref new TypedEventHandler(this, &App::OnVisibilityChanged); - - // Hook mouse pointer events - window->PointerPressed += ref new TypedEventHandler(this, &App::OnPointerPressed); - window->PointerReleased += ref new Windows::Foundation::TypedEventHandler(this, &App::OnPointerReleased); - window->PointerWheelChanged += ref new TypedEventHandler(this, &App::OnPointerWheelChanged); - window->PointerMoved += ref new Windows::Foundation::TypedEventHandler(this, &App::OnPointerMoved); - - // Hook keyboard events. - window->KeyDown += ref new TypedEventHandler(this, &App::OnKeyDown); - window->KeyUp += ref new TypedEventHandler(this, &App::OnKeyUp); - window->CharacterReceived += ref new Windows::Foundation::TypedEventHandler(this, &raylibUWP::App::OnCharacterReceived); - - // The CoreWindow has been created, we can pass this to raylib for EGL context creation when it's time - UWPSetCoreWindowPtr((void*)window); - - // Register backrequested event to stop window from being closed (Most noticable on XBox when B is pressed) - auto navigation = SystemNavigationManager::GetForCurrentView(); - navigation->BackRequested += ref new Windows::Foundation::EventHandler(this, &raylibUWP::App::OnBackRequested); -} - -void App::Load(Platform::String ^entryPoint) {} // Ignored for this example - -void App::Run() -{ - // Set up our UWP implementation - UWPSetQueryTimeFunc([]() { - static auto timeStart = std::chrono::high_resolution_clock::now(); - std::chrono::duration time_span = std::chrono::duration_cast>(std::chrono::high_resolution_clock::now() - timeStart); - return time_span.count(); }); - - UWPSetSleepFunc([](double seconds) { std::this_thread::sleep_for(std::chrono::duration(seconds)); }); - - UWPSetDisplaySizeFunc([](int* width, int* height) { - // Get display dimensions - DisplayInformation^ dInfo = DisplayInformation::GetForCurrentView(); - *width = dInfo->ScreenWidthInRawPixels; - *height = dInfo->ScreenHeightInRawPixels; }); - - UWPSetMouseHideFunc([]() { CoreWindow::GetForCurrentThread()->PointerCursor = nullptr; }); - - UWPSetMouseShowFunc([]() { CoreWindow::GetForCurrentThread()->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0); }); - - UWPSetMouseLockFunc([]() { - CoreWindow::GetForCurrentThread()->PointerCursor = nullptr; - mouseLocked = true; }); - - UWPSetMouseUnlockFunc([]() { - CoreWindow::GetForCurrentThread()->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0); - mouseLocked = false; }); - - UWPSetMouseSetPosFunc([](int x, int y) { - CoreWindow^ window = CoreWindow::GetForCurrentThread(); - Point mousePosScreen = Point(x + window->Bounds.X, y + window->Bounds.Y); - window->PointerPosition = mousePosScreen; }); - - // Set custom output handle - SetTraceLogCallback([](int logType, const char* text, va_list args) - { - std::string format = text; - - switch (logType) - { - case LOG_TRACE: format = std::string("TRACE: ") + format; break; - case LOG_DEBUG: format = std::string("DEBUG: ") + format; break; - case LOG_INFO: format = std::string("INFO: ") + format; break; - case LOG_WARNING: format = std::string("WARNING: ") + format; break; - case LOG_ERROR: format = std::string("ERROR: ") + format; break; - case LOG_FATAL: format = std::string("FATAL: ") + format; break; - default: break; - } - - char buf[1024]; // TODO: Is this large enough? - vsnprintf(buf, sizeof(buf), format.c_str(), args); - std::string output = std::string(buf) + std::string("\n"); - OutputDebugStringA(output.c_str()); - }); - - // Create window - InitWindow(800, 450, "raylib UWP - Basic example"); - - // Run game loop - while (!WindowShouldClose() && !mSuspended) - { - if (mWindowVisible) - { - PreProcessInputs(); - GameLoop(); - PostProcessInputs(); - - CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); - } - else - { - CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending); - } - } - - CloseWindow(); -} - -void App::Uninitialize() -{ - // Do any UWP cleanup here. -} - -// This method is called every frame -void App::GameLoop() -{ - // Update - //---------------------------------------------------------------------------------- - posX += GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_X) * 5; - posY += GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_Y) * -5; - - auto mPos = GetMousePosition(); - - if (IsKeyPressed(KEY_A)) - { - posX -= 50; - EnableCursor(); - } - - if (IsKeyPressed(KEY_D)) - { - posX += 50; - DisableCursor(); - } - - static float pos = 0; - pos -= GetMouseWheelMove(); - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RED); - - DrawRectangle(posX, posY, 400, 100, WHITE); - - DrawLine(0, 0, GetScreenWidth(), GetScreenHeight(), BLUE); - - DrawCircle(mPos.x, mPos.y, 40, BLUE); - - if (IsKeyDown(KEY_S)) DrawCircle(100, 100, 100, BLUE); - - if (IsKeyDown(KEY_LEFT_ALT)) DrawRectangle(250, 250, 20, 20, BLACK); - if (IsKeyDown(KEY_BACKSPACE)) DrawRectangle(280, 250, 20, 20, BLACK); - if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) DrawRectangle(280, 250, 20, 20, BLACK); - - DrawRectangle(280, (int)pos + 50, 20, 20, BLACK); - DrawRectangle(250, 280 + (gTime++ % 60), 10, 10, PURPLE); - - EndDrawing(); - //---------------------------------------------------------------------------------- -} - -void App::PreProcessInputs() -{ - // Here, we will see if we have bound gamepads. If we do we check they are still present. If they aren't present we free the binding. - // if anyone does not have a binding but there is a gamepad available, we will bind it to the first player who is missing a controller. - for (auto i = 0; i < MAX_GAMEPADS; i++) - { - // Ensure that the gamepad bindings are still in tact - if (gGamepadBindings[i].Gamepad != nullptr) - { - // Check the gamepad is present - auto found = false; - for (auto j = 0; j < Gamepad::Gamepads->Size; j++) - { - if (gGamepadBindings[i].Gamepad == Gamepad::Gamepads->GetAt(j)) - { - found = true; - break; - } - } - - if (!found) - { - gGamepadBindings[i].Gamepad = nullptr; - gGamepadBindings[i].Ready = false; - } - else gGamepadBindings[i].Ready = true; - } - - // Now we check to find any unbound gamepads we can use - if (gGamepadBindings[i].Gamepad == nullptr) - { - // Loop over all the attached gamepads - Gamepad^ freeGamepad = nullptr; - for (auto j = 0; j < Gamepad::Gamepads->Size; j++) - { - freeGamepad = Gamepad::Gamepads->GetAt(j); - // Loop over existing bindings - for (auto k = 0; k < MAX_GAMEPADS; k++) - { - if (gGamepadBindings[k].Gamepad == freeGamepad) - freeGamepad = nullptr; - } - - // If we passed all 4, this is a free gamepad - if (freeGamepad != nullptr) break; - } - - if (freeGamepad != nullptr) - { - gGamepadBindings[i].Gamepad = freeGamepad; - gGamepadBindings[i].Ready = true; - } - else gGamepadBindings[i].Ready = false; - } - } - - // Send the active gamepads to raylib - for (int i = 0; i < MAX_GAMEPADS; i++) - { - UWPActivateGamepadEvent(i, gGamepadBindings[i].Ready); - } - - // Get current gamepad state - for (int i = 0; i < MAX_GAMEPADS; i++) - { - if (gGamepadBindings[i].Ready) - { - // Get current gamepad state - auto gamepad = gGamepadBindings[i].Gamepad; - auto reading = gamepad->GetCurrentReading(); - - // Register all button presses - UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_RIGHT_FACE_DOWN, ((reading.Buttons & GamepadButtons::A) == GamepadButtons::A)); - UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT, ((reading.Buttons & GamepadButtons::B) == GamepadButtons::B)); - UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_RIGHT_FACE_LEFT, ((reading.Buttons & GamepadButtons::X) == GamepadButtons::X)); - UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_RIGHT_FACE_UP, ((reading.Buttons & GamepadButtons::Y) == GamepadButtons::Y)); - - UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_LEFT_TRIGGER_1, ((reading.Buttons & GamepadButtons::LeftShoulder) == GamepadButtons::LeftShoulder)); - UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_RIGHT_TRIGGER_1, ((reading.Buttons & GamepadButtons::RightShoulder) == GamepadButtons::RightShoulder)); - - UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_MIDDLE_LEFT, ((reading.Buttons & GamepadButtons::View) == GamepadButtons::View)); // Changed for XB1 Controller - UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_MIDDLE_RIGHT, ((reading.Buttons & GamepadButtons::Menu) == GamepadButtons::Menu)); // Changed for XB1 Controller - - UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_LEFT_FACE_UP, ((reading.Buttons & GamepadButtons::DPadUp) == GamepadButtons::DPadUp)); - UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_LEFT_FACE_RIGHT, ((reading.Buttons & GamepadButtons::DPadRight) == GamepadButtons::DPadRight)); - UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_LEFT_FACE_DOWN, ((reading.Buttons & GamepadButtons::DPadDown) == GamepadButtons::DPadDown)); - UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_LEFT_FACE_LEFT, ((reading.Buttons & GamepadButtons::DPadLeft) == GamepadButtons::DPadLeft)); - UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_MIDDLE, false); // Home button not supported by UWP - - // Register buttons for 2nd triggers (because UWP doesn't count these as buttons but rather axis) - UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_LEFT_TRIGGER_2, (bool)(reading.LeftTrigger > 0.1)); - UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_RIGHT_TRIGGER_2, (bool)(reading.RightTrigger > 0.1)); - - // Get current axis state - UWPRegisterGamepadAxis(i, GAMEPAD_AXIS_LEFT_X, (float)reading.LeftThumbstickX); - UWPRegisterGamepadAxis(i, GAMEPAD_AXIS_LEFT_Y, (float)reading.LeftThumbstickY); - UWPRegisterGamepadAxis(i, GAMEPAD_AXIS_RIGHT_X, (float)reading.RightThumbstickX); - UWPRegisterGamepadAxis(i, GAMEPAD_AXIS_RIGHT_Y, (float)reading.RightThumbstickY); - UWPRegisterGamepadAxis(i, GAMEPAD_AXIS_LEFT_TRIGGER, (float)reading.LeftTrigger); - UWPRegisterGamepadAxis(i, GAMEPAD_AXIS_RIGHT_TRIGGER, (float)reading.RightTrigger); - } - } -} - -void App::PostProcessInputs() -{ - /* - * So here's the deal. UWP doesn't officially have mouse locking, so we're doing it ourselves here. - * If anyone has any better ideas on how to implement this feel free! - * This is done after the game loop so getting mouse delta etc. still works. - */ - if (mouseLocked) - { - auto w = GetScreenWidth(); - auto h = GetScreenHeight(); - SetMousePosition(w / 2, h / 2); - } -} - -// Events -void App::OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args) -{ - // Run() won't start until the CoreWindow is activated. - CoreWindow::GetForCurrentThread()->Activate(); -} - -void App::OnResuming(Platform::Object^ sender, Platform::Object^ args) -{ - // TODO: In your game, you will need to load your state here - mSuspended = false; -} - -void App::OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args) -{ - // TODO: In your game, you will need to save your state here - mSuspended = true; -} - -void App::OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args) -{ - UWPResizeEvent(args->Size.Width, args->Size.Height); - args->Handled = true; -} - -void App::OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args) -{ - mWindowVisible = args->Visible; - args->Handled = true; -} - -// Input event handlers -void App::OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args) -{ - auto props = args->CurrentPoint->Properties; - auto device = args->CurrentPoint->PointerDevice; - - if (device->PointerDeviceType == Windows::Devices::Input::PointerDeviceType::Mouse) - { - if (props->IsLeftButtonPressed) UWPMouseButtonEvent(MOUSE_BUTTON_LEFT, true); - if (props->IsMiddleButtonPressed) UWPMouseButtonEvent(MOUSE_BUTTON_MIDDLE, true); - if (props->IsRightButtonPressed) UWPMouseButtonEvent(MOUSE_BUTTON_RIGHT, true); - } - else if (device->PointerDeviceType == PointerDeviceType::Touch) - { - auto pos = args->CurrentPoint->Position; - UWPGestureTouch(args->CurrentPoint->PointerId, pos.X, pos.Y, true); - } - - args->Handled = true; -} - -void App::OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args) -{ - auto props = args->CurrentPoint->Properties; - auto device = args->CurrentPoint->PointerDevice; - - if (device->PointerDeviceType == PointerDeviceType::Mouse) - { - if (!props->IsLeftButtonPressed) UWPMouseButtonEvent(MOUSE_BUTTON_LEFT, false); - if (!props->IsMiddleButtonPressed) UWPMouseButtonEvent(MOUSE_BUTTON_MIDDLE, false); - if (!props->IsRightButtonPressed) UWPMouseButtonEvent(MOUSE_BUTTON_RIGHT, false); - } - else if (device->PointerDeviceType == PointerDeviceType::Touch) - { - auto pos = args->CurrentPoint->Position; - UWPGestureTouch(args->CurrentPoint->PointerId, pos.X, pos.Y, false); - } - - args->Handled = true; -} - -void App::OnPointerWheelChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args) -{ - UWPMouseWheelEvent(args->CurrentPoint->Properties->MouseWheelDelta); - args->Handled = true; -} - -void App::OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args) -{ - auto pos = args->CurrentPoint->Position; - if (args->CurrentPoint->PointerDevice->PointerDeviceType == PointerDeviceType::Mouse) - { - UWPMousePosEvent((double)pos.X, (double)pos.Y); - args->Handled = true; - } - else if (args->CurrentPoint->PointerDevice->PointerDeviceType == PointerDeviceType::Touch) - { - UWPGestureMove(args->CurrentPoint->PointerId, pos.X, pos.Y); - } -} - -int App::GetRaylibKey(Windows::System::VirtualKey kVey) -{ - using VK = Windows::System::VirtualKey; - int actualKey = -1; - switch (kVey) - { - case VK::Back: actualKey = KEY_BACKSPACE; break; - case VK::Space: actualKey = KEY_SPACE; break; - case VK::Escape: actualKey = KEY_ESCAPE; break; - case VK::Enter: actualKey = KEY_ENTER; break; - case VK::Delete: actualKey = KEY_DELETE; break; - case VK::Right: actualKey = KEY_RIGHT; break; - case VK::Left: actualKey = KEY_LEFT; break; - case VK::Down: actualKey = KEY_DOWN; break; - case VK::Up: actualKey = KEY_UP; break; - case VK::F1: actualKey = KEY_F1; break; - case VK::F2: actualKey = KEY_F2; break; - case VK::F3: actualKey = KEY_F3; break; - case VK::F4: actualKey = KEY_F4; break; - case VK::F5: actualKey = KEY_F5; break; - case VK::F6: actualKey = KEY_F6; break; - case VK::F7: actualKey = KEY_F7; break; - case VK::F8: actualKey = KEY_F8; break; - case VK::F9: actualKey = KEY_F9; break; - case VK::F10: actualKey = KEY_F10; break; - case VK::F11: actualKey = KEY_F11; break; - case VK::F12: actualKey = KEY_F12; break; - case VK::LeftShift: actualKey = KEY_LEFT_SHIFT; break; - case VK::LeftControl: actualKey = KEY_LEFT_CONTROL; break; - case VK::LeftMenu: actualKey = KEY_LEFT_ALT; break; - case VK::RightShift: actualKey = KEY_RIGHT_SHIFT; break; - case VK::RightControl: actualKey = KEY_RIGHT_CONTROL; break; - case VK::RightMenu: actualKey = KEY_RIGHT_ALT; break; - case VK::Number0: actualKey = KEY_ZERO; break; - case VK::Number1: actualKey = KEY_ONE; break; - case VK::Number2: actualKey = KEY_TWO; break; - case VK::Number3: actualKey = KEY_THREE; break; - case VK::Number4: actualKey = KEY_FOUR; break; - case VK::Number5: actualKey = KEY_FIVE; break; - case VK::Number6: actualKey = KEY_SIX; break; - case VK::Number7: actualKey = KEY_SEVEN; break; - case VK::Number8: actualKey = KEY_EIGHT; break; - case VK::Number9: actualKey = KEY_NINE; break; - case VK::NumberPad0: actualKey = KEY_KP_0; break; - case VK::NumberPad1: actualKey = KEY_KP_1; break; - case VK::NumberPad2: actualKey = KEY_KP_2; break; - case VK::NumberPad3: actualKey = KEY_KP_3; break; - case VK::NumberPad4: actualKey = KEY_KP_4; break; - case VK::NumberPad5: actualKey = KEY_KP_5; break; - case VK::NumberPad6: actualKey = KEY_KP_6; break; - case VK::NumberPad7: actualKey = KEY_KP_7; break; - case VK::NumberPad8: actualKey = KEY_KP_8; break; - case VK::NumberPad9: actualKey = KEY_KP_9; break; - case VK::Decimal: actualKey = KEY_KP_DECIMAL; break; - case VK::Divide: actualKey = KEY_KP_DIVIDE; break; - case VK::Multiply: actualKey = KEY_KP_MULTIPLY; break; - case VK::Subtract: actualKey = KEY_KP_SUBTRACT; break; - case VK::Add: actualKey = KEY_KP_ADD; break; - // UWP Doesn't have a specific keypad enter or equal... - case VK::A: actualKey = KEY_A; break; - case VK::B: actualKey = KEY_B; break; - case VK::C: actualKey = KEY_C; break; - case VK::D: actualKey = KEY_D; break; - case VK::E: actualKey = KEY_E; break; - case VK::F: actualKey = KEY_F; break; - case VK::G: actualKey = KEY_G; break; - case VK::H: actualKey = KEY_H; break; - case VK::I: actualKey = KEY_I; break; - case VK::J: actualKey = KEY_J; break; - case VK::K: actualKey = KEY_K; break; - case VK::L: actualKey = KEY_L; break; - case VK::M: actualKey = KEY_M; break; - case VK::N: actualKey = KEY_N; break; - case VK::O: actualKey = KEY_O; break; - case VK::P: actualKey = KEY_P; break; - case VK::Q: actualKey = KEY_Q; break; - case VK::R: actualKey = KEY_R; break; - case VK::S: actualKey = KEY_S; break; - case VK::T: actualKey = KEY_T; break; - case VK::U: actualKey = KEY_U; break; - case VK::V: actualKey = KEY_V; break; - case VK::W: actualKey = KEY_W; break; - case VK::X: actualKey = KEY_X; break; - case VK::Y: actualKey = KEY_Y; break; - case VK::Z: actualKey = KEY_Z; break; - // I don't think we can have any more - } - return actualKey; -} - -void App::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args) -{ - auto k = GetRaylibKey(args->VirtualKey); - auto controlState = (sender->GetKeyState(Windows::System::VirtualKey::Control) & Windows::UI::Core::CoreVirtualKeyStates::Down) == Windows::UI::Core::CoreVirtualKeyStates::Down; - if (k != -1) UWPKeyDownEvent(k, true, controlState); - args->Handled = true; -} - -void App::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args) -{ - auto k = GetRaylibKey(args->VirtualKey); - if (k != -1) UWPKeyDownEvent(k, false, false); - args->Handled = true; -} - -void App::OnCharacterReceived(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CharacterReceivedEventArgs^ args) -{ - UWPKeyCharEvent(args->KeyCode); -} - -void App::OnBackRequested(Platform::Object^ sender, Windows::UI::Core::BackRequestedEventArgs^ args) -{ - // This simply stops the program from closing. - args->Handled = true; -} - -// AppSource implementation -Windows::ApplicationModel::Core::IFrameworkView ^AppSource::CreateView() -{ - return ref new App(); -} diff --git a/projects/VS2017.UWP/raylib.App.UWP/App.h b/projects/VS2017.UWP/raylib.App.UWP/App.h deleted file mode 100644 index 6cbeadac..00000000 --- a/projects/VS2017.UWP/raylib.App.UWP/App.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -#include - -#include "pch.h" - -namespace raylibUWP -{ - ref class App sealed : public Windows::ApplicationModel::Core::IFrameworkView - { - public: - App(); - - // IFrameworkView methods. - void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView) override; - void SetWindow(Windows::UI::Core::CoreWindow^ window) override; - void Load(Platform::String^ entryPoint) override; - void Run() override; - void Uninitialize() override; - private: - bool mWindowVisible = true; - bool mSuspended = false; - - void GameLoop(); - void PreProcessInputs(); - void PostProcessInputs(); - - // Helpers - int GetRaylibKey(Windows::System::VirtualKey kVey); - - // Events - void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args); - void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args); - void OnResuming(Platform::Object^ sender, Platform::Object^ args); - void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args); - void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args); - void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); - void OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); - void OnPointerWheelChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); - void OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); - void OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args); - void OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args); - void OnCharacterReceived(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CharacterReceivedEventArgs^ args); - void OnBackRequested(Platform::Object^ sender, Windows::UI::Core::BackRequestedEventArgs^ args); - }; - - ref class AppSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource - { - public: - Windows::ApplicationModel::Core::IFrameworkView^ CreateView() override; - }; -} diff --git a/projects/VS2017.UWP/raylib.App.UWP/Assets/Logo.scale-100.png b/projects/VS2017.UWP/raylib.App.UWP/Assets/Logo.scale-100.png deleted file mode 100644 index e26771cb..00000000 Binary files a/projects/VS2017.UWP/raylib.App.UWP/Assets/Logo.scale-100.png and /dev/null differ diff --git a/projects/VS2017.UWP/raylib.App.UWP/Assets/SmallLogo.scale-100.png b/projects/VS2017.UWP/raylib.App.UWP/Assets/SmallLogo.scale-100.png deleted file mode 100644 index 1eb0d9d5..00000000 Binary files a/projects/VS2017.UWP/raylib.App.UWP/Assets/SmallLogo.scale-100.png and /dev/null differ diff --git a/projects/VS2017.UWP/raylib.App.UWP/Assets/SplashScreen.scale-100.png b/projects/VS2017.UWP/raylib.App.UWP/Assets/SplashScreen.scale-100.png deleted file mode 100644 index c951e031..00000000 Binary files a/projects/VS2017.UWP/raylib.App.UWP/Assets/SplashScreen.scale-100.png and /dev/null differ diff --git a/projects/VS2017.UWP/raylib.App.UWP/Assets/StoreLogo.scale-100.png b/projects/VS2017.UWP/raylib.App.UWP/Assets/StoreLogo.scale-100.png deleted file mode 100644 index dcb67271..00000000 Binary files a/projects/VS2017.UWP/raylib.App.UWP/Assets/StoreLogo.scale-100.png and /dev/null differ diff --git a/projects/VS2017.UWP/raylib.App.UWP/Assets/WideLogo.scale-100.png b/projects/VS2017.UWP/raylib.App.UWP/Assets/WideLogo.scale-100.png deleted file mode 100644 index 9dd94b62..00000000 Binary files a/projects/VS2017.UWP/raylib.App.UWP/Assets/WideLogo.scale-100.png and /dev/null differ diff --git a/projects/VS2017.UWP/raylib.App.UWP/Package.appxmanifest b/projects/VS2017.UWP/raylib.App.UWP/Package.appxmanifest deleted file mode 100644 index 56020a50..00000000 --- a/projects/VS2017.UWP/raylib.App.UWP/Package.appxmanifest +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - raylibUWP - raysan5 - Assets\StoreLogo.png - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/projects/VS2017.UWP/raylib.App.UWP/packages.config b/projects/VS2017.UWP/raylib.App.UWP/packages.config deleted file mode 100644 index 70c3dea0..00000000 --- a/projects/VS2017.UWP/raylib.App.UWP/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/projects/VS2017.UWP/raylib.App.UWP/pch.cpp b/projects/VS2017.UWP/raylib.App.UWP/pch.cpp deleted file mode 100644 index bcb5590b..00000000 --- a/projects/VS2017.UWP/raylib.App.UWP/pch.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "pch.h" diff --git a/projects/VS2017.UWP/raylib.App.UWP/pch.h b/projects/VS2017.UWP/raylib.App.UWP/pch.h deleted file mode 100644 index dcbd2378..00000000 --- a/projects/VS2017.UWP/raylib.App.UWP/pch.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include -#include - -// OpenGL ES includes -#include -#include - -// EGL includes -#include -#include -#include - -// ANGLE include for Windows Store -#include \ No newline at end of file diff --git a/projects/VS2017.UWP/raylib.App.UWP/raylib.App.UWP.TemporaryKey.pfx b/projects/VS2017.UWP/raylib.App.UWP/raylib.App.UWP.TemporaryKey.pfx deleted file mode 100644 index 0ada3be0..00000000 Binary files a/projects/VS2017.UWP/raylib.App.UWP/raylib.App.UWP.TemporaryKey.pfx and /dev/null differ diff --git a/projects/VS2017.UWP/raylib.App.UWP/raylib.App.UWP.filters b/projects/VS2017.UWP/raylib.App.UWP/raylib.App.UWP.filters deleted file mode 100644 index 4e83c979..00000000 --- a/projects/VS2017.UWP/raylib.App.UWP/raylib.App.UWP.filters +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - Assets - - - Assets - - - Assets - - - Assets - - - Assets - - - - - - - - - - - - - - {d16954bb-de54-472b-ac10-ecab10d3fdc8} - - - \ No newline at end of file diff --git a/projects/VS2017.UWP/raylib.App.UWP/raylib.App.UWP.vcxproj b/projects/VS2017.UWP/raylib.App.UWP/raylib.App.UWP.vcxproj deleted file mode 100644 index 0c3c0e77..00000000 --- a/projects/VS2017.UWP/raylib.App.UWP/raylib.App.UWP.vcxproj +++ /dev/null @@ -1,179 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - Debug - ARM - - - Release - ARM - - - - {b842558c-c034-4e4b-9457-a286f26e83cc} - raylibUWP - en-US - 14.0 - true - Windows Store - 10.0.18362.0 - 10.0.18362.0 - 10.0 - raylib.App.UWP - - - - Application - true - $(DefaultPlatformToolset) - - - Application - false - $(DefaultPlatformToolset) - - - - - - - - raylib.App.UWP.TemporaryKey.pfx - - - $(IncludePath) - $(LibraryPath) - $(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform) - $(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform) - - - $(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform) - $(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform) - - - $(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform) - $(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform) - - - $(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform) - $(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform) - - - $(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform) - $(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform) - - - $(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform) - $(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform) - - - - mincore.lib;winmm.lib;%(AdditionalDependencies) - $(VCInstallDir)\lib\store\arm;$(VCInstallDir)\lib\arm;%(AdditionalLibraryDirectories) - - - - - mincore.lib;winmm.lib;%(AdditionalDependencies) - $(VCInstallDir)\lib\store; $(VCInstallDir)\lib;%(AdditionalLibraryDirectories) - - - - - mincore.lib;winmm.lib;%(AdditionalDependencies) - $(VCInstallDir)\lib\store\amd64;$(VCInstallDir)\lib\amd64;%(AdditionalLibraryDirectories) - - - - - pch.h - $(IntDir)pch.pch - $(SolutionDir)..\..\src;$(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories) - /bigobj %(AdditionalOptions) - 4453;28204 - PLATFORM_UWP;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - MultiThreadedDebugDLL - MultiThreadedDebugDLL - - - true - - - - - pch.h - $(IntDir)pch.pch - $(SolutionDir)..\..\src;$(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories) - /bigobj %(AdditionalOptions) - 4453;28204 - PLATFORM_UWP;NDEBUG;%(PreprocessorDefinitions) - Default - false - MultiThreadedDLL - MultiThreadedDLL - MultiThreadedDLL - - - /NODEFAULTLIB %(AdditionalOptions) - - - - - - - - - - - - - - - - - Create - - - - - Designer - - - - - - {ea91e088-7c71-4f32-b761-e054305cd519} - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - \ No newline at end of file diff --git a/projects/VS2017.UWP/raylib.App.UWP/raylib.App.UWP.vcxproj.filters b/projects/VS2017.UWP/raylib.App.UWP/raylib.App.UWP.vcxproj.filters deleted file mode 100644 index ce747ba6..00000000 --- a/projects/VS2017.UWP/raylib.App.UWP/raylib.App.UWP.vcxproj.filters +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - Logo - - - Logo - - - Logo - - - Logo - - - Logo - - - - - - - - {cdf72d55-f249-4ad6-9a91-f8a084e64933} - - - - - - \ No newline at end of file diff --git a/projects/VS2017.UWP/raylib.UWP.sln b/projects/VS2017.UWP/raylib.UWP.sln deleted file mode 100644 index fb528655..00000000 --- a/projects/VS2017.UWP/raylib.UWP.sln +++ /dev/null @@ -1,57 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.438 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "raylib.App.UWP", "raylib.App.UWP\raylib.App.UWP.vcxproj", "{B842558C-C034-4E4B-9457-A286F26E83CC}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "raylib.UWP", "raylib.UWP\raylib.UWP.vcxproj", "{EA91E088-7C71-4F32-B761-E054305CD519}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|ARM = Debug|ARM - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|ARM = Release|ARM - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B842558C-C034-4E4B-9457-A286F26E83CC}.Debug|ARM.ActiveCfg = Debug|ARM - {B842558C-C034-4E4B-9457-A286F26E83CC}.Debug|ARM.Build.0 = Debug|ARM - {B842558C-C034-4E4B-9457-A286F26E83CC}.Debug|ARM.Deploy.0 = Debug|ARM - {B842558C-C034-4E4B-9457-A286F26E83CC}.Debug|x64.ActiveCfg = Debug|x64 - {B842558C-C034-4E4B-9457-A286F26E83CC}.Debug|x64.Build.0 = Debug|x64 - {B842558C-C034-4E4B-9457-A286F26E83CC}.Debug|x64.Deploy.0 = Debug|x64 - {B842558C-C034-4E4B-9457-A286F26E83CC}.Debug|x86.ActiveCfg = Debug|Win32 - {B842558C-C034-4E4B-9457-A286F26E83CC}.Debug|x86.Build.0 = Debug|Win32 - {B842558C-C034-4E4B-9457-A286F26E83CC}.Debug|x86.Deploy.0 = Debug|Win32 - {B842558C-C034-4E4B-9457-A286F26E83CC}.Release|ARM.ActiveCfg = Release|ARM - {B842558C-C034-4E4B-9457-A286F26E83CC}.Release|ARM.Build.0 = Release|ARM - {B842558C-C034-4E4B-9457-A286F26E83CC}.Release|ARM.Deploy.0 = Release|ARM - {B842558C-C034-4E4B-9457-A286F26E83CC}.Release|x64.ActiveCfg = Release|x64 - {B842558C-C034-4E4B-9457-A286F26E83CC}.Release|x64.Build.0 = Release|x64 - {B842558C-C034-4E4B-9457-A286F26E83CC}.Release|x64.Deploy.0 = Release|x64 - {B842558C-C034-4E4B-9457-A286F26E83CC}.Release|x86.ActiveCfg = Release|Win32 - {B842558C-C034-4E4B-9457-A286F26E83CC}.Release|x86.Build.0 = Release|Win32 - {B842558C-C034-4E4B-9457-A286F26E83CC}.Release|x86.Deploy.0 = Release|Win32 - {EA91E088-7C71-4F32-B761-E054305CD519}.Debug|ARM.ActiveCfg = Debug|ARM - {EA91E088-7C71-4F32-B761-E054305CD519}.Debug|ARM.Build.0 = Debug|ARM - {EA91E088-7C71-4F32-B761-E054305CD519}.Debug|x64.ActiveCfg = Debug|x64 - {EA91E088-7C71-4F32-B761-E054305CD519}.Debug|x64.Build.0 = Debug|x64 - {EA91E088-7C71-4F32-B761-E054305CD519}.Debug|x86.ActiveCfg = Debug|Win32 - {EA91E088-7C71-4F32-B761-E054305CD519}.Debug|x86.Build.0 = Debug|Win32 - {EA91E088-7C71-4F32-B761-E054305CD519}.Release|ARM.ActiveCfg = Release|ARM - {EA91E088-7C71-4F32-B761-E054305CD519}.Release|ARM.Build.0 = Release|ARM - {EA91E088-7C71-4F32-B761-E054305CD519}.Release|x64.ActiveCfg = Release|x64 - {EA91E088-7C71-4F32-B761-E054305CD519}.Release|x64.Build.0 = Release|x64 - {EA91E088-7C71-4F32-B761-E054305CD519}.Release|x86.ActiveCfg = Release|Win32 - {EA91E088-7C71-4F32-B761-E054305CD519}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {E32C7998-071A-419B-8869-E957374307CA} - EndGlobalSection -EndGlobal diff --git a/projects/VS2017.UWP/raylib.UWP/packages.config b/projects/VS2017.UWP/raylib.UWP/packages.config deleted file mode 100644 index 70c3dea0..00000000 --- a/projects/VS2017.UWP/raylib.UWP/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/projects/VS2017.UWP/raylib.UWP/raylib.UWP.vcxproj b/projects/VS2017.UWP/raylib.UWP/raylib.UWP.vcxproj deleted file mode 100644 index 41d5c0f7..00000000 --- a/projects/VS2017.UWP/raylib.UWP/raylib.UWP.vcxproj +++ /dev/null @@ -1,251 +0,0 @@ - - - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - Win32 - - - Release - x64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {ea91e088-7c71-4f32-b761-e054305cd519} - StaticLibrary - raylib_UWP - en-US - 14.0 - true - Windows Store - 10.0.18362.0 - 10.0.18362.0 - 10.0 - - - - StaticLibrary - true - $(DefaultPlatformToolset) - - - StaticLibrary - true - $(DefaultPlatformToolset) - - - StaticLibrary - true - $(DefaultPlatformToolset) - - - StaticLibrary - false - $(DefaultPlatformToolset) - - - StaticLibrary - false - $(DefaultPlatformToolset) - - - StaticLibrary - false - $(DefaultPlatformToolset) - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - $(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform) - $(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform) - - - false - $(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform) - $(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform) - - - false - $(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform) - $(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform) - - - false - $(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform) - $(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform) - - - false - $(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform) - $(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform) - - - false - $(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform) - $(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform) - - - - NotUsing - false - true - SUPPORT_GIF_RECORDING;_CRT_SECURE_NO_WARNINGS;GRAPHICS_API_OPENGL_ES2;PLATFORM_UWP;_UNICODE;UNICODE;%(PreprocessorDefinitions) - $(SolutionDir)packages\ANGLE.WindowsStore.2.1.13\Include;$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) - - - Console - false - false - - - - - NotUsing - false - true - _CRT_SECURE_NO_WARNINGS;GRAPHICS_API_OPENGL_ES2;PLATFORM_UWP;_UNICODE;UNICODE;%(PreprocessorDefinitions) - $(SolutionDir)packages\ANGLE.WindowsStore.2.1.13\Include;$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) - - - Console - false - false - - - - - NotUsing - false - true - _CRT_SECURE_NO_WARNINGS;GRAPHICS_API_OPENGL_ES2;PLATFORM_UWP;_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;%(ClCompile.PreprocessorDefinitions) - $(SolutionDir)packages\ANGLE.WindowsStore.2.1.13\Include;$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) - - - Console - false - false - - - - - NotUsing - false - true - _CRT_SECURE_NO_WARNINGS;GRAPHICS_API_OPENGL_ES2;PLATFORM_UWP;_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;%(ClCompile.PreprocessorDefinitions) - $(SolutionDir)packages\ANGLE.WindowsStore.2.1.13\Include;$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) - - - Console - false - false - - - - - NotUsing - false - true - _CRT_SECURE_NO_WARNINGS;GRAPHICS_API_OPENGL_ES2;PLATFORM_UWP;_UNICODE;UNICODE;%(PreprocessorDefinitions) - $(SolutionDir)packages\ANGLE.WindowsStore.2.1.13\Include;$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) - - - Console - false - false - - - - - NotUsing - false - true - _CRT_SECURE_NO_WARNINGS;GRAPHICS_API_OPENGL_ES2;PLATFORM_UWP;_UNICODE;UNICODE;%(PreprocessorDefinitions) - $(SolutionDir)packages\ANGLE.WindowsStore.2.1.13\Include;$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) - - - Console - false - false - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - \ No newline at end of file diff --git a/projects/VS2017.UWP/raylib.UWP/raylib.UWP.vcxproj.filters b/projects/VS2017.UWP/raylib.UWP/raylib.UWP.vcxproj.filters deleted file mode 100644 index 8050a1ef..00000000 --- a/projects/VS2017.UWP/raylib.UWP/raylib.UWP.vcxproj.filters +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/core.c b/src/core.c index 12cfb735..3b0b8b89 100644 --- a/src/core.c +++ b/src/core.c @@ -11,7 +11,6 @@ * - PLATFORM_RPI: Raspberry Pi 0,1,2,3 (Raspbian, native mode) * - PLATFORM_DRM: Linux native mode, including Raspberry Pi 4 with V3D fkms driver * - PLATFORM_WEB: HTML5 with WebAssembly -* - PLATFORM_UWP: Windows 10 App, Windows Phone, Xbox One * * CONFIGURATION: * @@ -24,17 +23,17 @@ * NOTE: OpenGL ES 2.0 is required and graphic device is managed by EGL * * #define PLATFORM_RPI -* Windowing and input system configured for Raspberry Pi i native mode (no X.org required, tested on Raspbian), +* Windowing and input system configured for Raspberry Pi in native mode (no XWindow required), +* graphic device is managed by EGL and inputs are processed is raw mode, reading from /dev/input/ +* +* #define PLATFORM_DRM +* Windowing and input system configured for DRM native mode (RPI4 and other devices) * graphic device is managed by EGL and inputs are processed is raw mode, reading from /dev/input/ * * #define PLATFORM_WEB * Windowing and input system configured for HTML5 (run on browser), code converted from C to asm.js * using emscripten compiler. OpenGL ES 2.0 required for direct translation to WebGL equivalent code. * -* #define PLATFORM_UWP -* Universal Windows Platform support, using OpenGL ES 2.0 through ANGLE on multiple Windows platforms, -* including Windows 10 App, Windows Phone and Xbox One platforms. -* * #define SUPPORT_DEFAULT_FONT (default) * Default font is loaded on window initialization to be available for the user to render simple text. * NOTE: If enabled, uses external module functions to load default raylib font (module: text) @@ -167,7 +166,7 @@ #include // Required for: stat() [Used in GetFileModTime()] -#if (defined(PLATFORM_DESKTOP) || defined(PLATFORM_UWP)) && defined(_WIN32) && (defined(_MSC_VER) || defined(__TINYC__)) +#if defined(PLATFORM_DESKTOP) && defined(_WIN32) && (defined(_MSC_VER) || defined(__TINYC__)) #define DIRENT_MALLOC RL_MALLOC #define DIRENT_FREE RL_FREE @@ -192,6 +191,8 @@ // NOTE: Already provided by rlgl implementation (on glad.h) #include "GLFW/glfw3.h" // GLFW3 library: Windows, OpenGL context and Input management // NOTE: GLFW3 already includes gl.h (OpenGL) headers + +//https://randomascii.wordpress.com/2020/10/04/windows-timer-resolution-the-great-rule-change/ // Support retrieving native window handlers #if defined(_WIN32) @@ -256,13 +257,6 @@ //#include "GLES2/gl2.h" // OpenGL ES 2.0 library (not required in this module, only in rlgl) #endif -#if defined(PLATFORM_UWP) - #include "EGL/egl.h" // Native platform windowing system interface - #include "EGL/eglext.h" // EGL extensions - //#include "GLES2/gl2.h" // OpenGL ES 2.0 library (not required in this module, only in rlgl) - #include "uwp_events.h" // UWP bootstrapping functions -#endif - #if defined(PLATFORM_WEB) #define GLFW_INCLUDE_ES2 // GLFW3: Enable OpenGL ES 2.0 (translated to WebGL) #include "GLFW/glfw3.h" // GLFW3 library: Windows, OpenGL context and Input management @@ -361,7 +355,7 @@ typedef struct CoreData { #if defined(PLATFORM_RPI) EGL_DISPMANX_WINDOW_T handle; // Native window handle (graphic device) #endif -#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM) || defined(PLATFORM_UWP) +#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM) #if defined(PLATFORM_DRM) int fd; // File descriptor for /dev/dri/... drmModeConnector *connector; // Direct Rendering Manager (DRM) mode connector @@ -744,14 +738,6 @@ static void RestoreTerminal(void) // NOTE: data parameter could be used to pass any kind of required data to the initialization void InitWindow(int width, int height, const char *title) { -#if defined(PLATFORM_UWP) - if (!UWPIsConfigured()) - { - TRACELOG(LOG_FATAL, "UWP Functions have not been set yet, please set these before initializing raylib!"); - return; - } -#endif - TRACELOG(LOG_INFO, "Initializing raylib %s", RAYLIB_VERSION); if ((title != NULL) && (title[0] != 0)) CORE.Window.title = title; @@ -762,11 +748,6 @@ void InitWindow(int width, int height, const char *title) CORE.Input.Mouse.cursor = MOUSE_CURSOR_ARROW; CORE.Input.Gamepad.lastButtonPressed = -1; -#if defined(PLATFORM_UWP) - // The axis count is 6 (2 thumbsticks and left and right trigger) - CORE.Input.Gamepad.axisCount = 6; -#endif - #if defined(PLATFORM_ANDROID) CORE.Window.screen.width = width; CORE.Window.screen.height = height; @@ -827,7 +808,7 @@ void InitWindow(int width, int height, const char *title) } } #endif -#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) || defined(PLATFORM_RPI) || defined(PLATFORM_UWP) || defined(PLATFORM_DRM) +#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM) // Initialize graphics device (display device and OpenGL context) // NOTE: returns true if window and graphic device has been initialized successfully CORE.Window.ready = InitGraphicsDevice(width, height); @@ -910,7 +891,7 @@ void InitWindow(int width, int height, const char *title) CORE.Time.frameCounter = 0; #endif -#endif // PLATFORM_DESKTOP || PLATFORM_WEB || PLATFORM_RPI || PLATFORM_DRM || PLATFORM_UWP +#endif // PLATFORM_DESKTOP || PLATFORM_WEB || PLATFORM_RPI || PLATFORM_DRM } // Close window and unload OpenGL context @@ -936,11 +917,11 @@ void CloseWindow(void) glfwTerminate(); #endif -#if defined(_WIN32) && defined(SUPPORT_WINMM_HIGHRES_TIMER) && !defined(SUPPORT_BUSY_WAIT_LOOP) && !defined(PLATFORM_UWP) +#if defined(_WIN32) && defined(SUPPORT_WINMM_HIGHRES_TIMER) && !defined(SUPPORT_BUSY_WAIT_LOOP) timeEndPeriod(1); // Restore time period #endif -#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM) || defined(PLATFORM_UWP) +#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM) #if defined(PLATFORM_DRM) if (CORE.Window.prevFB) { @@ -1073,7 +1054,7 @@ bool WindowShouldClose(void) else return true; #endif -#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM) || defined(PLATFORM_UWP) +#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM) if (CORE.Window.ready) return CORE.Window.shouldClose; else return true; #endif @@ -1103,7 +1084,7 @@ bool IsWindowHidden(void) // Check if window has been minimized bool IsWindowMinimized(void) { -#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) || defined(PLATFORM_UWP) +#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) return ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0); #else return false; @@ -1123,7 +1104,7 @@ bool IsWindowMaximized(void) // Check if window has the focus bool IsWindowFocused(void) { -#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) || defined(PLATFORM_UWP) +#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) return ((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) == 0); // TODO! #else return true; @@ -1133,7 +1114,7 @@ bool IsWindowFocused(void) // Check if window has been resizedLastFrame bool IsWindowResized(void) { -#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) || defined(PLATFORM_UWP) +#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) return CORE.Window.resizedLastFrame; #else return false; @@ -1876,9 +1857,7 @@ void ShowCursor(void) #if defined(PLATFORM_DESKTOP) glfwSetInputMode(CORE.Window.handle, GLFW_CURSOR, GLFW_CURSOR_NORMAL); #endif -#if defined(PLATFORM_UWP) - UWPGetMouseShowFunc()(); -#endif + CORE.Input.Mouse.cursorHidden = false; } @@ -1888,9 +1867,7 @@ void HideCursor(void) #if defined(PLATFORM_DESKTOP) glfwSetInputMode(CORE.Window.handle, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); #endif -#if defined(PLATFORM_UWP) - UWPGetMouseHideFunc()(); -#endif + CORE.Input.Mouse.cursorHidden = true; } @@ -1909,9 +1886,7 @@ void EnableCursor(void) #if defined(PLATFORM_WEB) emscripten_exit_pointerlock(); #endif -#if defined(PLATFORM_UWP) - UWPGetMouseUnlockFunc()(); -#endif + CORE.Input.Mouse.cursorHidden = false; } @@ -1924,9 +1899,7 @@ void DisableCursor(void) #if defined(PLATFORM_WEB) emscripten_request_pointerlock("#canvas", 1); #endif -#if defined(PLATFORM_UWP) - UWPGetMouseLockFunc()(); -#endif + CORE.Input.Mouse.cursorHidden = true; } @@ -2667,10 +2640,6 @@ double GetTime(void) return (double)(time - CORE.Time.base)*1e-9; // Elapsed time since InitTimer() #endif - -#if defined(PLATFORM_UWP) - return UWPGetQueryTimeFunc()(); -#endif } // Setup window configuration flags (view FLAGS) @@ -3517,9 +3486,6 @@ void SetMousePosition(int x, int y) // NOTE: emscripten not implemented glfwSetCursorPos(CORE.Window.handle, CORE.Input.Mouse.currentPosition.x, CORE.Input.Mouse.currentPosition.y); #endif -#if defined(PLATFORM_UWP) - UWPGetMouseSetPosFunc()(x, y); -#endif } // Set mouse offset @@ -3567,7 +3533,7 @@ void SetMouseCursor(int cursor) // Get touch position X for touch point 0 (relative to screen size) int GetTouchX(void) { -#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) || defined(PLATFORM_UWP) +#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) return (int)CORE.Input.Touch.position[0].x; #else // PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_DRM return GetMouseX(); @@ -3577,7 +3543,7 @@ int GetTouchX(void) // Get touch position Y for touch point 0 (relative to screen size) int GetTouchY(void) { -#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) || defined(PLATFORM_UWP) +#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) return (int)CORE.Input.Touch.position[0].y; #else // PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_DRM return GetMouseY(); @@ -3611,7 +3577,7 @@ Vector2 GetTouchPosition(int index) position.y = position.y*((float)CORE.Window.render.height/(float)CORE.Window.display.height) - CORE.Window.renderOffset.y/2; } #endif -#if defined(PLATFORM_WEB) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM) || defined(PLATFORM_UWP) +#if defined(PLATFORM_WEB) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM) if (index < MAX_TOUCH_POINTS) position = CORE.Input.Touch.position[index]; else TRACELOG(LOG_WARNING, "INPUT: Required touch point out of range (Max touch points: %i)", MAX_TOUCH_POINTS); @@ -3901,7 +3867,7 @@ static bool InitGraphicsDevice(int width, int height) } #endif // PLATFORM_DESKTOP || PLATFORM_WEB -#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM) || defined(PLATFORM_UWP) +#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM) CORE.Window.fullscreen = true; CORE.Window.flags |= FLAG_FULLSCREEN_MODE; @@ -4102,175 +4068,6 @@ static bool InitGraphicsDevice(int width, int height) EGL_NONE }; -#if defined(PLATFORM_UWP) - const EGLint surfaceAttributes[] = - { - // EGL_ANGLE_SURFACE_RENDER_TO_BACK_BUFFER is part of the same optimization as EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER (see above). - // If you have compilation issues with it then please update your Visual Studio templates. - EGL_ANGLE_SURFACE_RENDER_TO_BACK_BUFFER, EGL_TRUE, - EGL_NONE - }; - - const EGLint defaultDisplayAttributes[] = - { - // 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, - }; - - const EGLint fl9_3DisplayAttributes[] = - { - // These can be used to request ANGLE's D3D11 renderer, with D3D11 Feature Level 9_3. - // These attributes are used if the call to eglInitialize fails with the default display attributes. - 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_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, - EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE, - EGL_NONE, - }; - - const EGLint warpDisplayAttributes[] = - { - // These attributes can be used to request D3D11 WARP. - // They are used if eglInitialize fails with both the default display attributes and the 9_3 display attributes. - EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, - EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE, - EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, - EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE, - EGL_NONE, - }; - - // eglGetPlatformDisplayEXT is an alternative to eglGetDisplay. It allows us to pass in display attributes, used to configure D3D11. - PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)(eglGetProcAddress("eglGetPlatformDisplayEXT")); - if (!eglGetPlatformDisplayEXT) - { - TRACELOG(LOG_WARNING, "DISPLAY: Failed to get function pointer: eglGetPlatformDisplayEXT()"); - return false; - } - - // - // To initialize the display, we make three sets of calls to eglGetPlatformDisplayEXT and eglInitialize, with varying - // parameters passed to eglGetPlatformDisplayEXT: - // 1) The first calls uses "defaultDisplayAttributes" as a parameter. This corresponds to D3D11 Feature Level 10_0+. - // 2) If eglInitialize fails for step 1 (e.g. because 10_0+ isn't supported by the default GPU), then we try again - // using "fl9_3DisplayAttributes". This corresponds to D3D11 Feature Level 9_3. - // 3) If eglInitialize fails for step 2 (e.g. because 9_3+ isn't supported by the default GPU), then we try again - // using "warpDisplayAttributes". This corresponds to D3D11 Feature Level 11_0 on WARP, a D3D11 software rasterizer. - // - - // This tries to initialize EGL to D3D11 Feature Level 10_0+. See above comment for details. - CORE.Window.device = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, defaultDisplayAttributes); - if (CORE.Window.device == EGL_NO_DISPLAY) - { - TRACELOG(LOG_WARNING, "DISPLAY: Failed to initialize EGL device"); - return false; - } - - if (eglInitialize(CORE.Window.device, NULL, NULL) == EGL_FALSE) - { - // This tries to initialize EGL to D3D11 Feature Level 9_3, if 10_0+ is unavailable (e.g. on some mobile devices). - CORE.Window.device = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, fl9_3DisplayAttributes); - if (CORE.Window.device == EGL_NO_DISPLAY) - { - TRACELOG(LOG_WARNING, "DISPLAY: Failed to initialize EGL device"); - return false; - } - - if (eglInitialize(CORE.Window.device, NULL, NULL) == EGL_FALSE) - { - // This initializes EGL to D3D11 Feature Level 11_0 on WARP, if 9_3+ is unavailable on the default GPU. - CORE.Window.device = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, warpDisplayAttributes); - if (CORE.Window.device == EGL_NO_DISPLAY) - { - TRACELOG(LOG_WARNING, "DISPLAY: Failed to initialize EGL device"); - return false; - } - - if (eglInitialize(CORE.Window.device, NULL, NULL) == EGL_FALSE) - { - // If all of the calls to eglInitialize returned EGL_FALSE then an error has occurred. - TRACELOG(LOG_WARNING, "DISPLAY: Failed to initialize EGL device"); - return false; - } - } - } - - EGLint numConfigs = 0; - if ((eglChooseConfig(CORE.Window.device, framebufferAttribs, &CORE.Window.config, 1, &numConfigs) == EGL_FALSE) || (numConfigs == 0)) - { - TRACELOG(LOG_WARNING, "DISPLAY: Failed to choose first EGL configuration"); - return false; - } - - // Create a PropertySet and initialize with the EGLNativeWindowType. - //PropertySet^ surfaceCreationProperties = ref new PropertySet(); - //surfaceCreationProperties->Insert(ref new String(EGLNativeWindowTypeProperty), window); // CoreWindow^ window - - // You can configure the surface to render at a lower resolution and be scaled up to - // the full window size. The scaling is often free on mobile hardware. - // - // One way to configure the SwapChainPanel is to specify precisely which resolution it should render at. - // Size customRenderSurfaceSize = Size(800, 600); - // surfaceCreationProperties->Insert(ref new String(EGLRenderSurfaceSizeProperty), PropertyValue::CreateSize(customRenderSurfaceSize)); - // - // Another way is to tell the SwapChainPanel to render at a certain scale factor compared to its size. - // e.g. if the SwapChainPanel is 1920x1280 then setting a factor of 0.5f will make the app render at 960x640 - // float customResolutionScale = 0.5f; - // surfaceCreationProperties->Insert(ref new String(EGLRenderResolutionScaleProperty), PropertyValue::CreateSingle(customResolutionScale)); - - - // eglCreateWindowSurface() requires a EGLNativeWindowType parameter, - // In Windows platform: typedef HWND EGLNativeWindowType; - - - // Property: EGLNativeWindowTypeProperty - // Type: IInspectable - // Description: Set this property to specify the window type to use for creating a surface. - // If this property is missing, surface creation will fail. - // - //const wchar_t EGLNativeWindowTypeProperty[] = L"EGLNativeWindowTypeProperty"; - - //https://stackoverflow.com/questions/46550182/how-to-create-eglsurface-using-c-winrt-and-angle - - //CORE.Window.surface = eglCreateWindowSurface(CORE.Window.device, CORE.Window.config, reinterpret_cast(surfaceCreationProperties), surfaceAttributes); - CORE.Window.surface = eglCreateWindowSurface(CORE.Window.device, CORE.Window.config, (EGLNativeWindowType) UWPGetCoreWindowPtr(), surfaceAttributes); - if (CORE.Window.surface == EGL_NO_SURFACE) - { - TRACELOG(LOG_WARNING, "DISPLAY: Failed to create EGL fullscreen surface"); - return false; - } - - CORE.Window.context = eglCreateContext(CORE.Window.device, CORE.Window.config, EGL_NO_CONTEXT, contextAttribs); - if (CORE.Window.context == EGL_NO_CONTEXT) - { - TRACELOG(LOG_WARNING, "DISPLAY: Failed to create EGL context"); - return false; - } - - // Get EGL device window size - eglQuerySurface(CORE.Window.device, CORE.Window.surface, EGL_WIDTH, &CORE.Window.screen.width); - eglQuerySurface(CORE.Window.device, CORE.Window.surface, EGL_HEIGHT, &CORE.Window.screen.height); - - // Get display size - UWPGetDisplaySizeFunc()(&CORE.Window.display.width, &CORE.Window.display.height); - - // Use the width and height of the surface for render - CORE.Window.render.width = CORE.Window.screen.width; - CORE.Window.render.height = CORE.Window.screen.height; - -#endif // PLATFORM_UWP - #if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM) EGLint numConfigs = 0; @@ -4470,7 +4267,7 @@ static bool InitGraphicsDevice(int width, int height) TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height); TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y); } -#endif // PLATFORM_ANDROID || PLATFORM_RPI || PLATFORM_DRM || PLATFORM_UWP +#endif // PLATFORM_ANDROID || PLATFORM_RPI || PLATFORM_DRM // Load OpenGL extensions // NOTE: GL procedures address loader is required to load extensions @@ -4512,7 +4309,7 @@ static bool InitGraphicsDevice(int width, int height) ClearBackground(RAYWHITE); // Default background color for raylib games :P -#if defined(PLATFORM_ANDROID) || defined(PLATFORM_UWP) +#if defined(PLATFORM_ANDROID) CORE.Window.ready = true; #endif @@ -4634,7 +4431,7 @@ static void InitTimer(void) // However, it can also reduce overall system performance, because the thread scheduler switches tasks more often. // High resolutions can also prevent the CPU power management system from entering power-saving modes. // Setting a higher resolution does not improve the accuracy of the high-resolution performance counter. -#if defined(_WIN32) && defined(SUPPORT_WINMM_HIGHRES_TIMER) && !defined(SUPPORT_BUSY_WAIT_LOOP) && !defined(PLATFORM_UWP) +#if defined(_WIN32) && defined(SUPPORT_WINMM_HIGHRES_TIMER) && !defined(SUPPORT_BUSY_WAIT_LOOP) timeBeginPeriod(1); // Setup high-resolution timer to 1ms (granularity of 1-2 ms) #endif @@ -4671,10 +4468,6 @@ void WaitTime(float ms) #endif // System halt functions - #if defined(PLATFORM_UWP) - UWPGetSleepFunc()(ms/1000); - return; - #endif #if defined(_WIN32) Sleep((unsigned int)ms); #endif @@ -4709,7 +4502,7 @@ void SwapScreenBuffer(void) glfwSwapBuffers(CORE.Window.handle); #endif -#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM) || defined(PLATFORM_UWP) +#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM) eglSwapBuffers(CORE.Window.device, CORE.Window.surface); #if defined(PLATFORM_DRM) @@ -4761,7 +4554,7 @@ void SwapScreenBuffer(void) CORE.Window.prevBO = bo; #endif // PLATFORM_DRM -#endif // PLATFORM_ANDROID || PLATFORM_RPI || PLATFORM_DRM || PLATFORM_UWP +#endif // PLATFORM_ANDROID || PLATFORM_RPI || PLATFORM_DRM } // Register all input events @@ -4801,7 +4594,7 @@ void PollInputEvents(void) // Register gamepads buttons events for (int i = 0; i < MAX_GAMEPADS; i++) { - if (CORE.Input.Gamepad.ready[i]) // Check if gamepad is available + if (CORE.Input.Gamepad.ready[i]) { // Register previous gamepad states for (int k = 0; k < MAX_GAMEPAD_BUTTONS; k++) CORE.Input.Gamepad.previousButtonState[i][k] = CORE.Input.Gamepad.currentButtonState[i][k]; @@ -4809,25 +4602,6 @@ void PollInputEvents(void) } #endif -#if defined(PLATFORM_UWP) - // Register previous keys states - for (int i = 0; i < 512; i++) CORE.Input.Keyboard.previousKeyState[i] = CORE.Input.Keyboard.currentKeyState[i]; - - for (int i = 0; i < MAX_GAMEPADS; i++) - { - if (CORE.Input.Gamepad.ready[i]) - { - for (int k = 0; k < MAX_GAMEPAD_BUTTONS; k++) CORE.Input.Gamepad.previousButtonState[i][k] = CORE.Input.Gamepad.currentButtonState[i][k]; - } - } - - // Register previous mouse states - CORE.Input.Mouse.previousWheelMove = CORE.Input.Mouse.currentWheelMove; - CORE.Input.Mouse.currentWheelMove = 0.0f; - - for (int i = 0; i < 3; i++) CORE.Input.Mouse.previousButtonState[i] = CORE.Input.Mouse.currentButtonState[i]; -#endif // PLATFORM_UWP - #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) // Keyboard/Mouse input polling (automatically managed by GLFW3 through callback) @@ -6412,279 +6186,6 @@ static void *GamepadThread(void *arg) } #endif // PLATFORM_RPI || PLATFORM_DRM -#if defined(PLATFORM_UWP) -// UWP function pointers -// NOTE: Those pointers are set by UWP App -static UWPQueryTimeFunc uwpQueryTimeFunc = NULL; -static UWPSleepFunc uwpSleepFunc = NULL; -static UWPDisplaySizeFunc uwpDisplaySizeFunc = NULL; -static UWPMouseFunc uwpMouseLockFunc = NULL; -static UWPMouseFunc uwpMouseUnlockFunc = NULL; -static UWPMouseFunc uwpMouseShowFunc = NULL; -static UWPMouseFunc uwpMouseHideFunc = NULL; -static UWPMouseSetPosFunc uwpMouseSetPosFunc = NULL; -static void *uwpCoreWindow = NULL; - -// Check all required UWP function pointers have been set -bool UWPIsConfigured() -{ - bool pass = true; - - if (uwpQueryTimeFunc == NULL) { TRACELOG(LOG_WARNING, "UWP: UWPSetQueryTimeFunc() must be called with a valid function before InitWindow()"); pass = false; } - if (uwpSleepFunc == NULL) { TRACELOG(LOG_WARNING, "UWP: UWPSetSleepFunc() must be called with a valid function before InitWindow()"); pass = false; } - if (uwpDisplaySizeFunc == NULL) { TRACELOG(LOG_WARNING, "UWP: UWPSetDisplaySizeFunc() must be called with a valid function before InitWindow()"); pass = false; } - if (uwpMouseLockFunc == NULL) { TRACELOG(LOG_WARNING, "UWP: UWPSetMouseLockFunc() must be called with a valid function before InitWindow()"); pass = false; } - if (uwpMouseUnlockFunc == NULL) { TRACELOG(LOG_WARNING, "UWP: UWPSetMouseUnlockFunc() must be called with a valid function before InitWindow()"); pass = false; } - if (uwpMouseShowFunc == NULL) { TRACELOG(LOG_WARNING, "UWP: UWPSetMouseShowFunc() must be called with a valid function before InitWindow()"); pass = false; } - if (uwpMouseHideFunc == NULL) { TRACELOG(LOG_WARNING, "UWP: UWPSetMouseHideFunc() must be called with a valid function before InitWindow()"); pass = false; } - if (uwpMouseSetPosFunc == NULL) { TRACELOG(LOG_WARNING, "UWP: UWPSetMouseSetPosFunc() must be called with a valid function before InitWindow()"); pass = false; } - if (uwpCoreWindow == NULL) { TRACELOG(LOG_WARNING, "UWP: A pointer to the UWP core window must be set before InitWindow()"); pass = false; } - - return pass; -} - -// UWP function handlers get/set -void UWPSetDataPath(const char *path) { CORE.Storage.basePath = path; } -UWPQueryTimeFunc UWPGetQueryTimeFunc(void) { return uwpQueryTimeFunc; } -void UWPSetQueryTimeFunc(UWPQueryTimeFunc func) { uwpQueryTimeFunc = func; } -UWPSleepFunc UWPGetSleepFunc(void) { return uwpSleepFunc; } -void UWPSetSleepFunc(UWPSleepFunc func) { uwpSleepFunc = func; } -UWPDisplaySizeFunc UWPGetDisplaySizeFunc(void) { return uwpDisplaySizeFunc; } -void UWPSetDisplaySizeFunc(UWPDisplaySizeFunc func) { uwpDisplaySizeFunc = func; } -UWPMouseFunc UWPGetMouseLockFunc() { return uwpMouseLockFunc; } -void UWPSetMouseLockFunc(UWPMouseFunc func) { uwpMouseLockFunc = func; } -UWPMouseFunc UWPGetMouseUnlockFunc() { return uwpMouseUnlockFunc; } -void UWPSetMouseUnlockFunc(UWPMouseFunc func) { uwpMouseUnlockFunc = func; } -UWPMouseFunc UWPGetMouseShowFunc() { return uwpMouseShowFunc; } -void UWPSetMouseShowFunc(UWPMouseFunc func) { uwpMouseShowFunc = func; } -UWPMouseFunc UWPGetMouseHideFunc() { return uwpMouseHideFunc; } -void UWPSetMouseHideFunc(UWPMouseFunc func) { uwpMouseHideFunc = func; } -UWPMouseSetPosFunc UWPGetMouseSetPosFunc() { return uwpMouseSetPosFunc; } -void UWPSetMouseSetPosFunc(UWPMouseSetPosFunc func) { uwpMouseSetPosFunc = func; } - -void *UWPGetCoreWindowPtr() { return uwpCoreWindow; } -void UWPSetCoreWindowPtr(void *ptr) { uwpCoreWindow = ptr; } -void UWPMouseWheelEvent(int deltaY) { CORE.Input.Mouse.currentWheelMove = (float)deltaY; } - -void UWPKeyDownEvent(int key, bool down, bool controlKey) -{ - if (key == CORE.Input.Keyboard.exitKey && down) - { - // Time to close the window. - CORE.Window.shouldClose = true; - } -#if defined(SUPPORT_SCREEN_CAPTURE) - else if (key == KEY_F12 && down) - { -#if defined(SUPPORT_GIF_RECORDING) - if (controlKey) - { - if (gifRecording) - { - gifRecording = false; - - MsfGifResult result = msf_gif_end(&gifState); - - SaveFileData(TextFormat("%s/screenrec%03i.gif", CORE.Storage.basePath, screenshotCounter), result.data, result.dataSize); - msf_gif_free(result); - - #if defined(PLATFORM_WEB) - // Download file from MEMFS (emscripten memory filesystem) - // saveFileFromMEMFSToDisk() function is defined in raylib/templates/web_shel/shell.html - emscripten_run_script(TextFormat("saveFileFromMEMFSToDisk('%s','%s')", TextFormat("screenrec%03i.gif", screenshotCounter - 1), TextFormat("screenrec%03i.gif", screenshotCounter - 1))); - #endif - - TRACELOG(LOG_INFO, "SYSTEM: Finish animated GIF recording"); - } - else - { - gifRecording = true; - gifFramesCounter = 0; - - msf_gif_begin(&gifState, CORE.Window.screen.width, CORE.Window.screen.height); - screenshotCounter++; - - TRACELOG(LOG_INFO, "SYSTEM: Start animated GIF recording: %s", TextFormat("screenrec%03i.gif", screenshotCounter)); - } - } - else -#endif // SUPPORT_GIF_RECORDING - { - TakeScreenshot(TextFormat("screenshot%03i.png", screenshotCounter)); - screenshotCounter++; - } - } -#endif // SUPPORT_SCREEN_CAPTURE - else - { - CORE.Input.Keyboard.currentKeyState[key] = down; - } -} - -void UWPKeyCharEvent(int key) -{ - if (CORE.Input.Keyboard.keyPressedQueueCount < MAX_KEY_PRESSED_QUEUE) - { - // Add character to the queue - CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = key; - CORE.Input.Keyboard.keyPressedQueueCount++; - } -} - -void UWPMouseButtonEvent(int button, bool down) -{ - CORE.Input.Mouse.currentButtonState[button] = down; - -#if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES) - // Process mouse events as touches to be able to use mouse-gestures - GestureEvent gestureEvent = { 0 }; - - // Register touch actions - if ((CORE.Input.Mouse.currentButtonState[button] == 1) && (CORE.Input.Mouse.previousButtonState[button] == 0)) gestureEvent.touchAction = TOUCH_DOWN; - else if ((CORE.Input.Mouse.currentButtonState[button] == 0) && (CORE.Input.Mouse.previousButtonState[button] == 1)) gestureEvent.touchAction = TOUCH_UP; - - // NOTE: TOUCH_MOVE event is registered in MouseCursorPosCallback() - - // Assign a pointer ID - gestureEvent.pointerId[0] = 0; - - // Register touch points count - gestureEvent.pointCount = 1; - - // Register touch points position, only one point registered - gestureEvent.position[0] = GetMousePosition(); - - // Normalize gestureEvent.position[0] for CORE.Window.screen.width and CORE.Window.screen.height - gestureEvent.position[0].x /= (float)GetScreenWidth(); - gestureEvent.position[0].y /= (float)GetScreenHeight(); - - // Gesture data is sent to gestures system for processing - ProcessGestureEvent(gestureEvent); -#endif -} - -void UWPMousePosEvent(double x, double y) -{ - CORE.Input.Mouse.currentPosition.x = (float)x; - CORE.Input.Mouse.currentPosition.y = (float)y; - CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; - -#if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES) - // Process mouse events as touches to be able to use mouse-gestures - GestureEvent gestureEvent = { 0 }; - - gestureEvent.touchAction = TOUCH_MOVE; - - // Assign a pointer ID - gestureEvent.pointerId[0] = 0; - - // Register touch points count - gestureEvent.pointCount = 1; - - // Register touch points position, only one point registered - gestureEvent.position[0] = CORE.Input.Mouse.currentPosition; - - // Normalize gestureEvent.position[0] for CORE.Window.screen.width and CORE.Window.screen.height - gestureEvent.position[0].x /= (float)GetScreenWidth(); - gestureEvent.position[0].y /= (float)GetScreenHeight(); - - // Gesture data is sent to gestures system for processing - ProcessGestureEvent(gestureEvent); -#endif -} - -void UWPResizeEvent(int width, int height) -{ - SetupViewport(width, height); // Reset viewport and projection matrix for new size - - // Set current screen size - CORE.Window.screen.width = width; - CORE.Window.screen.height = height; - CORE.Window.currentFbo.width = width; - CORE.Window.currentFbo.height = height; - - // NOTE: Postprocessing texture is not scaled to new size - - CORE.Window.resizedLastFrame = true; -} - -void UWPActivateGamepadEvent(int gamepad, bool active) -{ - if (gamepad < MAX_GAMEPADS) CORE.Input.Gamepad.ready[gamepad] = active; -} - -void UWPRegisterGamepadButton(int gamepad, int button, bool down) -{ - if (gamepad < MAX_GAMEPADS) - { - if (button < MAX_GAMEPAD_BUTTONS) - { - CORE.Input.Gamepad.currentButtonState[gamepad][button] = down; - CORE.Input.Gamepad.lastButtonPressed = button; - } - } -} - -void UWPRegisterGamepadAxis(int gamepad, int axis, float value) -{ - if (gamepad < MAX_GAMEPADS) - { - if (axis < MAX_GAMEPAD_AXIS) CORE.Input.Gamepad.axisState[gamepad][axis] = value; - } -} - -void UWPGestureMove(int pointer, float x, float y) -{ -#if defined(SUPPORT_GESTURES_SYSTEM) - GestureEvent gestureEvent = { 0 }; - - // Assign the pointer ID and touch action - gestureEvent.pointerId[0] = pointer; - gestureEvent.touchAction = TOUCH_MOVE; - - // Register touch points count - gestureEvent.pointCount = 1; - - // Register touch points position, only one point registered - gestureEvent.position[0].x = x; - gestureEvent.position[0].y = y; - - // Normalize gestureEvent.position[0] for CORE.Window.screen.width and CORE.Window.screen.height - gestureEvent.position[0].x /= (float)GetScreenWidth(); - gestureEvent.position[0].y /= (float)GetScreenHeight(); - - // Gesture data is sent to gestures system for processing - ProcessGestureEvent(gestureEvent); -#endif -} - -void UWPGestureTouch(int pointer, float x, float y, bool touch) -{ -#if defined(SUPPORT_GESTURES_SYSTEM) - GestureEvent gestureEvent = { 0 }; - - // Assign the pointer ID and touch action - gestureEvent.pointerId[0] = pointer; - gestureEvent.touchAction = touch ? TOUCH_DOWN : TOUCH_UP; - - // Register touch points count - gestureEvent.pointCount = 1; - - // Register touch points position, only one point registered - gestureEvent.position[0].x = x; - gestureEvent.position[0].y = y; - - // Normalize gestureEvent.position[0] for CORE.Window.screen.width and CORE.Window.screen.height - gestureEvent.position[0].x /= (float)GetScreenWidth(); - gestureEvent.position[0].y /= (float)GetScreenHeight(); - - // Gesture data is sent to gestures system for processing - ProcessGestureEvent(gestureEvent); -#endif -} - -#endif // PLATFORM_UWP - #if defined(PLATFORM_DRM) // Search matching DRM mode in connector's mode list static int FindMatchingConnectorMode(const drmModeConnector *connector, const drmModeModeInfo *mode) diff --git a/src/uwp_events.h b/src/uwp_events.h deleted file mode 100644 index 25c7113a..00000000 --- a/src/uwp_events.h +++ /dev/null @@ -1,88 +0,0 @@ -/********************************************************************************************** -* -* raylib.uwp_events - Functions for bootstrapping UWP functionality -* -* -* LICENSE: zlib/libpng -* -* Copyright (c) 2020-2021 Reece Mackie (@Rover656) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#ifndef UWP_EVENTS_H -#define UWP_EVENTS_H - -#if defined(__cplusplus) -extern "C" { -#endif - -#if defined(PLATFORM_UWP) -bool UWPIsConfigured(); // Check if UWP functions are set and ready to use -void UWPSetDataPath(const char *path); // Set the UWP data path for saving and loading - -typedef double(*UWPQueryTimeFunc)(); // Callback function to query time -UWPQueryTimeFunc UWPGetQueryTimeFunc(void); // Get query time function -void UWPSetQueryTimeFunc(UWPQueryTimeFunc func); // Set query time function - -typedef void (*UWPSleepFunc)(double sleepUntil); // Callback function for sleep -UWPSleepFunc UWPGetSleepFunc(void); // Get sleep function -void UWPSetSleepFunc(UWPSleepFunc func); // Set sleep function - -typedef void (*UWPDisplaySizeFunc)(int *width, int *height); // Callback function for display size change -UWPDisplaySizeFunc UWPGetDisplaySizeFunc(void); // Get display size function -void UWPSetDisplaySizeFunc(UWPDisplaySizeFunc func); // Set display size function - -typedef void (*UWPMouseFunc)(void); // Callback function for mouse cursor control -UWPMouseFunc UWPGetMouseLockFunc(); // Get mouse lock function -void UWPSetMouseLockFunc(UWPMouseFunc func); // Set mouse lock function -UWPMouseFunc UWPGetMouseUnlockFunc(); // Get mouse unlock function -void UWPSetMouseUnlockFunc(UWPMouseFunc func); // Set mouse unlock function -UWPMouseFunc UWPGetMouseShowFunc(); // Get mouse show function -void UWPSetMouseShowFunc(UWPMouseFunc func); // Set mouse show function -UWPMouseFunc UWPGetMouseHideFunc(); // Get mouse hide function -void UWPSetMouseHideFunc(UWPMouseFunc func); // Set mouse hide function - -typedef void (*UWPMouseSetPosFunc)(int x, int y); // Callback function to set mouse position -UWPMouseSetPosFunc UWPGetMouseSetPosFunc(); // Get mouse set position function -void UWPSetMouseSetPosFunc(UWPMouseSetPosFunc func); // Set mouse set position function - -// NOTE: Below functions are implemented in core.c but are placed here so they can be called by user code -// This choice is made as platform-specific code is preferred to be kept away from raylib.h - -void UWPKeyDownEvent(int key, bool down, bool controlKey); // Check for key down event -void UWPKeyCharEvent(int key); // Check for a character event (CoreWindow::CharacterRecieved) -void UWPMouseButtonEvent(int button, bool down); // Check for mouse button state changes event -void UWPMousePosEvent(double x, double y); // Check for mouse cursor move event -void UWPMouseWheelEvent(int deltaY); // Check for mouse wheel move event -void UWPResizeEvent(int width, int height); // Check for window resize event -void UWPActivateGamepadEvent(int gamepad, bool active); // Check for gamepad activated event -void UWPRegisterGamepadButton(int gamepad, int button, bool down); // Check for gamepad button state change event -void UWPRegisterGamepadAxis(int gamepad, int axis, float value); // Check for gamepad axis state change event -void UWPGestureMove(int pointer, float x, float y); // Check for touch point move event -void UWPGestureTouch(int pointer, float x, float y, bool touch); // Check for touch down or up event - -void *UWPGetCoreWindowPtr(); // Get core window pointer -void UWPSetCoreWindowPtr(void *ptr); // Set core window pointer, so that it can be passed to EGL - -#if defined(__cplusplus) -} -#endif - -#endif // PLATFORM_UWP - -#endif // UWP_EVENTS_H