src/core/winrt/SDL_winrtapp_direct3d.cpp
author David Ludwig <dludwig@pobox.com>
Wed, 03 Dec 2014 10:55:23 -0500
changeset 9256 9c45fc8605d9
parent 9240 dc4ad21d8596
child 9619 b94b6d0bff0f
permissions -rw-r--r--
WinRT: fixed bug whereby SDL would override an app's default orientation WinRT apps can set a default, preferred orientation via a .appxmanifest file. SDL was overriding this on app startup, and making the app use all possible orientations (landscape and portrait). Thanks to Eric Wing for the heads up on this!
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8616
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8600
diff changeset
     1
/*
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8600
diff changeset
     2
  Simple DirectMedia Layer
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8600
diff changeset
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8600
diff changeset
     4
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8600
diff changeset
     5
  This software is provided 'as-is', without any express or implied
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8600
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8600
diff changeset
     7
  arising from the use of this software.
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8600
diff changeset
     8
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8600
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8600
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8600
diff changeset
    11
  freely, subject to the following restrictions:
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8600
diff changeset
    12
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8600
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8600
diff changeset
    14
     claim that you wrote the original software. If you use this software
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8600
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8600
diff changeset
    16
     appreciated but is not required.
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8600
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8600
diff changeset
    18
     misrepresented as being the original software.
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8600
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8600
diff changeset
    20
*/
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8600
diff changeset
    21
#include "../../SDL_internal.h"
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8600
diff changeset
    22
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    23
/* Standard C++11 includes */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    24
#include <functional>
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    25
#include <string>
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    26
#include <sstream>
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    27
using namespace std;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    28
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    29
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    30
/* Windows includes */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    31
#include "ppltasks.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    32
using namespace concurrency;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    33
using namespace Windows::ApplicationModel;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    34
using namespace Windows::ApplicationModel::Core;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    35
using namespace Windows::ApplicationModel::Activation;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    36
using namespace Windows::Devices::Input;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    37
using namespace Windows::Graphics::Display;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    38
using namespace Windows::Foundation;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    39
using namespace Windows::System;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    40
using namespace Windows::UI::Core;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    41
using namespace Windows::UI::Input;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    42
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    43
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    44
using namespace Windows::Phone::UI::Input;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    45
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    46
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    47
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    48
/* SDL includes */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    49
extern "C" {
8600
092802455aed build fixes for most WinRT-related files
David Ludwig <dludwig@pobox.com>
parents: 8582
diff changeset
    50
#include "../../SDL_internal.h"
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    51
#include "SDL_assert.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    52
#include "SDL_events.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    53
#include "SDL_hints.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    54
#include "SDL_log.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    55
#include "SDL_main.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    56
#include "SDL_stdinc.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    57
#include "SDL_render.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    58
#include "../../video/SDL_sysvideo.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    59
//#include "../../SDL_hints_c.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    60
#include "../../events/SDL_events_c.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    61
#include "../../events/SDL_keyboard_c.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    62
#include "../../events/SDL_mouse_c.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    63
#include "../../events/SDL_windowevents_c.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    64
#include "../../render/SDL_sysrender.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    65
#include "../windows/SDL_windows.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    66
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    67
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    68
#include "../../video/winrt/SDL_winrtevents_c.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    69
#include "../../video/winrt/SDL_winrtvideo_cpp.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    70
#include "SDL_winrtapp_common.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    71
#include "SDL_winrtapp_direct3d.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    72
8679
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8678
diff changeset
    73
#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8678
diff changeset
    74
/* Calling IDXGIDevice3::Trim on the active Direct3D 11.x device is necessary
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8678
diff changeset
    75
 * when Windows 8.1 apps are about to get suspended.
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8678
diff changeset
    76
 */
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8678
diff changeset
    77
extern "C" void D3D11_Trim(SDL_Renderer *);
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8678
diff changeset
    78
#endif
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8678
diff changeset
    79
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    80
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    81
// Compile-time debugging options:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    82
// To enable, uncomment; to disable, comment them out.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    83
//#define LOG_POINTER_EVENTS 1
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    84
//#define LOG_WINDOW_EVENTS 1
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    85
//#define LOG_ORIENTATION_EVENTS 1
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    86
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    87
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    88
// HACK, DLudwig: record a reference to the global, WinRT 'app'/view.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    89
// SDL/WinRT will use this throughout its code.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    90
//
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    91
// TODO, WinRT: consider replacing SDL_WinRTGlobalApp with something
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    92
// non-global, such as something created inside
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    93
// SDL_InitSubSystem(SDL_INIT_VIDEO), or something inside
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    94
// SDL_CreateWindow().
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    95
SDL_WinRTApp ^ SDL_WinRTGlobalApp = nullptr;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    96
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    97
ref class SDLApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    98
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
    99
public:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   100
    virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   101
};
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   102
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   103
IFrameworkView^ SDLApplicationSource::CreateView()
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   104
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   105
    // TODO, WinRT: see if this function (CreateView) can ever get called
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   106
    // more than once.  For now, just prevent it from ever assigning
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   107
    // SDL_WinRTGlobalApp more than once.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   108
    SDL_assert(!SDL_WinRTGlobalApp);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   109
    SDL_WinRTApp ^ app = ref new SDL_WinRTApp();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   110
    if (!SDL_WinRTGlobalApp)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   111
    {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   112
        SDL_WinRTGlobalApp = app;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   113
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   114
    return app;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   115
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   116
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   117
int SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **))
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   118
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   119
    WINRT_SDLAppEntryPoint = mainFunction;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   120
    auto direct3DApplicationSource = ref new SDLApplicationSource();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   121
    CoreApplication::Run(direct3DApplicationSource);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   122
    return 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   123
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   124
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   125
static void WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const char *oldValue, const char *newValue)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   126
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   127
    SDL_assert(SDL_strcmp(name, SDL_HINT_ORIENTATIONS) == 0);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   128
