Updates the SDL library to the latest standard bugfix release

This commit is contained in:
JeffR 2023-07-13 15:20:29 -05:00
parent cb766f2878
commit 083d2175ea
1280 changed files with 343926 additions and 179615 deletions

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -44,15 +44,12 @@ extern "C" {
#include "../../events/SDL_events_c.h"
}
/* Forward declarations */
static void WINRT_YieldXAMLThread();
/* Global event management */
void
WINRT_PumpEvents(_THIS)
void WINRT_PumpEvents(_THIS)
{
if (SDL_WinRTGlobalApp) {
SDL_WinRTGlobalApp->PumpEvents();
@ -61,7 +58,6 @@ WINRT_PumpEvents(_THIS)
}
}
/* XAML Thread management */
enum SDL_XAMLAppThreadState
@ -72,12 +68,11 @@ enum SDL_XAMLAppThreadState
};
static SDL_XAMLAppThreadState _threadState = ThreadState_NotLaunched;
static SDL_Thread * _XAMLThread = nullptr;
static SDL_mutex * _mutex = nullptr;
static SDL_cond * _cond = nullptr;
static SDL_Thread *_XAMLThread = nullptr;
static SDL_mutex *_mutex = nullptr;
static SDL_cond *_cond = nullptr;
static void
WINRT_YieldXAMLThread()
static void WINRT_YieldXAMLThread()
{
SDL_LockMutex(_mutex);
SDL_assert(_threadState == ThreadState_Running);
@ -93,8 +88,7 @@ WINRT_YieldXAMLThread()
SDL_UnlockMutex(_mutex);
}
static int
WINRT_XAMLThreadMain(void * userdata)
static int WINRT_XAMLThreadMain(void *userdata)
{
// TODO, WinRT: pass the C-style main() a reasonably realistic
// representation of command line arguments.
@ -103,48 +97,47 @@ WINRT_XAMLThreadMain(void * userdata)
return WINRT_SDLAppEntryPoint(argc, argv);
}
void
WINRT_CycleXAMLThread(void)
void WINRT_CycleXAMLThread(void)
{
switch (_threadState) {
case ThreadState_NotLaunched:
{
_cond = SDL_CreateCond();
case ThreadState_NotLaunched:
{
_cond = SDL_CreateCond();
_mutex = SDL_CreateMutex();
_threadState = ThreadState_Running;
_XAMLThread = SDL_CreateThreadInternal(WINRT_XAMLThreadMain, "SDL/XAML App Thread", 0, nullptr);
_mutex = SDL_CreateMutex();
_threadState = ThreadState_Running;
_XAMLThread = SDL_CreateThreadInternal(WINRT_XAMLThreadMain, "SDL/XAML App Thread", 0, nullptr);
SDL_LockMutex(_mutex);
while (_threadState != ThreadState_Yielding) {
SDL_CondWait(_cond, _mutex);
}
SDL_UnlockMutex(_mutex);
break;
SDL_LockMutex(_mutex);
while (_threadState != ThreadState_Yielding) {
SDL_CondWait(_cond, _mutex);
}
SDL_UnlockMutex(_mutex);
case ThreadState_Running:
{
SDL_assert(false);
break;
}
case ThreadState_Yielding:
{
SDL_LockMutex(_mutex);
SDL_assert(_threadState == ThreadState_Yielding);
_threadState = ThreadState_Running;
SDL_UnlockMutex(_mutex);
SDL_CondSignal(_cond);
SDL_LockMutex(_mutex);
while (_threadState != ThreadState_Yielding) {
SDL_CondWait(_cond, _mutex);
}
SDL_UnlockMutex(_mutex);
break;
}
case ThreadState_Running:
{
SDL_assert(false);
break;
}
case ThreadState_Yielding:
{
SDL_LockMutex(_mutex);
SDL_assert(_threadState == ThreadState_Yielding);
_threadState = ThreadState_Running;
SDL_UnlockMutex(_mutex);
SDL_CondSignal(_cond);
SDL_LockMutex(_mutex);
while (_threadState != ThreadState_Yielding) {
SDL_CondWait(_cond, _mutex);
}
SDL_UnlockMutex(_mutex);
}
}
}

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -39,40 +39,41 @@ extern void WINRT_PumpEvents(_THIS);
}
#endif
/*
* Internal-use, C++/CX functions:
*/
#ifdef __cplusplus_winrt
/* Pointers (Mice, Touch, etc.) */
typedef enum {
typedef enum
{
NormalizeZeroToOne,
TransformToSDLWindowSize
} WINRT_CursorNormalizationType;
extern Windows::Foundation::Point WINRT_TransformCursorPosition(SDL_Window * window,
extern Windows::Foundation::Point WINRT_TransformCursorPosition(SDL_Window *window,
Windows::Foundation::Point rawPosition,
WINRT_CursorNormalizationType normalization);
extern SDL_bool WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt, Uint8 *button, Uint8 *pressed);
extern void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint);
extern void WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint);
extern void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint);
extern void WINRT_ProcessPointerEnteredEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint);
extern void WINRT_ProcessPointerExitedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint);
extern void WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint);
extern void WINRT_ProcessMouseMovedEvent(SDL_Window * window, Windows::Devices::Input::MouseEventArgs ^args);
extern SDL_bool WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^ pt, Uint8 *button, Uint8 *pressed);
extern void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint);
extern void WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint);
extern void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint);
extern void WINRT_ProcessPointerEnteredEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint);
extern void WINRT_ProcessPointerExitedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint);
extern void WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint);
extern void WINRT_ProcessMouseMovedEvent(SDL_Window *window, Windows::Devices::Input::MouseEventArgs ^ args);
/* Keyboard */
extern void WINRT_ProcessKeyDownEvent(Windows::UI::Core::KeyEventArgs ^args);
extern void WINRT_ProcessKeyUpEvent(Windows::UI::Core::KeyEventArgs ^args);
extern void WINRT_ProcessCharacterReceivedEvent(Windows::UI::Core::CharacterReceivedEventArgs ^args);
extern void WINRT_ProcessKeyDownEvent(Windows::UI::Core::KeyEventArgs ^ args);
extern void WINRT_ProcessKeyUpEvent(Windows::UI::Core::KeyEventArgs ^ args);
extern void WINRT_ProcessCharacterReceivedEvent(Windows::UI::Core::CharacterReceivedEventArgs ^ args);
#if NTDDI_VERSION >= NTDDI_WIN10
extern void WINTRT_InitialiseInputPaneEvents(_THIS);
extern SDL_bool WINRT_HasScreenKeyboardSupport(_THIS);
extern void WINRT_ShowScreenKeyboard(_THIS, SDL_Window *window);
extern void WINRT_HideScreenKeyboard(_THIS, SDL_Window *window);
extern SDL_bool WINRT_IsScreenKeyboardShown(_THIS, SDL_Window *window);
#endif // NTDDI_VERSION >= ...
#endif // NTDDI_VERSION >= ...
/* XAML Thread Management */
extern void WINRT_CycleXAMLThread(void);

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -27,7 +27,6 @@
#include <windows.foundation.h>
#include <windows.system.h>
/* SDL includes */
extern "C" {
#include "SDL_mouse.h"
@ -35,13 +34,11 @@ extern "C" {
}
#include "SDL_winrtvideo_cpp.h"
/* Game Bar events can come in off the main thread. Use the following
WinRT CoreDispatcher to deal with them on SDL's thread.
*/
static Platform::WeakReference WINRT_MainThreadDispatcher;
/* Win10's initial SDK (the 10.0.10240.0 release) does not include references
to Game Bar APIs, as the Game Bar was released via Win10 10.0.10586.0.
@ -51,26 +48,26 @@ static Platform::WeakReference WINRT_MainThreadDispatcher;
MIDL_INTERFACE("1DB9A292-CC78-4173-BE45-B61E67283EA7")
IGameBarStatics_ : public IInspectable
{
public:
virtual HRESULT STDMETHODCALLTYPE add_VisibilityChanged(
__FIEventHandler_1_IInspectable *handler,
Windows::Foundation::EventRegistrationToken *token) = 0;
virtual HRESULT STDMETHODCALLTYPE remove_VisibilityChanged(
public:
virtual HRESULT STDMETHODCALLTYPE add_VisibilityChanged(
__FIEventHandler_1_IInspectable * handler,
Windows::Foundation::EventRegistrationToken * token) = 0;
virtual HRESULT STDMETHODCALLTYPE remove_VisibilityChanged(
Windows::Foundation::EventRegistrationToken token) = 0;
virtual HRESULT STDMETHODCALLTYPE add_IsInputRedirectedChanged(
__FIEventHandler_1_IInspectable *handler,
Windows::Foundation::EventRegistrationToken *token) = 0;
virtual HRESULT STDMETHODCALLTYPE remove_IsInputRedirectedChanged(
virtual HRESULT STDMETHODCALLTYPE add_IsInputRedirectedChanged(
__FIEventHandler_1_IInspectable * handler,
Windows::Foundation::EventRegistrationToken * token) = 0;
virtual HRESULT STDMETHODCALLTYPE remove_IsInputRedirectedChanged(
Windows::Foundation::EventRegistrationToken token) = 0;
virtual HRESULT STDMETHODCALLTYPE get_Visible(
boolean *value) = 0;
virtual HRESULT STDMETHODCALLTYPE get_IsInputRedirected(
boolean *value) = 0;
virtual HRESULT STDMETHODCALLTYPE get_Visible(
boolean * value) = 0;
virtual HRESULT STDMETHODCALLTYPE get_IsInputRedirected(
boolean * value) = 0;
};
/* Declare the game bar's COM GUID */
@ -80,8 +77,7 @@ static GUID IID_IGameBarStatics_ = { MAKELONG(0xA292, 0x1DB9), 0xCC78, 0x4173, {
If a pointer is returned, it's ->Release() method must be called
after the caller has finished using it.
*/
static IGameBarStatics_ *
WINRT_GetGameBar()
static IGameBarStatics_ *WINRT_GetGameBar()
{
wchar_t *wClassName = L"Windows.Gaming.UI.GameBar";
HSTRING hClassName;
@ -99,7 +95,7 @@ WINRT_GetGameBar()
goto done;
}
pActivationFactory->QueryInterface(IID_IGameBarStatics_, (void **) &pGameBar);
pActivationFactory->QueryInterface(IID_IGameBarStatics_, (void **)&pGameBar);
done:
if (pActivationFactory) {
@ -111,8 +107,7 @@ done:
return pGameBar;
}
static void
WINRT_HandleGameBarIsInputRedirected_MainThread()
static void WINRT_HandleGameBarIsInputRedirected_MainThread()
{
IGameBarStatics_ *gameBar;
boolean isInputRedirected = 0;
@ -121,12 +116,12 @@ WINRT_HandleGameBarIsInputRedirected_MainThread()
return;
}
gameBar = WINRT_GetGameBar();
if (!gameBar) {
if (gameBar == NULL) {
/* Shouldn't happen, but just in case... */
return;
}
if (SUCCEEDED(gameBar->get_IsInputRedirected(&isInputRedirected))) {
if ( ! isInputRedirected) {
if (!isInputRedirected) {
/* Input-control is now back to the SDL app. Restore the cursor,
in case Windows does not (it does not in either Win10
10.0.10240.0 or 10.0.10586.0, maybe later version(s) too.
@ -138,10 +133,9 @@ WINRT_HandleGameBarIsInputRedirected_MainThread()
gameBar->Release();
}
static void
WINRT_HandleGameBarIsInputRedirected_NonMainThread(Platform::Object ^ o1, Platform::Object ^o2)
static void WINRT_HandleGameBarIsInputRedirected_NonMainThread(Platform::Object ^ o1, Platform::Object ^ o2)
{
Windows::UI::Core::CoreDispatcher ^dispatcher = WINRT_MainThreadDispatcher.Resolve<Windows::UI::Core::CoreDispatcher>();
Windows::UI::Core::CoreDispatcher ^ dispatcher = WINRT_MainThreadDispatcher.Resolve<Windows::UI::Core::CoreDispatcher>();
if (dispatcher) {
dispatcher->RunAsync(
Windows::UI::Core::CoreDispatcherPriority::Normal,
@ -149,8 +143,7 @@ WINRT_HandleGameBarIsInputRedirected_NonMainThread(Platform::Object ^ o1, Platfo
}
}
void
WINRT_InitGameBar(_THIS)
void WINRT_InitGameBar(_THIS)
{
SDL_VideoData *driverdata = (SDL_VideoData *)_this->driverdata;
IGameBarStatics_ *gameBar = WINRT_GetGameBar();
@ -162,24 +155,23 @@ WINRT_InitGameBar(_THIS)
SDL thread.
*/
WINRT_MainThreadDispatcher = Windows::UI::Core::CoreWindow::GetForCurrentThread()->Dispatcher;
Windows::Foundation::EventHandler<Platform::Object ^> ^handler = \
Windows::Foundation::EventHandler<Platform::Object ^> ^ handler =
ref new Windows::Foundation::EventHandler<Platform::Object ^>(&WINRT_HandleGameBarIsInputRedirected_NonMainThread);
__FIEventHandler_1_IInspectable * pHandler = reinterpret_cast<__FIEventHandler_1_IInspectable *>(handler);
__FIEventHandler_1_IInspectable *pHandler = reinterpret_cast<__FIEventHandler_1_IInspectable *>(handler);
gameBar->add_IsInputRedirectedChanged(pHandler, &driverdata->gameBarIsInputRedirectedToken);
gameBar->Release();
}
}
void
WINRT_QuitGameBar(_THIS)
void WINRT_QuitGameBar(_THIS)
{
SDL_VideoData *driverdata;
IGameBarStatics_ *gameBar;
if (!_this || !_this->driverdata) {
if (_this == NULL || _this->driverdata == NULL) {
return;
}
gameBar = WINRT_GetGameBar();
if (!gameBar) {
if (gameBar == NULL) {
return;
}
driverdata = (SDL_VideoData *)_this->driverdata;

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -26,7 +26,6 @@
#include <Windows.h>
#include <agile.h>
/* SDL-specific includes */
#include "SDL.h"
#include "SDL_winrtevents_c.h"
@ -36,223 +35,241 @@ extern "C" {
#include "../../events/SDL_keyboard_c.h"
}
static SDL_Scancode WinRT_Official_Keycodes[] = {
SDL_SCANCODE_UNKNOWN, /* VirtualKey.None -- 0 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.LeftButton -- 1 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.RightButton -- 2 */
SDL_SCANCODE_CANCEL, /* VirtualKey.Cancel -- 3 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.MiddleButton -- 4 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.XButton1 -- 5 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.XButton2 -- 6 */
SDL_SCANCODE_UNKNOWN, /* -- 7 */
SDL_SCANCODE_BACKSPACE, /* VirtualKey.Back -- 8 */
SDL_SCANCODE_TAB, /* VirtualKey.Tab -- 9 */
SDL_SCANCODE_UNKNOWN, /* -- 10 */
SDL_SCANCODE_UNKNOWN, /* -- 11 */
SDL_SCANCODE_CLEAR, /* VirtualKey.Clear -- 12 */
SDL_SCANCODE_RETURN, /* VirtualKey.Enter -- 13 */
SDL_SCANCODE_UNKNOWN, /* -- 14 */
SDL_SCANCODE_UNKNOWN, /* -- 15 */
SDL_SCANCODE_LSHIFT, /* VirtualKey.Shift -- 16 */
SDL_SCANCODE_LCTRL, /* VirtualKey.Control -- 17 */
SDL_SCANCODE_MENU, /* VirtualKey.Menu -- 18 */
SDL_SCANCODE_PAUSE, /* VirtualKey.Pause -- 19 */
SDL_SCANCODE_CAPSLOCK, /* VirtualKey.CapitalLock -- 20 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Kana or VirtualKey.Hangul -- 21 */
SDL_SCANCODE_UNKNOWN, /* -- 22 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Junja -- 23 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Final -- 24 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Hanja or VirtualKey.Kanji -- 25 */
SDL_SCANCODE_UNKNOWN, /* -- 26 */
SDL_SCANCODE_ESCAPE, /* VirtualKey.Escape -- 27 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Convert -- 28 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.NonConvert -- 29 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Accept -- 30 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.ModeChange -- 31 (maybe SDL_SCANCODE_MODE ?) */
SDL_SCANCODE_SPACE, /* VirtualKey.Space -- 32 */
SDL_SCANCODE_PAGEUP, /* VirtualKey.PageUp -- 33 */
SDL_SCANCODE_PAGEDOWN, /* VirtualKey.PageDown -- 34 */
SDL_SCANCODE_END, /* VirtualKey.End -- 35 */
SDL_SCANCODE_HOME, /* VirtualKey.Home -- 36 */
SDL_SCANCODE_LEFT, /* VirtualKey.Left -- 37 */
SDL_SCANCODE_UP, /* VirtualKey.Up -- 38 */
SDL_SCANCODE_RIGHT, /* VirtualKey.Right -- 39 */
SDL_SCANCODE_DOWN, /* VirtualKey.Down -- 40 */
SDL_SCANCODE_SELECT, /* VirtualKey.Select -- 41 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Print -- 42 (maybe SDL_SCANCODE_PRINTSCREEN ?) */
SDL_SCANCODE_EXECUTE, /* VirtualKey.Execute -- 43 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Snapshot -- 44 */
SDL_SCANCODE_INSERT, /* VirtualKey.Insert -- 45 */
SDL_SCANCODE_DELETE, /* VirtualKey.Delete -- 46 */
SDL_SCANCODE_HELP, /* VirtualKey.Help -- 47 */
SDL_SCANCODE_0, /* VirtualKey.Number0 -- 48 */
SDL_SCANCODE_1, /* VirtualKey.Number1 -- 49 */
SDL_SCANCODE_2, /* VirtualKey.Number2 -- 50 */
SDL_SCANCODE_3, /* VirtualKey.Number3 -- 51 */
SDL_SCANCODE_4, /* VirtualKey.Number4 -- 52 */
SDL_SCANCODE_5, /* VirtualKey.Number5 -- 53 */
SDL_SCANCODE_6, /* VirtualKey.Number6 -- 54 */
SDL_SCANCODE_7, /* VirtualKey.Number7 -- 55 */
SDL_SCANCODE_8, /* VirtualKey.Number8 -- 56 */
SDL_SCANCODE_9, /* VirtualKey.Number9 -- 57 */
SDL_SCANCODE_UNKNOWN, /* -- 58 */
SDL_SCANCODE_UNKNOWN, /* -- 59 */
SDL_SCANCODE_UNKNOWN, /* -- 60 */
SDL_SCANCODE_UNKNOWN, /* -- 61 */
SDL_SCANCODE_UNKNOWN, /* -- 62 */
SDL_SCANCODE_UNKNOWN, /* -- 63 */
SDL_SCANCODE_UNKNOWN, /* -- 64 */
SDL_SCANCODE_A, /* VirtualKey.A -- 65 */
SDL_SCANCODE_B, /* VirtualKey.B -- 66 */
SDL_SCANCODE_C, /* VirtualKey.C -- 67 */
SDL_SCANCODE_D, /* VirtualKey.D -- 68 */
SDL_SCANCODE_E, /* VirtualKey.E -- 69 */
SDL_SCANCODE_F, /* VirtualKey.F -- 70 */
SDL_SCANCODE_G, /* VirtualKey.G -- 71 */
SDL_SCANCODE_H, /* VirtualKey.H -- 72 */
SDL_SCANCODE_I, /* VirtualKey.I -- 73 */
SDL_SCANCODE_J, /* VirtualKey.J -- 74 */
SDL_SCANCODE_K, /* VirtualKey.K -- 75 */
SDL_SCANCODE_L, /* VirtualKey.L -- 76 */
SDL_SCANCODE_M, /* VirtualKey.M -- 77 */
SDL_SCANCODE_N, /* VirtualKey.N -- 78 */
SDL_SCANCODE_O, /* VirtualKey.O -- 79 */
SDL_SCANCODE_P, /* VirtualKey.P -- 80 */
SDL_SCANCODE_Q, /* VirtualKey.Q -- 81 */
SDL_SCANCODE_R, /* VirtualKey.R -- 82 */
SDL_SCANCODE_S, /* VirtualKey.S -- 83 */
SDL_SCANCODE_T, /* VirtualKey.T -- 84 */
SDL_SCANCODE_U, /* VirtualKey.U -- 85 */
SDL_SCANCODE_V, /* VirtualKey.V -- 86 */
SDL_SCANCODE_W, /* VirtualKey.W -- 87 */
SDL_SCANCODE_X, /* VirtualKey.X -- 88 */
SDL_SCANCODE_Y, /* VirtualKey.Y -- 89 */
SDL_SCANCODE_Z, /* VirtualKey.Z -- 90 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.LeftWindows -- 91 (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_LGUI ?) */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.RightWindows -- 92 (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_RGUI ?) */
SDL_SCANCODE_APPLICATION, /* VirtualKey.Application -- 93 */
SDL_SCANCODE_UNKNOWN, /* -- 94 */
SDL_SCANCODE_SLEEP, /* VirtualKey.Sleep -- 95 */
SDL_SCANCODE_KP_0, /* VirtualKey.NumberPad0 -- 96 */
SDL_SCANCODE_KP_1, /* VirtualKey.NumberPad1 -- 97 */
SDL_SCANCODE_KP_2, /* VirtualKey.NumberPad2 -- 98 */
SDL_SCANCODE_KP_3, /* VirtualKey.NumberPad3 -- 99 */
SDL_SCANCODE_KP_4, /* VirtualKey.NumberPad4 -- 100 */
SDL_SCANCODE_KP_5, /* VirtualKey.NumberPad5 -- 101 */
SDL_SCANCODE_KP_6, /* VirtualKey.NumberPad6 -- 102 */
SDL_SCANCODE_KP_7, /* VirtualKey.NumberPad7 -- 103 */
SDL_SCANCODE_KP_8, /* VirtualKey.NumberPad8 -- 104 */
SDL_SCANCODE_KP_9, /* VirtualKey.NumberPad9 -- 105 */
SDL_SCANCODE_KP_MULTIPLY, /* VirtualKey.Multiply -- 106 */
SDL_SCANCODE_KP_PLUS, /* VirtualKey.Add -- 107 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Separator -- 108 */
SDL_SCANCODE_KP_MINUS, /* VirtualKey.Subtract -- 109 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Decimal -- 110 (maybe SDL_SCANCODE_DECIMALSEPARATOR, SDL_SCANCODE_KP_DECIMAL, or SDL_SCANCODE_KP_PERIOD ?) */
SDL_SCANCODE_KP_DIVIDE, /* VirtualKey.Divide -- 111 */
SDL_SCANCODE_F1, /* VirtualKey.F1 -- 112 */
SDL_SCANCODE_F2, /* VirtualKey.F2 -- 113 */
SDL_SCANCODE_F3, /* VirtualKey.F3 -- 114 */
SDL_SCANCODE_F4, /* VirtualKey.F4 -- 115 */
SDL_SCANCODE_F5, /* VirtualKey.F5 -- 116 */
SDL_SCANCODE_F6, /* VirtualKey.F6 -- 117 */
SDL_SCANCODE_F7, /* VirtualKey.F7 -- 118 */
SDL_SCANCODE_F8, /* VirtualKey.F8 -- 119 */
SDL_SCANCODE_F9, /* VirtualKey.F9 -- 120 */
SDL_SCANCODE_F10, /* VirtualKey.F10 -- 121 */
SDL_SCANCODE_F11, /* VirtualKey.F11 -- 122 */
SDL_SCANCODE_F12, /* VirtualKey.F12 -- 123 */
SDL_SCANCODE_F13, /* VirtualKey.F13 -- 124 */
SDL_SCANCODE_F14, /* VirtualKey.F14 -- 125 */
SDL_SCANCODE_F15, /* VirtualKey.F15 -- 126 */
SDL_SCANCODE_F16, /* VirtualKey.F16 -- 127 */
SDL_SCANCODE_F17, /* VirtualKey.F17 -- 128 */
SDL_SCANCODE_F18, /* VirtualKey.F18 -- 129 */
SDL_SCANCODE_F19, /* VirtualKey.F19 -- 130 */
SDL_SCANCODE_F20, /* VirtualKey.F20 -- 131 */
SDL_SCANCODE_F21, /* VirtualKey.F21 -- 132 */
SDL_SCANCODE_F22, /* VirtualKey.F22 -- 133 */
SDL_SCANCODE_F23, /* VirtualKey.F23 -- 134 */
SDL_SCANCODE_F24, /* VirtualKey.F24 -- 135 */
SDL_SCANCODE_UNKNOWN, /* -- 136 */
SDL_SCANCODE_UNKNOWN, /* -- 137 */
SDL_SCANCODE_UNKNOWN, /* -- 138 */
SDL_SCANCODE_UNKNOWN, /* -- 139 */
SDL_SCANCODE_UNKNOWN, /* -- 140 */
SDL_SCANCODE_UNKNOWN, /* -- 141 */
SDL_SCANCODE_UNKNOWN, /* -- 142 */
SDL_SCANCODE_UNKNOWN, /* -- 143 */
SDL_SCANCODE_NUMLOCKCLEAR, /* VirtualKey.NumberKeyLock -- 144 */
SDL_SCANCODE_SCROLLLOCK, /* VirtualKey.Scroll -- 145 */
SDL_SCANCODE_UNKNOWN, /* -- 146 */
SDL_SCANCODE_UNKNOWN, /* -- 147 */
SDL_SCANCODE_UNKNOWN, /* -- 148 */
SDL_SCANCODE_UNKNOWN, /* -- 149 */
SDL_SCANCODE_UNKNOWN, /* -- 150 */
SDL_SCANCODE_UNKNOWN, /* -- 151 */
SDL_SCANCODE_UNKNOWN, /* -- 152 */
SDL_SCANCODE_UNKNOWN, /* -- 153 */
SDL_SCANCODE_UNKNOWN, /* -- 154 */
SDL_SCANCODE_UNKNOWN, /* -- 155 */
SDL_SCANCODE_UNKNOWN, /* -- 156 */
SDL_SCANCODE_UNKNOWN, /* -- 157 */
SDL_SCANCODE_UNKNOWN, /* -- 158 */
SDL_SCANCODE_UNKNOWN, /* -- 159 */
SDL_SCANCODE_LSHIFT, /* VirtualKey.LeftShift -- 160 */
SDL_SCANCODE_RSHIFT, /* VirtualKey.RightShift -- 161 */
SDL_SCANCODE_LCTRL, /* VirtualKey.LeftControl -- 162 */
SDL_SCANCODE_RCTRL, /* VirtualKey.RightControl -- 163 */
SDL_SCANCODE_MENU, /* VirtualKey.LeftMenu -- 164 */
SDL_SCANCODE_MENU, /* VirtualKey.RightMenu -- 165 */
SDL_SCANCODE_AC_BACK, /* VirtualKey.GoBack -- 166 : The go back key. */
SDL_SCANCODE_AC_FORWARD, /* VirtualKey.GoForward -- 167 : The go forward key. */
SDL_SCANCODE_AC_REFRESH, /* VirtualKey.Refresh -- 168 : The refresh key. */
SDL_SCANCODE_AC_STOP, /* VirtualKey.Stop -- 169 : The stop key. */
SDL_SCANCODE_AC_SEARCH, /* VirtualKey.Search -- 170 : The search key. */
SDL_SCANCODE_AC_BOOKMARKS, /* VirtualKey.Favorites -- 171 : The favorites key. */
SDL_SCANCODE_AC_HOME /* VirtualKey.GoHome -- 172 : The go home key. */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.None -- 0 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.LeftButton -- 1 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.RightButton -- 2 */
SDL_SCANCODE_CANCEL, /* VirtualKey.Cancel -- 3 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.MiddleButton -- 4 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.XButton1 -- 5 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.XButton2 -- 6 */
SDL_SCANCODE_UNKNOWN, /* -- 7 */
SDL_SCANCODE_BACKSPACE, /* VirtualKey.Back -- 8 */
SDL_SCANCODE_TAB, /* VirtualKey.Tab -- 9 */
SDL_SCANCODE_UNKNOWN, /* -- 10 */
SDL_SCANCODE_UNKNOWN, /* -- 11 */
SDL_SCANCODE_CLEAR, /* VirtualKey.Clear -- 12 */
SDL_SCANCODE_RETURN, /* VirtualKey.Enter -- 13 */
SDL_SCANCODE_UNKNOWN, /* -- 14 */
SDL_SCANCODE_UNKNOWN, /* -- 15 */
SDL_SCANCODE_LSHIFT, /* VirtualKey.Shift -- 16 */
SDL_SCANCODE_LCTRL, /* VirtualKey.Control -- 17 */
SDL_SCANCODE_MENU, /* VirtualKey.Menu -- 18 */
SDL_SCANCODE_PAUSE, /* VirtualKey.Pause -- 19 */
SDL_SCANCODE_CAPSLOCK, /* VirtualKey.CapitalLock -- 20 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Kana or VirtualKey.Hangul -- 21 */
SDL_SCANCODE_UNKNOWN, /* -- 22 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Junja -- 23 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Final -- 24 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Hanja or VirtualKey.Kanji -- 25 */
SDL_SCANCODE_UNKNOWN, /* -- 26 */
SDL_SCANCODE_ESCAPE, /* VirtualKey.Escape -- 27 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Convert -- 28 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.NonConvert -- 29 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Accept -- 30 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.ModeChange -- 31 (maybe SDL_SCANCODE_MODE ?) */
SDL_SCANCODE_SPACE, /* VirtualKey.Space -- 32 */
SDL_SCANCODE_PAGEUP, /* VirtualKey.PageUp -- 33 */
SDL_SCANCODE_PAGEDOWN, /* VirtualKey.PageDown -- 34 */
SDL_SCANCODE_END, /* VirtualKey.End -- 35 */
SDL_SCANCODE_HOME, /* VirtualKey.Home -- 36 */
SDL_SCANCODE_LEFT, /* VirtualKey.Left -- 37 */
SDL_SCANCODE_UP, /* VirtualKey.Up -- 38 */
SDL_SCANCODE_RIGHT, /* VirtualKey.Right -- 39 */
SDL_SCANCODE_DOWN, /* VirtualKey.Down -- 40 */
SDL_SCANCODE_SELECT, /* VirtualKey.Select -- 41 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Print -- 42 (maybe SDL_SCANCODE_PRINTSCREEN ?) */
SDL_SCANCODE_EXECUTE, /* VirtualKey.Execute -- 43 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Snapshot -- 44 */
SDL_SCANCODE_INSERT, /* VirtualKey.Insert -- 45 */
SDL_SCANCODE_DELETE, /* VirtualKey.Delete -- 46 */
SDL_SCANCODE_HELP, /* VirtualKey.Help -- 47 */
SDL_SCANCODE_0, /* VirtualKey.Number0 -- 48 */
SDL_SCANCODE_1, /* VirtualKey.Number1 -- 49 */
SDL_SCANCODE_2, /* VirtualKey.Number2 -- 50 */
SDL_SCANCODE_3, /* VirtualKey.Number3 -- 51 */
SDL_SCANCODE_4, /* VirtualKey.Number4 -- 52 */
SDL_SCANCODE_5, /* VirtualKey.Number5 -- 53 */
SDL_SCANCODE_6, /* VirtualKey.Number6 -- 54 */
SDL_SCANCODE_7, /* VirtualKey.Number7 -- 55 */
SDL_SCANCODE_8, /* VirtualKey.Number8 -- 56 */
SDL_SCANCODE_9, /* VirtualKey.Number9 -- 57 */
SDL_SCANCODE_UNKNOWN, /* -- 58 */
SDL_SCANCODE_UNKNOWN, /* -- 59 */
SDL_SCANCODE_UNKNOWN, /* -- 60 */
SDL_SCANCODE_UNKNOWN, /* -- 61 */
SDL_SCANCODE_UNKNOWN, /* -- 62 */
SDL_SCANCODE_UNKNOWN, /* -- 63 */
SDL_SCANCODE_UNKNOWN, /* -- 64 */
SDL_SCANCODE_A, /* VirtualKey.A -- 65 */
SDL_SCANCODE_B, /* VirtualKey.B -- 66 */
SDL_SCANCODE_C, /* VirtualKey.C -- 67 */
SDL_SCANCODE_D, /* VirtualKey.D -- 68 */
SDL_SCANCODE_E, /* VirtualKey.E -- 69 */
SDL_SCANCODE_F, /* VirtualKey.F -- 70 */
SDL_SCANCODE_G, /* VirtualKey.G -- 71 */
SDL_SCANCODE_H, /* VirtualKey.H -- 72 */
SDL_SCANCODE_I, /* VirtualKey.I -- 73 */
SDL_SCANCODE_J, /* VirtualKey.J -- 74 */
SDL_SCANCODE_K, /* VirtualKey.K -- 75 */
SDL_SCANCODE_L, /* VirtualKey.L -- 76 */
SDL_SCANCODE_M, /* VirtualKey.M -- 77 */
SDL_SCANCODE_N, /* VirtualKey.N -- 78 */
SDL_SCANCODE_O, /* VirtualKey.O -- 79 */
SDL_SCANCODE_P, /* VirtualKey.P -- 80 */
SDL_SCANCODE_Q, /* VirtualKey.Q -- 81 */
SDL_SCANCODE_R, /* VirtualKey.R -- 82 */
SDL_SCANCODE_S, /* VirtualKey.S -- 83 */
SDL_SCANCODE_T, /* VirtualKey.T -- 84 */
SDL_SCANCODE_U, /* VirtualKey.U -- 85 */
SDL_SCANCODE_V, /* VirtualKey.V -- 86 */
SDL_SCANCODE_W, /* VirtualKey.W -- 87 */
SDL_SCANCODE_X, /* VirtualKey.X -- 88 */
SDL_SCANCODE_Y, /* VirtualKey.Y -- 89 */
SDL_SCANCODE_Z, /* VirtualKey.Z -- 90 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.LeftWindows -- 91 (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_LGUI ?) */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.RightWindows -- 92 (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_RGUI ?) */
SDL_SCANCODE_APPLICATION, /* VirtualKey.Application -- 93 */
SDL_SCANCODE_UNKNOWN, /* -- 94 */
SDL_SCANCODE_SLEEP, /* VirtualKey.Sleep -- 95 */
SDL_SCANCODE_KP_0, /* VirtualKey.NumberPad0 -- 96 */
SDL_SCANCODE_KP_1, /* VirtualKey.NumberPad1 -- 97 */
SDL_SCANCODE_KP_2, /* VirtualKey.NumberPad2 -- 98 */
SDL_SCANCODE_KP_3, /* VirtualKey.NumberPad3 -- 99 */
SDL_SCANCODE_KP_4, /* VirtualKey.NumberPad4 -- 100 */
SDL_SCANCODE_KP_5, /* VirtualKey.NumberPad5 -- 101 */
SDL_SCANCODE_KP_6, /* VirtualKey.NumberPad6 -- 102 */
SDL_SCANCODE_KP_7, /* VirtualKey.NumberPad7 -- 103 */
SDL_SCANCODE_KP_8, /* VirtualKey.NumberPad8 -- 104 */
SDL_SCANCODE_KP_9, /* VirtualKey.NumberPad9 -- 105 */
SDL_SCANCODE_KP_MULTIPLY, /* VirtualKey.Multiply -- 106 */
SDL_SCANCODE_KP_PLUS, /* VirtualKey.Add -- 107 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Separator -- 108 */
SDL_SCANCODE_KP_MINUS, /* VirtualKey.Subtract -- 109 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Decimal -- 110 (maybe SDL_SCANCODE_DECIMALSEPARATOR, SDL_SCANCODE_KP_DECIMAL, or SDL_SCANCODE_KP_PERIOD ?) */
SDL_SCANCODE_KP_DIVIDE, /* VirtualKey.Divide -- 111 */
SDL_SCANCODE_F1, /* VirtualKey.F1 -- 112 */
SDL_SCANCODE_F2, /* VirtualKey.F2 -- 113 */
SDL_SCANCODE_F3, /* VirtualKey.F3 -- 114 */
SDL_SCANCODE_F4, /* VirtualKey.F4 -- 115 */
SDL_SCANCODE_F5, /* VirtualKey.F5 -- 116 */
SDL_SCANCODE_F6, /* VirtualKey.F6 -- 117 */
SDL_SCANCODE_F7, /* VirtualKey.F7 -- 118 */
SDL_SCANCODE_F8, /* VirtualKey.F8 -- 119 */
SDL_SCANCODE_F9, /* VirtualKey.F9 -- 120 */
SDL_SCANCODE_F10, /* VirtualKey.F10 -- 121 */
SDL_SCANCODE_F11, /* VirtualKey.F11 -- 122 */
SDL_SCANCODE_F12, /* VirtualKey.F12 -- 123 */
SDL_SCANCODE_F13, /* VirtualKey.F13 -- 124 */
SDL_SCANCODE_F14, /* VirtualKey.F14 -- 125 */
SDL_SCANCODE_F15, /* VirtualKey.F15 -- 126 */
SDL_SCANCODE_F16, /* VirtualKey.F16 -- 127 */
SDL_SCANCODE_F17, /* VirtualKey.F17 -- 128 */
SDL_SCANCODE_F18, /* VirtualKey.F18 -- 129 */
SDL_SCANCODE_F19, /* VirtualKey.F19 -- 130 */
SDL_SCANCODE_F20, /* VirtualKey.F20 -- 131 */
SDL_SCANCODE_F21, /* VirtualKey.F21 -- 132 */
SDL_SCANCODE_F22, /* VirtualKey.F22 -- 133 */
SDL_SCANCODE_F23, /* VirtualKey.F23 -- 134 */
SDL_SCANCODE_F24, /* VirtualKey.F24 -- 135 */
SDL_SCANCODE_UNKNOWN, /* -- 136 */
SDL_SCANCODE_UNKNOWN, /* -- 137 */
SDL_SCANCODE_UNKNOWN, /* -- 138 */
SDL_SCANCODE_UNKNOWN, /* -- 139 */
SDL_SCANCODE_UNKNOWN, /* -- 140 */
SDL_SCANCODE_UNKNOWN, /* -- 141 */
SDL_SCANCODE_UNKNOWN, /* -- 142 */
SDL_SCANCODE_UNKNOWN, /* -- 143 */
SDL_SCANCODE_NUMLOCKCLEAR, /* VirtualKey.NumberKeyLock -- 144 */
SDL_SCANCODE_SCROLLLOCK, /* VirtualKey.Scroll -- 145 */
SDL_SCANCODE_UNKNOWN, /* -- 146 */
SDL_SCANCODE_UNKNOWN, /* -- 147 */
SDL_SCANCODE_UNKNOWN, /* -- 148 */
SDL_SCANCODE_UNKNOWN, /* -- 149 */
SDL_SCANCODE_UNKNOWN, /* -- 150 */
SDL_SCANCODE_UNKNOWN, /* -- 151 */
SDL_SCANCODE_UNKNOWN, /* -- 152 */
SDL_SCANCODE_UNKNOWN, /* -- 153 */
SDL_SCANCODE_UNKNOWN, /* -- 154 */
SDL_SCANCODE_UNKNOWN, /* -- 155 */
SDL_SCANCODE_UNKNOWN, /* -- 156 */
SDL_SCANCODE_UNKNOWN, /* -- 157 */
SDL_SCANCODE_UNKNOWN, /* -- 158 */
SDL_SCANCODE_UNKNOWN, /* -- 159 */
SDL_SCANCODE_LSHIFT, /* VirtualKey.LeftShift -- 160 */
SDL_SCANCODE_RSHIFT, /* VirtualKey.RightShift -- 161 */
SDL_SCANCODE_LCTRL, /* VirtualKey.LeftControl -- 162 */
SDL_SCANCODE_RCTRL, /* VirtualKey.RightControl -- 163 */
SDL_SCANCODE_MENU, /* VirtualKey.LeftMenu -- 164 */
SDL_SCANCODE_MENU, /* VirtualKey.RightMenu -- 165 */
SDL_SCANCODE_AC_BACK, /* VirtualKey.GoBack -- 166 : The go back key. */
SDL_SCANCODE_AC_FORWARD, /* VirtualKey.GoForward -- 167 : The go forward key. */
SDL_SCANCODE_AC_REFRESH, /* VirtualKey.Refresh -- 168 : The refresh key. */
SDL_SCANCODE_AC_STOP, /* VirtualKey.Stop -- 169 : The stop key. */
SDL_SCANCODE_AC_SEARCH, /* VirtualKey.Search -- 170 : The search key. */
SDL_SCANCODE_AC_BOOKMARKS, /* VirtualKey.Favorites -- 171 : The favorites key. */
SDL_SCANCODE_AC_HOME /* VirtualKey.GoHome -- 172 : The go home key. */
};
/* Attempt to translate a keycode that isn't listed in WinRT's VirtualKey enum.
*/
static SDL_Scancode
WINRT_TranslateUnofficialKeycode(int keycode)
static SDL_Scancode WINRT_TranslateUnofficialKeycode(int keycode)
{
switch (keycode) {
case 173: return SDL_SCANCODE_MUTE; /* VK_VOLUME_MUTE */
case 174: return SDL_SCANCODE_VOLUMEDOWN; /* VK_VOLUME_DOWN */
case 175: return SDL_SCANCODE_VOLUMEUP; /* VK_VOLUME_UP */
case 176: return SDL_SCANCODE_AUDIONEXT; /* VK_MEDIA_NEXT_TRACK */
case 177: return SDL_SCANCODE_AUDIOPREV; /* VK_MEDIA_PREV_TRACK */
// case 178: return ; /* VK_MEDIA_STOP */
case 179: return SDL_SCANCODE_AUDIOPLAY; /* VK_MEDIA_PLAY_PAUSE */
case 180: return SDL_SCANCODE_MAIL; /* VK_LAUNCH_MAIL */
case 181: return SDL_SCANCODE_MEDIASELECT; /* VK_LAUNCH_MEDIA_SELECT */
// case 182: return ; /* VK_LAUNCH_APP1 */
case 183: return SDL_SCANCODE_CALCULATOR; /* VK_LAUNCH_APP2 */
// case 184: return ; /* ... reserved ... */
// case 185: return ; /* ... reserved ... */
case 186: return SDL_SCANCODE_SEMICOLON; /* VK_OEM_1, ';:' key on US standard keyboards */
case 187: return SDL_SCANCODE_EQUALS; /* VK_OEM_PLUS */
case 188: return SDL_SCANCODE_COMMA; /* VK_OEM_COMMA */
case 189: return SDL_SCANCODE_MINUS; /* VK_OEM_MINUS */
case 190: return SDL_SCANCODE_PERIOD; /* VK_OEM_PERIOD */
case 191: return SDL_SCANCODE_SLASH; /* VK_OEM_2, '/?' key on US standard keyboards */
case 192: return SDL_SCANCODE_GRAVE; /* VK_OEM_3, '`~' key on US standard keyboards */
// ?
// ... reserved or unassigned ...
// ?
case 219: return SDL_SCANCODE_LEFTBRACKET; /* VK_OEM_4, '[{' key on US standard keyboards */
case 220: return SDL_SCANCODE_BACKSLASH; /* VK_OEM_5, '\|' key on US standard keyboards */
case 221: return SDL_SCANCODE_RIGHTBRACKET; /* VK_OEM_6, ']}' key on US standard keyboards */
case 222: return SDL_SCANCODE_APOSTROPHE; /* VK_OEM_7, 'single/double quote' on US standard keyboards */
default: break;
case 173:
return SDL_SCANCODE_MUTE; /* VK_VOLUME_MUTE */
case 174:
return SDL_SCANCODE_VOLUMEDOWN; /* VK_VOLUME_DOWN */
case 175:
return SDL_SCANCODE_VOLUMEUP; /* VK_VOLUME_UP */
case 176:
return SDL_SCANCODE_AUDIONEXT; /* VK_MEDIA_NEXT_TRACK */
case 177:
return SDL_SCANCODE_AUDIOPREV; /* VK_MEDIA_PREV_TRACK */
// case 178: return ; /* VK_MEDIA_STOP */
case 179:
return SDL_SCANCODE_AUDIOPLAY; /* VK_MEDIA_PLAY_PAUSE */
case 180:
return SDL_SCANCODE_MAIL; /* VK_LAUNCH_MAIL */
case 181:
return SDL_SCANCODE_MEDIASELECT; /* VK_LAUNCH_MEDIA_SELECT */
// case 182: return ; /* VK_LAUNCH_APP1 */
case 183:
return SDL_SCANCODE_CALCULATOR; /* VK_LAUNCH_APP2 */
// case 184: return ; /* ... reserved ... */
// case 185: return ; /* ... reserved ... */
case 186:
return SDL_SCANCODE_SEMICOLON; /* VK_OEM_1, ';:' key on US standard keyboards */
case 187:
return SDL_SCANCODE_EQUALS; /* VK_OEM_PLUS */
case 188:
return SDL_SCANCODE_COMMA; /* VK_OEM_COMMA */
case 189:
return SDL_SCANCODE_MINUS; /* VK_OEM_MINUS */
case 190:
return SDL_SCANCODE_PERIOD; /* VK_OEM_PERIOD */
case 191:
return SDL_SCANCODE_SLASH; /* VK_OEM_2, '/?' key on US standard keyboards */
case 192:
return SDL_SCANCODE_GRAVE; /* VK_OEM_3, '`~' key on US standard keyboards */
// ?
// ... reserved or unassigned ...
// ?
case 219:
return SDL_SCANCODE_LEFTBRACKET; /* VK_OEM_4, '[{' key on US standard keyboards */
case 220:
return SDL_SCANCODE_BACKSLASH; /* VK_OEM_5, '\|' key on US standard keyboards */
case 221:
return SDL_SCANCODE_RIGHTBRACKET; /* VK_OEM_6, ']}' key on US standard keyboards */
case 222:
return SDL_SCANCODE_APOSTROPHE; /* VK_OEM_7, 'single/double quote' on US standard keyboards */
default:
break;
}
return SDL_SCANCODE_UNKNOWN;
}
static SDL_Scancode
WINRT_TranslateKeycode(int keycode, unsigned int nativeScancode)
static SDL_Scancode WINRT_TranslateKeycode(int keycode, unsigned int nativeScancode)
{
// TODO, WinRT: try filling out the WinRT keycode table as much as possible, using the Win32 table for interpretation hints
@ -271,21 +288,21 @@ WINRT_TranslateKeycode(int keycode, unsigned int nativeScancode)
*/
if (nativeScancode < SDL_arraysize(windows_scancode_table)) {
switch (keycode) {
case 16: // VirtualKey.Shift
switch (windows_scancode_table[nativeScancode]) {
case SDL_SCANCODE_LSHIFT:
case SDL_SCANCODE_RSHIFT:
return windows_scancode_table[nativeScancode];
}
break;
case 16: // VirtualKey.Shift
switch (windows_scancode_table[nativeScancode]) {
case SDL_SCANCODE_LSHIFT:
case SDL_SCANCODE_RSHIFT:
return windows_scancode_table[nativeScancode];
}
break;
// Add others, as necessary.
//
// Unfortunately, this hack doesn't seem to work in determining
// handedness with Control keys.
default:
break;
default:
break;
}
}
@ -313,8 +330,7 @@ WINRT_TranslateKeycode(int keycode, unsigned int nativeScancode)
return scancode;
}
void
WINRT_ProcessKeyDownEvent(Windows::UI::Core::KeyEventArgs ^args)
void WINRT_ProcessKeyDownEvent(Windows::UI::Core::KeyEventArgs ^ args)
{
SDL_Scancode sdlScancode = WINRT_TranslateKeycode((int)args->VirtualKey, args->KeyStatus.ScanCode);
#if 0
@ -339,8 +355,7 @@ WINRT_ProcessKeyDownEvent(Windows::UI::Core::KeyEventArgs ^args)
SDL_SendKeyboardKey(SDL_PRESSED, sdlScancode);
}
void
WINRT_ProcessKeyUpEvent(Windows::UI::Core::KeyEventArgs ^args)
void WINRT_ProcessKeyUpEvent(Windows::UI::Core::KeyEventArgs ^ args)
{
SDL_Scancode sdlScancode = WINRT_TranslateKeycode((int)args->VirtualKey, args->KeyStatus.ScanCode);
#if 0
@ -365,8 +380,7 @@ WINRT_ProcessKeyUpEvent(Windows::UI::Core::KeyEventArgs ^args)
SDL_SendKeyboardKey(SDL_RELEASED, sdlScancode);
}
void
WINRT_ProcessCharacterReceivedEvent(Windows::UI::Core::CharacterReceivedEventArgs ^args)
void WINRT_ProcessCharacterReceivedEvent(Windows::UI::Core::CharacterReceivedEventArgs ^ args)
{
wchar_t src_ucs2[2];
char dest_utf8[16];
@ -383,9 +397,32 @@ WINRT_ProcessCharacterReceivedEvent(Windows::UI::Core::CharacterReceivedEventArg
}
}
#if NTDDI_VERSION >= NTDDI_WIN10
static bool WINRT_InputPaneVisible = false;
void WINTRT_OnInputPaneShowing(Windows::UI::ViewManagement::InputPane ^ sender, Windows::UI::ViewManagement::InputPaneVisibilityEventArgs ^ args)
{
WINRT_InputPaneVisible = true;
}
void WINTRT_OnInputPaneHiding(Windows::UI::ViewManagement::InputPane ^ sender, Windows::UI::ViewManagement::InputPaneVisibilityEventArgs ^ args)
{
WINRT_InputPaneVisible = false;
}
void WINTRT_InitialiseInputPaneEvents(_THIS)
{
using namespace Windows::UI::ViewManagement;
InputPane ^ inputPane = InputPane::GetForCurrentView();
if (inputPane) {
inputPane->Showing += ref new Windows::Foundation::TypedEventHandler<Windows::UI::ViewManagement::InputPane ^,
Windows::UI::ViewManagement::InputPaneVisibilityEventArgs ^>(&WINTRT_OnInputPaneShowing);
inputPane->Hiding += ref new Windows::Foundation::TypedEventHandler<Windows::UI::ViewManagement::InputPane ^,
Windows::UI::ViewManagement::InputPaneVisibilityEventArgs ^>(&WINTRT_OnInputPaneHiding);
}
}
SDL_bool WINRT_HasScreenKeyboardSupport(_THIS)
{
return SDL_TRUE;
@ -414,17 +451,29 @@ SDL_bool WINRT_IsScreenKeyboardShown(_THIS, SDL_Window *window)
using namespace Windows::UI::ViewManagement;
InputPane ^ inputPane = InputPane::GetForCurrentView();
if (inputPane) {
// dludwig@pobox.com: checking inputPane->Visible doesn't seem to detect visibility,
// at least not on the Windows Phone 10.0.10240.0 emulator. Checking
// the size of inputPane->OccludedRect, however, does seem to work.
Windows::Foundation::Rect rect = inputPane->OccludedRect;
if (rect.Width > 0 && rect.Height > 0) {
return SDL_TRUE;
switch (SDL_WinRTGetDeviceFamily()) {
case SDL_WINRT_DEVICEFAMILY_XBOX:
// Documentation recommends using inputPane->Visible
// https://learn.microsoft.com/en-us/uwp/api/windows.ui.viewmanagement.inputpane.visible?view=winrt-22621
// This does not seem to work on latest UWP/Xbox.
// Workaround: Listen to Showing/Hiding events
if (WINRT_InputPaneVisible) {
return SDL_TRUE;
}
break;
default:
// OccludedRect is recommend on universal apps per docs
// https://learn.microsoft.com/en-us/uwp/api/windows.ui.viewmanagement.inputpane.visible?view=winrt-22621
Windows::Foundation::Rect rect = inputPane->OccludedRect;
if (rect.Width > 0 && rect.Height > 0) {
return SDL_TRUE;
}
break;
}
}
return SDL_FALSE;
}
#endif // NTDDI_VERSION >= ...
#endif // NTDDI_VERSION >= ...
#endif // SDL_VIDEO_DRIVER_WINRT

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -34,23 +34,20 @@ using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::UI::Popups;
static String ^
WINRT_UTF8ToPlatformString(const char * str)
{
wchar_t * wstr = WIN_UTF8ToString(str);
static String ^ WINRT_UTF8ToPlatformString(const char *str) {
wchar_t *wstr = WIN_UTF8ToString(str);
String ^ rtstr = ref new String(wstr);
SDL_free(wstr);
return rtstr;
}
extern "C" int
WINRT_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
extern "C" int WINRT_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
{
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) && (NTDDI_VERSION == NTDDI_WIN8)
/* Sadly, Windows Phone 8 doesn't include the MessageDialog class that
* Windows 8.x/RT does, even though MSDN's reference documentation for
* Windows Phone 8 mentions it.
*
*
* The .NET runtime on Windows Phone 8 does, however, include a
* MessageBox class. Perhaps this could be called, somehow?
*/
@ -60,15 +57,15 @@ WINRT_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
const int maxbuttons = 2;
const char * platform = "Windows Phone 8.1+";
const char *platform = "Windows Phone 8.1+";
#else
const int maxbuttons = 3;
const char * platform = "Windows 8.x";
const char *platform = "Windows 8.x";
#endif
if (messageboxdata->numbuttons > maxbuttons) {
return SDL_SetError("WinRT's MessageDialog only supports %d buttons, at most, on %s. %d were requested.",
maxbuttons, platform, messageboxdata->numbuttons);
maxbuttons, platform, messageboxdata->numbuttons);
}
/* Build a MessageDialog object and its buttons */
@ -115,4 +112,3 @@ WINRT_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
#endif /* SDL_VIDEO_DRIVER_WINRT */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -44,45 +44,65 @@ extern "C" {
#include "SDL_winrtvideo_cpp.h"
#include "SDL_winrtmouse_c.h"
extern "C" SDL_bool WINRT_UsingRelativeMouseMode = SDL_FALSE;
static SDL_Cursor *
WINRT_CreateSystemCursor(SDL_SystemCursor id)
static SDL_Cursor *WINRT_CreateSystemCursor(SDL_SystemCursor id)
{
SDL_Cursor *cursor;
CoreCursorType cursorType = CoreCursorType::Arrow;
switch(id)
{
switch (id) {
default:
SDL_assert(0);
return NULL;
case SDL_SYSTEM_CURSOR_ARROW: cursorType = CoreCursorType::Arrow; break;
case SDL_SYSTEM_CURSOR_IBEAM: cursorType = CoreCursorType::IBeam; break;
case SDL_SYSTEM_CURSOR_WAIT: cursorType = CoreCursorType::Wait; break;
case SDL_SYSTEM_CURSOR_CROSSHAIR: cursorType = CoreCursorType::Cross; break;
case SDL_SYSTEM_CURSOR_WAITARROW: cursorType = CoreCursorType::Wait; break;
case SDL_SYSTEM_CURSOR_SIZENWSE: cursorType = CoreCursorType::SizeNorthwestSoutheast; break;
case SDL_SYSTEM_CURSOR_SIZENESW: cursorType = CoreCursorType::SizeNortheastSouthwest; break;
case SDL_SYSTEM_CURSOR_SIZEWE: cursorType = CoreCursorType::SizeWestEast; break;
case SDL_SYSTEM_CURSOR_SIZENS: cursorType = CoreCursorType::SizeNorthSouth; break;
case SDL_SYSTEM_CURSOR_SIZEALL: cursorType = CoreCursorType::SizeAll; break;
case SDL_SYSTEM_CURSOR_NO: cursorType = CoreCursorType::UniversalNo; break;
case SDL_SYSTEM_CURSOR_HAND: cursorType = CoreCursorType::Hand; break;
case SDL_SYSTEM_CURSOR_ARROW:
cursorType = CoreCursorType::Arrow;
break;
case SDL_SYSTEM_CURSOR_IBEAM:
cursorType = CoreCursorType::IBeam;
break;
case SDL_SYSTEM_CURSOR_WAIT:
cursorType = CoreCursorType::Wait;
break;
case SDL_SYSTEM_CURSOR_CROSSHAIR:
cursorType = CoreCursorType::Cross;
break;
case SDL_SYSTEM_CURSOR_WAITARROW:
cursorType = CoreCursorType::Wait;
break;
case SDL_SYSTEM_CURSOR_SIZENWSE:
cursorType = CoreCursorType::SizeNorthwestSoutheast;
break;
case SDL_SYSTEM_CURSOR_SIZENESW:
cursorType = CoreCursorType::SizeNortheastSouthwest;
break;
case SDL_SYSTEM_CURSOR_SIZEWE:
cursorType = CoreCursorType::SizeWestEast;
break;
case SDL_SYSTEM_CURSOR_SIZENS:
cursorType = CoreCursorType::SizeNorthSouth;
break;
case SDL_SYSTEM_CURSOR_SIZEALL:
cursorType = CoreCursorType::SizeAll;
break;
case SDL_SYSTEM_CURSOR_NO:
cursorType = CoreCursorType::UniversalNo;
break;
case SDL_SYSTEM_CURSOR_HAND:
cursorType = CoreCursorType::Hand;
break;
}
cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor));
cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor));
if (cursor) {
/* Create a pointer to a COM reference to a cursor. The extra
pointer is used (on top of the COM reference) to allow the cursor
to be referenced by the SDL_cursor's driverdata field, which is
a void pointer.
*/
CoreCursor ^* theCursor = new CoreCursor^(nullptr);
CoreCursor ^ *theCursor = new CoreCursor ^ (nullptr);
*theCursor = ref new CoreCursor(cursorType, 0);
cursor->driverdata = (void *) theCursor;
cursor->driverdata = (void *)theCursor;
} else {
SDL_OutOfMemory();
}
@ -90,34 +110,31 @@ WINRT_CreateSystemCursor(SDL_SystemCursor id)
return cursor;
}
static SDL_Cursor *
WINRT_CreateDefaultCursor()
static SDL_Cursor *WINRT_CreateDefaultCursor()
{
return WINRT_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
}
static void
WINRT_FreeCursor(SDL_Cursor * cursor)
static void WINRT_FreeCursor(SDL_Cursor *cursor)
{
if (cursor->driverdata) {
CoreCursor ^* theCursor = (CoreCursor ^*) cursor->driverdata;
*theCursor = nullptr; // Release the COM reference to the CoreCursor
delete theCursor; // Delete the pointer to the COM reference
CoreCursor ^ *theCursor = (CoreCursor ^ *)cursor->driverdata;
*theCursor = nullptr; // Release the COM reference to the CoreCursor
delete theCursor; // Delete the pointer to the COM reference
}
SDL_free(cursor);
}
static int
WINRT_ShowCursor(SDL_Cursor * cursor)
static int WINRT_ShowCursor(SDL_Cursor *cursor)
{
// TODO, WinRT, XAML: make WINRT_ShowCursor work when XAML support is enabled.
if ( ! CoreWindow::GetForCurrentThread()) {
if (!CoreWindow::GetForCurrentThread()) {
return 0;
}
CoreWindow ^ coreWindow = CoreWindow::GetForCurrentThread();
if (cursor) {
CoreCursor ^* theCursor = (CoreCursor ^*) cursor->driverdata;
CoreCursor ^ *theCursor = (CoreCursor ^ *)cursor->driverdata;
coreWindow->PointerCursor = *theCursor;
} else {
// HACK ALERT: TL;DR - Hiding the cursor in WinRT/UWP apps is weird, and
@ -164,13 +181,13 @@ WINRT_ShowCursor(SDL_Cursor * cursor)
// - src/main/winrt/SDL2-WinRTResources.rc -- declares the cursor resource, and its ID (of 5000)
//
const unsigned int win32CursorResourceID = 5000;
const unsigned int win32CursorResourceID = 5000;
CoreCursor ^ blankCursor = ref new CoreCursor(CoreCursorType::Custom, win32CursorResourceID);
// Set 'PointerCursor' to 'blankCursor' in a way that shouldn't throw
// an exception if the app hasn't loaded that resource.
ABI::Windows::UI::Core::ICoreCursor * iblankCursor = reinterpret_cast<ABI::Windows::UI::Core::ICoreCursor *>(blankCursor);
ABI::Windows::UI::Core::ICoreWindow * icoreWindow = reinterpret_cast<ABI::Windows::UI::Core::ICoreWindow *>(coreWindow);
ABI::Windows::UI::Core::ICoreCursor *iblankCursor = reinterpret_cast<ABI::Windows::UI::Core::ICoreCursor *>(blankCursor);
ABI::Windows::UI::Core::ICoreWindow *icoreWindow = reinterpret_cast<ABI::Windows::UI::Core::ICoreWindow *>(coreWindow);
HRESULT hr = icoreWindow->put_PointerCursor(iblankCursor);
if (FAILED(hr)) {
// The app doesn't contain the cursor resource, or some other error
@ -182,15 +199,13 @@ WINRT_ShowCursor(SDL_Cursor * cursor)
return 0;
}
static int
WINRT_SetRelativeMouseMode(SDL_bool enabled)
static int WINRT_SetRelativeMouseMode(SDL_bool enabled)
{
WINRT_UsingRelativeMouseMode = enabled;
return 0;
}
void
WINRT_InitMouse(_THIS)
void WINRT_InitMouse(_THIS)
{
SDL_Mouse *mouse = SDL_GetMouse();
@ -201,19 +216,18 @@ WINRT_InitMouse(_THIS)
*/
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
//mouse->CreateCursor = WINRT_CreateCursor;
// mouse->CreateCursor = WINRT_CreateCursor;
mouse->CreateSystemCursor = WINRT_CreateSystemCursor;
mouse->ShowCursor = WINRT_ShowCursor;
mouse->FreeCursor = WINRT_FreeCursor;
//mouse->WarpMouse = WINRT_WarpMouse;
// mouse->WarpMouse = WINRT_WarpMouse;
mouse->SetRelativeMouseMode = WINRT_SetRelativeMouseMode;
SDL_SetDefaultCursor(WINRT_CreateDefaultCursor());
#endif
}
void
WINRT_QuitMouse(_THIS)
void WINRT_QuitMouse(_THIS)
{
}

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -37,17 +37,16 @@ using namespace Windows::UI::Core;
/* ANGLE/WinRT constants */
static const int ANGLE_D3D_FEATURE_LEVEL_ANY = 0;
#define EGL_PLATFORM_ANGLE_ANGLE 0x3202
#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203
#define EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE 0x3204
#define EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE 0x3205
#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208
#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE 0x3209
#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE 0x320B
#define EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE 0x320F
#define EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER 0x320B
#define EGL_PLATFORM_ANGLE_ANGLE 0x3202
#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203
#define EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE 0x3204
#define EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE 0x3205
#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208
#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE 0x3209
#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE 0x320B
#define EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE 0x320F
#define EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER 0x320B
/*
* SDL/EGL top-level implementation
@ -63,7 +62,7 @@ WINRT_GLES_LoadLibrary(_THIS, const char *path)
}
/* Load ANGLE/WinRT-specific functions */
CreateWinrtEglWindow_Old_Function CreateWinrtEglWindow = (CreateWinrtEglWindow_Old_Function) SDL_LoadFunction(_this->egl_data->egl_dll_handle, "CreateWinrtEglWindow");
CreateWinrtEglWindow_Old_Function CreateWinrtEglWindow = (CreateWinrtEglWindow_Old_Function)SDL_LoadFunction(_this->egl_data->opengl_dll_handle, "CreateWinrtEglWindow");
if (CreateWinrtEglWindow) {
/* 'CreateWinrtEglWindow' was found, which means that an an older
* version of ANGLE/WinRT is being used. Continue setting up EGL,
@ -98,30 +97,39 @@ WINRT_GLES_LoadLibrary(_THIS, const char *path)
/* Declare some ANGLE/EGL initialization property-sets, as suggested by
* MSOpenTech's ANGLE-for-WinRT template apps:
*/
const EGLint defaultDisplayAttributes[] =
{
EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE,
EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE,
const EGLint defaultDisplayAttributes[] = {
EGL_PLATFORM_ANGLE_TYPE_ANGLE,
EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER,
EGL_TRUE,
EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE,
EGL_TRUE,
EGL_NONE,
};
const EGLint fl9_3DisplayAttributes[] =
{
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,
const EGLint fl9_3DisplayAttributes[] = {
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[] =
{
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,
const EGLint warpDisplayAttributes[] = {
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,
};
@ -193,11 +201,10 @@ WINRT_GLES_UnloadLibrary(_THIS)
extern "C" {
SDL_EGL_CreateContext_impl(WINRT)
SDL_EGL_SwapWindow_impl(WINRT)
SDL_EGL_MakeCurrent_impl(WINRT)
SDL_EGL_SwapWindow_impl(WINRT)
SDL_EGL_MakeCurrent_impl(WINRT)
}
#endif /* SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -33,14 +33,13 @@
#define WINRT_GLES_GetProcAddress SDL_EGL_GetProcAddress
#define WINRT_GLES_SetSwapInterval SDL_EGL_SetSwapInterval
#define WINRT_GLES_GetSwapInterval SDL_EGL_GetSwapInterval
#define WINRT_GLES_DeleteContext SDL_EGL_DeleteContext
#define WINRT_GLES_DeleteContext SDL_EGL_DeleteContext
extern int WINRT_GLES_LoadLibrary(_THIS, const char *path);
extern void WINRT_GLES_UnloadLibrary(_THIS);
extern SDL_GLContext WINRT_GLES_CreateContext(_THIS, SDL_Window * window);
extern int WINRT_GLES_SwapWindow(_THIS, SDL_Window * window);
extern int WINRT_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
extern SDL_GLContext WINRT_GLES_CreateContext(_THIS, SDL_Window *window);
extern int WINRT_GLES_SwapWindow(_THIS, SDL_Window *window);
extern int WINRT_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context);
#ifdef __cplusplus
@ -52,16 +51,16 @@ typedef Microsoft::WRL::ComPtr<IUnknown> WINRT_EGLNativeWindowType_Old;
/* Function pointer typedefs for 'old' ANGLE/WinRT's functions, which may
* require that C++ objects be passed in:
*/
typedef EGLDisplay (EGLAPIENTRY *eglGetDisplay_Old_Function)(WINRT_EGLNativeWindowType_Old);
typedef EGLSurface (EGLAPIENTRY *eglCreateWindowSurface_Old_Function)(EGLDisplay, EGLConfig, WINRT_EGLNativeWindowType_Old, const EGLint *);
typedef HRESULT (EGLAPIENTRY *CreateWinrtEglWindow_Old_Function)(Microsoft::WRL::ComPtr<IUnknown>, int, IUnknown ** result);
typedef EGLDisplay(EGLAPIENTRY *eglGetDisplay_Old_Function)(WINRT_EGLNativeWindowType_Old);
typedef EGLSurface(EGLAPIENTRY *eglCreateWindowSurface_Old_Function)(EGLDisplay, EGLConfig, WINRT_EGLNativeWindowType_Old, const EGLint *);
typedef HRESULT(EGLAPIENTRY *CreateWinrtEglWindow_Old_Function)(Microsoft::WRL::ComPtr<IUnknown>, int, IUnknown **result);
#endif /* __cplusplus */
/* Function pointer typedefs for 'new' ANGLE/WinRT functions, which, unlike
* the old functions, do not require C++ support and work with plain C.
*/
typedef EGLDisplay (EGLAPIENTRY *eglGetPlatformDisplayEXT_Function)(EGLenum, void *, const EGLint *);
typedef EGLDisplay(EGLAPIENTRY *eglGetPlatformDisplayEXT_Function)(EGLenum, void *, const EGLint *);
#endif /* SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL */

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -38,19 +38,16 @@ extern "C" {
/* File-specific globals: */
static SDL_TouchID WINRT_TouchID = 1;
void
WINRT_InitTouch(_THIS)
void WINRT_InitTouch(_THIS)
{
SDL_AddTouch(WINRT_TouchID, SDL_TOUCH_DEVICE_DIRECT, "");
}
//
// Applies necessary geometric transformations to raw cursor positions:
//
Windows::Foundation::Point
WINRT_TransformCursorPosition(SDL_Window * window,
WINRT_TransformCursorPosition(SDL_Window *window,
Windows::Foundation::Point rawPosition,
WINRT_CursorNormalizationType normalization)
{
@ -61,7 +58,7 @@ WINRT_TransformCursorPosition(SDL_Window * window,
return rawPosition;
}
SDL_WindowData * windowData = (SDL_WindowData *) window->driverdata;
SDL_WindowData *windowData = (SDL_WindowData *)window->driverdata;
if (windowData->coreWindow == nullptr) {
// For some reason, the window isn't associated with a CoreWindow.
// This might end up being the case as XAML support is extended.
@ -85,39 +82,37 @@ WINRT_TransformCursorPosition(SDL_Window * window,
outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width;
outputPosition.Y = rawPosition.Y / nativeWindow->Bounds.Height;
#else
switch (WINRT_DISPLAY_PROPERTY(CurrentOrientation))
{
case DisplayOrientations::Portrait:
outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width;
outputPosition.Y = rawPosition.Y / nativeWindow->Bounds.Height;
break;
case DisplayOrientations::PortraitFlipped:
outputPosition.X = 1.0f - (rawPosition.X / nativeWindow->Bounds.Width);
outputPosition.Y = 1.0f - (rawPosition.Y / nativeWindow->Bounds.Height);
break;
case DisplayOrientations::Landscape:
outputPosition.X = rawPosition.Y / nativeWindow->Bounds.Height;
outputPosition.Y = 1.0f - (rawPosition.X / nativeWindow->Bounds.Width);
break;
case DisplayOrientations::LandscapeFlipped:
outputPosition.X = 1.0f - (rawPosition.Y / nativeWindow->Bounds.Height);
outputPosition.Y = rawPosition.X / nativeWindow->Bounds.Width;
break;
default:
break;
switch (WINRT_DISPLAY_PROPERTY(CurrentOrientation)) {
case DisplayOrientations::Portrait:
outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width;
outputPosition.Y = rawPosition.Y / nativeWindow->Bounds.Height;
break;
case DisplayOrientations::PortraitFlipped:
outputPosition.X = 1.0f - (rawPosition.X / nativeWindow->Bounds.Width);
outputPosition.Y = 1.0f - (rawPosition.Y / nativeWindow->Bounds.Height);
break;
case DisplayOrientations::Landscape:
outputPosition.X = rawPosition.Y / nativeWindow->Bounds.Height;
outputPosition.Y = 1.0f - (rawPosition.X / nativeWindow->Bounds.Width);
break;
case DisplayOrientations::LandscapeFlipped:
outputPosition.X = 1.0f - (rawPosition.Y / nativeWindow->Bounds.Height);
outputPosition.Y = rawPosition.X / nativeWindow->Bounds.Width;
break;
default:
break;
}
#endif
if (normalization == TransformToSDLWindowSize) {
outputPosition.X *= ((float32) window->w);
outputPosition.Y *= ((float32) window->h);
outputPosition.X *= ((float32)window->w);
outputPosition.Y *= ((float32)window->h);
}
return outputPosition;
}
SDL_bool
WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt, Uint8 *button, Uint8 *pressed)
SDL_bool WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^ pt, Uint8 *button, Uint8 *pressed)
{
using namespace Windows::UI::Input;
@ -125,40 +120,39 @@ WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt, Uint8 *b
*button = SDL_BUTTON_LEFT;
return SDL_TRUE;
#else
switch (pt->Properties->PointerUpdateKind)
{
case PointerUpdateKind::LeftButtonPressed:
case PointerUpdateKind::LeftButtonReleased:
*button = SDL_BUTTON_LEFT;
*pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::LeftButtonPressed);
return SDL_TRUE;
switch (pt->Properties->PointerUpdateKind) {
case PointerUpdateKind::LeftButtonPressed:
case PointerUpdateKind::LeftButtonReleased:
*button = SDL_BUTTON_LEFT;
*pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::LeftButtonPressed);
return SDL_TRUE;
case PointerUpdateKind::RightButtonPressed:
case PointerUpdateKind::RightButtonReleased:
*button = SDL_BUTTON_RIGHT;
*pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::RightButtonPressed);
return SDL_TRUE;
case PointerUpdateKind::RightButtonPressed:
case PointerUpdateKind::RightButtonReleased:
*button = SDL_BUTTON_RIGHT;
*pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::RightButtonPressed);
return SDL_TRUE;
case PointerUpdateKind::MiddleButtonPressed:
case PointerUpdateKind::MiddleButtonReleased:
*button = SDL_BUTTON_MIDDLE;
*pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::MiddleButtonPressed);
return SDL_TRUE;
case PointerUpdateKind::MiddleButtonPressed:
case PointerUpdateKind::MiddleButtonReleased:
*button = SDL_BUTTON_MIDDLE;
*pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::MiddleButtonPressed);
return SDL_TRUE;
case PointerUpdateKind::XButton1Pressed:
case PointerUpdateKind::XButton1Released:
*button = SDL_BUTTON_X1;
*pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::XButton1Pressed);
return SDL_TRUE;
case PointerUpdateKind::XButton1Pressed:
case PointerUpdateKind::XButton1Released:
*button = SDL_BUTTON_X1;
*pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::XButton1Pressed);
return SDL_TRUE;
case PointerUpdateKind::XButton2Pressed:
case PointerUpdateKind::XButton2Released:
*button = SDL_BUTTON_X2;
*pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::XButton2Pressed);
return SDL_TRUE;
case PointerUpdateKind::XButton2Pressed:
case PointerUpdateKind::XButton2Released:
*button = SDL_BUTTON_X2;
*pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::XButton2Pressed);
return SDL_TRUE;
default:
break;
default:
break;
}
#endif
@ -167,64 +161,63 @@ WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt, Uint8 *b
return SDL_FALSE;
}
//const char *
//WINRT_ConvertPointerUpdateKindToString(Windows::UI::Input::PointerUpdateKind kind)
// const char *
// WINRT_ConvertPointerUpdateKindToString(Windows::UI::Input::PointerUpdateKind kind)
//{
// using namespace Windows::UI::Input;
// using namespace Windows::UI::Input;
//
// switch (kind)
// {
// case PointerUpdateKind::Other:
// return "Other";
// case PointerUpdateKind::LeftButtonPressed:
// return "LeftButtonPressed";
// case PointerUpdateKind::LeftButtonReleased:
// return "LeftButtonReleased";
// case PointerUpdateKind::RightButtonPressed:
// return "RightButtonPressed";
// case PointerUpdateKind::RightButtonReleased:
// return "RightButtonReleased";
// case PointerUpdateKind::MiddleButtonPressed:
// return "MiddleButtonPressed";
// case PointerUpdateKind::MiddleButtonReleased:
// return "MiddleButtonReleased";
// case PointerUpdateKind::XButton1Pressed:
// return "XButton1Pressed";
// case PointerUpdateKind::XButton1Released:
// return "XButton1Released";
// case PointerUpdateKind::XButton2Pressed:
// return "XButton2Pressed";
// case PointerUpdateKind::XButton2Released:
// return "XButton2Released";
// }
// switch (kind)
// {
// case PointerUpdateKind::Other:
// return "Other";
// case PointerUpdateKind::LeftButtonPressed:
// return "LeftButtonPressed";
// case PointerUpdateKind::LeftButtonReleased:
// return "LeftButtonReleased";
// case PointerUpdateKind::RightButtonPressed:
// return "RightButtonPressed";
// case PointerUpdateKind::RightButtonReleased:
// return "RightButtonReleased";
// case PointerUpdateKind::MiddleButtonPressed:
// return "MiddleButtonPressed";
// case PointerUpdateKind::MiddleButtonReleased:
// return "MiddleButtonReleased";
// case PointerUpdateKind::XButton1Pressed:
// return "XButton1Pressed";
// case PointerUpdateKind::XButton1Released:
// return "XButton1Released";
// case PointerUpdateKind::XButton2Pressed:
// return "XButton2Pressed";
// case PointerUpdateKind::XButton2Released:
// return "XButton2Released";
// }
//
// return "";
//}
// return "";
// }
static bool
WINRT_IsTouchEvent(Windows::UI::Input::PointerPoint ^pointerPoint)
static bool WINRT_IsTouchEvent(Windows::UI::Input::PointerPoint ^ pointerPoint)
{
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
return true;
#else
using namespace Windows::Devices::Input;
switch (pointerPoint->PointerDevice->PointerDeviceType) {
case PointerDeviceType::Touch:
case PointerDeviceType::Pen:
return true;
default:
return false;
case PointerDeviceType::Touch:
case PointerDeviceType::Pen:
return true;
default:
return false;
}
#endif
}
void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint)
{
if (!window) {
return;
}
if ( ! WINRT_IsTouchEvent(pointerPoint)) {
if (!WINRT_IsTouchEvent(pointerPoint)) {
Uint8 button, pressed;
WINRT_GetSDLButtonForPointerPoint(pointerPoint, &button, &pressed);
SDL_assert(pressed == 1);
@ -235,7 +228,7 @@ void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::Po
SDL_SendTouch(
WINRT_TouchID,
(SDL_FingerID) pointerPoint->PointerId,
(SDL_FingerID)pointerPoint->PointerId,
window,
SDL_TRUE,
normalizedPoint.X,
@ -244,8 +237,7 @@ void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::Po
}
}
void
WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
void WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint)
{
if (!window || WINRT_UsingRelativeMouseMode) {
return;
@ -254,7 +246,7 @@ WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPo
Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne);
Windows::Foundation::Point windowPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, TransformToSDLWindowSize);
if ( ! WINRT_IsTouchEvent(pointerPoint)) {
if (!WINRT_IsTouchEvent(pointerPoint)) {
/* For some odd reason Moved events are used for multiple mouse buttons */
Uint8 button, pressed;
if (WINRT_GetSDLButtonForPointerPoint(pointerPoint, &button, &pressed)) {
@ -265,7 +257,7 @@ WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPo
} else {
SDL_SendTouchMotion(
WINRT_TouchID,
(SDL_FingerID) pointerPoint->PointerId,
(SDL_FingerID)pointerPoint->PointerId,
window,
normalizedPoint.X,
normalizedPoint.Y,
@ -273,7 +265,7 @@ WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPo
}
}
void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint)
{
if (!window) {
return;
@ -289,7 +281,7 @@ void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::P
SDL_SendTouch(
WINRT_TouchID,
(SDL_FingerID) pointerPoint->PointerId,
(SDL_FingerID)pointerPoint->PointerId,
window,
SDL_FALSE,
normalizedPoint.X,
@ -298,7 +290,7 @@ void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::P
}
}
void WINRT_ProcessPointerEnteredEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
void WINRT_ProcessPointerEnteredEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint)
{
if (!window) {
return;
@ -309,7 +301,7 @@ void WINRT_ProcessPointerEnteredEvent(SDL_Window *window, Windows::UI::Input::Po
}
}
void WINRT_ProcessPointerExitedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
void WINRT_ProcessPointerExitedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint)
{
if (!window) {
return;
@ -320,19 +312,17 @@ void WINRT_ProcessPointerExitedEvent(SDL_Window *window, Windows::UI::Input::Poi
}
}
void
WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
void WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint)
{
if (!window) {
return;
}
float motion = (float) pointerPoint->Properties->MouseWheelDelta / WHEEL_DELTA;
SDL_SendMouseWheel(window, 0, 0, (float) motion, SDL_MOUSEWHEEL_NORMAL);
float motion = (float)pointerPoint->Properties->MouseWheelDelta / WHEEL_DELTA;
SDL_SendMouseWheel(window, 0, 0, (float)motion, SDL_MOUSEWHEEL_NORMAL);
}
void
WINRT_ProcessMouseMovedEvent(SDL_Window * window, Windows::Devices::Input::MouseEventArgs ^args)
void WINRT_ProcessMouseMovedEvent(SDL_Window *window, Windows::Devices::Input::MouseEventArgs ^ args)
{
if (!window || !WINRT_UsingRelativeMouseMode) {
return;

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -46,11 +46,9 @@ using namespace Windows::Graphics::Display;
using namespace Windows::UI::Core;
using namespace Windows::UI::ViewManagement;
/* [re]declare Windows GUIDs locally, to limit the amount of external lib(s) SDL has to link to */
static const GUID SDL_IID_IDisplayRequest = { 0xe5732044, 0xf49f, 0x4b60, { 0x8d, 0xd4, 0x5e, 0x7e, 0x3a, 0x63, 0x2a, 0xc0 } };
static const GUID SDL_IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } };
static const GUID SDL_IID_IDisplayRequest = { 0xe5732044, 0xf49f, 0x4b60, { 0x8d, 0xd4, 0x5e, 0x7e, 0x3a, 0x63, 0x2a, 0xc0 } };
static const GUID SDL_IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } };
/* SDL includes */
extern "C" {
@ -75,14 +73,12 @@ extern "C" {
#include "SDL_system.h"
#include "SDL_hints.h"
/* Initialization/Query functions */
static int WINRT_VideoInit(_THIS);
static int WINRT_InitModes(_THIS);
static int WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
static int WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode);
static void WINRT_VideoQuit(_THIS);
/* Window functions */
static int WINRT_CreateWindow(_THIS, SDL_Window * window);
static void WINRT_SetWindowSize(_THIS, SDL_Window * window);
@ -92,21 +88,18 @@ static SDL_bool WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo
/* Misc functions */
static ABI::Windows::System::Display::IDisplayRequest * WINRT_CreateDisplayRequest(_THIS);
static ABI::Windows::System::Display::IDisplayRequest *WINRT_CreateDisplayRequest(_THIS);
extern void WINRT_SuspendScreenSaver(_THIS);
/* SDL-internal globals: */
SDL_Window * WINRT_GlobalSDLWindow = NULL;
SDL_Window *WINRT_GlobalSDLWindow = NULL;
/* WinRT driver bootstrap functions */
static void
WINRT_DeleteDevice(SDL_VideoDevice * device)
static void WINRT_DeleteDevice(SDL_VideoDevice *device)
{
if (device->driverdata) {
SDL_VideoData * video_data = (SDL_VideoData *)device->driverdata;
SDL_VideoData *video_data = (SDL_VideoData *)device->driverdata;
if (video_data->winrtEglWindow) {
video_data->winrtEglWindow->Release();
}
@ -116,24 +109,23 @@ WINRT_DeleteDevice(SDL_VideoDevice * device)
SDL_free(device);
}
static SDL_VideoDevice *
WINRT_CreateDevice(int devindex)
static SDL_VideoDevice *WINRT_CreateDevice(void)
{
SDL_VideoDevice *device;
SDL_VideoData *data;
/* Initialize all variables that we clean on shutdown */
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
if (!device) {
device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice));
if (device == NULL) {
SDL_OutOfMemory();
return (0);
return 0;
}
data = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
if (!data) {
data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData));
if (data == NULL) {
SDL_OutOfMemory();
SDL_free(device);
return (0);
return 0;
}
device->driverdata = data;
@ -154,6 +146,8 @@ WINRT_CreateDevice(int devindex)
device->ShowScreenKeyboard = WINRT_ShowScreenKeyboard;
device->HideScreenKeyboard = WINRT_HideScreenKeyboard;
device->IsScreenKeyboardShown = WINRT_IsScreenKeyboardShown;
WINTRT_InitialiseInputPaneEvents(device);
#endif
#ifdef SDL_VIDEO_OPENGL_EGL
@ -178,8 +172,7 @@ VideoBootStrap WINRT_bootstrap = {
WINRT_CreateDevice
};
static void SDLCALL
WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const char *oldValue, const char *newValue)
static void SDLCALL WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const char *oldValue, const char *newValue)
{
SDL_assert(SDL_strcmp(name, SDL_HINT_ORIENTATIONS) == 0);
@ -202,13 +195,13 @@ WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const c
std::string orientationName;
std::getline(tokenizer, orientationName, ' ');
if (orientationName == "LandscapeLeft") {
orientationFlags |= (unsigned int) DisplayOrientations::LandscapeFlipped;
orientationFlags |= (unsigned int)DisplayOrientations::LandscapeFlipped;
} else if (orientationName == "LandscapeRight") {
orientationFlags |= (unsigned int) DisplayOrientations::Landscape;
orientationFlags |= (unsigned int)DisplayOrientations::Landscape;
} else if (orientationName == "Portrait") {
orientationFlags |= (unsigned int) DisplayOrientations::Portrait;
orientationFlags |= (unsigned int)DisplayOrientations::Portrait;
} else if (orientationName == "PortraitUpsideDown") {
orientationFlags |= (unsigned int) DisplayOrientations::PortraitFlipped;
orientationFlags |= (unsigned int)DisplayOrientations::PortraitFlipped;
}
}
}
@ -216,11 +209,10 @@ WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const c
// If no valid orientation flags were specified, use a reasonable set of defaults:
if (!orientationFlags) {
// TODO, WinRT: consider seeing if an app's default orientation flags can be found out via some API call(s).
orientationFlags = (unsigned int) ( \
DisplayOrientations::Landscape |
DisplayOrientations::LandscapeFlipped |
DisplayOrientations::Portrait |
DisplayOrientations::PortraitFlipped);
orientationFlags = (unsigned int)(DisplayOrientations::Landscape |
DisplayOrientations::LandscapeFlipped |
DisplayOrientations::Portrait |
DisplayOrientations::PortraitFlipped);
}
// Set the orientation/rotation preferences. Please note that this does
@ -237,13 +229,12 @@ WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const c
// for details. Microsoft's "Display orientation sample" also gives an
// outline of how Windows treats device rotation
// (http://code.msdn.microsoft.com/Display-Orientation-Sample-19a58e93).
WINRT_DISPLAY_PROPERTY(AutoRotationPreferences) = (DisplayOrientations) orientationFlags;
WINRT_DISPLAY_PROPERTY(AutoRotationPreferences) = (DisplayOrientations)orientationFlags;
}
int
WINRT_VideoInit(_THIS)
int WINRT_VideoInit(_THIS)
{
SDL_VideoData * driverdata = (SDL_VideoData *) _this->driverdata;
SDL_VideoData *driverdata = (SDL_VideoData *)_this->driverdata;
if (WINRT_InitModes(_this) < 0) {
return -1;
}
@ -262,11 +253,9 @@ WINRT_VideoInit(_THIS)
return 0;
}
extern "C"
Uint32 D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat);
extern "C" Uint32 D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat);
static void
WINRT_DXGIModeToSDLDisplayMode(const DXGI_MODE_DESC * dxgiMode, SDL_DisplayMode * sdlMode)
static void WINRT_DXGIModeToSDLDisplayMode(const DXGI_MODE_DESC *dxgiMode, SDL_DisplayMode *sdlMode)
{
SDL_zerop(sdlMode);
sdlMode->w = dxgiMode->Width;
@ -275,17 +264,16 @@ WINRT_DXGIModeToSDLDisplayMode(const DXGI_MODE_DESC * dxgiMode, SDL_DisplayMode
sdlMode->format = D3D11_DXGIFormatToSDLPixelFormat(dxgiMode->Format);
}
static int
WINRT_AddDisplaysForOutput (_THIS, IDXGIAdapter1 * dxgiAdapter1, int outputIndex)
static int WINRT_AddDisplaysForOutput(_THIS, IDXGIAdapter1 *dxgiAdapter1, int outputIndex)
{
HRESULT hr;
IDXGIOutput * dxgiOutput = NULL;
IDXGIOutput *dxgiOutput = NULL;
DXGI_OUTPUT_DESC dxgiOutputDesc;
SDL_VideoDisplay display;
char * displayName = NULL;
char *displayName = NULL;
UINT numModes;
DXGI_MODE_DESC * dxgiModes = NULL;
int functionResult = -1; /* -1 for failure, 0 for success */
DXGI_MODE_DESC *dxgiModes = NULL;
int functionResult = -1; /* -1 for failure, 0 for success */
DXGI_MODE_DESC modeToMatch, closestMatch;
SDL_zero(display);
@ -324,10 +312,10 @@ WINRT_AddDisplaysForOutput (_THIS, IDXGIAdapter1 * dxgiAdapter1, int outputIndex
mode.w = (dxgiOutputDesc.DesktopCoordinates.right - dxgiOutputDesc.DesktopCoordinates.left);
mode.h = (dxgiOutputDesc.DesktopCoordinates.bottom - dxgiOutputDesc.DesktopCoordinates.top);
mode.format = DXGI_FORMAT_B8G8R8A8_UNORM;
mode.refresh_rate = 0; /* Display mode is unknown, so just fill in zero, as specified by SDL's header files */
mode.refresh_rate = 0; /* Display mode is unknown, so just fill in zero, as specified by SDL's header files */
display.desktop_mode = mode;
display.current_mode = mode;
if ( ! SDL_AddDisplayMode(&display, &mode)) {
if (!SDL_AddDisplayMode(&display, &mode)) {
goto done;
}
} else if (FAILED(hr)) {
@ -349,7 +337,7 @@ WINRT_AddDisplaysForOutput (_THIS, IDXGIAdapter1 * dxgiAdapter1, int outputIndex
}
dxgiModes = (DXGI_MODE_DESC *)SDL_calloc(numModes, sizeof(DXGI_MODE_DESC));
if ( ! dxgiModes) {
if (dxgiModes == NULL) {
SDL_OutOfMemory();
goto done;
}
@ -371,7 +359,7 @@ WINRT_AddDisplaysForOutput (_THIS, IDXGIAdapter1 * dxgiAdapter1, int outputIndex
goto done;
}
functionResult = 0; /* 0 for Success! */
functionResult = 0; /* 0 for Success! */
done:
if (dxgiModes) {
SDL_free(dxgiModes);
@ -385,11 +373,10 @@ done:
return functionResult;
}
static int
WINRT_AddDisplaysForAdapter (_THIS, IDXGIFactory2 * dxgiFactory2, int adapterIndex)
static int WINRT_AddDisplaysForAdapter(_THIS, IDXGIFactory2 *dxgiFactory2, int adapterIndex)
{
HRESULT hr;
IDXGIAdapter1 * dxgiAdapter1;
IDXGIAdapter1 *dxgiAdapter1;
hr = dxgiFactory2->EnumAdapters1(adapterIndex, &dxgiAdapter1);
if (FAILED(hr)) {
@ -399,7 +386,7 @@ WINRT_AddDisplaysForAdapter (_THIS, IDXGIFactory2 * dxgiFactory2, int adapterInd
return -1;
}
for (int outputIndex = 0; ; ++outputIndex) {
for (int outputIndex = 0;; ++outputIndex) {
if (WINRT_AddDisplaysForOutput(_this, dxgiAdapter1, outputIndex) < 0) {
/* HACK: The Windows App Certification Kit 10.0 can fail, when
running the Store Apps' test, "Direct3D Feature Test". The
@ -446,12 +433,11 @@ WINRT_AddDisplaysForAdapter (_THIS, IDXGIFactory2 * dxgiFactory2, int adapterInd
#endif
mode.format = DXGI_FORMAT_B8G8R8A8_UNORM;
mode.refresh_rate = 0; /* Display mode is unknown, so just fill in zero, as specified by SDL's header files */
mode.refresh_rate = 0; /* Display mode is unknown, so just fill in zero, as specified by SDL's header files */
display.desktop_mode = mode;
display.current_mode = mode;
if ((SDL_AddDisplayMode(&display, &mode) < 0) ||
(SDL_AddVideoDisplay(&display, SDL_FALSE) < 0))
{
(SDL_AddVideoDisplay(&display, SDL_FALSE) < 0)) {
return SDL_SetError("Failed to apply DXGI Display-detection workaround");
}
}
@ -464,8 +450,7 @@ WINRT_AddDisplaysForAdapter (_THIS, IDXGIFactory2 * dxgiFactory2, int adapterInd
return 0;
}
int
WINRT_InitModes(_THIS)
int WINRT_InitModes(_THIS)
{
/* HACK: Initialize a single display, for whatever screen the app's
CoreApplicationView is on.
@ -474,14 +459,14 @@ WINRT_InitModes(_THIS)
*/
HRESULT hr;
IDXGIFactory2 * dxgiFactory2 = NULL;
IDXGIFactory2 *dxgiFactory2 = NULL;
hr = CreateDXGIFactory1(SDL_IID_IDXGIFactory2, (void **)&dxgiFactory2);
if (FAILED(hr)) {
return WIN_SetErrorFromHRESULT(__FUNCTION__ ", CreateDXGIFactory1() failed", hr);
}
for (int adapterIndex = 0; ; ++adapterIndex) {
for (int adapterIndex = 0;; ++adapterIndex) {
if (WINRT_AddDisplaysForAdapter(_this, dxgiFactory2, adapterIndex) < 0) {
break;
}
@ -490,16 +475,14 @@ WINRT_InitModes(_THIS)
return 0;
}
static int
WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
static int WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
{
return 0;
}
void
WINRT_VideoQuit(_THIS)
void WINRT_VideoQuit(_THIS)
{
SDL_VideoData * driverdata = (SDL_VideoData *) _this->driverdata;
SDL_VideoData *driverdata = (SDL_VideoData *)_this->driverdata;
if (driverdata && driverdata->displayRequest) {
driverdata->displayRequest->Release();
driverdata->displayRequest = NULL;
@ -508,23 +491,18 @@ WINRT_VideoQuit(_THIS)
WINRT_QuitMouse(_this);
}
static const Uint32 WINRT_DetectableFlags =
SDL_WINDOW_MAXIMIZED |
SDL_WINDOW_FULLSCREEN_DESKTOP |
SDL_WINDOW_SHOWN |
SDL_WINDOW_HIDDEN |
SDL_WINDOW_MOUSE_FOCUS;
static const Uint32 WINRT_DetectableFlags = SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_SHOWN | SDL_WINDOW_HIDDEN | SDL_WINDOW_MOUSE_FOCUS;
extern "C" Uint32
WINRT_DetectWindowFlags(SDL_Window * window)
WINRT_DetectWindowFlags(SDL_Window *window)
{
Uint32 latestFlags = 0;
SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
bool is_fullscreen = false;
#if SDL_WINRT_USE_APPLICATIONVIEW
if (data->appView) {
is_fullscreen = data->appView->IsFullScreen;
is_fullscreen = data->appView->IsFullScreenMode;
}
#elif (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) || (NTDDI_VERSION == NTDDI_WIN8)
is_fullscreen = true;
@ -532,7 +510,7 @@ WINRT_DetectWindowFlags(SDL_Window * window)
if (data->coreWindow.Get()) {
if (is_fullscreen) {
SDL_VideoDisplay * display = SDL_GetDisplayForWindow(window);
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
int w = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Width);
int h = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Height);
@ -543,17 +521,17 @@ WINRT_DetectWindowFlags(SDL_Window * window)
const DisplayOrientations currentOrientation = WINRT_DISPLAY_PROPERTY(CurrentOrientation);
switch (currentOrientation) {
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
case DisplayOrientations::Landscape:
case DisplayOrientations::LandscapeFlipped:
case DisplayOrientations::Landscape:
case DisplayOrientations::LandscapeFlipped:
#else
case DisplayOrientations::Portrait:
case DisplayOrientations::PortraitFlipped:
case DisplayOrientations::Portrait:
case DisplayOrientations::PortraitFlipped:
#endif
{
int tmp = w;
w = h;
h = tmp;
} break;
{
int tmp = w;
w = h;
h = tmp;
} break;
}
#endif
@ -584,47 +562,44 @@ WINRT_DetectWindowFlags(SDL_Window * window)
}
// TODO, WinRT: consider removing WINRT_UpdateWindowFlags, and just calling WINRT_DetectWindowFlags as-appropriate (with appropriate calls to SDL_SendWindowEvent)
void
WINRT_UpdateWindowFlags(SDL_Window * window, Uint32 mask)
void WINRT_UpdateWindowFlags(SDL_Window *window, Uint32 mask)
{
mask &= WINRT_DetectableFlags;
if (window) {
Uint32 apply = WINRT_DetectWindowFlags(window);
if ((apply & mask) & SDL_WINDOW_FULLSCREEN) {
window->last_fullscreen_flags = window->flags; // seems necessary to programmatically un-fullscreen, via SDL APIs
window->last_fullscreen_flags = window->flags; // seems necessary to programmatically un-fullscreen, via SDL APIs
}
window->flags = (window->flags & ~mask) | (apply & mask);
}
}
static bool
WINRT_IsCoreWindowActive(CoreWindow ^ coreWindow)
static bool WINRT_IsCoreWindowActive(CoreWindow ^ coreWindow)
{
/* WinRT does not appear to offer API(s) to determine window-activation state,
at least not that I am aware of in Win8 - Win10. As such, SDL tracks this
itself, via window-activation events.
If there *is* an API to track this, it should probably get used instead
of the following hack (that uses "SDLHelperWindowActivationState").
-- DavidL.
*/
if (coreWindow->CustomProperties->HasKey("SDLHelperWindowActivationState")) {
CoreWindowActivationState activationState = \
CoreWindowActivationState activationState =
safe_cast<CoreWindowActivationState>(coreWindow->CustomProperties->Lookup("SDLHelperWindowActivationState"));
return (activationState != CoreWindowActivationState::Deactivated);
return activationState != CoreWindowActivationState::Deactivated;
}
/* Assume that non-SDL tracked windows are active, although this should
probably be avoided, if possible.
This might not even be possible, in normal SDL use, at least as of
this writing (Dec 22, 2015; via latest hg.libsdl.org/SDL clone) -- DavidL
*/
return true;
}
int
WINRT_CreateWindow(_THIS, SDL_Window * window)
int WINRT_CreateWindow(_THIS, SDL_Window *window)
{
// Make sure that only one window gets created, at least until multimonitor
// support is added.
@ -632,7 +607,7 @@ WINRT_CreateWindow(_THIS, SDL_Window * window)
return SDL_SetError("WinRT only supports one window");
}
SDL_WindowData *data = new SDL_WindowData; /* use 'new' here as SDL_WindowData may use WinRT/C++ types */
SDL_WindowData *data = new SDL_WindowData; /* use 'new' here as SDL_WindowData may use WinRT/C++ types */
if (!data) {
return SDL_OutOfMemory();
}
@ -662,7 +637,7 @@ WINRT_CreateWindow(_THIS, SDL_Window * window)
data->egl_surface = EGL_NO_SURFACE;
} else {
/* OpenGL ES 2 was reuqested. Set up an EGL surface. */
SDL_VideoData * video_data = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *video_data = (SDL_VideoData *)_this->driverdata;
/* Call SDL_EGL_ChooseConfig and eglCreateWindowSurface directly,
* rather than via SDL_EGL_CreateSurface, as older versions of
@ -671,10 +646,10 @@ WINRT_CreateWindow(_THIS, SDL_Window * window)
*/
if (SDL_EGL_ChooseConfig(_this) != 0) {
/* SDL_EGL_ChooseConfig failed, SDL_GetError() should have info */
return -1;
return -1;
}
if (video_data->winrtEglWindow) { /* ... is the 'old' version of ANGLE/WinRT being used? */
if (video_data->winrtEglWindow) { /* ... is the 'old' version of ANGLE/WinRT being used? */
/* Attempt to create a window surface using older versions of
* ANGLE/WinRT:
*/
@ -690,7 +665,7 @@ WINRT_CreateWindow(_THIS, SDL_Window * window)
/* Attempt to create a window surface using newer versions of
* ANGLE/WinRT:
*/
IInspectable * coreWindowAsIInspectable = reinterpret_cast<IInspectable *>(data->coreWindow.Get());
IInspectable *coreWindowAsIInspectable = reinterpret_cast<IInspectable *>(data->coreWindow.Get());
data->egl_surface = _this->egl_data->eglCreateWindowSurface(
_this->egl_data->egl_display,
_this->egl_data->egl_config,
@ -721,8 +696,8 @@ WINRT_CreateWindow(_THIS, SDL_Window * window)
window->x = 0;
window->y = 0;
window->flags |= SDL_WINDOW_SHOWN;
SDL_SetMouseFocus(NULL); // TODO: detect this
SDL_SetKeyboardFocus(NULL); // TODO: detect this
SDL_SetMouseFocus(NULL); // TODO: detect this
SDL_SetKeyboardFocus(NULL); // TODO: detect this
} else {
/* WinRT 8.x apps seem to live in an environment where the OS controls the
app's window size, with some apps being fullscreen, depending on
@ -756,7 +731,7 @@ WINRT_CreateWindow(_THIS, SDL_Window * window)
WINRT_UpdateWindowFlags(
window,
0xffffffff /* Update any window flag(s) that WINRT_UpdateWindow can handle */
0xffffffff /* Update any window flag(s) that WINRT_UpdateWindow can handle */
);
/* Try detecting if the window is active */
@ -765,7 +740,7 @@ WINRT_CreateWindow(_THIS, SDL_Window * window)
SDL_SetKeyboardFocus(window);
}
}
/* Make sure the WinRT app's IFramworkView can post events on
behalf of SDL:
*/
@ -775,27 +750,25 @@ WINRT_CreateWindow(_THIS, SDL_Window * window)
return 0;
}
void
WINRT_SetWindowSize(_THIS, SDL_Window * window)
void WINRT_SetWindowSize(_THIS, SDL_Window *window)
{
#if NTDDI_VERSION >= NTDDI_WIN10
SDL_WindowData * data = (SDL_WindowData *)window->driverdata;
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
const Windows::Foundation::Size size(WINRT_PHYSICAL_PIXELS_TO_DIPS(window->w),
WINRT_PHYSICAL_PIXELS_TO_DIPS(window->h));
data->appView->TryResizeView(size); // TODO, WinRT: return failure (to caller?) from TryResizeView()
#endif
}
void
WINRT_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
void WINRT_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
{
#if NTDDI_VERSION >= NTDDI_WIN10
SDL_WindowData * data = (SDL_WindowData *)window->driverdata;
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
bool isWindowActive = WINRT_IsCoreWindowActive(data->coreWindow.Get());
if (isWindowActive) {
if (fullscreen) {
if (!data->appView->IsFullScreenMode) {
data->appView->TryEnterFullScreenMode(); // TODO, WinRT: return failure (to caller?) from TryEnterFullScreenMode()
data->appView->TryEnterFullScreenMode(); // TODO, WinRT: return failure (to caller?) from TryEnterFullScreenMode()
}
} else {
if (data->appView->IsFullScreenMode) {
@ -806,11 +779,9 @@ WINRT_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
#endif
}
void
WINRT_DestroyWindow(_THIS, SDL_Window * window)
void WINRT_DestroyWindow(_THIS, SDL_Window *window)
{
SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
if (WINRT_GlobalSDLWindow == window) {
WINRT_GlobalSDLWindow = NULL;
@ -824,8 +795,7 @@ WINRT_DestroyWindow(_THIS, SDL_Window * window)
}
}
SDL_bool
WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
SDL_bool WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
{
SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
@ -834,22 +804,21 @@ WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
info->info.winrt.window = reinterpret_cast<IInspectable *>(data->coreWindow.Get());
return SDL_TRUE;
} else {
SDL_SetError("Application not compiled with SDL %d.%d",
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
SDL_SetError("Application not compiled with SDL %d",
SDL_MAJOR_VERSION);
return SDL_FALSE;
}
return SDL_FALSE;
}
static ABI::Windows::System::Display::IDisplayRequest *
WINRT_CreateDisplayRequest(_THIS)
static ABI::Windows::System::Display::IDisplayRequest *WINRT_CreateDisplayRequest(_THIS)
{
/* Setup a WinRT DisplayRequest object, usable for enabling/disabling screensaver requests */
wchar_t *wClassName = L"Windows.System.Display.DisplayRequest";
HSTRING hClassName;
IActivationFactory *pActivationFactory = NULL;
IInspectable * pDisplayRequestRaw = nullptr;
ABI::Windows::System::Display::IDisplayRequest * pDisplayRequest = nullptr;
IInspectable *pDisplayRequestRaw = nullptr;
ABI::Windows::System::Display::IDisplayRequest *pDisplayRequest = nullptr;
HRESULT hr;
hr = ::WindowsCreateString(wClassName, (UINT32)SDL_wcslen(wClassName), &hClassName);
@ -867,7 +836,7 @@ WINRT_CreateDisplayRequest(_THIS)
goto done;
}
hr = pDisplayRequestRaw->QueryInterface(SDL_IID_IDisplayRequest, (void **) &pDisplayRequest);
hr = pDisplayRequestRaw->QueryInterface(SDL_IID_IDisplayRequest, (void **)&pDisplayRequest);
if (FAILED(hr)) {
goto done;
}
@ -886,12 +855,11 @@ done:
return pDisplayRequest;
}
void
WINRT_SuspendScreenSaver(_THIS)
void WINRT_SuspendScreenSaver(_THIS)
{
SDL_VideoData *driverdata = (SDL_VideoData *)_this->driverdata;
if (driverdata && driverdata->displayRequest) {
ABI::Windows::System::Display::IDisplayRequest * displayRequest = (ABI::Windows::System::Display::IDisplayRequest *) driverdata->displayRequest;
ABI::Windows::System::Display::IDisplayRequest *displayRequest = (ABI::Windows::System::Display::IDisplayRequest *)driverdata->displayRequest;
if (_this->suspend_screensaver) {
displayRequest->RequestActive();
} else {

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -29,9 +29,9 @@
#include "SDL_video.h"
#include "SDL_events.h"
#if NTDDI_VERSION >= NTDDI_WINBLUE /* ApplicationView's functionality only becomes
useful for SDL in Win[Phone] 8.1 and up.
Plus, it is not available at all in WinPhone 8.0. */
#if NTDDI_VERSION >= NTDDI_WINBLUE /* ApplicationView's functionality only becomes \
useful for SDL in Win[Phone] 8.1 and up. \
Plus, it is not available at all in WinPhone 8.0. */
#define SDL_WINRT_USE_APPLICATIONVIEW 1
#endif
@ -41,7 +41,8 @@ extern "C" {
}
/* Private display data */
typedef struct SDL_VideoData {
typedef struct SDL_VideoData
{
/* An object created by ANGLE/WinRT (OpenGL ES 2 for WinRT) that gets
* passed to eglGetDisplay and eglCreateWindowSurface:
*/
@ -55,7 +56,7 @@ typedef struct SDL_VideoData {
/* A WinRT DisplayRequest, used for implementing SDL_*ScreenSaver() functions.
* This is really a pointer to a 'ABI::Windows::System::Display::IDisplayRequest *',
* It's casted to 'IUnknown *', to help with building SDL.
*/
*/
IUnknown *displayRequest;
} SDL_VideoData;
@ -63,19 +64,19 @@ typedef struct SDL_VideoData {
For now, SDL/WinRT only supports one window (due to platform limitations of
WinRT.
*/
extern SDL_Window * WINRT_GlobalSDLWindow;
extern SDL_Window *WINRT_GlobalSDLWindow;
/* Updates one or more SDL_Window flags, by querying the OS' native windowing APIs.
SDL_Window flags that can be updated should be specified in 'mask'.
*/
extern void WINRT_UpdateWindowFlags(SDL_Window * window, Uint32 mask);
extern "C" Uint32 WINRT_DetectWindowFlags(SDL_Window * window); /* detects flags w/o applying them */
extern void WINRT_UpdateWindowFlags(SDL_Window *window, Uint32 mask);
extern "C" Uint32 WINRT_DetectWindowFlags(SDL_Window *window); /* detects flags w/o applying them */
/* Display mode internals */
//typedef struct
// typedef struct
//{
// Windows::Graphics::Display::DisplayOrientations currentOrientation;
//} SDL_DisplayModeData;
// Windows::Graphics::Display::DisplayOrientations currentOrientation;
// } SDL_DisplayModeData;
#ifdef __cplusplus_winrt
@ -87,8 +88,8 @@ extern "C" Uint32 WINRT_DetectWindowFlags(SDL_Window * window); /* detects flag
#endif
/* Converts DIPS to/from physical pixels */
#define WINRT_DIPS_TO_PHYSICAL_PIXELS(DIPS) ((int)(0.5f + (((float)(DIPS) * (float)WINRT_DISPLAY_PROPERTY(LogicalDpi)) / 96.f)))
#define WINRT_PHYSICAL_PIXELS_TO_DIPS(PHYSPIX) (((float)(PHYSPIX) * 96.f)/WINRT_DISPLAY_PROPERTY(LogicalDpi))
#define WINRT_DIPS_TO_PHYSICAL_PIXELS(DIPS) ((int)(0.5f + (((float)(DIPS) * (float)WINRT_DISPLAY_PROPERTY(LogicalDpi)) / 96.f)))
#define WINRT_PHYSICAL_PIXELS_TO_DIPS(PHYSPIX) (((float)(PHYSPIX)*96.f) / WINRT_DISPLAY_PROPERTY(LogicalDpi))
/* Internal window data */
struct SDL_WindowData