author  David Ludwig <dludwig@pobox.com> 
Mon, 11 Apr 2016 00:22:39 0400  
changeset 10144  aa9904a56acf 
parent 9998  f67cf37e9cd4 
permissions  rwrr 
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 
9998
f67cf37e9cd4
Updated copyright to 2016
Sam Lantinga <slouken@libsdl.org>
parents:
9993
diff
changeset

3 
Copyright (C) 19972016 Sam Lantinga <slouken@libsdl.org> 
8616
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 'asis', 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 WinRTrelated 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 appsuspend, 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 appsuspend, 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 appsuspend, 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 appsuspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents:
8678
diff
changeset

76 
*/ 
dd52820b7f5c
WinRT: Call IDXGIDevice3::Trim before appsuspend, 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 appsuspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents:
8678
diff
changeset

78 
#endif 
dd52820b7f5c
WinRT: Call IDXGIDevice3::Trim before appsuspend, 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 
// Compiletime 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 
// nonglobal, 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 .appxmanifestset 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/enus/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/DisplayOrientationSample19a58e93). 
8757
aeeeb47a5a77
WinRT: displayinformation 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 
9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

187 
WINRT_ProcessWindowSizeChange() // TODO: Pass an SDL_Windowidentifying thing into WINRT_ProcessWindowSizeChange() 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

188 
{ 
9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

189 
CoreWindow ^ coreWindow = CoreWindow::GetForCurrentThread(); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

190 
if (coreWindow) { 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

191 
if (WINRT_GlobalSDLWindow) { 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

192 
SDL_Window * window = WINRT_GlobalSDLWindow; 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

193 
SDL_WindowData * data = (SDL_WindowData *) window>driverdata; 
8664
565698ab1c40
WinRT globals cleanup: Removed WINRT_GlobalSDLVideoDevice
David Ludwig <dludwig@pobox.com>
parents:
8621
diff
changeset

194 

9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

195 
int x = WINRT_DIPS_TO_PHYSICAL_PIXELS(data>coreWindow>Bounds.Left); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

196 
int y = WINRT_DIPS_TO_PHYSICAL_PIXELS(data>coreWindow>Bounds.Top); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

197 
int w = WINRT_DIPS_TO_PHYSICAL_PIXELS(data>coreWindow>Bounds.Width); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

198 
int h = WINRT_DIPS_TO_PHYSICAL_PIXELS(data>coreWindow>Bounds.Height); 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

199 

9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

200 
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) && (NTDDI_VERSION == NTDDI_WIN8) 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

201 
/* WinPhone 8.0 always keeps its native window size in portrait, 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

202 
regardless of orientation. This changes in WinPhone 8.1, 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

203 
in which the native window's size changes along with 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

204 
orientation. 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

205 

9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

206 
Attempt to emulate WinPhone 8.1's behavior on WinPhone 8.0, with 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

207 
regards to window size. This fixes a rendering bug that occurs 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

208 
when a WinPhone 8.0 app is rotated to either 90 or 270 degrees. 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

209 
*/ 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

210 
const DisplayOrientations currentOrientation = WINRT_DISPLAY_PROPERTY(CurrentOrientation); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

211 
switch (currentOrientation) { 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

212 
case DisplayOrientations::Landscape: 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

213 
case DisplayOrientations::LandscapeFlipped: { 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

214 
int tmp = w; 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

215 
w = h; 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

216 
h = tmp; 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

217 
} break; 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

218 
} 
8755
f2fc45874b9c
Fixed renderingalignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents:
8679
diff
changeset

219 
#endif 
9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

220 

9971
fa7c016ac2d3
WinRT: made bug 3202/3213's fix apply for WinRT apps
David Ludwig <dludwig@pobox.com>
parents:
9957
diff
changeset

221 
const Uint32 latestFlags = WINRT_DetectWindowFlags(window); 
fa7c016ac2d3
WinRT: made bug 3202/3213's fix apply for WinRT apps
David Ludwig <dludwig@pobox.com>
parents:
9957
diff
changeset

222 
if (latestFlags & SDL_WINDOW_MAXIMIZED) { 
fa7c016ac2d3
WinRT: made bug 3202/3213's fix apply for WinRT apps
David Ludwig <dludwig@pobox.com>
parents:
9957
diff
changeset

223 
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MAXIMIZED, 0, 0); 
9992
2117f13501e8
WinRT: fixed bug whereby a Win8.x app's SDL_Window wasn't getting demarked as maximized (on window restore)
David Ludwig <dludwig@pobox.com>
parents:
9991
diff
changeset

224 
} else { 
2117f13501e8
WinRT: fixed bug whereby a Win8.x app's SDL_Window wasn't getting demarked as maximized (on window restore)
David Ludwig <dludwig@pobox.com>
parents:
9991
diff
changeset

225 
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0); 
9971
fa7c016ac2d3
WinRT: made bug 3202/3213's fix apply for WinRT apps
David Ludwig <dludwig@pobox.com>
parents:
9957
diff
changeset

226 
} 
fa7c016ac2d3
WinRT: made bug 3202/3213's fix apply for WinRT apps
David Ludwig <dludwig@pobox.com>
parents:
9957
diff
changeset

227 

fa7c016ac2d3
WinRT: made bug 3202/3213's fix apply for WinRT apps
David Ludwig <dludwig@pobox.com>
parents:
9957
diff
changeset

228 
WINRT_UpdateWindowFlags(window, SDL_WINDOW_FULLSCREEN_DESKTOP); 
9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

229 

355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

230 
/* The window can move during a resize event, such as when maximizing 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

231 
or resizing from a corner */ 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

232 
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, x, y); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

233 
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, w, h); 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

234 
} 
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 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

238 
SDL_WinRTApp::SDL_WinRTApp() : 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

239 
m_windowClosed(false), 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

240 
m_windowVisible(true) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

241 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

242 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

243 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

244 
void SDL_WinRTApp::Initialize(CoreApplicationView^ applicationView) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

245 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

246 
applicationView>Activated += 
9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

247 
ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &SDL_WinRTApp::OnAppActivated); 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

248 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

249 
CoreApplication::Suspending += 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

250 
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

251 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

252 
CoreApplication::Resuming += 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

253 
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

254 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

255 
CoreApplication::Exiting += 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

256 
ref new EventHandler<Platform::Object^>(this, &SDL_WinRTApp::OnExiting); 
10144
aa9904a56acf
WinRT: bug hackfix  gamepad detection was failing on Xbox One
David Ludwig <dludwig@pobox.com>
parents:
9998
diff
changeset

257 

aa9904a56acf
WinRT: bug hackfix  gamepad detection was failing on Xbox One
David Ludwig <dludwig@pobox.com>
parents:
9998
diff
changeset

258 
#if NTDDI_VERSION >= NTDDI_WIN10 
aa9904a56acf
WinRT: bug hackfix  gamepad detection was failing on Xbox One
David Ludwig <dludwig@pobox.com>
parents:
9998
diff
changeset

259 
/* HACK ALERT! Xbox One doesn't seem to detect gamepads unless something 
aa9904a56acf
WinRT: bug hackfix  gamepad detection was failing on Xbox One
David Ludwig <dludwig@pobox.com>
parents:
9998
diff
changeset

260 
gets registered to receive Win10's Windows.Gaming.Input.Gamepad.GamepadAdded 
aa9904a56acf
WinRT: bug hackfix  gamepad detection was failing on Xbox One
David Ludwig <dludwig@pobox.com>
parents:
9998
diff
changeset

261 
events. We'll register an event handler for these events here, to make 
aa9904a56acf
WinRT: bug hackfix  gamepad detection was failing on Xbox One
David Ludwig <dludwig@pobox.com>
parents:
9998
diff
changeset

262 
sure that gamepad detection works later on, if requested. 
aa9904a56acf
WinRT: bug hackfix  gamepad detection was failing on Xbox One
David Ludwig <dludwig@pobox.com>
parents:
9998
diff
changeset

263 
*/ 
aa9904a56acf
WinRT: bug hackfix  gamepad detection was failing on Xbox One
David Ludwig <dludwig@pobox.com>
parents:
9998
diff
changeset

264 
Windows::Gaming::Input::Gamepad::GamepadAdded += 
aa9904a56acf
WinRT: bug hackfix  gamepad detection was failing on Xbox One
David Ludwig <dludwig@pobox.com>
parents:
9998
diff
changeset

265 
ref new Windows::Foundation::EventHandler<Windows::Gaming::Input::Gamepad^>( 
aa9904a56acf
WinRT: bug hackfix  gamepad detection was failing on Xbox One
David Ludwig <dludwig@pobox.com>
parents:
9998
diff
changeset

266 
this, &SDL_WinRTApp::OnGamepadAdded 
aa9904a56acf
WinRT: bug hackfix  gamepad detection was failing on Xbox One
David Ludwig <dludwig@pobox.com>
parents:
9998
diff
changeset

267 
); 
aa9904a56acf
WinRT: bug hackfix  gamepad detection was failing on Xbox One
David Ludwig <dludwig@pobox.com>
parents:
9998
diff
changeset

268 
#endif 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

269 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

270 

8621
5252788cb448
Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents:
8616
diff
changeset

271 
#if NTDDI_VERSION > NTDDI_WIN8 
5252788cb448
Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents:
8616
diff
changeset

272 
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

273 
#else 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

274 
void SDL_WinRTApp::OnOrientationChanged(Object^ sender) 
8621
5252788cb448
Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents:
8616
diff
changeset

275 
#endif 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

276 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

277 
#if LOG_ORIENTATION_EVENTS==1 
9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

278 
{ 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

279 
CoreWindow^ window = CoreWindow::GetForCurrentThread(); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

280 
if (window) { 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

281 
SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, CoreWindow Bounds={%f,%f,%f,%f}\n", 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

282 
__FUNCTION__, 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

283 
WINRT_DISPLAY_PROPERTY(CurrentOrientation), 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

284 
WINRT_DISPLAY_PROPERTY(NativeOrientation), 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

285 
WINRT_DISPLAY_PROPERTY(AutoRotationPreferences), 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

286 
window>Bounds.X, 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

287 
window>Bounds.Y, 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

288 
window>Bounds.Width, 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

289 
window>Bounds.Height); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

290 
} else { 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

291 
SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d\n", 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

292 
__FUNCTION__, 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

293 
WINRT_DISPLAY_PROPERTY(CurrentOrientation), 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

294 
WINRT_DISPLAY_PROPERTY(NativeOrientation), 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

295 
WINRT_DISPLAY_PROPERTY(AutoRotationPreferences)); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

296 
} 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

297 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

298 
#endif 
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 
WINRT_ProcessWindowSizeChange(); 
9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

301 

355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

302 
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

303 
// HACK: Make sure that orientation changes 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

304 
// lead to the Direct3D renderer's viewport getting updated: 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

305 
// 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

306 
// For some reason, this doesn't seem to need to be done on Windows 8.x, 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

307 
// even when going from Landscape to LandscapeFlipped. It only seems to 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

308 
// be needed on Windows Phone, at least when I tested on my devices. 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

309 
// I'm not currently sure why this is, but it seems to work fine.  David L. 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

310 
// 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

311 
// 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 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

312 
SDL_Window * window = WINRT_GlobalSDLWindow; 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

313 
if (window) { 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

314 
SDL_WindowData * data = (SDL_WindowData *)window>driverdata; 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

315 
int w = WINRT_DIPS_TO_PHYSICAL_PIXELS(data>coreWindow>Bounds.Width); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

316 
int h = WINRT_DIPS_TO_PHYSICAL_PIXELS(data>coreWindow>Bounds.Height); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

317 
SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_SIZE_CHANGED, w, h); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

318 
} 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

319 
#endif 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

320 

8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

321 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

322 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

323 
void SDL_WinRTApp::SetWindow(CoreWindow^ window) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

324 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

325 
#if LOG_WINDOW_EVENTS==1 
9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

326 
SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, window bounds={%f, %f, %f,%f}\n", 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

327 
__FUNCTION__, 
8755
f2fc45874b9c
Fixed renderingalignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents:
8679
diff
changeset

328 
WINRT_DISPLAY_PROPERTY(CurrentOrientation), 
f2fc45874b9c
Fixed renderingalignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents:
8679
diff
changeset

329 
WINRT_DISPLAY_PROPERTY(NativeOrientation), 
f2fc45874b9c
Fixed renderingalignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents:
8679
diff
changeset

330 
WINRT_DISPLAY_PROPERTY(AutoRotationPreferences), 
9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

331 
window>Bounds.X, 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

332 
window>Bounds.Y, 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

333 
window>Bounds.Width, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

334 
window>Bounds.Height); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

335 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

336 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

337 
window>SizeChanged += 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

338 
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

339 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

340 
window>VisibilityChanged += 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

341 
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

342 

9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

343 
window>Activated += 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

344 
ref new TypedEventHandler<CoreWindow^, WindowActivatedEventArgs^>(this, &SDL_WinRTApp::OnWindowActivated); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

345 

8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

346 
window>Closed += 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

347 
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

348 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

349 
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

350 
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

351 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

352 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

353 
window>PointerPressed += 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

354 
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

355 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

356 
window>PointerMoved += 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

357 
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

358 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

359 
window>PointerReleased += 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

360 
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

361 

9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

362 
window>PointerEntered += 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

363 
ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerEntered); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

364 

355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

365 
window>PointerExited += 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

366 
ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerExited); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

367 

8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

368 
window>PointerWheelChanged += 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

369 
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

370 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

371 
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

372 
// Retrieves relativeonly mouse movements: 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

373 
Windows::Devices::Input::MouseDevice::GetForCurrentView()>MouseMoved += 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

374 
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

375 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

376 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

377 
window>KeyDown += 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

378 
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

379 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

380 
window>KeyUp += 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

381 
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

382 

9240
dc4ad21d8596
WinRT: added initial SDL_TEXTINPUT support
David Ludwig <dludwig@pobox.com>
parents:
8757
diff
changeset

383 
window>CharacterReceived += 
dc4ad21d8596
WinRT: added initial SDL_TEXTINPUT support
David Ludwig <dludwig@pobox.com>
parents:
8757
diff
changeset

384 
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

385 

9957
0be86b512d34
WinRT: fixed bug: Back button(s) weren't working on Win10
David Ludwig <dludwig@pobox.com>
parents:
9931
diff
changeset

386 
#if NTDDI_VERSION >= NTDDI_WIN10 
0be86b512d34
WinRT: fixed bug: Back button(s) weren't working on Win10
David Ludwig <dludwig@pobox.com>
parents:
9931
diff
changeset

387 
Windows::UI::Core::SystemNavigationManager::GetForCurrentView()>BackRequested += 
0be86b512d34
WinRT: fixed bug: Back button(s) weren't working on Win10
David Ludwig <dludwig@pobox.com>
parents:
9931
diff
changeset

388 
ref new EventHandler<BackRequestedEventArgs^>(this, &SDL_WinRTApp::OnBackButtonPressed); 
0be86b512d34
WinRT: fixed bug: Back button(s) weren't working on Win10
David Ludwig <dludwig@pobox.com>
parents:
9931
diff
changeset

389 
#elif WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

390 
HardwareButtons::BackPressed += 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

391 
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

392 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

393 

8621
5252788cb448
Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents:
8616
diff
changeset

394 
#if NTDDI_VERSION > NTDDI_WIN8 
5252788cb448
Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents:
8616
diff
changeset

395 
DisplayInformation::GetForCurrentView()>OrientationChanged += 
5252788cb448
Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents:
8616
diff
changeset

396 
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

397 
#else 
5252788cb448
Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents:
8616
diff
changeset

398 
DisplayProperties::OrientationChanged += 
5252788cb448
Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents:
8616
diff
changeset

399 
ref new DisplayPropertiesEventHandler(this, &SDL_WinRTApp::OnOrientationChanged); 
5252788cb448
Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents:
8616
diff
changeset

400 
#endif 
5252788cb448
Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents:
8616
diff
changeset

401 

5252788cb448
Fixed broken rotation detection routines on WinRT
David Ludwig <dludwig@pobox.com>
parents:
8616
diff
changeset

402 
// 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

403 
// 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

404 
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

405 

9931
0bb3dd1c95f2
WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents:
9924
diff
changeset

406 
#if (WINAPI_FAMILY == WINAPI_FAMILY_APP) && (NTDDI_VERSION < NTDDI_WIN10) // for Windows 8/8.1/RT apps... (and not Phone apps) 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

407 
// 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

408 
// 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

409 
// to be done for networkenabled apps, as per Windows Store requirements. 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

410 
using namespace Windows::UI::ApplicationSettings; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

411 
SettingsPane::GetForCurrentView()>CommandsRequested += 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

412 
ref new TypedEventHandler<SettingsPane^, SettingsPaneCommandsRequestedEventArgs^> 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

413 
(this, &SDL_WinRTApp::OnSettingsPaneCommandsRequested); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

414 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

415 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

416 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

417 
void SDL_WinRTApp::Load(Platform::String^ entryPoint) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

418 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

419 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

420 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

421 
void SDL_WinRTApp::Run() 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

422 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

423 
SDL_SetMainReady(); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

424 
if (WINRT_SDLAppEntryPoint) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

425 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

426 
// TODO, WinRT: pass the Cstyle main() a reasonably realistic 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

427 
// representation of command line arguments. 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

428 
int argc = 0; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

429 
char **argv = NULL; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

430 
WINRT_SDLAppEntryPoint(argc, argv); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

431 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

432 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

433 

8666
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

434 
static bool IsSDLWindowEventPending(SDL_WindowEventID windowEventID) 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

435 
{ 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

436 
SDL_Event events[128]; 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

437 
const int count = SDL_PeepEvents(events, sizeof(events)/sizeof(SDL_Event), SDL_PEEKEVENT, SDL_WINDOWEVENT, SDL_WINDOWEVENT); 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

438 
for (int i = 0; i < count; ++i) { 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

439 
if (events[i].window.event == windowEventID) { 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

440 
return true; 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

441 
} 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

442 
} 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

443 
return false; 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

444 
} 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

445 

20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

446 
bool SDL_WinRTApp::ShouldWaitForAppResumeEvents() 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

447 
{ 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

448 
/* Don't wait if the app is visible: */ 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

449 
if (m_windowVisible) { 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

450 
return false; 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

451 
} 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

452 

20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

453 
/* Don't wait until the windowhide events finish processing. 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

454 
* Do note that if an appsuspend event is sent (as indicated 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

455 
* by SDL_APP_WILLENTERBACKGROUND and SDL_APP_DIDENTERBACKGROUND 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

456 
* events), then this code may be a moot point, as WinRT's 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

457 
* own event pump (aka ProcessEvents()) will pause regardless 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

458 
* of what we do here. This happens on Windows Phone 8, to note. 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

459 
* Windows 8.x apps, on the other hand, may get a chance to run 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

460 
* these. 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

461 
*/ 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

462 
if (IsSDLWindowEventPending(SDL_WINDOWEVENT_HIDDEN)) { 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

463 
return false; 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

464 
} else if (IsSDLWindowEventPending(SDL_WINDOWEVENT_FOCUS_LOST)) { 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

465 
return false; 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

466 
} else if (IsSDLWindowEventPending(SDL_WINDOWEVENT_MINIMIZED)) { 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

467 
return false; 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

468 
} 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

469 

20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

470 
return true; 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

471 
} 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/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 
void SDL_WinRTApp::PumpEvents() 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

474 
{ 
8666
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

475 
if (!m_windowClosed) { 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

476 
if (!ShouldWaitForAppResumeEvents()) { 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

477 
/* This is the normal way in which events should be pumped. 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

478 
* 'ProcessAllIfPresent' will make ProcessEvents() process anywhere 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

479 
* from zero to N events, and will then return. 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

480 
*/ 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

481 
CoreWindow::GetForCurrentThread()>Dispatcher>ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); 
8666
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

482 
} else { 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

483 
/* This style of eventpumping, with 'ProcessOneAndAllPending', 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

484 
* will cause anywhere from one to N events to be processed. If 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

485 
* at least one event is processed, the call will return. If 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

486 
* no events are pending, then the call will wait until one is 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

487 
* available, and will not return (to the caller) until this 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

488 
* happens! This should only occur when the app is hidden. 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

489 
*/ 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

490 
CoreWindow::GetForCurrentThread()>Dispatcher>ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

491 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

492 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

493 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

494 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

495 
void SDL_WinRTApp::Uninitialize() 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

496 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

497 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

498 

9931
0bb3dd1c95f2
WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents:
9924
diff
changeset

499 
#if (WINAPI_FAMILY == WINAPI_FAMILY_APP) && (NTDDI_VERSION < NTDDI_WIN10) 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

500 
void SDL_WinRTApp::OnSettingsPaneCommandsRequested( 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

501 
Windows::UI::ApplicationSettings::SettingsPane ^p, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

502 
Windows::UI::ApplicationSettings::SettingsPaneCommandsRequestedEventArgs ^args) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

503 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

504 
using namespace Platform; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

505 
using namespace Windows::UI::ApplicationSettings; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

506 
using namespace Windows::UI::Popups; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

507 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

508 
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

509 
String ^privacyPolicyLabel = nullptr; // label/link text 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

510 
const char *tmpHintValue = NULL; // SDL_GetHintretrieved value, used immediately 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

511 
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

512 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

513 
// 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

514 
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

515 
if (tmpHintValue && tmpHintValue[0] != '\0') { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

516 
// 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

517 
tmpStr = WIN_UTF8ToString(tmpHintValue); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

518 
privacyPolicyURL = 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 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

521 
// Optionally retrieve custom labeltext for the link. If this isn't 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

522 
// 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

523 
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

524 
if (tmpHintValue && tmpHintValue[0] != '\0') { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

525 
tmpStr = WIN_UTF8ToString(tmpHintValue); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

526 
privacyPolicyLabel = ref new String(tmpStr); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

527 
SDL_free(tmpStr); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

528 
} else { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

529 
privacyPolicyLabel = ref new String(L"Privacy Policy"); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

530 
} 
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 
// 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

533 
// clicked: 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

534 
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

535 
ref new UICommandInvokedHandler([=](IUICommand ^) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

536 
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

537 
})); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

538 
args>Request>ApplicationCommands>Append(cmd); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

539 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

540 
} 
9931
0bb3dd1c95f2
WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents:
9924
diff
changeset

541 
#endif // if (WINAPI_FAMILY == WINAPI_FAMILY_APP) && (NTDDI_VERSION < NTDDI_WIN10) 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

542 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

543 
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

544 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

545 
#if LOG_WINDOW_EVENTS==1 
9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

546 
SDL_Log("%s, size={%f,%f}, bounds={%f,%f,%f,%f}, current orientation=%d, native orientation=%d, auto rot. pref=%d, WINRT_GlobalSDLWindow?=%s\n", 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

547 
__FUNCTION__, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

548 
args>Size.Width, args>Size.Height, 
9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

549 
sender>Bounds.X, sender>Bounds.Y, sender>Bounds.Width, sender>Bounds.Height, 
8755
f2fc45874b9c
Fixed renderingalignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents:
8679
diff
changeset

550 
WINRT_DISPLAY_PROPERTY(CurrentOrientation), 
f2fc45874b9c
Fixed renderingalignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents:
8679
diff
changeset

551 
WINRT_DISPLAY_PROPERTY(NativeOrientation), 
f2fc45874b9c
Fixed renderingalignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents:
8679
diff
changeset

552 
WINRT_DISPLAY_PROPERTY(AutoRotationPreferences), 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

553 
(WINRT_GlobalSDLWindow ? "yes" : "no")); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

