Review UWP configuration
This commit is contained in:
parent
bbdf9f4880
commit
e18e8c6276
4 changed files with 26 additions and 26 deletions
|
@ -18,16 +18,21 @@ using namespace Platform;
|
||||||
using namespace raylibUWP;
|
using namespace raylibUWP;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
To-do list
|
TODO list:
|
||||||
- Cache reference to our CoreWindow?
|
- Cache reference to our CoreWindow?
|
||||||
- Implement gestures
|
- Implement gestures support
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Declare uwpWindow as exter to be used by raylib internals
|
||||||
|
// NOTE: It should be properly assigned before calling InitWindow()
|
||||||
|
extern "C" { EGLNativeWindowType uwpWindow; };
|
||||||
|
|
||||||
/* INPUT CODE */
|
/* INPUT CODE */
|
||||||
// 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)
|
||||||
|
|
||||||
static bool gamepadReady[MAX_GAMEPADS] = { false }; // Flag to know if gamepad is ready
|
static bool gamepadReady[MAX_GAMEPADS] = { false }; // Flag to know if gamepad is ready
|
||||||
static float gamepadAxisState[MAX_GAMEPADS][MAX_GAMEPAD_AXIS]; // Gamepad axis state
|
static float gamepadAxisState[MAX_GAMEPADS][MAX_GAMEPAD_AXIS]; // Gamepad axis state
|
||||||
static char previousGamepadState[MAX_GAMEPADS][MAX_GAMEPAD_BUTTONS]; // Previous gamepad buttons state
|
static char previousGamepadState[MAX_GAMEPADS][MAX_GAMEPAD_BUTTONS]; // Previous gamepad buttons state
|
||||||
|
@ -36,7 +41,6 @@ static char currentGamepadState[MAX_GAMEPADS][MAX_GAMEPAD_BUTTONS]; // Curre
|
||||||
static char previousKeyState[512] = { 0 }; // Contains previous frame keyboard state
|
static char previousKeyState[512] = { 0 }; // Contains previous frame keyboard state
|
||||||
static char currentKeyState[512] = { 0 }; // Contains current frame keyboard state
|
static char currentKeyState[512] = { 0 }; // Contains current frame keyboard state
|
||||||
|
|
||||||
//...
|
|
||||||
static char previousMouseState[3] = { 0 }; // Registers previous mouse button state
|
static char previousMouseState[3] = { 0 }; // Registers previous mouse button state
|
||||||
static char currentMouseState[3] = { 0 }; // Registers current mouse button state
|
static char currentMouseState[3] = { 0 }; // Registers current mouse button state
|
||||||
static int previousMouseWheelY = 0; // Registers previous mouse wheel variation
|
static int previousMouseWheelY = 0; // Registers previous mouse wheel variation
|
||||||
|
@ -46,7 +50,7 @@ static bool cursorOnScreen = false; // Tracks if cursor is inside client
|
||||||
static bool cursorHidden = false; // Track if cursor is hidden
|
static bool cursorHidden = false; // Track if cursor is hidden
|
||||||
|
|
||||||
static Vector2 mousePosition;
|
static Vector2 mousePosition;
|
||||||
static Vector2 mouseDelta; // NOTE: Added to keep track of mouse movement while the cursor is locked - no equivalent in "core.c"
|
static Vector2 mouseDelta; // NOTE: Added to keep track of mouse movement while the cursor is locked - no equivalent in "core.c"
|
||||||
static bool toggleCursorLock;
|
static bool toggleCursorLock;
|
||||||
|
|
||||||
CoreCursor ^regularCursor = ref new CoreCursor(CoreCursorType::Arrow, 0); // The "visible arrow" cursor type
|
CoreCursor ^regularCursor = ref new CoreCursor(CoreCursorType::Arrow, 0); // The "visible arrow" cursor type
|
||||||
|
@ -122,7 +126,7 @@ void ProcessKeyEvent(Windows::System::VirtualKey key, int action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CALLBACKS */
|
// Callbacks
|
||||||
void App::PointerPressed(CoreWindow^ window, PointerEventArgs^ args)
|
void App::PointerPressed(CoreWindow^ window, PointerEventArgs^ args)
|
||||||
{
|
{
|
||||||
if (args->CurrentPoint->Properties->IsLeftButtonPressed)
|
if (args->CurrentPoint->Properties->IsLeftButtonPressed)
|
||||||
|
@ -206,6 +210,7 @@ void UWPSetMousePosition(Vector2 position)
|
||||||
window->PointerPosition = mousePosScreen;
|
window->PointerPosition = mousePosScreen;
|
||||||
mousePosition = position;
|
mousePosition = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enables cursor (unlock cursor)
|
// Enables cursor (unlock cursor)
|
||||||
void UWPEnableCursor()
|
void UWPEnableCursor()
|
||||||
{
|
{
|
||||||
|
@ -321,8 +326,7 @@ bool UWPIsKeyPressed(int key)
|
||||||
{
|
{
|
||||||
bool pressed = false;
|
bool pressed = false;
|
||||||
|
|
||||||
if ((currentKeyState[key] != previousKeyState[key]) && (currentKeyState[key] == 1))
|
if ((currentKeyState[key] != previousKeyState[key]) && (currentKeyState[key] == 1)) pressed = true;
|
||||||
pressed = true;
|
|
||||||
else pressed = false;
|
else pressed = false;
|
||||||
|
|
||||||
return pressed;
|
return pressed;
|
||||||
|
@ -422,7 +426,10 @@ void App::SetWindow(CoreWindow^ window)
|
||||||
currentDisplayInformation->OrientationChanged += ref new TypedEventHandler<DisplayInformation^, Object^>(this, &App::OnOrientationChanged);
|
currentDisplayInformation->OrientationChanged += ref new TypedEventHandler<DisplayInformation^, Object^>(this, &App::OnOrientationChanged);
|
||||||
|
|
||||||
// The CoreWindow has been created, so EGL can be initialized.
|
// The CoreWindow has been created, so EGL can be initialized.
|
||||||
InitWindow(800, 450, (EGLNativeWindowType)window);
|
|
||||||
|
uwpWindow = (EGLNativeWindowType)window;
|
||||||
|
|
||||||
|
InitWindow(800, 450, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initializes scene resources
|
// Initializes scene resources
|
||||||
|
@ -446,7 +453,6 @@ void App::Run()
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
|
||||||
posX += gamepadAxisState[GAMEPAD_PLAYER1][GAMEPAD_XBOX_AXIS_LEFT_X] * 5;
|
posX += gamepadAxisState[GAMEPAD_PLAYER1][GAMEPAD_XBOX_AXIS_LEFT_X] * 5;
|
||||||
posY += gamepadAxisState[GAMEPAD_PLAYER1][GAMEPAD_XBOX_AXIS_LEFT_Y] * -5;
|
posY += gamepadAxisState[GAMEPAD_PLAYER1][GAMEPAD_XBOX_AXIS_LEFT_Y] * -5;
|
||||||
DrawRectangle(posX, posY, 400, 100, RED);
|
DrawRectangle(posX, posY, 400, 100, RED);
|
||||||
|
@ -455,38 +461,32 @@ void App::Run()
|
||||||
|
|
||||||
DrawCircle(mousePosition.x, mousePosition.y, 40, BLUE);
|
DrawCircle(mousePosition.x, mousePosition.y, 40, BLUE);
|
||||||
|
|
||||||
if(UWPIsKeyDown(KEY_S))
|
if (UWPIsKeyDown(KEY_S)) DrawCircle(100, 100, 100, BLUE);
|
||||||
{
|
|
||||||
DrawCircle(100, 100, 100, BLUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(UWPIsKeyPressed(KEY_A))
|
if (UWPIsKeyPressed(KEY_A))
|
||||||
{
|
{
|
||||||
posX -= 50;
|
posX -= 50;
|
||||||
UWPEnableCursor();
|
UWPEnableCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UWPIsKeyPressed(KEY_D))
|
if (UWPIsKeyPressed(KEY_D))
|
||||||
{
|
{
|
||||||
posX += 50;
|
posX += 50;
|
||||||
|
|
||||||
UWPDisableCursor();
|
UWPDisableCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentKeyState[KEY_LEFT_ALT])
|
if (currentKeyState[KEY_LEFT_ALT]) DrawRectangle(250, 250, 20, 20, BLACK);
|
||||||
DrawRectangle(250, 250, 20, 20, BLACK);
|
if (currentKeyState[KEY_BACKSPACE]) DrawRectangle(280, 250, 20, 20, BLACK);
|
||||||
if (currentKeyState[KEY_BACKSPACE])
|
if (currentMouseState[MOUSE_LEFT_BUTTON]) DrawRectangle(280, 250, 20, 20, BLACK);
|
||||||
DrawRectangle(280, 250, 20, 20, BLACK);
|
|
||||||
|
|
||||||
if (currentMouseState[MOUSE_LEFT_BUTTON])
|
|
||||||
DrawRectangle(280, 250, 20, 20, BLACK);
|
|
||||||
|
|
||||||
static int pos = 0;
|
static int pos = 0;
|
||||||
pos -= currentMouseWheelY;
|
pos -= currentMouseWheelY;
|
||||||
DrawRectangle(280, pos + 50, 20, 20, BLACK);
|
|
||||||
|
|
||||||
|
DrawRectangle(280, pos + 50, 20, 20, BLACK);
|
||||||
DrawRectangle(250, 280 + (time++ % 60), 10, 10, PURPLE);
|
DrawRectangle(250, 280 + (time++ % 60), 10, 10, PURPLE);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|
||||||
UWP_PollInput();
|
UWP_PollInput();
|
||||||
|
|
||||||
CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
|
CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<mp:PhoneIdentity PhoneProductId="56d2ca94-c361-4e9f-9a33-bacd751552fa" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
|
<mp:PhoneIdentity PhoneProductId="56d2ca94-c361-4e9f-9a33-bacd751552fa" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
|
||||||
<Properties>
|
<Properties>
|
||||||
<DisplayName>raylibUWP</DisplayName>
|
<DisplayName>raylibUWP</DisplayName>
|
||||||
<PublisherDisplayName>Alumno</PublisherDisplayName>
|
<PublisherDisplayName>raysan5</PublisherDisplayName>
|
||||||
<Logo>Assets\StoreLogo.png</Logo>
|
<Logo>Assets\StoreLogo.png</Logo>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Dependencies>
|
<Dependencies>
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
<AppContainerApplication>true</AppContainerApplication>
|
<AppContainerApplication>true</AppContainerApplication>
|
||||||
<ApplicationType>Windows Store</ApplicationType>
|
<ApplicationType>Windows Store</ApplicationType>
|
||||||
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
|
||||||
<WindowsTargetPlatformMinVersion>10.0.10586.0</WindowsTargetPlatformMinVersion>
|
<WindowsTargetPlatformMinVersion>10.0.14393.0</WindowsTargetPlatformMinVersion>
|
||||||
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
|
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
|
||||||
<ProjectName>raylib.App.UWP</ProjectName>
|
<ProjectName>raylib.App.UWP</ProjectName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue