First draft of UWP rework.
This commit is contained in:
parent
e65d15f6ad
commit
8061116f0e
|
|
@ -9,9 +9,6 @@
|
||||||
* #define PCH
|
* #define PCH
|
||||||
* This defines what header is the PCH and needs to be included
|
* This defines what header is the PCH and needs to be included
|
||||||
*
|
*
|
||||||
* #define HOLDHACK
|
|
||||||
* This enables a hack to fix flickering key presses (Temporary)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2013-2020 Ramon Santamaria (@raysan5)
|
* Copyright (c) 2013-2020 Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||||
|
|
@ -40,6 +37,7 @@
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <wrl.h>
|
#include <wrl.h>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
//EGL
|
//EGL
|
||||||
#include <EGL/eglplatform.h>
|
#include <EGL/eglplatform.h>
|
||||||
|
|
@ -59,25 +57,12 @@ using namespace Windows::Graphics::Display;
|
||||||
using namespace Microsoft::WRL;
|
using namespace Microsoft::WRL;
|
||||||
using namespace Platform;
|
using namespace Platform;
|
||||||
|
|
||||||
extern "C" { EGLNativeWindowType handle; };
|
|
||||||
|
|
||||||
/*
|
|
||||||
TODO list:
|
|
||||||
- Cache reference to our CoreWindow?
|
|
||||||
- Implement gestures support
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Stand-ins for "core.c" variables
|
// Stand-ins for "core.c" variables
|
||||||
#define MAX_GAMEPADS 4 // Max number of gamepads supported
|
#define MAX_GAMEPADS 4 // Max number of gamepads supported
|
||||||
#define MAX_GAMEPAD_BUTTONS 32 // Max bumber of buttons supported (per gamepad)
|
#define MAX_GAMEPAD_BUTTONS 32 // Max bumber of buttons supported (per gamepad)
|
||||||
#define MAX_GAMEPAD_AXIS 8 // Max number of axis supported (per gamepad)
|
#define MAX_GAMEPAD_AXIS 8 // Max number of axis supported (per gamepad)
|
||||||
|
|
||||||
//Mouse cursor locking
|
// TODO: I want to remove this "BaseApp" thing and just implement this in App.
|
||||||
bool cursorLocked = false;
|
|
||||||
Vector2 mouseDelta = {0, 0};
|
|
||||||
|
|
||||||
//Our mouse cursor
|
|
||||||
CoreCursor ^regularCursor = ref new CoreCursor(CoreCursorType::Arrow, 0); // The "visible arrow" cursor type
|
|
||||||
|
|
||||||
//Base app implementation
|
//Base app implementation
|
||||||
ref class BaseApp : public Windows::ApplicationModel::Core::IFrameworkView
|
ref class BaseApp : public Windows::ApplicationModel::Core::IFrameworkView
|
||||||
|
|
@ -100,26 +85,22 @@ public:
|
||||||
|
|
||||||
virtual void SetWindow(Windows::UI::Core::CoreWindow^ window)
|
virtual void SetWindow(Windows::UI::Core::CoreWindow^ window)
|
||||||
{
|
{
|
||||||
|
// Hook window events
|
||||||
window->SizeChanged += ref new TypedEventHandler<CoreWindow^, WindowSizeChangedEventArgs^>(this, &BaseApp::OnWindowSizeChanged);
|
window->SizeChanged += ref new TypedEventHandler<CoreWindow^, WindowSizeChangedEventArgs^>(this, &BaseApp::OnWindowSizeChanged);
|
||||||
window->VisibilityChanged += ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &BaseApp::OnVisibilityChanged);
|
window->VisibilityChanged += ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &BaseApp::OnVisibilityChanged);
|
||||||
window->Closed += ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &BaseApp::OnWindowClosed);
|
|
||||||
|
|
||||||
|
// Hook mouse pointer events
|
||||||
window->PointerPressed += ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &BaseApp::PointerPressed);
|
window->PointerPressed += ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &BaseApp::PointerPressed);
|
||||||
|
window->PointerReleased += ref new Windows::Foundation::TypedEventHandler<Windows::UI::Core::CoreWindow^, Windows::UI::Core::PointerEventArgs^>(this, &BaseApp::PointerReleased);
|
||||||
window->PointerWheelChanged += ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &BaseApp::PointerWheelChanged);
|
window->PointerWheelChanged += ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &BaseApp::PointerWheelChanged);
|
||||||
|
window->PointerMoved += ref new Windows::Foundation::TypedEventHandler<Windows::UI::Core::CoreWindow^, Windows::UI::Core::PointerEventArgs^>(this, &BaseApp::PointerMoved);
|
||||||
|
|
||||||
|
// Hook keyboard events.
|
||||||
window->KeyDown += ref new TypedEventHandler<CoreWindow ^, KeyEventArgs ^>(this, &BaseApp::OnKeyDown);
|
window->KeyDown += ref new TypedEventHandler<CoreWindow ^, KeyEventArgs ^>(this, &BaseApp::OnKeyDown);
|
||||||
window->KeyUp += ref new TypedEventHandler<CoreWindow ^, KeyEventArgs ^>(this, &BaseApp::OnKeyUp);
|
window->KeyUp += ref new TypedEventHandler<CoreWindow ^, KeyEventArgs ^>(this, &BaseApp::OnKeyUp);
|
||||||
|
|
||||||
Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved += ref new TypedEventHandler<MouseDevice^, MouseEventArgs^>(this, &BaseApp::MouseMoved);
|
// The CoreWindow has been created, we can pass this to raylib for EGL context creation when it's time
|
||||||
|
UWPSetCoreWindowPtr((void*) window);
|
||||||
DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView();
|
|
||||||
currentDisplayInformation->DpiChanged += ref new TypedEventHandler<DisplayInformation^, Object^>(this, &BaseApp::OnDpiChanged);
|
|
||||||
currentDisplayInformation->OrientationChanged += ref new TypedEventHandler<DisplayInformation^, Object^>(this, &BaseApp::OnOrientationChanged);
|
|
||||||
|
|
||||||
// The CoreWindow has been created, so EGL can be initialized.
|
|
||||||
|
|
||||||
handle = (EGLNativeWindowType)window;
|
|
||||||
|
|
||||||
InitWindow(width, height, "raylib game example");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Load(Platform::String^ entryPoint) {}
|
virtual void Load(Platform::String^ entryPoint) {}
|
||||||
|
|
@ -132,36 +113,86 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Run()
|
virtual void Run()
|
||||||
|
{
|
||||||
|
// Set up our UWP implementation
|
||||||
|
UWPSetQueryTimeFunc([]()
|
||||||
|
{
|
||||||
|
static auto timeStart = std::chrono::high_resolution_clock::now();
|
||||||
|
auto delta = std::chrono::high_resolution_clock::now() - timeStart;
|
||||||
|
return (double)std::chrono::duration_cast<std::chrono::seconds>(delta).count();
|
||||||
|
});
|
||||||
|
|
||||||
|
UWPSetSleepFunc([](double seconds) { std::this_thread::sleep_for(std::chrono::duration<double>(seconds)); });
|
||||||
|
|
||||||
|
UWPSetDisplaySizeFunc([](int* width, int* height)
|
||||||
{
|
{
|
||||||
// Get display dimensions
|
// Get display dimensions
|
||||||
DisplayInformation^ dInfo = DisplayInformation::GetForCurrentView();
|
DisplayInformation^ dInfo = DisplayInformation::GetForCurrentView();
|
||||||
Vector2 screenSize = { dInfo->ScreenWidthInRawPixels, dInfo->ScreenHeightInRawPixels };
|
*width = dInfo->ScreenWidthInRawPixels;
|
||||||
|
*height = dInfo->ScreenHeightInRawPixels;
|
||||||
|
});
|
||||||
|
|
||||||
// Send display dimensions
|
UWPSetMouseHideFunc([]()
|
||||||
UWPMessage *msg = CreateUWPMessage();
|
{
|
||||||
msg->type = UWP_MSG_SET_DISPLAY_DIMS;
|
CoreWindow::GetForCurrentThread()->PointerCursor = nullptr;
|
||||||
msg->paramVector0 = screenSize;
|
});
|
||||||
UWPSendMessage(msg);
|
|
||||||
|
|
||||||
// Send the time to the core
|
UWPSetMouseShowFunc([]()
|
||||||
using clock = std::chrono::high_resolution_clock;
|
{
|
||||||
auto timeStart = clock::now();
|
CoreWindow::GetForCurrentThread()->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
UWPSetMouseLockFunc([]()
|
||||||
|
{
|
||||||
|
CoreWindow::GetForCurrentThread()->PointerCursor = nullptr;
|
||||||
|
// TODO:
|
||||||
|
});
|
||||||
|
|
||||||
|
UWPSetMouseUnlockFunc([]()
|
||||||
|
{
|
||||||
|
CoreWindow::GetForCurrentThread()->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
|
||||||
|
// TODO:
|
||||||
|
});
|
||||||
|
|
||||||
|
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(width, height, "raylib game example");
|
||||||
|
|
||||||
// Set fps if 0
|
// Set fps if 0
|
||||||
if (GetFPS() <= 0) SetTargetFPS(60);
|
if (GetFPS() <= 0) SetTargetFPS(60);
|
||||||
|
|
||||||
while (!mWindowClosed)
|
while (!WindowShouldClose())
|
||||||
{
|
{
|
||||||
if (mWindowVisible)
|
if (mWindowVisible)
|
||||||
{
|
{
|
||||||
// Send time
|
|
||||||
auto delta = clock::now() - timeStart;
|
|
||||||
|
|
||||||
UWPMessage *timeMsg = CreateUWPMessage();
|
|
||||||
timeMsg->type = UWP_MSG_SET_GAME_TIME;
|
|
||||||
timeMsg->paramDouble0 = std::chrono::duration_cast<std::chrono::seconds>(delta).count();
|
|
||||||
UWPSendMessage(timeMsg);
|
|
||||||
|
|
||||||
// Call update function
|
// Call update function
|
||||||
Update();
|
Update();
|
||||||
|
|
||||||
|
|
@ -188,177 +219,16 @@ protected:
|
||||||
// Input polling
|
// Input polling
|
||||||
void PollInput()
|
void PollInput()
|
||||||
{
|
{
|
||||||
// Process Messages
|
|
||||||
{
|
|
||||||
// Loop over pending messages
|
|
||||||
while (UWPHasMessages())
|
|
||||||
{
|
|
||||||
// Get the message
|
|
||||||
auto msg = UWPGetMessage();
|
|
||||||
|
|
||||||
// Carry out the command
|
|
||||||
switch(msg->type)
|
|
||||||
{
|
|
||||||
case UWP_MSG_SHOW_MOUSE: // Do the same thing because of how UWP works...
|
|
||||||
case UWP_MSG_UNLOCK_MOUSE:
|
|
||||||
{
|
|
||||||
CoreWindow::GetForCurrentThread()->PointerCursor = regularCursor;
|
|
||||||
cursorLocked = false;
|
|
||||||
MoveMouse(GetMousePosition());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case UWP_MSG_HIDE_MOUSE: // Do the same thing because of how UWP works...
|
|
||||||
case UWP_MSG_LOCK_MOUSE:
|
|
||||||
{
|
|
||||||
CoreWindow::GetForCurrentThread()->PointerCursor = nullptr;
|
|
||||||
cursorLocked = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case UWP_MSG_SET_MOUSE_LOCATION:
|
|
||||||
{
|
|
||||||
MoveMouse(msg->paramVector0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete the message
|
|
||||||
DeleteUWPMessage(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process Keyboard
|
|
||||||
{
|
|
||||||
for (int k = 0x08; k < 0xA6; k++) {
|
|
||||||
auto state = CoreWindow::GetForCurrentThread()->GetKeyState((Windows::System::VirtualKey) k);
|
|
||||||
|
|
||||||
#ifdef HOLDHACK
|
|
||||||
// Super hacky way of waiting three frames to see if we are ready to register the key as deregistered
|
|
||||||
// This will wait an entire 4 frames before deregistering the key, this makes sure that the key is not flickering
|
|
||||||
if (KeyboardStateHack[k] == 2)
|
|
||||||
{
|
|
||||||
if ((state & CoreVirtualKeyStates::None) == CoreVirtualKeyStates::None)
|
|
||||||
{
|
|
||||||
KeyboardStateHack[k] = 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (KeyboardStateHack[k] == 3)
|
|
||||||
{
|
|
||||||
if ((state & CoreVirtualKeyStates::None) == CoreVirtualKeyStates::None)
|
|
||||||
{
|
|
||||||
KeyboardStateHack[k] = 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (KeyboardStateHack[k] == 4)
|
|
||||||
{
|
|
||||||
if ((state & CoreVirtualKeyStates::None) == CoreVirtualKeyStates::None)
|
|
||||||
{
|
|
||||||
//Reset key...
|
|
||||||
KeyboardStateHack[k] = 0;
|
|
||||||
|
|
||||||
//Tell core
|
|
||||||
RegisterKey(k, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// Left and right alt, KeyUp and KeyDown are not called for it
|
|
||||||
// No need to hack because this is not a character
|
|
||||||
|
|
||||||
// TODO: Maybe do all other key registrations like this, no more key events?
|
|
||||||
|
|
||||||
if (k == 0xA4 || k == 0xA5)
|
|
||||||
{
|
|
||||||
if ((state & CoreVirtualKeyStates::Down) == CoreVirtualKeyStates::Down)
|
|
||||||
{
|
|
||||||
RegisterKey(k, 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RegisterKey(k, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process Mouse
|
|
||||||
{
|
|
||||||
|
|
||||||
if (CurrentPointerID > -1)
|
|
||||||
{
|
|
||||||
auto point = PointerPoint::GetCurrentPoint(CurrentPointerID);
|
|
||||||
auto props = point->Properties;
|
|
||||||
|
|
||||||
if (props->IsLeftButtonPressed)
|
|
||||||
{
|
|
||||||
RegisterClick(MOUSE_LEFT_BUTTON, 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RegisterClick(MOUSE_LEFT_BUTTON, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (props->IsRightButtonPressed)
|
|
||||||
{
|
|
||||||
RegisterClick(MOUSE_RIGHT_BUTTON, 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RegisterClick(MOUSE_RIGHT_BUTTON, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (props->IsMiddleButtonPressed)
|
|
||||||
{
|
|
||||||
RegisterClick(MOUSE_MIDDLE_BUTTON, 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RegisterClick(MOUSE_MIDDLE_BUTTON, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CoreWindow ^window = CoreWindow::GetForCurrentThread();
|
|
||||||
|
|
||||||
if (cursorLocked)
|
|
||||||
{
|
|
||||||
// Track cursor movement delta, recenter it on the client
|
|
||||||
auto curMousePos = GetMousePosition();
|
|
||||||
|
|
||||||
auto x = curMousePos.x + mouseDelta.x;
|
|
||||||
auto y = curMousePos.y + mouseDelta.y;
|
|
||||||
|
|
||||||
UpdateMousePosition({ x, y });
|
|
||||||
|
|
||||||
// Why we're not using UWPSetMousePosition here...
|
|
||||||
// UWPSetMousePosition changes the "mousePosition" variable to match where the cursor actually is.
|
|
||||||
// Our cursor is locked to the middle of screen, and we don't want that reflected in "mousePosition"
|
|
||||||
Vector2 centerClient = { (float)(GetScreenWidth() / 2), (float)(GetScreenHeight() / 2) };
|
|
||||||
window->PointerPosition = Point(centerClient.x + window->Bounds.X, centerClient.y + window->Bounds.Y);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Record the cursor's position relative to the client
|
|
||||||
auto x = window->PointerPosition.X - window->Bounds.X;
|
|
||||||
auto y = window->PointerPosition.Y - window->Bounds.Y;
|
|
||||||
|
|
||||||
UpdateMousePosition({ x, y });
|
|
||||||
}
|
|
||||||
|
|
||||||
mouseDelta = { 0 ,0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process Gamepads
|
// Process Gamepads
|
||||||
{
|
{
|
||||||
// Check if gamepads are ready
|
// Check if gamepads are ready
|
||||||
for (int i = 0; i < MAX_GAMEPADS; i++)
|
for (int i = 0; i < MAX_GAMEPADS; i++)
|
||||||
{
|
{
|
||||||
|
// TODO: ROVER - I want to remove this problem if possible.
|
||||||
// HACK: UWP keeps a contiguous list of gamepads. For the interest of time I'm just doing a 1:1 mapping of
|
// HACK: UWP keeps a contiguous list of gamepads. For the interest of time I'm just doing a 1:1 mapping of
|
||||||
// connected gamepads with their spot in the list, but this has serious robustness problems
|
// connected gamepads with their spot in the list, but this has serious robustness problems
|
||||||
// e.g. player 1, 2, and 3 are playing a game - if player2 disconnects, p3's controller would now be mapped to p2's character since p3 is now second in the list.
|
// e.g. player 1, 2, and 3 are playing a game - if player2 disconnects, p3's controller would now be mapped to p2's character since p3 is now second in the list.
|
||||||
|
UWPActivateGamepadEvent(i, i < Gamepad::Gamepads->Size);
|
||||||
UWPMessage* msg = CreateUWPMessage();
|
|
||||||
msg->type = UWP_MSG_SET_GAMEPAD_ACTIVE;
|
|
||||||
msg->paramInt0 = i;
|
|
||||||
msg->paramBool0 = i < Gamepad::Gamepads->Size;
|
|
||||||
UWPSendMessage(msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get current gamepad state
|
// Get current gamepad state
|
||||||
|
|
@ -371,30 +241,30 @@ protected:
|
||||||
GamepadReading reading = gamepad->GetCurrentReading();
|
GamepadReading reading = gamepad->GetCurrentReading();
|
||||||
|
|
||||||
// NOTE: Maybe it would be wiser to redefine the gamepad button mappings in "raylib.h" for the UWP platform instead of remapping them manually
|
// NOTE: Maybe it would be wiser to redefine the gamepad button mappings in "raylib.h" for the UWP platform instead of remapping them manually
|
||||||
RegisterGamepadButton(i, GAMEPAD_BUTTON_RIGHT_FACE_DOWN, ((reading.Buttons & GamepadButtons::A) == GamepadButtons::A));
|
UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_RIGHT_FACE_DOWN, ((reading.Buttons & GamepadButtons::A) == GamepadButtons::A));
|
||||||
RegisterGamepadButton(i, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT, ((reading.Buttons & GamepadButtons::B) == GamepadButtons::B));
|
UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT, ((reading.Buttons & GamepadButtons::B) == GamepadButtons::B));
|
||||||
RegisterGamepadButton(i, GAMEPAD_BUTTON_RIGHT_FACE_LEFT, ((reading.Buttons & GamepadButtons::X) == GamepadButtons::X));
|
UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_RIGHT_FACE_LEFT, ((reading.Buttons & GamepadButtons::X) == GamepadButtons::X));
|
||||||
RegisterGamepadButton(i, GAMEPAD_BUTTON_RIGHT_FACE_UP, ((reading.Buttons & GamepadButtons::Y) == GamepadButtons::Y));
|
UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_RIGHT_FACE_UP, ((reading.Buttons & GamepadButtons::Y) == GamepadButtons::Y));
|
||||||
|
|
||||||
RegisterGamepadButton(i, GAMEPAD_BUTTON_LEFT_TRIGGER_1, ((reading.Buttons & GamepadButtons::LeftShoulder) == GamepadButtons::LeftShoulder));
|
UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_LEFT_TRIGGER_1, ((reading.Buttons & GamepadButtons::LeftShoulder) == GamepadButtons::LeftShoulder));
|
||||||
RegisterGamepadButton(i, GAMEPAD_BUTTON_RIGHT_TRIGGER_1, ((reading.Buttons & GamepadButtons::RightShoulder) == GamepadButtons::RightShoulder));
|
UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_RIGHT_TRIGGER_1, ((reading.Buttons & GamepadButtons::RightShoulder) == GamepadButtons::RightShoulder));
|
||||||
|
|
||||||
RegisterGamepadButton(i, GAMEPAD_BUTTON_MIDDLE_LEFT, ((reading.Buttons & GamepadButtons::View) == GamepadButtons::View)); // Changed for XB1 Controller
|
UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_MIDDLE_LEFT, ((reading.Buttons & GamepadButtons::View) == GamepadButtons::View)); // Changed for XB1 Controller
|
||||||
RegisterGamepadButton(i, GAMEPAD_BUTTON_MIDDLE_RIGHT, ((reading.Buttons & GamepadButtons::Menu) == GamepadButtons::Menu)); // Changed for XB1 Controller
|
UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_MIDDLE_RIGHT, ((reading.Buttons & GamepadButtons::Menu) == GamepadButtons::Menu)); // Changed for XB1 Controller
|
||||||
|
|
||||||
RegisterGamepadButton(i, GAMEPAD_BUTTON_LEFT_FACE_UP, ((reading.Buttons & GamepadButtons::DPadUp) == GamepadButtons::DPadUp));
|
UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_LEFT_FACE_UP, ((reading.Buttons & GamepadButtons::DPadUp) == GamepadButtons::DPadUp));
|
||||||
RegisterGamepadButton(i, GAMEPAD_BUTTON_LEFT_FACE_RIGHT, ((reading.Buttons & GamepadButtons::DPadRight) == GamepadButtons::DPadRight));
|
UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_LEFT_FACE_RIGHT, ((reading.Buttons & GamepadButtons::DPadRight) == GamepadButtons::DPadRight));
|
||||||
RegisterGamepadButton(i, GAMEPAD_BUTTON_LEFT_FACE_DOWN, ((reading.Buttons & GamepadButtons::DPadDown) == GamepadButtons::DPadDown));
|
UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_LEFT_FACE_DOWN, ((reading.Buttons & GamepadButtons::DPadDown) == GamepadButtons::DPadDown));
|
||||||
RegisterGamepadButton(i, GAMEPAD_BUTTON_LEFT_FACE_LEFT, ((reading.Buttons & GamepadButtons::DPadLeft) == GamepadButtons::DPadLeft));
|
UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_LEFT_FACE_LEFT, ((reading.Buttons & GamepadButtons::DPadLeft) == GamepadButtons::DPadLeft));
|
||||||
RegisterGamepadButton(i, GAMEPAD_BUTTON_MIDDLE, false); // Home button not supported by UWP
|
UWPRegisterGamepadButton(i, GAMEPAD_BUTTON_MIDDLE, false); // Home button not supported by UWP
|
||||||
|
|
||||||
// Get current axis state
|
// Get current axis state
|
||||||
RegisterGamepadAxis(i, GAMEPAD_AXIS_LEFT_X, (float)reading.LeftThumbstickX);
|
UWPRegisterGamepadAxis(i, GAMEPAD_AXIS_LEFT_X, (float)reading.LeftThumbstickX);
|
||||||
RegisterGamepadAxis(i, GAMEPAD_AXIS_LEFT_Y, (float)reading.LeftThumbstickY);
|
UWPRegisterGamepadAxis(i, GAMEPAD_AXIS_LEFT_Y, (float)reading.LeftThumbstickY);
|
||||||
RegisterGamepadAxis(i, GAMEPAD_AXIS_RIGHT_X, (float)reading.RightThumbstickX);
|
UWPRegisterGamepadAxis(i, GAMEPAD_AXIS_RIGHT_X, (float)reading.RightThumbstickX);
|
||||||
RegisterGamepadAxis(i, GAMEPAD_AXIS_RIGHT_Y, (float)reading.RightThumbstickY);
|
UWPRegisterGamepadAxis(i, GAMEPAD_AXIS_RIGHT_Y, (float)reading.RightThumbstickY);
|
||||||
RegisterGamepadAxis(i, GAMEPAD_AXIS_LEFT_TRIGGER, (float)reading.LeftTrigger);
|
UWPRegisterGamepadAxis(i, GAMEPAD_AXIS_LEFT_TRIGGER, (float)reading.LeftTrigger);
|
||||||
RegisterGamepadAxis(i, GAMEPAD_AXIS_RIGHT_TRIGGER, (float)reading.RightTrigger);
|
UWPRegisterGamepadAxis(i, GAMEPAD_AXIS_RIGHT_TRIGGER, (float)reading.RightTrigger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -407,14 +277,16 @@ protected:
|
||||||
CoreWindow::GetForCurrentThread()->Activate();
|
CoreWindow::GetForCurrentThread()->Activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnResuming(Platform::Object^ sender, Platform::Object^ args) {}
|
void OnResuming(Platform::Object^ sender, Platform::Object^ args)
|
||||||
|
{
|
||||||
|
// TODO: Suspend and Resume lifecycle. This should be implemented by the developer, however we need to implement an example of it here.
|
||||||
|
// Basically, we'd save all resources here and free any temporary stuff as if we were about to close, however *if* resume is called, we need to be ready.
|
||||||
|
}
|
||||||
|
|
||||||
// Window event handlers.
|
// Window event handlers.
|
||||||
void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args)
|
void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args)
|
||||||
{
|
{
|
||||||
UWPMessage* msg = CreateUWPMessage();
|
UWPResizeEvent(args->Size.Width, args->Size.Height);
|
||||||
msg->type = UWP_MSG_HANDLE_RESIZE;
|
|
||||||
UWPSendMessage(msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args)
|
void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args)
|
||||||
|
|
@ -422,140 +294,137 @@ protected:
|
||||||
mWindowVisible = args->Visible;
|
mWindowVisible = args->Visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args)
|
|
||||||
{
|
|
||||||
mWindowClosed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// DisplayInformation event handlers.
|
|
||||||
void OnDpiChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args) {}
|
|
||||||
void OnOrientationChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args) {}
|
|
||||||
|
|
||||||
// Input event handlers
|
// Input event handlers
|
||||||
void PointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args)
|
void PointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args)
|
||||||
{
|
{
|
||||||
//Get the current active pointer ID for our loop
|
auto props = args->CurrentPoint->Properties;
|
||||||
CurrentPointerID = args->CurrentPoint->PointerId;
|
|
||||||
args->Handled = true;
|
// TODO: UWP Touch input/simulation.
|
||||||
|
if (args->CurrentPoint->PointerDevice->PointerDeviceType == Windows::Devices::Input::PointerDeviceType::Mouse)
|
||||||
|
{
|
||||||
|
if (props->IsLeftButtonPressed) UWPMouseButtonEvent(MOUSE_LEFT_BUTTON, true);
|
||||||
|
if (props->IsMiddleButtonPressed) UWPMouseButtonEvent(MOUSE_MIDDLE_BUTTON, true);
|
||||||
|
if (props->IsRightButtonPressed) UWPMouseButtonEvent(MOUSE_RIGHT_BUTTON, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args)
|
||||||
|
{
|
||||||
|
auto props = args->CurrentPoint->Properties;
|
||||||
|
|
||||||
|
// TODO: UWP Touch input.
|
||||||
|
if (args->CurrentPoint->PointerDevice->PointerDeviceType == Windows::Devices::Input::PointerDeviceType::Mouse)
|
||||||
|
{
|
||||||
|
if (!props->IsLeftButtonPressed) UWPMouseButtonEvent(MOUSE_LEFT_BUTTON, false);
|
||||||
|
if (!props->IsMiddleButtonPressed) UWPMouseButtonEvent(MOUSE_MIDDLE_BUTTON, false);
|
||||||
|
if (!props->IsRightButtonPressed) UWPMouseButtonEvent(MOUSE_RIGHT_BUTTON, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PointerWheelChanged(Windows::UI::Core::CoreWindow ^sender, Windows::UI::Core::PointerEventArgs^ args)
|
void PointerWheelChanged(Windows::UI::Core::CoreWindow ^sender, Windows::UI::Core::PointerEventArgs^ args)
|
||||||
{
|
{
|
||||||
UWPMessage* msg = CreateUWPMessage();
|
UWPMouseWheelEvent(args->CurrentPoint->Properties->MouseWheelDelta);
|
||||||
msg->type = UWP_MSG_SCROLL_WHEEL_UPDATE;
|
|
||||||
msg->paramFloat0 = args->CurrentPoint->Properties->MouseWheelDelta;
|
|
||||||
UWPSendMessage(msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MouseMoved(Windows::Devices::Input::MouseDevice^ mouseDevice, Windows::Devices::Input::MouseEventArgs^ args)
|
void PointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args)
|
||||||
{
|
{
|
||||||
mouseDelta.x += args->MouseDelta.X;
|
auto pos = args->CurrentPoint->Position;
|
||||||
mouseDelta.y += args->MouseDelta.Y;
|
UWPMousePosEvent((double)pos.X, (double)pos.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetRaylibKey(Windows::System::VirtualKey kVey)
|
||||||
|
{
|
||||||
|
int actualKey = -1;
|
||||||
|
switch ((int) kVey)// TODO: Use VK enum and finish keys
|
||||||
|
{
|
||||||
|
case 0x08: actualKey = KEY_BACKSPACE; break;
|
||||||
|
case 0x20: actualKey = KEY_SPACE; break;
|
||||||
|
case 0x1B: actualKey = KEY_ESCAPE; break;
|
||||||
|
case 0x0D: actualKey = KEY_ENTER; break;
|
||||||
|
case 0x2E: actualKey = KEY_DELETE; break;
|
||||||
|
case 0x27: actualKey = KEY_RIGHT; break;
|
||||||
|
case 0x25: actualKey = KEY_LEFT; break;
|
||||||
|
case 0x28: actualKey = KEY_DOWN; break;
|
||||||
|
case 0x26: actualKey = KEY_UP; break;
|
||||||
|
case 0x70: actualKey = KEY_F1; break;
|
||||||
|
case 0x71: actualKey = KEY_F2; break;
|
||||||
|
case 0x72: actualKey = KEY_F3; break;
|
||||||
|
case 0x73: actualKey = KEY_F4; break;
|
||||||
|
case 0x74: actualKey = KEY_F5; break;
|
||||||
|
case 0x75: actualKey = KEY_F6; break;
|
||||||
|
case 0x76: actualKey = KEY_F7; break;
|
||||||
|
case 0x77: actualKey = KEY_F8; break;
|
||||||
|
case 0x78: actualKey = KEY_F9; break;
|
||||||
|
case 0x79: actualKey = KEY_F10; break;
|
||||||
|
case 0x7A: actualKey = KEY_F11; break;
|
||||||
|
case 0x7B: actualKey = KEY_F12; break;
|
||||||
|
case 0xA0: actualKey = KEY_LEFT_SHIFT; break;
|
||||||
|
case 0xA2: actualKey = KEY_LEFT_CONTROL; break;
|
||||||
|
case 0xA4: actualKey = KEY_LEFT_ALT; break;
|
||||||
|
case 0xA1: actualKey = KEY_RIGHT_SHIFT; break;
|
||||||
|
case 0xA3: actualKey = KEY_RIGHT_CONTROL; break;
|
||||||
|
case 0xA5: actualKey = KEY_RIGHT_ALT; break;
|
||||||
|
case 0x30: actualKey = KEY_ZERO; break;
|
||||||
|
case 0x31: actualKey = KEY_ONE; break;
|
||||||
|
case 0x32: actualKey = KEY_TWO; break;
|
||||||
|
case 0x33: actualKey = KEY_THREE; break;
|
||||||
|
case 0x34: actualKey = KEY_FOUR; break;
|
||||||
|
case 0x35: actualKey = KEY_FIVE; break;
|
||||||
|
case 0x36: actualKey = KEY_SIX; break;
|
||||||
|
case 0x37: actualKey = KEY_SEVEN; break;
|
||||||
|
case 0x38: actualKey = KEY_EIGHT; break;
|
||||||
|
case 0x39: actualKey = KEY_NINE; break;
|
||||||
|
case 0x41: actualKey = KEY_A; break;
|
||||||
|
case 0x42: actualKey = KEY_B; break;
|
||||||
|
case 0x43: actualKey = KEY_C; break;
|
||||||
|
case 0x44: actualKey = KEY_D; break;
|
||||||
|
case 0x45: actualKey = KEY_E; break;
|
||||||
|
case 0x46: actualKey = KEY_F; break;
|
||||||
|
case 0x47: actualKey = KEY_G; break;
|
||||||
|
case 0x48: actualKey = KEY_H; break;
|
||||||
|
case 0x49: actualKey = KEY_I; break;
|
||||||
|
case 0x4A: actualKey = KEY_J; break;
|
||||||
|
case 0x4B: actualKey = KEY_K; break;
|
||||||
|
case 0x4C: actualKey = KEY_L; break;
|
||||||
|
case 0x4D: actualKey = KEY_M; break;
|
||||||
|
case 0x4E: actualKey = KEY_N; break;
|
||||||
|
case 0x4F: actualKey = KEY_O; break;
|
||||||
|
case 0x50: actualKey = KEY_P; break;
|
||||||
|
case 0x51: actualKey = KEY_Q; break;
|
||||||
|
case 0x52: actualKey = KEY_R; break;
|
||||||
|
case 0x53: actualKey = KEY_S; break;
|
||||||
|
case 0x54: actualKey = KEY_T; break;
|
||||||
|
case 0x55: actualKey = KEY_U; break;
|
||||||
|
case 0x56: actualKey = KEY_V; break;
|
||||||
|
case 0x57: actualKey = KEY_W; break;
|
||||||
|
case 0x58: actualKey = KEY_X; break;
|
||||||
|
case 0x59: actualKey = KEY_Y; break;
|
||||||
|
case 0x5A: actualKey = KEY_Z; break;
|
||||||
|
}
|
||||||
|
return actualKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnKeyDown(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args)
|
void OnKeyDown(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args)
|
||||||
{
|
{
|
||||||
#ifdef HOLDHACK
|
auto k = GetRaylibKey(args->VirtualKey);
|
||||||
// Start the hack
|
if (k != -1)
|
||||||
KeyboardStateHack[(int)args->VirtualKey] = 1;
|
UWPKeyDownEvent(k, true);
|
||||||
#endif
|
|
||||||
|
|
||||||
RegisterKey((int)args->VirtualKey, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnKeyUp(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args)
|
void OnKeyUp(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args)
|
||||||
{
|
{
|
||||||
#ifdef HOLDHACK
|
auto k = GetRaylibKey(args->VirtualKey);
|
||||||
// The same hack
|
if (k != -1)
|
||||||
if (KeyboardStateHack[(int)args->VirtualKey] == 1)
|
UWPKeyDownEvent(k, false);
|
||||||
{
|
|
||||||
KeyboardStateHack[(int)args->VirtualKey] = 2;
|
|
||||||
}
|
|
||||||
else if (KeyboardStateHack[(int)args->VirtualKey] == 2)
|
|
||||||
{
|
|
||||||
KeyboardStateHack[(int)args->VirtualKey] = 3;
|
|
||||||
}
|
|
||||||
else if (KeyboardStateHack[(int)args->VirtualKey] == 3)
|
|
||||||
{
|
|
||||||
KeyboardStateHack[(int)args->VirtualKey] = 4;
|
|
||||||
}
|
|
||||||
else if (KeyboardStateHack[(int)args->VirtualKey] == 4)
|
|
||||||
{
|
|
||||||
RegisterKey((int)args->VirtualKey, 0);
|
|
||||||
KeyboardStateHack[(int)args->VirtualKey] = 0;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// No hack, allow flickers
|
|
||||||
RegisterKey((int)args->VirtualKey, 0);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void RegisterKey(int key, char status)
|
|
||||||
{
|
|
||||||
UWPMessage* msg = CreateUWPMessage();
|
|
||||||
msg->type = UWPMessageType::UWP_MSG_REGISTER_KEY;
|
|
||||||
msg->paramInt0 = key;
|
|
||||||
msg->paramChar0 = status;
|
|
||||||
UWPSendMessage(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MoveMouse(Vector2 pos)
|
|
||||||
{
|
|
||||||
CoreWindow ^window = CoreWindow::GetForCurrentThread();
|
|
||||||
Point mousePosScreen = Point(pos.x + window->Bounds.X, pos.y + window->Bounds.Y);
|
|
||||||
window->PointerPosition = mousePosScreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegisterGamepadButton(int gamepad, int button, char status)
|
|
||||||
{
|
|
||||||
UWPMessage* msg = CreateUWPMessage();
|
|
||||||
msg->type = UWP_MSG_SET_GAMEPAD_BUTTON;
|
|
||||||
msg->paramInt0 = gamepad;
|
|
||||||
msg->paramInt1 = button;
|
|
||||||
msg->paramChar0 = status;
|
|
||||||
UWPSendMessage(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegisterGamepadAxis(int gamepad, int axis, float value)
|
|
||||||
{
|
|
||||||
UWPMessage* msg = CreateUWPMessage();
|
|
||||||
msg->type = UWP_MSG_SET_GAMEPAD_AXIS;
|
|
||||||
msg->paramInt0 = gamepad;
|
|
||||||
msg->paramInt1 = axis;
|
|
||||||
msg->paramFloat0 = value;
|
|
||||||
UWPSendMessage(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateMousePosition(Vector2 pos)
|
|
||||||
{
|
|
||||||
UWPMessage* msg = CreateUWPMessage();
|
|
||||||
msg->type = UWP_MSG_UPDATE_MOUSE_LOCATION;
|
|
||||||
msg->paramVector0 = pos;
|
|
||||||
UWPSendMessage(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegisterClick(int button, char status)
|
|
||||||
{
|
|
||||||
UWPMessage* msg = CreateUWPMessage();
|
|
||||||
msg->type = UWPMessageType::UWP_MSG_REGISTER_CLICK;
|
|
||||||
msg->paramInt0 = button;
|
|
||||||
msg->paramChar0 = status;
|
|
||||||
UWPSendMessage(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool mWindowClosed = false;
|
bool mWindowClosed = false;
|
||||||
bool mWindowVisible = true;
|
bool mWindowVisible = true;
|
||||||
|
|
||||||
int width = 640;
|
int width = 640;
|
||||||
int height = 480;
|
int height = 480;
|
||||||
|
|
||||||
int CurrentPointerID = -1;
|
|
||||||
|
|
||||||
#ifdef HOLDHACK
|
|
||||||
char KeyboardStateHack[0xA6]; // 0xA6 because the highest key we compare against is 0xA5
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Application source for creating the program
|
// Application source for creating the program
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
|
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
|
||||||
<AppContainerApplication>true</AppContainerApplication>
|
<AppContainerApplication>true</AppContainerApplication>
|
||||||
<ApplicationType>Windows Store</ApplicationType>
|
<ApplicationType>Windows Store</ApplicationType>
|
||||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
<WindowsTargetPlatformMinVersion>10.0.17763.0</WindowsTargetPlatformMinVersion>
|
<WindowsTargetPlatformMinVersion>10.0.17763.0</WindowsTargetPlatformMinVersion>
|
||||||
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
|
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
|
||||||
<ProjectName>raylib.App.UWP</ProjectName>
|
<ProjectName>raylib.App.UWP</ProjectName>
|
||||||
|
|
@ -152,7 +152,6 @@
|
||||||
<AppxManifest Include="Package.appxmanifest">
|
<AppxManifest Include="Package.appxmanifest">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</AppxManifest>
|
</AppxManifest>
|
||||||
<None Include="packages.config" />
|
|
||||||
<None Include="raylib.App.UWP.TemporaryKey.pfx" />
|
<None Include="raylib.App.UWP.TemporaryKey.pfx" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
@ -160,6 +159,9 @@
|
||||||
<Project>{ea91e088-7c71-4f32-b761-e054305cd519}</Project>
|
<Project>{ea91e088-7c71-4f32-b761-e054305cd519}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
<Import Project="..\packages\ANGLE.WindowsStore.2.1.13\build\native\ANGLE.WindowsStore.targets" Condition="Exists('..\packages\ANGLE.WindowsStore.2.1.13\build\native\ANGLE.WindowsStore.targets')" />
|
<Import Project="..\packages\ANGLE.WindowsStore.2.1.13\build\native\ANGLE.WindowsStore.targets" Condition="Exists('..\packages\ANGLE.WindowsStore.2.1.13\build\native\ANGLE.WindowsStore.targets')" />
|
||||||
|
|
|
||||||
|
|
@ -29,12 +29,12 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AppxManifest Include="Package.appxmanifest" />
|
<AppxManifest Include="Package.appxmanifest" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<None Include="packages.config" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="Logo">
|
<Filter Include="Logo">
|
||||||
<UniqueIdentifier>{cdf72d55-f249-4ad6-9a91-f8a084e64933}</UniqueIdentifier>
|
<UniqueIdentifier>{cdf72d55-f249-4ad6-9a91-f8a084e64933}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
4
projects/VS2017.UWP/raylib.UWP/packages.config
Normal file
4
projects/VS2017.UWP/raylib.UWP/packages.config
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="ANGLE.WindowsStore" version="2.1.13" targetFramework="native" />
|
||||||
|
</packages>
|
||||||
|
|
@ -52,6 +52,9 @@
|
||||||
<ClCompile Include="..\..\..\src\textures.c" />
|
<ClCompile Include="..\..\..\src\textures.c" />
|
||||||
<ClCompile Include="..\..\..\src\utils.c" />
|
<ClCompile Include="..\..\..\src\utils.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{ea91e088-7c71-4f32-b761-e054305cd519}</ProjectGuid>
|
<ProjectGuid>{ea91e088-7c71-4f32-b761-e054305cd519}</ProjectGuid>
|
||||||
<Keyword>StaticLibrary</Keyword>
|
<Keyword>StaticLibrary</Keyword>
|
||||||
|
|
@ -60,7 +63,7 @@
|
||||||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
|
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
|
||||||
<AppContainerApplication>true</AppContainerApplication>
|
<AppContainerApplication>true</AppContainerApplication>
|
||||||
<ApplicationType>Windows Store</ApplicationType>
|
<ApplicationType>Windows Store</ApplicationType>
|
||||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
<WindowsTargetPlatformMinVersion>10.0.15063.0</WindowsTargetPlatformMinVersion>
|
<WindowsTargetPlatformMinVersion>10.0.15063.0</WindowsTargetPlatformMinVersion>
|
||||||
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
|
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
@ -239,5 +242,12 @@
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="..\packages\ANGLE.WindowsStore.2.1.13\build\native\ANGLE.WindowsStore.targets" Condition="Exists('..\packages\ANGLE.WindowsStore.2.1.13\build\native\ANGLE.WindowsStore.targets')" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ErrorText>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}.</ErrorText>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Error Condition="!Exists('..\packages\ANGLE.WindowsStore.2.1.13\build\native\ANGLE.WindowsStore.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\ANGLE.WindowsStore.2.1.13\build\native\ANGLE.WindowsStore.targets'))" />
|
||||||
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -26,4 +26,7 @@
|
||||||
<ClCompile Include="..\..\..\src\textures.c" />
|
<ClCompile Include="..\..\..\src\textures.c" />
|
||||||
<ClCompile Include="..\..\..\src\utils.c" />
|
<ClCompile Include="..\..\..\src\utils.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
325
src/core.c
325
src/core.c
|
|
@ -328,10 +328,6 @@ typedef struct {
|
||||||
typedef struct { int x; int y; } Point;
|
typedef struct { int x; int y; } Point;
|
||||||
typedef struct { unsigned int width; unsigned int height; } Size;
|
typedef struct { unsigned int width; unsigned int height; } Size;
|
||||||
|
|
||||||
#if defined(PLATFORM_UWP)
|
|
||||||
extern EGLNativeWindowType handle; // Native window handler for UWP (external, defined in UWP App)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Core global state context data
|
// Core global state context data
|
||||||
typedef struct CoreData {
|
typedef struct CoreData {
|
||||||
struct {
|
struct {
|
||||||
|
|
@ -610,6 +606,14 @@ static void RestoreTerminal(void)
|
||||||
// NOTE: data parameter could be used to pass any kind of required data to the initialization
|
// 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)
|
void InitWindow(int width, int height, const char *title)
|
||||||
{
|
{
|
||||||
|
#if defined(PLATFORM_UWP)
|
||||||
|
if (!UWPIsConfigured())
|
||||||
|
{
|
||||||
|
TRACELOG(LOG_ERROR, "UWP Functions have not been set yet, please set these before initializing raylib!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
TRACELOG(LOG_INFO, "Initializing raylib %s", RAYLIB_VERSION);
|
TRACELOG(LOG_INFO, "Initializing raylib %s", RAYLIB_VERSION);
|
||||||
|
|
||||||
CORE.Window.title = title;
|
CORE.Window.title = title;
|
||||||
|
|
@ -619,6 +623,11 @@ void InitWindow(int width, int height, const char *title)
|
||||||
CORE.Input.Mouse.scale = (Vector2){ 1.0f, 1.0f };
|
CORE.Input.Mouse.scale = (Vector2){ 1.0f, 1.0f };
|
||||||
CORE.Input.Gamepad.lastButtonPressed = -1;
|
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)
|
#if defined(PLATFORM_ANDROID)
|
||||||
CORE.Window.screen.width = width;
|
CORE.Window.screen.width = width;
|
||||||
CORE.Window.screen.height = height;
|
CORE.Window.screen.height = height;
|
||||||
|
|
@ -758,7 +767,7 @@ void CloseWindow(void)
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(SUPPORT_BUSY_WAIT_LOOP) && defined(_WIN32)
|
#if !defined(SUPPORT_BUSY_WAIT_LOOP) && defined(_WIN32) && !defined(PLATFORM_UWP)
|
||||||
timeEndPeriod(1); // Restore time period
|
timeEndPeriod(1); // Restore time period
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -1207,9 +1216,7 @@ void ShowCursor(void)
|
||||||
glfwSetInputMode(CORE.Window.handle, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
glfwSetInputMode(CORE.Window.handle, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PLATFORM_UWP)
|
#if defined(PLATFORM_UWP)
|
||||||
UWPMessage *msg = CreateUWPMessage();
|
UWPGetMouseShowFunc()();
|
||||||
msg->type = UWP_MSG_SHOW_MOUSE;
|
|
||||||
SendMessageToUWP(msg);
|
|
||||||
#endif
|
#endif
|
||||||
CORE.Input.Mouse.cursorHidden = false;
|
CORE.Input.Mouse.cursorHidden = false;
|
||||||
}
|
}
|
||||||
|
|
@ -1221,9 +1228,7 @@ void HideCursor(void)
|
||||||
glfwSetInputMode(CORE.Window.handle, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
|
glfwSetInputMode(CORE.Window.handle, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PLATFORM_UWP)
|
#if defined(PLATFORM_UWP)
|
||||||
UWPMessage *msg = CreateUWPMessage();
|
UWPGetMouseHideFunc()();
|
||||||
msg->type = UWP_MSG_HIDE_MOUSE;
|
|
||||||
SendMessageToUWP(msg);
|
|
||||||
#endif
|
#endif
|
||||||
CORE.Input.Mouse.cursorHidden = true;
|
CORE.Input.Mouse.cursorHidden = true;
|
||||||
}
|
}
|
||||||
|
|
@ -1707,8 +1712,7 @@ double GetTime(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PLATFORM_UWP)
|
#if defined(PLATFORM_UWP)
|
||||||
// Updated through messages
|
return UWPGetQueryTimeFunc()();
|
||||||
return CORE.Time.current;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3158,7 +3162,7 @@ static bool InitGraphicsDevice(int width, int height)
|
||||||
//https://stackoverflow.com/questions/46550182/how-to-create-eglsurface-using-c-winrt-and-angle
|
//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<IInspectable*>(surfaceCreationProperties), surfaceAttributes);
|
//CORE.Window.surface = eglCreateWindowSurface(CORE.Window.device, CORE.Window.config, reinterpret_cast<IInspectable*>(surfaceCreationProperties), surfaceAttributes);
|
||||||
CORE.Window.surface = eglCreateWindowSurface(CORE.Window.device, CORE.Window.config, handle, surfaceAttributes);
|
CORE.Window.surface = eglCreateWindowSurface(CORE.Window.device, CORE.Window.config, (EGLNativeWindowType) UWPGetCoreWindowPtr(), surfaceAttributes);
|
||||||
if (CORE.Window.surface == EGL_NO_SURFACE)
|
if (CORE.Window.surface == EGL_NO_SURFACE)
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_WARNING, "DISPLAY: Failed to create EGL fullscreen surface");
|
TRACELOG(LOG_WARNING, "DISPLAY: Failed to create EGL fullscreen surface");
|
||||||
|
|
@ -3173,8 +3177,11 @@ static bool InitGraphicsDevice(int width, int height)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get EGL device window size
|
// Get EGL device window size
|
||||||
eglQuerySurface(CORE.Window.device, CORE.Window.surface, EGL_WIDTH, &CORE.Window.display.width);
|
eglQuerySurface(CORE.Window.device, CORE.Window.surface, EGL_WIDTH, &CORE.Window.screen.width);
|
||||||
eglQuerySurface(CORE.Window.device, CORE.Window.surface, EGL_HEIGHT, &CORE.Window.display.height);
|
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);
|
||||||
|
|
||||||
#endif // PLATFORM_UWP
|
#endif // PLATFORM_UWP
|
||||||
|
|
||||||
|
|
@ -3287,8 +3294,13 @@ static bool InitGraphicsDevice(int width, int height)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Grab the width and height of the surface
|
// Grab the width and height of the surface
|
||||||
|
#if defined(PLATFORM_UWP)
|
||||||
|
CORE.Window.render.width = CORE.Window.screen.width;
|
||||||
|
CORE.Window.render.height = CORE.Window.screen.height;
|
||||||
|
#else
|
||||||
CORE.Window.render.width = CORE.Window.display.width;
|
CORE.Window.render.width = CORE.Window.display.width;
|
||||||
CORE.Window.render.height = CORE.Window.display.height;
|
CORE.Window.render.height = CORE.Window.display.height;
|
||||||
|
#endif
|
||||||
|
|
||||||
TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully");
|
TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully");
|
||||||
TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height);
|
TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height);
|
||||||
|
|
@ -3323,7 +3335,7 @@ static bool InitGraphicsDevice(int width, int height)
|
||||||
|
|
||||||
ClearBackground(RAYWHITE); // Default background color for raylib games :P
|
ClearBackground(RAYWHITE); // Default background color for raylib games :P
|
||||||
|
|
||||||
#if defined(PLATFORM_ANDROID)
|
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_UWP)
|
||||||
CORE.Window.ready = true;
|
CORE.Window.ready = true;
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -3428,7 +3440,7 @@ static void InitTimer(void)
|
||||||
{
|
{
|
||||||
srand((unsigned int)time(NULL)); // Initialize random seed
|
srand((unsigned int)time(NULL)); // Initialize random seed
|
||||||
|
|
||||||
#if !defined(SUPPORT_BUSY_WAIT_LOOP) && defined(_WIN32)
|
#if !defined(SUPPORT_BUSY_WAIT_LOOP) && defined(_WIN32) && !defined(PLATFORM_UWP)
|
||||||
timeBeginPeriod(1); // Setup high-resolution timer to 1ms (granularity of 1-2 ms)
|
timeBeginPeriod(1); // Setup high-resolution timer to 1ms (granularity of 1-2 ms)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -3452,7 +3464,9 @@ static void InitTimer(void)
|
||||||
// Ref: http://www.geisswerks.com/ryan/FAQS/timing.html --> All about timming on Win32!
|
// Ref: http://www.geisswerks.com/ryan/FAQS/timing.html --> All about timming on Win32!
|
||||||
static void Wait(float ms)
|
static void Wait(float ms)
|
||||||
{
|
{
|
||||||
#if defined(SUPPORT_BUSY_WAIT_LOOP) && !defined(PLATFORM_UWP)
|
#if defined(PLATFORM_UWP)
|
||||||
|
UWPGetSleepFunc()(ms / 1000);
|
||||||
|
#elif defined(SUPPORT_BUSY_WAIT_LOOP)
|
||||||
double prevTime = GetTime();
|
double prevTime = GetTime();
|
||||||
double nextTime = 0.0;
|
double nextTime = 0.0;
|
||||||
|
|
||||||
|
|
@ -3480,7 +3494,7 @@ static void Wait(float ms)
|
||||||
usleep(ms*1000.0f);
|
usleep(ms*1000.0f);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SUPPORT_HALFBUSY_WAIT_LOOP)
|
#if defined(SUPPORT_HALFBUSY_WAIT_LOOP)// && !defined(PLATFORM_UWP)
|
||||||
while (GetTime() < destTime) { }
|
while (GetTime() < destTime) { }
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -3637,142 +3651,6 @@ static void PollInputEvents(void)
|
||||||
CORE.Input.Mouse.currentWheelMove = 0;
|
CORE.Input.Mouse.currentWheelMove = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) CORE.Input.Mouse.previousButtonState[i] = CORE.Input.Mouse.currentButtonState[i];
|
for (int i = 0; i < 3; i++) CORE.Input.Mouse.previousButtonState[i] = CORE.Input.Mouse.currentButtonState[i];
|
||||||
|
|
||||||
// Loop over pending messages
|
|
||||||
while (HasMessageFromUWP())
|
|
||||||
{
|
|
||||||
UWPMessage *msg = GetMessageFromUWP();
|
|
||||||
|
|
||||||
switch (msg->type)
|
|
||||||
{
|
|
||||||
case UWP_MSG_REGISTER_KEY:
|
|
||||||
{
|
|
||||||
// Convert from virtualKey
|
|
||||||
int actualKey = -1;
|
|
||||||
|
|
||||||
switch (msg->paramInt0)
|
|
||||||
{
|
|
||||||
case 0x08: actualKey = KEY_BACKSPACE; break;
|
|
||||||
case 0x20: actualKey = KEY_SPACE; break;
|
|
||||||
case 0x1B: actualKey = KEY_ESCAPE; break;
|
|
||||||
case 0x0D: actualKey = KEY_ENTER; break;
|
|
||||||
case 0x2E: actualKey = KEY_DELETE; break;
|
|
||||||
case 0x27: actualKey = KEY_RIGHT; break;
|
|
||||||
case 0x25: actualKey = KEY_LEFT; break;
|
|
||||||
case 0x28: actualKey = KEY_DOWN; break;
|
|
||||||
case 0x26: actualKey = KEY_UP; break;
|
|
||||||
case 0x70: actualKey = KEY_F1; break;
|
|
||||||
case 0x71: actualKey = KEY_F2; break;
|
|
||||||
case 0x72: actualKey = KEY_F3; break;
|
|
||||||
case 0x73: actualKey = KEY_F4; break;
|
|
||||||
case 0x74: actualKey = KEY_F5; break;
|
|
||||||
case 0x75: actualKey = KEY_F6; break;
|
|
||||||
case 0x76: actualKey = KEY_F7; break;
|
|
||||||
case 0x77: actualKey = KEY_F8; break;
|
|
||||||
case 0x78: actualKey = KEY_F9; break;
|
|
||||||
case 0x79: actualKey = KEY_F10; break;
|
|
||||||
case 0x7A: actualKey = KEY_F11; break;
|
|
||||||
case 0x7B: actualKey = KEY_F12; break;
|
|
||||||
case 0xA0: actualKey = KEY_LEFT_SHIFT; break;
|
|
||||||
case 0xA2: actualKey = KEY_LEFT_CONTROL; break;
|
|
||||||
case 0xA4: actualKey = KEY_LEFT_ALT; break;
|
|
||||||
case 0xA1: actualKey = KEY_RIGHT_SHIFT; break;
|
|
||||||
case 0xA3: actualKey = KEY_RIGHT_CONTROL; break;
|
|
||||||
case 0xA5: actualKey = KEY_RIGHT_ALT; break;
|
|
||||||
case 0x30: actualKey = KEY_ZERO; break;
|
|
||||||
case 0x31: actualKey = KEY_ONE; break;
|
|
||||||
case 0x32: actualKey = KEY_TWO; break;
|
|
||||||
case 0x33: actualKey = KEY_THREE; break;
|
|
||||||
case 0x34: actualKey = KEY_FOUR; break;
|
|
||||||
case 0x35: actualKey = KEY_FIVE; break;
|
|
||||||
case 0x36: actualKey = KEY_SIX; break;
|
|
||||||
case 0x37: actualKey = KEY_SEVEN; break;
|
|
||||||
case 0x38: actualKey = KEY_EIGHT; break;
|
|
||||||
case 0x39: actualKey = KEY_NINE; break;
|
|
||||||
case 0x41: actualKey = KEY_A; break;
|
|
||||||
case 0x42: actualKey = KEY_B; break;
|
|
||||||
case 0x43: actualKey = KEY_C; break;
|
|
||||||
case 0x44: actualKey = KEY_D; break;
|
|
||||||
case 0x45: actualKey = KEY_E; break;
|
|
||||||
case 0x46: actualKey = KEY_F; break;
|
|
||||||
case 0x47: actualKey = KEY_G; break;
|
|
||||||
case 0x48: actualKey = KEY_H; break;
|
|
||||||
case 0x49: actualKey = KEY_I; break;
|
|
||||||
case 0x4A: actualKey = KEY_J; break;
|
|
||||||
case 0x4B: actualKey = KEY_K; break;
|
|
||||||
case 0x4C: actualKey = KEY_L; break;
|
|
||||||
case 0x4D: actualKey = KEY_M; break;
|
|
||||||
case 0x4E: actualKey = KEY_N; break;
|
|
||||||
case 0x4F: actualKey = KEY_O; break;
|
|
||||||
case 0x50: actualKey = KEY_P; break;
|
|
||||||
case 0x51: actualKey = KEY_Q; break;
|
|
||||||
case 0x52: actualKey = KEY_R; break;
|
|
||||||
case 0x53: actualKey = KEY_S; break;
|
|
||||||
case 0x54: actualKey = KEY_T; break;
|
|
||||||
case 0x55: actualKey = KEY_U; break;
|
|
||||||
case 0x56: actualKey = KEY_V; break;
|
|
||||||
case 0x57: actualKey = KEY_W; break;
|
|
||||||
case 0x58: actualKey = KEY_X; break;
|
|
||||||
case 0x59: actualKey = KEY_Y; break;
|
|
||||||
case 0x5A: actualKey = KEY_Z; break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (actualKey > -1) CORE.Input.Keyboard.currentKeyState[actualKey] = msg->paramChar0;
|
|
||||||
|
|
||||||
} break;
|
|
||||||
case UWP_MSG_REGISTER_CLICK: CORE.Input.Mouse.currentButtonState[msg->paramInt0] = msg->paramChar0; break;
|
|
||||||
case UWP_MSG_SCROLL_WHEEL_UPDATE: CORE.Input.Mouse.currentWheelMove += msg->paramInt0; break;
|
|
||||||
case UWP_MSG_UPDATE_MOUSE_LOCATION: CORE.Input.Mouse.position = msg->paramVector0; break;
|
|
||||||
case UWP_MSG_SET_GAMEPAD_ACTIVE: if (msg->paramInt0 < MAX_GAMEPADS) CORE.Input.Gamepad.ready[msg->paramInt0] = msg->paramBool0; break;
|
|
||||||
case UWP_MSG_SET_GAMEPAD_BUTTON:
|
|
||||||
{
|
|
||||||
if ((msg->paramInt0 < MAX_GAMEPADS) && (msg->paramInt1 < MAX_GAMEPAD_BUTTONS)) CORE.Input.Gamepad.currentState[msg->paramInt0][msg->paramInt1] = msg->paramChar0;
|
|
||||||
} break;
|
|
||||||
case UWP_MSG_SET_GAMEPAD_AXIS:
|
|
||||||
{
|
|
||||||
if ((msg->paramInt0 < MAX_GAMEPADS) && (msg->paramInt1 < MAX_GAMEPAD_AXIS)) CORE.Input.Gamepad.axisState[msg->paramInt0][msg->paramInt1] = msg->paramFloat0;
|
|
||||||
|
|
||||||
// Register buttons for 2nd triggers
|
|
||||||
CORE.Input.Gamepad.currentState[msg->paramInt0][GAMEPAD_BUTTON_LEFT_TRIGGER_2] = (char)(CORE.Input.Gamepad.axisState[msg->paramInt0][GAMEPAD_AXIS_LEFT_TRIGGER] > 0.1);
|
|
||||||
CORE.Input.Gamepad.currentState[msg->paramInt0][GAMEPAD_BUTTON_RIGHT_TRIGGER_2] = (char)(CORE.Input.Gamepad.axisState[msg->paramInt0][GAMEPAD_AXIS_RIGHT_TRIGGER] > 0.1);
|
|
||||||
} break;
|
|
||||||
case UWP_MSG_SET_DISPLAY_DIMS:
|
|
||||||
{
|
|
||||||
CORE.Window.display.width = msg->paramVector0.x;
|
|
||||||
CORE.Window.display.height = msg->paramVector0.y;
|
|
||||||
} break;
|
|
||||||
case UWP_MSG_HANDLE_RESIZE:
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
|
|
||||||
// If window is resized, viewport and projection matrix needs to be re-calculated
|
|
||||||
rlViewport(0, 0, CORE.Window.screen.width, CORE.Window.screen.height); // Set viewport width and height
|
|
||||||
rlMatrixMode(RL_PROJECTION); // Switch to projection matrix
|
|
||||||
rlLoadIdentity(); // Reset current matrix (projection)
|
|
||||||
rlOrtho(0, CORE.Window.screen.width, CORE.Window.screen.height, 0, 0.0f, 1.0f); // Orthographic projection mode with top-left corner at (0,0)
|
|
||||||
rlMatrixMode(RL_MODELVIEW); // Switch back to modelview matrix
|
|
||||||
rlLoadIdentity(); // Reset current matrix (modelview)
|
|
||||||
rlClearScreenBuffers(); // Clear screen buffers (color and depth)
|
|
||||||
|
|
||||||
// Window size must be updated to be used on 3D mode to get new aspect ratio (BeginMode3D())
|
|
||||||
// NOTE: Be careful! GLFW3 will choose the closest fullscreen resolution supported by current monitor,
|
|
||||||
// for example, if reescaling back to 800x450 (desired), it could set 720x480 (closest fullscreen supported)
|
|
||||||
CORE.Window.currentFbo.width = CORE.Window.screen.width;
|
|
||||||
CORE.Window.currentFbo.height = CORE.Window.screen.height;
|
|
||||||
|
|
||||||
// NOTE: Postprocessing texture is not scaled to new size
|
|
||||||
|
|
||||||
CORE.Window.resized = true;
|
|
||||||
|
|
||||||
} break;
|
|
||||||
case UWP_MSG_SET_GAME_TIME: CORE.Time.current = msg->paramDouble0; break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
|
|
||||||
DeleteUWPMessage(msg); //Delete, we are done
|
|
||||||
}
|
|
||||||
#endif // PLATFORM_UWP
|
#endif // PLATFORM_UWP
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
|
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
|
||||||
|
|
@ -5258,3 +5136,138 @@ static void *GamepadThread(void *arg)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif // PLATFORM_RPI
|
#endif // PLATFORM_RPI
|
||||||
|
|
||||||
|
#if defined(PLATFORM_UWP)
|
||||||
|
|
||||||
|
void UWPMouseWheelEvent(int deltaY)
|
||||||
|
{
|
||||||
|
CORE.Input.Mouse.currentWheelMove = (int)deltaY;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UWPKeyDownEvent(int key, bool down)
|
||||||
|
{
|
||||||
|
if (key == CORE.Input.Keyboard.exitKey && down)
|
||||||
|
{
|
||||||
|
// Time to close the window.
|
||||||
|
CORE.Window.shouldClose = true;
|
||||||
|
}// TODO: Could UWP possibly support GIF recording?
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CORE.Input.Keyboard.currentKeyState[key] = down;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
/*if (CORE.Input.Keyboard.keyPressedQueueCount < MAX_CHARS_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.position.x = (float)x;
|
||||||
|
CORE.Input.Mouse.position.y = (float)y;
|
||||||
|
CORE.Input.Touch.position[0] = CORE.Input.Mouse.position;
|
||||||
|
|
||||||
|
#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.Touch.position[0];
|
||||||
|
|
||||||
|
// 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.resized = 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.currentState[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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PLATFORM_UWP
|
||||||
|
|
|
||||||
|
|
@ -663,6 +663,7 @@ RLAPI int GetPixelDataSize(int width, int height, int format);// Get pixel data
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(GRAPHICS_API_OPENGL_ES2)
|
#if defined(GRAPHICS_API_OPENGL_ES2)
|
||||||
|
#define GL_GLEXT_PROTOTYPES
|
||||||
#include <EGL/egl.h> // EGL library
|
#include <EGL/egl.h> // EGL library
|
||||||
#include <GLES2/gl2.h> // OpenGL ES 2.0 library
|
#include <GLES2/gl2.h> // OpenGL ES 2.0 library
|
||||||
#include <GLES2/gl2ext.h> // OpenGL ES 2.0 extensions library
|
#include <GLES2/gl2ext.h> // OpenGL ES 2.0 extensions library
|
||||||
|
|
|
||||||
173
src/utils.c
173
src/utils.c
|
|
@ -395,16 +395,6 @@ UWPMessage *UWPGetMessage(void)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UWPSendMessage(UWPMessage *msg)
|
|
||||||
{
|
|
||||||
if ((UWPInMessageId + 1) < MAX_UWP_MESSAGES)
|
|
||||||
{
|
|
||||||
UWPInMessageId++;
|
|
||||||
UWPInMessages[UWPInMessageId] = msg;
|
|
||||||
}
|
|
||||||
else TRACELOG(LOG_WARNING, "UWP: Not enough array space to register new inbound message");
|
|
||||||
}
|
|
||||||
|
|
||||||
void SendMessageToUWP(UWPMessage *msg)
|
void SendMessageToUWP(UWPMessage *msg)
|
||||||
{
|
{
|
||||||
if ((UWPOutMessageId + 1) < MAX_UWP_MESSAGES)
|
if ((UWPOutMessageId + 1) < MAX_UWP_MESSAGES)
|
||||||
|
|
@ -415,15 +405,166 @@ void SendMessageToUWP(UWPMessage *msg)
|
||||||
else TRACELOG(LOG_WARNING, "UWP: Not enough array space to register new outward message");
|
else TRACELOG(LOG_WARNING, "UWP: Not enough array space to register new outward message");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasMessageFromUWP(void)
|
|
||||||
|
// NEW UWP API
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
bool UWPIsConfigured()
|
||||||
{
|
{
|
||||||
return UWPInMessageId > -1;
|
bool pass = true;
|
||||||
|
if (uwpQueryTimeFunc == NULL)
|
||||||
|
{
|
||||||
|
TRACELOG(LOG_ERROR, "You must call UWPSetQueryTimeFunc with a valid function before calling InitWindow()");
|
||||||
|
pass = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
UWPMessage *GetMessageFromUWP(void)
|
if (uwpSleepFunc == NULL)
|
||||||
{
|
{
|
||||||
if (HasMessageFromUWP()) return UWPInMessages[UWPInMessageId--];
|
TRACELOG(LOG_ERROR, "You must call UWPSetSleepFunc with a valid function before calling InitWindow()");
|
||||||
|
pass = false;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (uwpDisplaySizeFunc == NULL)
|
||||||
|
{
|
||||||
|
TRACELOG(LOG_ERROR, "You must call UWPSetDisplaySizeFunc with a valid function before calling InitWindow()");
|
||||||
|
pass = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uwpMouseLockFunc == NULL)
|
||||||
|
{
|
||||||
|
TRACELOG(LOG_ERROR, "You must call UWPSetMouseLockFunc with a valid function before calling InitWindow()");
|
||||||
|
pass = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uwpMouseUnlockFunc == NULL)
|
||||||
|
{
|
||||||
|
TRACELOG(LOG_ERROR, "You must call UWPSetMouseUnlockFunc with a valid function before calling InitWindow()");
|
||||||
|
pass = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uwpMouseShowFunc == NULL)
|
||||||
|
{
|
||||||
|
TRACELOG(LOG_ERROR, "You must call UWPSetMouseShowFunc with a valid function before calling InitWindow()");
|
||||||
|
pass = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uwpMouseHideFunc == NULL)
|
||||||
|
{
|
||||||
|
TRACELOG(LOG_ERROR, "You must call UWPSetMouseHideFunc with a valid function before calling InitWindow()");
|
||||||
|
pass = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uwpMouseSetPosFunc == NULL)
|
||||||
|
{
|
||||||
|
TRACELOG(LOG_ERROR, "You must call UWPSetMouseSetPosFunc with a valid function before calling InitWindow()");
|
||||||
|
pass = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uwpCoreWindow == NULL)
|
||||||
|
{
|
||||||
|
TRACELOG(LOG_ERROR, "You must set a pointer to the UWP core window before calling InitWindow()");
|
||||||
|
pass = false;
|
||||||
|
}
|
||||||
|
return pass;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // PLATFORM_UWP
|
#endif // PLATFORM_UWP
|
||||||
|
|
|
||||||
103
src/utils.h
103
src/utils.h
|
|
@ -73,61 +73,72 @@ FILE *android_fopen(const char *fileName, const char *mode); // Repla
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PLATFORM_UWP)
|
#if defined(PLATFORM_UWP)
|
||||||
// UWP Messages System
|
// UWP Implementation Features
|
||||||
typedef enum {
|
|
||||||
UWP_MSG_NONE = 0,
|
|
||||||
|
|
||||||
// Send
|
// Determine if UWP functions are set and ready for raylib's use.
|
||||||
UWP_MSG_SHOW_MOUSE,
|
bool UWPIsConfigured();
|
||||||
UWP_MSG_HIDE_MOUSE,
|
|
||||||
UWP_MSG_LOCK_MOUSE,
|
|
||||||
UWP_MSG_UNLOCK_MOUSE,
|
|
||||||
UWP_MSG_SET_MOUSE_LOCATION, // paramVector0 (pos)
|
|
||||||
|
|
||||||
// Receive (Into C)
|
// Function for getting program time.
|
||||||
UWP_MSG_REGISTER_KEY, // paramInt0 (key), paramChar0 (status)
|
typedef double(*UWPQueryTimeFunc)();
|
||||||
UWP_MSG_REGISTER_CLICK, // paramInt0 (button), paramChar0 (status)
|
UWPQueryTimeFunc UWPGetQueryTimeFunc(void);
|
||||||
UWP_MSG_SCROLL_WHEEL_UPDATE, // paramInt0 (delta)
|
void UWPSetQueryTimeFunc(UWPQueryTimeFunc func);
|
||||||
UWP_MSG_UPDATE_MOUSE_LOCATION, // paramVector0 (pos)
|
|
||||||
UWP_MSG_SET_GAMEPAD_ACTIVE, // paramInt0 (gamepad), paramBool0 (active or not)
|
|
||||||
UWP_MSG_SET_GAMEPAD_BUTTON, // paramInt0 (gamepad), paramInt1 (button), paramChar0 (status)
|
|
||||||
UWP_MSG_SET_GAMEPAD_AXIS, // paramInt0 (gamepad), int1 (axis), paramFloat0 (value)
|
|
||||||
UWP_MSG_SET_DISPLAY_DIMS, // paramVector0 (display dimensions)
|
|
||||||
UWP_MSG_HANDLE_RESIZE, // paramVector0 (new dimensions) - Onresized event
|
|
||||||
UWP_MSG_SET_GAME_TIME, // paramInt0
|
|
||||||
} UWPMessageType;
|
|
||||||
|
|
||||||
typedef struct UWPMessage {
|
// Function for sleeping the current thread
|
||||||
UWPMessageType type; // Message type
|
typedef void (*UWPSleepFunc)(double sleepUntil);
|
||||||
|
UWPSleepFunc UWPGetSleepFunc(void);
|
||||||
|
void UWPSetSleepFunc(UWPSleepFunc func);
|
||||||
|
|
||||||
Vector2 paramVector0; // Vector parameters
|
// Function for querying the display size
|
||||||
int paramInt0; // Int parameter
|
typedef void(*UWPDisplaySizeFunc)(int *width, int* height);
|
||||||
int paramInt1; // Int parameter
|
UWPDisplaySizeFunc UWPGetDisplaySizeFunc(void);
|
||||||
char paramChar0; // Char parameters
|
void UWPSetDisplaySizeFunc(UWPDisplaySizeFunc func);
|
||||||
float paramFloat0; // Float parameters
|
|
||||||
double paramDouble0; // Double parameters
|
|
||||||
bool paramBool0; // Bool parameters
|
|
||||||
|
|
||||||
// More parameters can be added and fed to functions
|
// Functions for mouse cursor control
|
||||||
} UWPMessage;
|
typedef void(*UWPMouseFunc)(void);
|
||||||
|
UWPMouseFunc UWPGetMouseLockFunc();
|
||||||
|
void UWPSetMouseLockFunc(UWPMouseFunc func);
|
||||||
|
UWPMouseFunc UWPGetMouseUnlockFunc();
|
||||||
|
void UWPSetMouseUnlockFunc(UWPMouseFunc func);
|
||||||
|
UWPMouseFunc UWPGetMouseShowFunc();
|
||||||
|
void UWPSetMouseShowFunc(UWPMouseFunc func);
|
||||||
|
UWPMouseFunc UWPGetMouseHideFunc();
|
||||||
|
void UWPSetMouseHideFunc(UWPMouseFunc func);
|
||||||
|
|
||||||
// Allocate UWP Message
|
// Function for setting mouse cursor position.
|
||||||
RLAPI UWPMessage* CreateUWPMessage(void);
|
typedef void (*UWPMouseSetPosFunc)(int x, int y);
|
||||||
|
UWPMouseSetPosFunc UWPGetMouseSetPosFunc();
|
||||||
|
void UWPSetMouseSetPosFunc(UWPMouseSetPosFunc func);
|
||||||
|
|
||||||
// Free UWP Message
|
// The below functions are implemented in core.c but are placed here so they can be called by user code.
|
||||||
RLAPI void DeleteUWPMessage(UWPMessage* msg);
|
// This choice is made as platform-specific code is preferred to be kept away from raylib.h
|
||||||
|
|
||||||
// Get messages into C++
|
// Call this when a Key is pressed or released.
|
||||||
RLAPI bool UWPHasMessages(void);
|
void UWPKeyDownEvent(int key, bool down);
|
||||||
RLAPI UWPMessage* UWPGetMessage(void);
|
|
||||||
RLAPI void UWPSendMessage(UWPMessage* msg);
|
|
||||||
|
|
||||||
// For C to call
|
// Call when a mouse button state changes
|
||||||
#ifndef __cplusplus // Hide from C++ code
|
void UWPMouseButtonEvent(int button, bool down);
|
||||||
void SendMessageToUWP(UWPMessage* msg);
|
|
||||||
bool HasMessageFromUWP(void);
|
// Call when the mouse cursor moves
|
||||||
UWPMessage* GetMessageFromUWP(void);
|
void UWPMousePosEvent(double x, double y);
|
||||||
#endif
|
|
||||||
|
// Call when the mouse wheel moves
|
||||||
|
void UWPMouseWheelEvent(int deltaY);
|
||||||
|
|
||||||
|
// Call when the window resizes
|
||||||
|
void UWPResizeEvent(int width, int height);
|
||||||
|
|
||||||
|
// Call when a gamepad is made active
|
||||||
|
void UWPActivateGamepadEvent(int gamepad, bool active);
|
||||||
|
|
||||||
|
// Call when a gamepad button state changes
|
||||||
|
void UWPRegisterGamepadButton(int gamepad, int button, bool down);
|
||||||
|
|
||||||
|
// Call when a gamepad axis state changes
|
||||||
|
void UWPRegisterGamepadAxis(int gamepad, int axis, float value);
|
||||||
|
|
||||||
|
// Set the core window pointer so that we can pass it to EGL.
|
||||||
|
void* UWPGetCoreWindowPtr();
|
||||||
|
void UWPSetCoreWindowPtr(void* ptr);
|
||||||
|
|
||||||
#endif // defined(PLATFORM_UWP)
|
#endif // defined(PLATFORM_UWP)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user