554 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

555 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

556 
WINRT_ProcessWindowSizeChange(); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

557 
} 
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 
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

560 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

561 
#if LOG_WINDOW_EVENTS==1 
9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

562 
SDL_Log("%s, visible?=%s, bounds={%f,%f,%f,%f}, WINRT_GlobalSDLWindow?=%s\n", 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

563 
__FUNCTION__, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

564 
(args>Visible ? "yes" : "no"), 
9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

565 
sender>Bounds.X, sender>Bounds.Y, 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

566 
sender>Bounds.Width, sender>Bounds.Height, 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

567 
(WINRT_GlobalSDLWindow ? "yes" : "no")); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

568 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

569 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

570 
m_windowVisible = args>Visible; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

571 
if (WINRT_GlobalSDLWindow) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

572 
SDL_bool wasSDLWindowSurfaceValid = WINRT_GlobalSDLWindow>surface_valid; 
9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

573 
Uint32 latestWindowFlags = WINRT_DetectWindowFlags(WINRT_GlobalSDLWindow); 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

574 
if (args>Visible) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

575 
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

576 
SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0); 
9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

577 
if (latestWindowFlags & SDL_WINDOW_MAXIMIZED) { 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

578 
SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_MAXIMIZED, 0, 0); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

579 
} else { 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

580 
SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_RESTORED, 0, 0); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

581 
} 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

582 
} else { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

583 
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

584 
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

585 
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

586 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

587 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

588 
// HACK: Prevent SDL's windowhide handling code, which currently 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

589 
// 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

590 
// 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

591 
// 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

592 
// 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

593 
// fake window resize can be prevented. 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

594 
WINRT_GlobalSDLWindow>surface_valid = wasSDLWindowSurfaceValid; 
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 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

597 

9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

598 
void SDL_WinRTApp::OnWindowActivated(CoreWindow^ sender, WindowActivatedEventArgs^ args) 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

599 
{ 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

600 
#if LOG_WINDOW_EVENTS==1 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

601 
SDL_Log("%s, WINRT_GlobalSDLWindow?=%s\n\n", 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

602 
__FUNCTION__, 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

603 
(WINRT_GlobalSDLWindow ? "yes" : "no")); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

604 
#endif 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

605 

355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

606 
/* There's no property in Win 8.x to tell whether a window is active or 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

607 
not. [De]activation events are, however, sent to the app. We'll just 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

608 
record those, in case the CoreWindow gets wrapped by an SDL_Window at 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

609 
some future time. 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

610 
*/ 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

611 
sender>CustomProperties>Insert("SDLHelperWindowActivationState", args>WindowActivationState); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

612 

355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

613 
SDL_Window * window = WINRT_GlobalSDLWindow; 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

614 
if (window) { 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

615 
if (args>WindowActivationState != CoreWindowActivationState::Deactivated) { 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

616 
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SHOWN, 0, 0); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

617 
if (SDL_GetKeyboardFocus() != window) { 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

618 
SDL_SetKeyboardFocus(window); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

619 
} 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

620 

355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

621 
/* Send a mousemotion event as appropriate. 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

622 
This doesn't work when called from OnPointerEntered, at least 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

623 
not in WinRT CoreWindow apps (as OnPointerEntered doesn't 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

624 
appear to be called after windowreactivation, at least not 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

625 
in Windows 10, Build 10586.3 (November 2015 update, nonbeta). 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

626 

355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

627 
Don't do it on WinPhone 8.0 though, as CoreWindow's 'PointerPosition' 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

628 
property isn't available. 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

629 
*/ 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

630 
#if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP)  (NTDDI_VERSION >= NTDDI_WINBLUE) 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

631 
Point cursorPos = WINRT_TransformCursorPosition(window, sender>PointerPosition, TransformToSDLWindowSize); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

632 
SDL_SendMouseMotion(window, 0, 0, (int)cursorPos.X, (int)cursorPos.Y); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

633 
#endif 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

634 

355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

635 
/* TODO, WinRT: see if the Win32 bugfix from https://hg.libsdl.org/SDL/rev/d278747da408 needs to be applied (on window activation) */ 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

636 
//WIN_CheckAsyncMouseRelease(data); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

637 

355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

638 
/* TODO, WinRT: implement clipboard support, if possible */ 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

639 
///* 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

640 
// * FIXME: Update keyboard state 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

641 
// */ 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

642 
//WIN_CheckClipboardUpdate(data>videodata); 
9991
5843ea14ca5c
Fixed Bug 3217  WinRT: after alttab'ing back into fullscreen app, mouse cursor is sometimes wrong
David Ludwig <dludwig@pobox.com>
parents:
9971
diff
changeset

643 

5843ea14ca5c
Fixed Bug 3217  WinRT: after alttab'ing back into fullscreen app, mouse cursor is sometimes wrong
David Ludwig <dludwig@pobox.com>
parents:
9971
diff
changeset

644 
// HACK: Resetting the mousecursor here seems to fix 
5843ea14ca5c
Fixed Bug 3217  WinRT: after alttab'ing back into fullscreen app, mouse cursor is sometimes wrong
David Ludwig <dludwig@pobox.com>
parents:
9971
diff
changeset

645 
// https://bugzilla.libsdl.org/show_bug.cgi?id=3217, whereby a 
5843ea14ca5c
Fixed Bug 3217  WinRT: after alttab'ing back into fullscreen app, mouse cursor is sometimes wrong
David Ludwig <dludwig@pobox.com>
parents:
9971
diff
changeset

646 
// WinRT app's mouse cursor may switch to Windows' 'wait' cursor, 
5843ea14ca5c
Fixed Bug 3217  WinRT: after alttab'ing back into fullscreen app, mouse cursor is sometimes wrong
David Ludwig <dludwig@pobox.com>
parents:
9971
diff
changeset

647 
// after a user alttabs back into a fullscreened SDL app. 
5843ea14ca5c
Fixed Bug 3217  WinRT: after alttab'ing back into fullscreen app, mouse cursor is sometimes wrong
David Ludwig <dludwig@pobox.com>
parents:
9971
diff
changeset

648 
// This bug does not appear to reproduce 100% of the time. 
5843ea14ca5c
Fixed Bug 3217  WinRT: after alttab'ing back into fullscreen app, mouse cursor is sometimes wrong
David Ludwig <dludwig@pobox.com>
parents:
9971
diff
changeset

649 
// It may be a bug in Windows itself (v.10.0.586.36, as tested, 
5843ea14ca5c
Fixed Bug 3217  WinRT: after alttab'ing back into fullscreen app, mouse cursor is sometimes wrong
David Ludwig <dludwig@pobox.com>
parents:
9971
diff
changeset

650 
// and the mostrecent as of this writing). 
5843ea14ca5c
Fixed Bug 3217  WinRT: after alttab'ing back into fullscreen app, mouse cursor is sometimes wrong
David Ludwig <dludwig@pobox.com>
parents:
9971
diff
changeset

651 
SDL_SetCursor(NULL); 
9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

652 
} else { 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

653 
if (SDL_GetKeyboardFocus() == window) { 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

654 
SDL_SetKeyboardFocus(NULL); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

655 
} 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

656 
} 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

657 
} 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

658 
} 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