9256
9c45fc8605d9 WinRT: fixed bug whereby SDL would override an app's default orientation
David Ludwig <dludwig@pobox.com>
parents: 9240
diff changeset
   129
    /* HACK: prevent SDL from altering an app's .appxmanifest-set orientation
9c45fc8605d9 WinRT: fixed bug whereby SDL would override an app's default orientation
David Ludwig <dludwig@pobox.com>
parents: 9240
diff changeset
   130
     * from being changed on startup, by detecting when SDL_HINT_ORIENTATIONS
9c45fc8605d9 WinRT: fixed bug whereby SDL would override an app's default orientation
David Ludwig <dludwig@pobox.com>
parents: 9240
diff changeset
   131
     * is getting registered.
9c45fc8605d9 WinRT: fixed bug whereby SDL would override an app's default orientation
David Ludwig <dludwig@pobox.com>
parents: 9240
diff changeset
   132
     *
9c45fc8605d9 WinRT: fixed bug whereby SDL would override an app's default orientation
David Ludwig <dludwig@pobox.com>
parents: 9240
diff changeset
   133
     * TODO, WinRT: consider reading in an app's .appxmanifest file, and apply its orientation when 'newValue == NULL'.
9c45fc8605d9 WinRT: fixed bug whereby SDL would override an app's default orientation
David Ludwig <dludwig@pobox.com>
parents: 9240
diff changeset
   134
     */
9c45fc8605d9 WinRT: fixed bug whereby SDL would override an app's default orientation
David Ludwig <dludwig@pobox.com>
parents: 9240
diff changeset
   135
    if ((oldValue == NULL) && (newValue == NULL)) {
9c45fc8605d9 WinRT: fixed bug whereby SDL would override an app's default orientation
David Ludwig <dludwig@pobox.com>
parents: 9240
diff changeset
   136
        return;
9c45fc8605d9 WinRT: fixed bug whereby SDL would override an app's default orientation
David Ludwig <dludwig@pobox.com>
parents: 9240
diff changeset
   137
    }
9c45fc8605d9 WinRT: fixed bug whereby SDL would override an app's default orientation
David Ludwig <dludwig@pobox.com>
parents: 9240
diff changeset
   138
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   139
    // Start with no orientation flags, then add each in as they're parsed
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   140
    // from newValue.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   141
    unsigned int orientationFlags = 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   142
    if (newValue) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   143
        std::istringstream tokenizer(newValue);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   144
        while (!tokenizer.eof()) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   145
            std::string orientationName;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   146
            std::getline(tokenizer, orientationName, ' ');
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   147
            if (orientationName == "LandscapeLeft") {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   148
                orientationFlags |= (unsigned int) DisplayOrientations::LandscapeFlipped;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   149
            } else if (orientationName == "LandscapeRight") {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   150
                orientationFlags |= (unsigned int) DisplayOrientations::Landscape;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   151
            } else if (orientationName == "Portrait") {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   152
                orientationFlags |= (unsigned int) DisplayOrientations::Portrait;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   153
            } else if (orientationName == "PortraitUpsideDown") {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   154
                orientationFlags |= (unsigned int) DisplayOrientations::PortraitFlipped;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   155
            }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   156
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   157
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   158
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   159
    // If no valid orientation flags were specified, use a reasonable set of defaults:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   160
    if (!orientationFlags) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   161
        // TODO, WinRT: consider seeing if an app's default orientation flags can be found out via some API call(s).
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   162
        orientationFlags = (unsigned int) ( \
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   163
            DisplayOrientations::Landscape |
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   164
            DisplayOrientations::LandscapeFlipped |
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   165
            DisplayOrientations::Portrait |
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   166
            DisplayOrientations::PortraitFlipped);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   167
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   168
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   169
    // Set the orientation/rotation preferences.  Please note that this does
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   170
    // not constitute a 100%-certain lock of a given set of possible
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   171
    // orientations.  According to Microsoft's documentation on WinRT [1]
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   172
    // when a device is not capable of being rotated, Windows may ignore
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   173
    // the orientation preferences, and stick to what the device is capable of
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   174
    // displaying.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   175
    //
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   176
    // [1] Documentation on the 'InitialRotationPreference' setting for a
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   177
    // Windows app's manifest file describes how some orientation/rotation
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   178
    // preferences may be ignored.  See
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   179
    // http://msdn.microsoft.com/en-us/library/windows/apps/hh700343.aspx
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   180
    // for details.  Microsoft's "Display orientation sample" also gives an
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   181
    // outline of how Windows treats device rotation
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   182
    // (http://code.msdn.microsoft.com/Display-Orientation-Sample-19a58e93).
8757
aeeeb47a5a77 WinRT: display-information code cleanups
David Ludwig <dludwig@pobox.com>
parents: 8755
diff changeset
   183
    WINRT_DISPLAY_PROPERTY(AutoRotationPreferences) = (DisplayOrientations) orientationFlags;
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   184
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   185
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   186
static void
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   187
WINRT_ProcessWindowSizeChange()
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   188
{
8664
565698ab1c40 WinRT globals cleanup: Removed WINRT_GlobalSDLVideoDevice
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   189
    SDL_VideoDevice *_this = SDL_GetVideoDevice();
565698ab1c40 WinRT globals cleanup: Removed WINRT_GlobalSDLVideoDevice
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   190
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   191
    // Make the new window size be the one true fullscreen mode.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   192
    // This change was initially done, in part, to allow the Direct3D 11.1
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   193
    // renderer to receive window-resize events as a device rotates.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   194
    // Before, rotating a device from landscape, to portrait, and then
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   195
    // back to landscape would cause the Direct3D 11.1 swap buffer to
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   196
    // not get resized appropriately.  SDL would, on the rotation from
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   197
    // landscape to portrait, re-resize the SDL window to it's initial
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   198
    // size (landscape).  On the subsequent rotation, SDL would drop the
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   199
    // window-resize event as it appeared the SDL window didn't change
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   200
    // size, and the Direct3D 11.1 renderer wouldn't resize its swap
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   201
    // chain.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   202
    SDL_DisplayMode newDisplayMode;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   203
    if (WINRT_CalcDisplayModeUsingNativeWindow(&newDisplayMode) != 0) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   204
        return;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   205
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   206
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   207
    // Make note of the old display mode, and it's old driverdata.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   208
    SDL_DisplayMode oldDisplayMode;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   209
    SDL_zero(oldDisplayMode);
8664
565698ab1c40 WinRT globals cleanup: Removed WINRT_GlobalSDLVideoDevice
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   210
    if (_this) {
565698ab1c40 WinRT globals cleanup: Removed WINRT_GlobalSDLVideoDevice
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   211
        oldDisplayMode = _this->displays[0].desktop_mode;
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   212
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   213
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   214
    // Setup the new display mode in the appropriate spots.
8664
565698ab1c40 WinRT globals cleanup: Removed WINRT_GlobalSDLVideoDevice
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   215
    if (_this) {
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   216
        // Make a full copy of the display mode for display_modes[0],
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   217
        // one with with a separately malloced 'driverdata' field.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   218
        // SDL_VideoQuit(), if called, will attempt to free the driverdata
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   219
        // fields in 'desktop_mode' and each entry in the 'display_modes'
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   220
        // array.
8664
565698ab1c40 WinRT globals cleanup: Removed WINRT_GlobalSDLVideoDevice
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   221
        if (_this->displays[0].display_modes[0].driverdata) {
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   222
            // Free the previous mode's memory
8664
565698ab1c40 WinRT globals cleanup: Removed WINRT_GlobalSDLVideoDevice
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   223
            SDL_free(_this->displays[0].display_modes[0].driverdata);
565698ab1c40 WinRT globals cleanup: Removed WINRT_GlobalSDLVideoDevice
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   224
            _this->displays[0].display_modes[0].driverdata = NULL;
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   225
        }
8664
565698ab1c40 WinRT globals cleanup: Removed WINRT_GlobalSDLVideoDevice
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   226
        if (WINRT_DuplicateDisplayMode(&(_this->displays[0].display_modes[0]), &newDisplayMode) != 0) {
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   227
            // Uh oh, something went wrong.  A malloc call probably failed.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   228
            SDL_free(newDisplayMode.driverdata);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   229
            return;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   230
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   231
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   232
        // Install 'newDisplayMode' into 'current_mode' and 'desktop_mode'.
8664
565698ab1c40 WinRT globals cleanup: Removed WINRT_GlobalSDLVideoDevice
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   233
        _this->displays[0].current_mode = newDisplayMode;
565698ab1c40 WinRT globals cleanup: Removed WINRT_GlobalSDLVideoDevice
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   234
        _this->displays[0].desktop_mode = newDisplayMode;
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   235
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   236
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   237
    if (WINRT_GlobalSDLWindow) {
8755
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   238
        // If the window size changed, send a resize event to SDL and its host app:
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   239
        int window_w = 0;
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   240
        int window_h = 0;
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   241
        SDL_GetWindowSize(WINRT_GlobalSDLWindow, &window_w, &window_h);
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   242
        if ((window_w != newDisplayMode.w) || (window_h != newDisplayMode.h)) {
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   243
            SDL_SendWindowEvent(
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   244
                WINRT_GlobalSDLWindow,
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   245
                SDL_WINDOWEVENT_RESIZED,
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   246
                newDisplayMode.w,
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   247
                newDisplayMode.h);
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   248
        } else {
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   249
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
8755
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   250
            // HACK: Make sure that orientation changes
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   251
            // lead to the Direct3D renderer's viewport getting updated:
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   252
            //
8755
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   253
            // For some reason, this doesn't seem to need to be done on Windows 8.x,
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   254
            // even when going from Landscape to LandscapeFlipped.  It only seems to
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   255
            // be needed on Windows Phone, at least when I tested on my devices.
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   256
            // I'm not currently sure why this is, but it seems to work fine. -- David L.
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   257
            //
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   258
            // TODO, WinRT: do more extensive research into why orientation changes on Win 8.x don't need D3D changes, or if they might, in some cases
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   259
            const DisplayOrientations oldOrientation = ((SDL_DisplayModeData *)oldDisplayMode.driverdata)->currentOrientation;
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   260
            const DisplayOrientations newOrientation = ((SDL_DisplayModeData *)newDisplayMode.driverdata)->currentOrientation;
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   261
            if (oldOrientation != newOrientation)
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   262
            {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   263
                SDL_SendWindowEvent(
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   264
                    WINRT_GlobalSDLWindow,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   265
                    SDL_WINDOWEVENT_SIZE_CHANGED,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   266
                    newDisplayMode.w,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   267
                    newDisplayMode.h);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   268
            }
8755
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   269
#endif
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   270
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   271
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   272
    
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   273
    // Finally, free the 'driverdata' field of the old 'desktop_mode'.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   274
    if (oldDisplayMode.driverdata) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   275
        SDL_free(oldDisplayMode.driverdata);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   276
        oldDisplayMode.driverdata = NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   277
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   278
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   279
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   280
SDL_WinRTApp::SDL_WinRTApp() :
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   281
    m_windowClosed(false),
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   282
    m_windowVisible(true)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   283
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   284
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   285
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   286
void SDL_WinRTApp::Initialize(CoreApplicationView^ applicationView)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   287
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   288
    applicationView->Activated +=
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   289
        ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &SDL_WinRTApp::OnActivated);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   290
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   291
    CoreApplication::Suspending +=
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   292
        ref new EventHandler<SuspendingEventArgs^>(this, &SDL_WinRTApp::OnSuspending);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   293
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   294
    CoreApplication::Resuming +=
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   295
        ref new EventHandler<Platform::Object^>(this, &SDL_WinRTApp::OnResuming);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   296
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   297
    CoreApplication::Exiting +=
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   298
        ref new EventHandler<Platform::Object^>(this, &SDL_WinRTApp::OnExiting);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   299
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   300
8621
5252788cb448 Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents: 8616
diff changeset
   301
#if NTDDI_VERSION > NTDDI_WIN8
5252788cb448 Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents: 8616
diff changeset
   302
void SDL_WinRTApp::OnOrientationChanged(DisplayInformation^ sender, Object^ args)
5252788cb448 Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents: 8616
diff changeset
   303
#else
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   304
void SDL_WinRTApp::OnOrientationChanged(Object^ sender)
8621
5252788cb448 Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents: 8616
diff changeset
   305
#endif
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   306
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   307
#if LOG_ORIENTATION_EVENTS==1
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   308
    CoreWindow^ window = CoreWindow::GetForCurrentThread();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   309
    if (window) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   310
        SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, CoreWindow Size={%f,%f}\n",
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   311
            __FUNCTION__,
8755
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   312
            WINRT_DISPLAY_PROPERTY(CurrentOrientation),
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   313
            WINRT_DISPLAY_PROPERTY(NativeOrientation),
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   314
            WINRT_DISPLAY_PROPERTY(AutoRotationPreferences),
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   315
            window->Bounds.Width,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   316
            window->Bounds.Height);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   317
    } else {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   318
        SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d\n",
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   319
            __FUNCTION__,
8755
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   320
            WINRT_DISPLAY_PROPERTY(CurrentOrientation),
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   321
            WINRT_DISPLAY_PROPERTY(NativeOrientation),
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   322
            WINRT_DISPLAY_PROPERTY(AutoRotationPreferences));
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   323
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   324
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   325
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   326
    WINRT_ProcessWindowSizeChange();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   327
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   328
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   329
void SDL_WinRTApp::SetWindow(CoreWindow^ window)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   330
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   331
#if LOG_WINDOW_EVENTS==1
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   332
    SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, window Size={%f,%f}\n",
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   333
        __FUNCTION__,
8755
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   334
        WINRT_DISPLAY_PROPERTY(CurrentOrientation),
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   335
        WINRT_DISPLAY_PROPERTY(NativeOrientation),
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   336
        WINRT_DISPLAY_PROPERTY(AutoRotationPreferences),
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   337
        window->Bounds.Width,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   338
        window->Bounds.Height);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   339
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   340
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   341
    window->SizeChanged += 
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   342
        ref new TypedEventHandler<CoreWindow^, WindowSizeChangedEventArgs^>(this, &SDL_WinRTApp::OnWindowSizeChanged);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   343
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   344
    window->VisibilityChanged +=
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   345
        ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &SDL_WinRTApp::OnVisibilityChanged);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   346
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   347
    window->Closed += 
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   348
        ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &SDL_WinRTApp::OnWindowClosed);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   349
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   350
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   351
    window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   352
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   353
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   354
    window->PointerPressed +=
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   355
        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerPressed);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   356
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   357
    window->PointerMoved +=
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   358
        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerMoved);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   359
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   360
    window->PointerReleased +=
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   361
        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerReleased);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   362
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   363
    window->PointerWheelChanged +=
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   364
        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerWheelChanged);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   365
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   366
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   367
    // Retrieves relative-only mouse movements:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   368
    Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved +=
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   369
        ref new TypedEventHandler<MouseDevice^, MouseEventArgs^>(this, &SDL_WinRTApp::OnMouseMoved);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   370
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   371
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   372
    window->KeyDown +=
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   373
        ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &SDL_WinRTApp::OnKeyDown);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   374
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   375
    window->KeyUp +=
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   376
        ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &SDL_WinRTApp::OnKeyUp);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   377
9240
dc4ad21d8596 WinRT: added initial SDL_TEXTINPUT support
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   378
    window->CharacterReceived +=
dc4ad21d8596 WinRT: added initial SDL_TEXTINPUT support
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   379
        ref new TypedEventHandler<CoreWindow^, CharacterReceivedEventArgs^>(this, &SDL_WinRTApp::OnCharacterReceived);
dc4ad21d8596 WinRT: added initial SDL_TEXTINPUT support
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   380
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   381
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   382
    HardwareButtons::BackPressed +=
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   383
        ref new EventHandler<BackPressedEventArgs^>(this, &SDL_WinRTApp::OnBackButtonPressed);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   384
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   385
8621
5252788cb448 Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents: 8616
diff changeset
   386
#if NTDDI_VERSION > NTDDI_WIN8
5252788cb448 Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents: 8616
diff changeset
   387
    DisplayInformation::GetForCurrentView()->OrientationChanged +=
5252788cb448 Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents: 8616
diff changeset
   388
        ref new TypedEventHandler<Windows::Graphics::Display::DisplayInformation^, Object^>(this, &SDL_WinRTApp::OnOrientationChanged);
5252788cb448 Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents: 8616
diff changeset
   389
#else
5252788cb448 Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents: 8616
diff changeset
   390
    DisplayProperties::OrientationChanged +=
5252788cb448 Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents: 8616
diff changeset
   391
        ref new DisplayPropertiesEventHandler(this, &SDL_WinRTApp::OnOrientationChanged);
5252788cb448 Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents: 8616
diff changeset
   392
#endif
5252788cb448 Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents: 8616
diff changeset
   393
5252788cb448 Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents: 8616
diff changeset
   394
    // Register the hint, SDL_HINT_ORIENTATIONS, with SDL.
5252788cb448 Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents: 8616
diff changeset
   395
    // TODO, WinRT: see if an app's default orientation can be found out via WinRT API(s), then set the initial value of SDL_HINT_ORIENTATIONS accordingly.
5252788cb448 Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents: 8616
diff changeset
   396
    SDL_AddHintCallback(SDL_HINT_ORIENTATIONS, WINRT_SetDisplayOrientationsPreference, NULL);
5252788cb448 Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents: 8616
diff changeset
   397
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   398
#if WINAPI_FAMILY == WINAPI_FAMILY_APP  // for Windows 8/8.1/RT apps... (and not Phone apps)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   399
    // Make sure we know when a user has opened the app's settings pane.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   400
    // This is needed in order to display a privacy policy, which needs
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   401
    // to be done for network-enabled apps, as per Windows Store requirements.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   402
    using namespace Windows::UI::ApplicationSettings;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   403
    SettingsPane::GetForCurrentView()->CommandsRequested +=
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   404
        ref new TypedEventHandler<SettingsPane^, SettingsPaneCommandsRequestedEventArgs^>
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   405
            (this, &SDL_WinRTApp::OnSettingsPaneCommandsRequested);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   406
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   407
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   408
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   409
void SDL_WinRTApp::Load(Platform::String^ entryPoint)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   410
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   411
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   412
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   413
void SDL_WinRTApp::Run()
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   414
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   415
    SDL_SetMainReady();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   416
    if (WINRT_SDLAppEntryPoint)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   417
    {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   418
        // TODO, WinRT: pass the C-style main() a reasonably realistic
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   419
        // representation of command line arguments.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   420
        int argc = 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   421
        char **argv = NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   422
        WINRT_SDLAppEntryPoint(argc, argv);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   423
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   424
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   425
8666
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   426
static bool IsSDLWindowEventPending(SDL_WindowEventID windowEventID)
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   427
{
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   428
    SDL_Event events[128];
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   429
    const int count = SDL_PeepEvents(events, sizeof(events)/sizeof(SDL_Event), SDL_PEEKEVENT, SDL_WINDOWEVENT, SDL_WINDOWEVENT);
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   430
    for (int i = 0; i < count; ++i) {
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   431
        if (events[i].window.event == windowEventID) {
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   432
            return true;
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   433
        }
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   434
    }
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   435
    return false;
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   436
}
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   437
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   438
bool SDL_WinRTApp::ShouldWaitForAppResumeEvents()
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   439
{
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   440
    /* Don't wait if the app is visible: */
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   441
    if (m_windowVisible) {
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   442
        return false;
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   443
    }
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   444
    
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   445
    /* Don't wait until the window-hide events finish processing.
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   446
     * Do note that if an app-suspend event is sent (as indicated
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   447
     * by SDL_APP_WILLENTERBACKGROUND and SDL_APP_DIDENTERBACKGROUND
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   448
     * events), then this code may be a moot point, as WinRT's
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   449
     * own event pump (aka ProcessEvents()) will pause regardless
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   450
     * of what we do here.  This happens on Windows Phone 8, to note.
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   451
     * Windows 8.x apps, on the other hand, may get a chance to run
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   452
     * these.
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   453
     */
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   454
    if (IsSDLWindowEventPending(SDL_WINDOWEVENT_HIDDEN)) {
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   455
        return false;
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   456
    } else if (IsSDLWindowEventPending(SDL_WINDOWEVENT_FOCUS_LOST)) {
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   457
        return false;
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   458
    } else if (IsSDLWindowEventPending(SDL_WINDOWEVENT_MINIMIZED)) {
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   459
        return false;
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   460
    }
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   461
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   462
    return true;
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   463
}
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   464
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   465
void SDL_WinRTApp::PumpEvents()
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   466
{
8666
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   467
    if (!m_windowClosed) {
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   468
        if (!ShouldWaitForAppResumeEvents()) {
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   469
            /* This is the normal way in which events should be pumped.
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   470
             * 'ProcessAllIfPresent' will make ProcessEvents() process anywhere
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   471
             * from zero to N events, and will then return.
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   472
             */
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   473
            CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
8666
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   474
        } else {
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   475
            /* This style of event-pumping, with 'ProcessOneAndAllPending',
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   476
             * will cause anywhere from one to N events to be processed.  If
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   477
             * at least one event is processed, the call will return.  If
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   478
             * no events are pending, then the call will wait until one is
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   479
             * available, and will not return (to the caller) until this
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   480
             * happens!  This should only occur when the app is hidden.
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   481
             */
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   482
            CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   483
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   484
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   485
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   486
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   487
void SDL_WinRTApp::Uninitialize()
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   488
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   489
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   490
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   491
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   492
void SDL_WinRTApp::OnSettingsPaneCommandsRequested(
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   493
    Windows::UI::ApplicationSettings::SettingsPane ^p,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   494
    Windows::UI::ApplicationSettings::SettingsPaneCommandsRequestedEventArgs ^args)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   495
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   496
    using namespace Platform;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   497
    using namespace Windows::UI::ApplicationSettings;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   498
    using namespace Windows::UI::Popups;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   499
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   500
    String ^privacyPolicyURL = nullptr;     // a URL to an app's Privacy Policy
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   501
    String ^privacyPolicyLabel = nullptr;   // label/link text
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   502
    const char *tmpHintValue = NULL;        // SDL_GetHint-retrieved value, used immediately
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   503
    wchar_t *tmpStr = NULL;                 // used for UTF8 to UCS2 conversion
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   504
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   505
    // Setup a 'Privacy Policy' link, if one is available (via SDL_GetHint):
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   506
    tmpHintValue = SDL_GetHint(SDL_HINT_WINRT_PRIVACY_POLICY_URL);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   507
    if (tmpHintValue && tmpHintValue[0] != '\0') {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   508
        // Convert the privacy policy's URL to UCS2:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   509
        tmpStr = WIN_UTF8ToString(tmpHintValue);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   510
        privacyPolicyURL = ref new String(tmpStr);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   511
        SDL_free(tmpStr);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   512
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   513
        // Optionally retrieve custom label-text for the link.  If this isn't
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   514
        // available, a default value will be used instead.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   515
        tmpHintValue = SDL_GetHint(SDL_HINT_WINRT_PRIVACY_POLICY_LABEL);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   516
        if (tmpHintValue && tmpHintValue[0] != '\0') {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   517
            tmpStr = WIN_UTF8ToString(tmpHintValue);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   518
            privacyPolicyLabel = ref new String(tmpStr);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   519
            SDL_free(tmpStr);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   520
        } else {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   521
            privacyPolicyLabel = ref new String(L"Privacy Policy");
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   522
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   523
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   524
        // Register the link, along with a handler to be called if and when it is
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   525
        // clicked:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   526
        auto cmd = ref new SettingsCommand(L"privacyPolicy", privacyPolicyLabel,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   527
            ref new UICommandInvokedHandler([=](IUICommand ^) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   528
                Windows::System::Launcher::LaunchUriAsync(ref new Uri(privacyPolicyURL));
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   529
        }));
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   530
        args->Request->ApplicationCommands->Append(cmd);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   531
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   532
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   533
#endif // if WINAPI_FAMILY == WINAPI_FAMILY_APP
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   534
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   535
void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   536
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   537
#if LOG_WINDOW_EVENTS==1
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   538
    SDL_Log("%s, size={%f,%f}, current orientation=%d, native orientation=%d, auto rot. pref=%d, WINRT_GlobalSDLWindow?=%s\n",
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   539
        __FUNCTION__,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   540
        args->Size.Width, args->Size.Height,
8755
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   541
        WINRT_DISPLAY_PROPERTY(CurrentOrientation),
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   542
        WINRT_DISPLAY_PROPERTY(NativeOrientation),
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8679
diff changeset
   543
        WINRT_DISPLAY_PROPERTY(AutoRotationPreferences),
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   544
        (WINRT_GlobalSDLWindow ? "yes" : "no"));
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   545
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   546
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   547
    WINRT_ProcessWindowSizeChange();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   548
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   549
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   550
void SDL_WinRTApp::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   551
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   552
#if LOG_WINDOW_EVENTS==1
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   553
    SDL_Log("%s, visible?=%s, WINRT_GlobalSDLWindow?=%s\n",
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   554
        __FUNCTION__,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   555
        (args->Visible ? "yes" : "no"),
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   556
        (WINRT_GlobalSDLWindow ? "yes" : "no"));
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   557
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   558
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   559
    m_windowVisible = args->Visible;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   560
    if (WINRT_GlobalSDLWindow) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   561
        SDL_bool wasSDLWindowSurfaceValid = WINRT_GlobalSDLWindow->surface_valid;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   562
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   563
        if (args->Visible) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   564
            SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_SHOWN, 0, 0);
8678
7149b02f106b WinRT: Line ending fixes (CRLF to LF)
David Ludwig <dludwig@pobox.com>
parents: 8666
diff changeset
   565
            SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0);
7149b02f106b WinRT: Line ending fixes (CRLF to LF)
David Ludwig <dludwig@pobox.com>
parents: 8666
diff changeset
   566
            SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_RESTORED, 0, 0);
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   567
        } else {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   568
            SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_HIDDEN, 0, 0);
8678
7149b02f106b WinRT: Line ending fixes (CRLF to LF)
David Ludwig <dludwig@pobox.com>
parents: 8666
diff changeset
   569
            SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
7149b02f106b WinRT: Line ending fixes (CRLF to LF)
David Ludwig <dludwig@pobox.com>
parents: 8666
diff changeset
   570
            SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   571
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   572
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   573
        // HACK: Prevent SDL's window-hide handling code, which currently
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   574
        // triggers a fake window resize (possibly erronously), from
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   575
        // marking the SDL window's surface as invalid.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   576
        //
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   577
        // A better solution to this probably involves figuring out if the
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   578
        // fake window resize can be prevented.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   579
        WINRT_GlobalSDLWindow->surface_valid = wasSDLWindowSurfaceValid;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   580
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   581
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   583
void SDL_WinRTApp::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   584
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   585
#if LOG_WINDOW_EVENTS==1
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   586
    SDL_Log("%s\n", __FUNCTION__);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   587
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   588
    m_windowClosed = true;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   589
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   590
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   591
void SDL_WinRTApp::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   592
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   593
    CoreWindow::GetForCurrentThread()->Activate();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   594
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   595
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   596
void SDL_WinRTApp::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   597
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   598
    // Save app state asynchronously after requesting a deferral. Holding a deferral
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   599
    // indicates that the application is busy performing suspending operations. Be
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   600
    // aware that a deferral may not be held indefinitely. After about five seconds,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   601
    // the app will be forced to exit.
8665
b987c561c218 WinRT: Made app-backgrounded events get sent at separate, distinct times.
David Ludwig <dludwig@pobox.com>
parents: 8664
diff changeset
   602
b987c561c218 WinRT: Made app-backgrounded events get sent at separate, distinct times.
David Ludwig <dludwig@pobox.com>
parents: 8664
diff changeset
   603
    // ... but first, let the app know it's about to go to the background.
b987c561c218 WinRT: Made app-backgrounded events get sent at separate, distinct times.
David Ludwig <dludwig@pobox.com>
parents: 8664
diff changeset
   604
    // The separation of events may be important, given that the deferral
b987c561c218 WinRT: Made app-backgrounded events get sent at separate, distinct times.
David Ludwig <dludwig@pobox.com>
parents: 8664
diff changeset
   605
    // runs in a separate thread.  This'll make SDL_APP_WILLENTERBACKGROUND
b987c561c218 WinRT: Made app-backgrounded events get sent at separate, distinct times.
David Ludwig <dludwig@pobox.com>
parents: 8664
diff changeset
   606
    // the only event among the two that runs in the main thread.  Given
b987c561c218 WinRT: Made app-backgrounded events get sent at separate, distinct times.
David Ludwig <dludwig@pobox.com>
parents: 8664
diff changeset
   607
    // that a few WinRT operations can only be done from the main thread
b987c561c218 WinRT: Made app-backgrounded events get sent at separate, distinct times.
David Ludwig <dludwig@pobox.com>
parents: 8664
diff changeset
   608
    // (things that access the WinRT CoreWindow are one example of this),
b987c561c218 WinRT: Made app-backgrounded events get sent at separate, distinct times.
David Ludwig <dludwig@pobox.com>
parents: 8664
diff changeset
   609
    // this could be important.
b987c561c218 WinRT: Made app-backgrounded events get sent at separate, distinct times.
David Ludwig <dludwig@pobox.com>
parents: 8664
diff changeset
   610
    SDL_SendAppEvent(SDL_APP_WILLENTERBACKGROUND);
b987c561c218 WinRT: Made app-backgrounded events get sent at separate, distinct times.
David Ludwig <dludwig@pobox.com>
parents: 8664
diff changeset
   611
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   612
    SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   613
    create_task([this, deferral]()
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   614
    {
8666
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   615
        // Send an app did-enter-background event immediately to observers.
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   616
        // CoreDispatcher::ProcessEvents, which is the backbone on which
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   617
        // SDL_WinRTApp::PumpEvents is built, will not return to its caller
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   618
        // once it sends out a suspend event.  Any events posted to SDL's
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   619
        // event queue won't get received until the WinRT app is resumed.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   620
        // SDL_AddEventWatch() may be used to receive app-suspend events on
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   621
        // WinRT.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   622
        SDL_SendAppEvent(SDL_APP_DIDENTERBACKGROUND);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   623
8679
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8678
diff changeset
   624
        // Let the Direct3D 11 renderer prepare for the app to be backgrounded.
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8678
diff changeset
   625
        // This is necessary for Windows 8.1, possibly elsewhere in the future.
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8678
diff changeset
   626
        // More details at: http://msdn.microsoft.com/en-us/library/windows/apps/Hh994929.aspx
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8678
diff changeset
   627
#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8678
diff changeset
   628
        if (WINRT_GlobalSDLWindow) {
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8678
diff changeset
   629
            SDL_Renderer * renderer = SDL_GetRenderer(WINRT_GlobalSDLWindow);
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8678
diff changeset
   630
            if (renderer && (SDL_strcmp(renderer->info.name, "direct3d11") == 0)) {
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8678
diff changeset
   631
                D3D11_Trim(renderer);
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8678
diff changeset
   632
            }
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8678
diff changeset
   633
        }
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8678
diff changeset
   634
#endif
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8678
diff changeset
   635
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   636
        deferral->Complete();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   637
    });
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   638
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   639
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   640
void SDL_WinRTApp::OnResuming(Platform::Object^ sender, Platform::Object^ args)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   641
{
8666
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   642
    // Restore any data or state that was unloaded on suspend. By default, data
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   643
    // and state are persisted when resuming from suspend. Note that these events
20d52dc1a24a WinRT: Miscellaneous app-backgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents: 8665
diff changeset
   644
    // do not occur if the app was previously terminated.
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   645
    SDL_SendAppEvent(SDL_APP_WILLENTERFOREGROUND);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   646
    SDL_SendAppEvent(SDL_APP_DIDENTERFOREGROUND);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   647
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   648
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   649
void SDL_WinRTApp::OnExiting(Platform::Object^ sender, Platform::Object^ args)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   650
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   651
    SDL_SendAppEvent(SDL_APP_TERMINATING);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   652
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   653
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   654
static void
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   655
WINRT_LogPointerEvent(const char * header, Windows::UI::Core::PointerEventArgs ^ args, Windows::Foundation::Point transformedPoint)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   656
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   657
    Windows::UI::Input::PointerPoint ^ pt = args->CurrentPoint;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   658
    SDL_Log("%s: Position={%f,%f}, Transformed Pos={%f, %f}, MouseWheelDelta=%d, FrameId=%d, PointerId=%d, SDL button=%d\n",
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   659
        header,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   660
        pt->Position.X, pt->Position.Y,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   661
        transformedPoint.X, transformedPoint.Y,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   662
        pt->Properties->MouseWheelDelta,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   663
        pt->FrameId,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   664
        pt->PointerId,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   665
        WINRT_GetSDLButtonForPointerPoint(pt));
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   666
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   667
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   668
void SDL_WinRTApp::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   669
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   670
#if LOG_POINTER_EVENTS
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   671
    WINRT_LogPointerEvent("pointer pressed", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize));
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   672
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   673
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   674
    WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   675
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   676
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   677
void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   678
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   679
#if LOG_POINTER_EVENTS
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   680
    WINRT_LogPointerEvent("pointer moved", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize));
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   681
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   682
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   683
    WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   684
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   685
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   686
void SDL_WinRTApp::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   687
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   688
#if LOG_POINTER_EVENTS
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   689
    WINRT_LogPointerEvent("pointer released", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize));
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   690
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   691
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   692
    WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   693
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   694
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   695
void SDL_WinRTApp::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ args)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   696
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   697
#if LOG_POINTER_EVENTS
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   698
    WINRT_LogPointerEvent("pointer wheel changed", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize));
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   699
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   700
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   701
    WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   702
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   703
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   704
void SDL_WinRTApp::OnMouseMoved(MouseDevice^ mouseDevice, MouseEventArgs^ args)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   705
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   706
    WINRT_ProcessMouseMovedEvent(WINRT_GlobalSDLWindow, args);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   707
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   708
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   709
void SDL_WinRTApp::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   710
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   711
    WINRT_ProcessKeyDownEvent(args);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   712
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   713
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   714
void SDL_WinRTApp::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   715
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   716
    WINRT_ProcessKeyUpEvent(args);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   717
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   718
9240
dc4ad21d8596 WinRT: added initial SDL_TEXTINPUT support
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   719
void SDL_WinRTApp::OnCharacterReceived(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CharacterReceivedEventArgs^ args)
dc4ad21d8596 WinRT: added initial SDL_TEXTINPUT support
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   720
{
dc4ad21d8596 WinRT: added initial SDL_TEXTINPUT support
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   721
    WINRT_ProcessCharacterReceivedEvent(args);
dc4ad21d8596 WinRT: added initial SDL_TEXTINPUT support
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   722
}
dc4ad21d8596 WinRT: added initial SDL_TEXTINPUT support
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   723
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   724
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   725
void SDL_WinRTApp::OnBackButtonPressed(Platform::Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ args)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   726
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   727
    SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_AC_BACK);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   728
    SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_AC_BACK);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   729
8577
462760a8b82e WinRT: simulate keyboard events on Windows Phone 8 back-button presses
David Ludwig <dludwig@pobox.com>
parents: 8576
diff changeset
   730
    const char *hint = SDL_GetHint(SDL_HINT_WINRT_HANDLE_BACK_BUTTON);
462760a8b82e WinRT: simulate keyboard events on Windows Phone 8 back-button presses
David Ludwig <dludwig@pobox.com>
parents: 8576
diff changeset
   731
    if (hint) {
462760a8b82e WinRT: simulate keyboard events on Windows Phone 8 back-button presses
David Ludwig <dludwig@pobox.com>
parents: 8576
diff changeset
   732
        if (*hint == '1') {
462760a8b82e WinRT: simulate keyboard events on Windows Phone 8 back-button presses
David Ludwig <dludwig@pobox.com>
parents: 8576
diff changeset
   733
            args->Handled = true;
462760a8b82e WinRT: simulate keyboard events on Windows Phone 8 back-button presses
David Ludwig <dludwig@pobox.com>
parents: 8576
diff changeset
   734
        }
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   735
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   736
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   737
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8581
diff changeset
   738