659 

8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

660 
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

661 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

662 
#if LOG_WINDOW_EVENTS==1 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

663 
SDL_Log("%s\n", __FUNCTION__); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

664 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

665 
m_windowClosed = true; 
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 

9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

668 
void SDL_WinRTApp::OnAppActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args) 
8582
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 
CoreWindow::GetForCurrentThread()>Activate(); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

671 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

672 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

673 
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

674 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

675 
// 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

676 
// 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

677 
// 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

678 
// the app will be forced to exit. 
8665
b987c561c218
WinRT: Made appbackgrounded events get sent at separate, distinct times.
David Ludwig <dludwig@pobox.com>
parents:
8664
diff
changeset

679 

b987c561c218
WinRT: Made appbackgrounded events get sent at separate, distinct times.
David Ludwig <dludwig@pobox.com>
parents:
8664
diff
changeset

680 
// ... but first, let the app know it's about to go to the background. 
b987c561c218
WinRT: Made appbackgrounded events get sent at separate, distinct times.
David Ludwig <dludwig@pobox.com>
parents:
8664
diff
changeset

681 
// The separation of events may be important, given that the deferral 
b987c561c218
WinRT: Made appbackgrounded events get sent at separate, distinct times.
David Ludwig <dludwig@pobox.com>
parents:
8664
diff
changeset

682 
// runs in a separate thread. This'll make SDL_APP_WILLENTERBACKGROUND 
b987c561c218
WinRT: Made appbackgrounded events get sent at separate, distinct times.
David Ludwig <dludwig@pobox.com>
parents:
8664
diff
changeset

683 
// the only event among the two that runs in the main thread. Given 
b987c561c218
WinRT: Made appbackgrounded events get sent at separate, distinct times.
David Ludwig <dludwig@pobox.com>
parents:
8664
diff
changeset

684 
// that a few WinRT operations can only be done from the main thread 
b987c561c218
WinRT: Made appbackgrounded events get sent at separate, distinct times.
David Ludwig <dludwig@pobox.com>
parents:
8664
diff
changeset

685 
// (things that access the WinRT CoreWindow are one example of this), 
b987c561c218
WinRT: Made appbackgrounded events get sent at separate, distinct times.
David Ludwig <dludwig@pobox.com>
parents:
8664
diff
changeset

686 
// this could be important. 
b987c561c218
WinRT: Made appbackgrounded events get sent at separate, distinct times.
David Ludwig <dludwig@pobox.com>
parents:
8664
diff
changeset

687 
SDL_SendAppEvent(SDL_APP_WILLENTERBACKGROUND); 
b987c561c218
WinRT: Made appbackgrounded events get sent at separate, distinct times.
David Ludwig <dludwig@pobox.com>
parents:
8664
diff
changeset

688 

8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

689 
SuspendingDeferral^ deferral = args>SuspendingOperation>GetDeferral(); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

690 
create_task([this, deferral]() 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

691 
{ 
8666
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

692 
// Send an app didenterbackground event immediately to observers. 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

693 
// 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

694 
// 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

695 
// 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

696 
// 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

697 
// SDL_AddEventWatch() may be used to receive appsuspend events on 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

698 
// WinRT. 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

699 
SDL_SendAppEvent(SDL_APP_DIDENTERBACKGROUND); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

700 

8679
dd52820b7f5c
WinRT: Call IDXGIDevice3::Trim before appsuspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents:
8678
diff
changeset

701 
// Let the Direct3D 11 renderer prepare for the app to be backgrounded. 
dd52820b7f5c
WinRT: Call IDXGIDevice3::Trim before appsuspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents:
8678
diff
changeset

702 
// This is necessary for Windows 8.1, possibly elsewhere in the future. 
dd52820b7f5c
WinRT: Call IDXGIDevice3::Trim before appsuspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents:
8678
diff
changeset

703 
// More details at: http://msdn.microsoft.com/enus/library/windows/apps/Hh994929.aspx 
dd52820b7f5c
WinRT: Call IDXGIDevice3::Trim before appsuspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents:
8678
diff
changeset

704 
#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED 
dd52820b7f5c
WinRT: Call IDXGIDevice3::Trim before appsuspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents:
8678
diff
changeset

705 
if (WINRT_GlobalSDLWindow) { 
dd52820b7f5c
WinRT: Call IDXGIDevice3::Trim before appsuspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents:
8678
diff
changeset

706 
SDL_Renderer * renderer = SDL_GetRenderer(WINRT_GlobalSDLWindow); 
dd52820b7f5c
WinRT: Call IDXGIDevice3::Trim before appsuspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents:
8678
diff
changeset

707 
if (renderer && (SDL_strcmp(renderer>info.name, "direct3d11") == 0)) { 
dd52820b7f5c
WinRT: Call IDXGIDevice3::Trim before appsuspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents:
8678
diff
changeset

708 
D3D11_Trim(renderer); 
dd52820b7f5c
WinRT: Call IDXGIDevice3::Trim before appsuspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents:
8678
diff
changeset

709 
} 
dd52820b7f5c
WinRT: Call IDXGIDevice3::Trim before appsuspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents:
8678
diff
changeset

710 
} 
dd52820b7f5c
WinRT: Call IDXGIDevice3::Trim before appsuspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents:
8678
diff
changeset

711 
#endif 
dd52820b7f5c
WinRT: Call IDXGIDevice3::Trim before appsuspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents:
8678
diff
changeset

712 

8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

713 
deferral>Complete(); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

714 
}); 
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 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

717 
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

718 
{ 
8666
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

719 
// Restore any data or state that was unloaded on suspend. By default, data 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

720 
// and state are persisted when resuming from suspend. Note that these events 
20d52dc1a24a
WinRT: Miscellaneous appbackgrounding/restoring event fixes and additions
David Ludwig <dludwig@pobox.com>
parents:
8665
diff
changeset

721 
// 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

722 
SDL_SendAppEvent(SDL_APP_WILLENTERFOREGROUND); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

723 
SDL_SendAppEvent(SDL_APP_DIDENTERFOREGROUND); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

724 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

725 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

726 
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

727 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

728 
SDL_SendAppEvent(SDL_APP_TERMINATING); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

729 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

730 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

731 
static void 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

732 
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

733 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

734 
Windows::UI::Input::PointerPoint ^ pt = args>CurrentPoint; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

735 
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

736 
header, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

737 
pt>Position.X, pt>Position.Y, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

738 
transformedPoint.X, transformedPoint.Y, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

739 
pt>Properties>MouseWheelDelta, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

740 
pt>FrameId, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

741 
pt>PointerId, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

742 
WINRT_GetSDLButtonForPointerPoint(pt)); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

743 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

744 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

745 
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

746 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

747 
#if LOG_POINTER_EVENTS 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

748 
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

749 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

750 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

751 
WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args>CurrentPoint); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

752 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

753 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

754 
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

755 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

756 
#if LOG_POINTER_EVENTS 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

757 
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

758 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

759 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

760 
WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args>CurrentPoint); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

761 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

762 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

763 
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

764 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

765 
#if LOG_POINTER_EVENTS 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

766 
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

767 
#endif 
9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

768 

355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

769 
WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args>CurrentPoint); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

770 
} 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

771 

9924
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

772 
void SDL_WinRTApp::OnPointerEntered(CoreWindow^ sender, PointerEventArgs^ args) 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

773 
{ 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

774 
#if LOG_POINTER_EVENTS 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

775 
WINRT_LogPointerEvent("pointer entered", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args>CurrentPoint>Position, TransformToSDLWindowSize)); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

776 
#endif 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

777 

355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

778 
WINRT_ProcessPointerEnteredEvent(WINRT_GlobalSDLWindow, args>CurrentPoint); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

779 
} 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

780 

355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

781 
void SDL_WinRTApp::OnPointerExited(CoreWindow^ sender, PointerEventArgs^ args) 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

782 
{ 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

783 
#if LOG_POINTER_EVENTS 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

784 
WINRT_LogPointerEvent("pointer exited", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args>CurrentPoint>Position, TransformToSDLWindowSize)); 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

785 
#endif 
355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

786 

355cccccc7dc
WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents:
9619
diff
changeset

787 
WINRT_ProcessPointerExitedEvent(WINRT_GlobalSDLWindow, args>CurrentPoint); 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

788 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

789 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

790 
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

791 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

792 
#if LOG_POINTER_EVENTS 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

793 
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

794 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

795 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

796 
WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args>CurrentPoint); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

797 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

798 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

799 
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

800 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

801 
WINRT_ProcessMouseMovedEvent(WINRT_GlobalSDLWindow, args); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

802 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

803 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

804 
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

805 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

806 
WINRT_ProcessKeyDownEvent(args); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

807 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

808 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

809 
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

810 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

811 
WINRT_ProcessKeyUpEvent(args); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

812 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

813 

9240
dc4ad21d8596
WinRT: added initial SDL_TEXTINPUT support
David Ludwig <dludwig@pobox.com>
parents:
8757
diff
changeset

814 
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

815 
{ 
dc4ad21d8596
WinRT: added initial SDL_TEXTINPUT support
David Ludwig <dludwig@pobox.com>
parents:
8757
diff
changeset

816 
WINRT_ProcessCharacterReceivedEvent(args); 
dc4ad21d8596
WinRT: added initial SDL_TEXTINPUT support
David Ludwig <dludwig@pobox.com>
parents:
8757
diff
changeset

817 
} 
dc4ad21d8596
WinRT: added initial SDL_TEXTINPUT support
David Ludwig <dludwig@pobox.com>
parents:
8757
diff
changeset

818 

9957
0be86b512d34
WinRT: fixed bug: Back button(s) weren't working on Win10
David Ludwig <dludwig@pobox.com>
parents:
9931
diff
changeset

819 
template <typename BackButtonEventArgs> 
0be86b512d34
WinRT: fixed bug: Back button(s) weren't working on Win10
David Ludwig <dludwig@pobox.com>
parents:
9931
diff
changeset

820 
static void WINRT_OnBackButtonPressed(BackButtonEventArgs ^ args) 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

821 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

822 
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

823 
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

824 

8577
462760a8b82e
WinRT: simulate keyboard events on Windows Phone 8 backbutton presses
David Ludwig <dludwig@pobox.com>
parents:
8576
diff
changeset

825 
const char *hint = SDL_GetHint(SDL_HINT_WINRT_HANDLE_BACK_BUTTON); 
462760a8b82e
WinRT: simulate keyboard events on Windows Phone 8 backbutton presses
David Ludwig <dludwig@pobox.com>
parents:
8576
diff
changeset

826 
if (hint) { 
462760a8b82e
WinRT: simulate keyboard events on Windows Phone 8 backbutton presses
David Ludwig <dludwig@pobox.com>
parents:
8576
diff
changeset

827 
if (*hint == '1') { 
462760a8b82e
WinRT: simulate keyboard events on Windows Phone 8 backbutton presses
David Ludwig <dludwig@pobox.com>
parents:
8576
diff
changeset

828 
args>Handled = true; 
462760a8b82e
WinRT: simulate keyboard events on Windows Phone 8 backbutton presses
David Ludwig <dludwig@pobox.com>
parents:
8576
diff
changeset

829 
} 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

830 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

831 
} 
9957
0be86b512d34
WinRT: fixed bug: Back button(s) weren't working on Win10
David Ludwig <dludwig@pobox.com>
parents:
9931
diff
changeset

832 

0be86b512d34
WinRT: fixed bug: Back button(s) weren't working on Win10
David Ludwig <dludwig@pobox.com>
parents:
9931
diff
changeset

833 
#if NTDDI_VERSION == NTDDI_WIN10 
0be86b512d34
WinRT: fixed bug: Back button(s) weren't working on Win10
David Ludwig <dludwig@pobox.com>
parents:
9931
diff
changeset

834 
void SDL_WinRTApp::OnBackButtonPressed(Platform::Object^ sender, Windows::UI::Core::BackRequestedEventArgs^ args) 
0be86b512d34
WinRT: fixed bug: Back button(s) weren't working on Win10
David Ludwig <dludwig@pobox.com>
parents:
9931
diff
changeset

835 

0be86b512d34
WinRT: fixed bug: Back button(s) weren't working on Win10
David Ludwig <dludwig@pobox.com>
parents:
9931
diff
changeset

836 
{ 
0be86b512d34
WinRT: fixed bug: Back button(s) weren't working on Win10
David Ludwig <dludwig@pobox.com>
parents:
9931
diff
changeset

837 
WINRT_OnBackButtonPressed(args); 
0be86b512d34
WinRT: fixed bug: Back button(s) weren't working on Win10
David Ludwig <dludwig@pobox.com>
parents:
9931
diff
changeset

838 
} 
0be86b512d34
WinRT: fixed bug: Back button(s) weren't working on Win10
David Ludwig <dludwig@pobox.com>
parents:
9931
diff
changeset

839 
#elif WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP 
0be86b512d34
WinRT: fixed bug: Back button(s) weren't working on Win10
David Ludwig <dludwig@pobox.com>
parents:
9931
diff
changeset

840 
void SDL_WinRTApp::OnBackButtonPressed(Platform::Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ args) 
0be86b512d34
WinRT: fixed bug: Back button(s) weren't working on Win10
David Ludwig <dludwig@pobox.com>
parents:
9931
diff
changeset

841 

0be86b512d34
WinRT: fixed bug: Back button(s) weren't working on Win10
David Ludwig <dludwig@pobox.com>
parents:
9931
diff
changeset

842 
{ 
0be86b512d34
WinRT: fixed bug: Back button(s) weren't working on Win10
David Ludwig <dludwig@pobox.com>
parents:
9931
diff
changeset

843 
WINRT_OnBackButtonPressed(args); 
0be86b512d34
WinRT: fixed bug: Back button(s) weren't working on Win10
David Ludwig <dludwig@pobox.com>
parents:
9931
diff
changeset

844 
} 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

845 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8581
diff
changeset

846 

10144
aa9904a56acf
WinRT: bug hackfix  gamepad detection was failing on Xbox One
David Ludwig <dludwig@pobox.com>
parents:
9998
diff
changeset

847 
#if NTDDI_VERSION >= NTDDI_WIN10 
aa9904a56acf
WinRT: bug hackfix  gamepad detection was failing on Xbox One
David Ludwig <dludwig@pobox.com>
parents:
9998
diff
changeset

848 
void SDL_WinRTApp::OnGamepadAdded(Platform::Object ^sender, Windows::Gaming::Input::Gamepad ^gamepad) 
aa9904a56acf
WinRT: bug hackfix  gamepad detection was failing on Xbox One
David Ludwig <dludwig@pobox.com>
parents:
9998
diff
changeset

849 
{ 
aa9904a56acf
WinRT: bug hackfix  gamepad detection was failing on Xbox One
David Ludwig <dludwig@pobox.com>
parents:
9998
diff
changeset

850 
/* HACK ALERT: Nothing needs to be done here, as this method currently 
aa9904a56acf
WinRT: bug hackfix  gamepad detection was failing on Xbox One
David Ludwig <dludwig@pobox.com>
parents:
9998
diff
changeset

851 
only exists to allow something to be registered with Win10's 
aa9904a56acf
WinRT: bug hackfix  gamepad detection was failing on Xbox One
David Ludwig <dludwig@pobox.com>
parents:
9998
diff
changeset

852 
GamepadAdded event, an operation that seems to be necessary to get 
aa9904a56acf
WinRT: bug hackfix  gamepad detection was failing on Xbox One
David Ludwig <dludwig@pobox.com>
parents:
9998
diff
changeset

853 
Xinputbased detection to work on Xbox One. 
aa9904a56acf
WinRT: bug hackfix  gamepad detection was failing on Xbox One
David Ludwig <dludwig@pobox.com>
parents:
9998
diff
changeset

854 
*/ 
aa9904a56acf
WinRT: bug hackfix  gamepad detection was failing on Xbox One
David Ludwig <dludwig@pobox.com>
parents:
9998
diff
changeset

855 
} 
aa9904a56acf
WinRT: bug hackfix  gamepad detection was failing on Xbox One
David Ludwig <dludwig@pobox.com>
parents:
9998
diff
changeset

856 
#endif 