src/video/windowsrt/SDL_WinRTApp.cpp
author David Ludwig <dludwig@pobox.com>
Wed, 23 Jan 2013 09:51:04 -0500
changeset 8394 a7ce6d2c7c9b
parent 8393 1e602670ab25
child 8399 1fa9dcfbeac5
permissions -rw-r--r--
WinRT: made the grave/tilde key work
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     1
#include "SDLmain_WinRT_common.h"
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     2
#include "SDL_WinRTApp.h"
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     3
8329
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
     4
extern "C" {
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
     5
#include "SDL_assert.h"
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
     6
#include "SDL_stdinc.h"
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
     7
#include "../SDL_sysvideo.h"
8332
ea83d191cc17 WinRT: added mouse button event support
David Ludwig <dludwig@pobox.com>
parents: 8331
diff changeset
     8
#include "../../events/SDL_mouse_c.h"
8336
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
     9
#include "../../events/SDL_keyboard_c.h"
8383
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
    10
#include "../../events/SDL_windowevents_c.h"
8391
7206be6ff8d5 WinRT: made use of Win32 key codes if and when a documented WinRT key code can't be found
David Ludwig <dludwig@pobox.com>
parents: 8390
diff changeset
    11
#include "../../events/scancodes_windows.h"
8332
ea83d191cc17 WinRT: added mouse button event support
David Ludwig <dludwig@pobox.com>
parents: 8331
diff changeset
    12
#include "SDL_events.h"
8333
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
    13
#include "SDL_log.h"
8329
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
    14
}
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
    15
8393
1e602670ab25 WinRT: got backslash keys working, at least on Win8 in a Parallels 8 VM
David Ludwig <dludwig@pobox.com>
parents: 8392
diff changeset
    16
#include <unordered_map>
1e602670ab25 WinRT: got backslash keys working, at least on Win8 in a Parallels 8 VM
David Ludwig <dludwig@pobox.com>
parents: 8392
diff changeset
    17
8342
05d7aa70928e WinRT: started work on renderer by getting Direct3D 11.1 to display a single, fullscreen rectangle
David Ludwig <dludwig@pobox.com>
parents: 8336
diff changeset
    18
// TODO, WinRT: Remove reference(s) to BasicTimer.h
8376
a607bff42803 WinRT: fixed a build error caused by a reference to a missing and unused header file
David@Birdo.localdomain
parents: 8372
diff changeset
    19
//#include "BasicTimer.h"
8342
05d7aa70928e WinRT: started work on renderer by getting Direct3D 11.1 to display a single, fullscreen rectangle
David Ludwig <dludwig@pobox.com>
parents: 8336
diff changeset
    20
8324
285388934ded WinRT: got a C-style main(int,char**) function to be called on app init
David Ludwig <dludwig@pobox.com>
parents: 8323
diff changeset
    21
// HACK, DLudwig: The C-style main() will get loaded via the app's
285388934ded WinRT: got a C-style main(int,char**) function to be called on app init
David Ludwig <dludwig@pobox.com>
parents: 8323
diff changeset
    22
// WinRT-styled main(), which is part of SDLmain_for_WinRT.cpp.
285388934ded WinRT: got a C-style main(int,char**) function to be called on app init
David Ludwig <dludwig@pobox.com>
parents: 8323
diff changeset
    23
// This seems wrong on some level, but does seem to work.
285388934ded WinRT: got a C-style main(int,char**) function to be called on app init
David Ludwig <dludwig@pobox.com>
parents: 8323
diff changeset
    24
typedef int (*SDL_WinRT_MainFunction)(int, char **);
285388934ded WinRT: got a C-style main(int,char**) function to be called on app init
David Ludwig <dludwig@pobox.com>
parents: 8323
diff changeset
    25
static SDL_WinRT_MainFunction SDL_WinRT_main = nullptr;
285388934ded WinRT: got a C-style main(int,char**) function to be called on app init
David Ludwig <dludwig@pobox.com>
parents: 8323
diff changeset
    26
8329
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
    27
// HACK, DLudwig: record a reference to the global, Windows RT 'app'/view.
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
    28
// SDL/WinRT will use this throughout its code.
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
    29
//
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
    30
// TODO, WinRT: consider replacing SDL_WinRTGlobalApp with something
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
    31
// non-global, such as something created inside
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
    32
// SDL_InitSubSystem(SDL_INIT_VIDEO), or something inside
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
    33
// SDL_CreateWindow().
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
    34
SDL_WinRTApp ^ SDL_WinRTGlobalApp = nullptr;
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
    35
8324
285388934ded WinRT: got a C-style main(int,char**) function to be called on app init
David Ludwig <dludwig@pobox.com>
parents: 8323
diff changeset
    36
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    37
using namespace Windows::ApplicationModel;
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    38
using namespace Windows::ApplicationModel::Core;
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    39
using namespace Windows::ApplicationModel::Activation;
8378
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
    40
using namespace Windows::Devices::Input;
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    41
using namespace Windows::UI::Core;
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    42
using namespace Windows::System;
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    43
using namespace Windows::Foundation;
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    44
using namespace Windows::Graphics::Display;
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    45
using namespace concurrency;
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    46
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    47
SDL_WinRTApp::SDL_WinRTApp() :
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
    48
    m_windowClosed(false),
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
    49
    m_windowVisible(true),
8378
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
    50
    m_sdlWindowData(NULL),
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
    51
    m_useRelativeMouseMode(false)
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    52
{
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    53
}
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    54
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    55
void SDL_WinRTApp::Initialize(CoreApplicationView^ applicationView)
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    56
{
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
    57
    applicationView->Activated +=
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    58
        ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &SDL_WinRTApp::OnActivated);
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    59
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
    60
    CoreApplication::Suspending +=
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    61
        ref new EventHandler<SuspendingEventArgs^>(this, &SDL_WinRTApp::OnSuspending);
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    62
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
    63
    CoreApplication::Resuming +=
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    64
        ref new EventHandler<Platform::Object^>(this, &SDL_WinRTApp::OnResuming);
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    65
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
    66
    m_renderer = ref new SDL_winrtrenderer();
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    67
}
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    68
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    69
void SDL_WinRTApp::SetWindow(CoreWindow^ window)
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    70
{
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
    71
    window->SizeChanged += 
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    72
        ref new TypedEventHandler<CoreWindow^, WindowSizeChangedEventArgs^>(this, &SDL_WinRTApp::OnWindowSizeChanged);
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    73
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
    74
    window->VisibilityChanged +=
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
    75
        ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &SDL_WinRTApp::OnVisibilityChanged);
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    76
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
    77
    window->Closed += 
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    78
        ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &SDL_WinRTApp::OnWindowClosed);
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    79
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
    80
    window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    81
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
    82
    window->PointerPressed +=
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
    83
        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerPressed);
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    84
8332
ea83d191cc17 WinRT: added mouse button event support
David Ludwig <dludwig@pobox.com>
parents: 8331
diff changeset
    85
    window->PointerReleased +=
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
    86
        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerReleased);
8332
ea83d191cc17 WinRT: added mouse button event support
David Ludwig <dludwig@pobox.com>
parents: 8331
diff changeset
    87
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
    88
    window->PointerMoved +=
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
    89
        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerMoved);
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    90
8378
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
    91
    // Retrieves relative-only mouse movements:
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
    92
    Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved +=
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
    93
        ref new TypedEventHandler<MouseDevice^, MouseEventArgs^>(this, &SDL_WinRTApp::OnMouseMoved);
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
    94
8336
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
    95
    window->KeyDown +=
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
    96
        ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &SDL_WinRTApp::OnKeyDown);
8336
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
    97
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
    98
    window->KeyUp +=
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
    99
        ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &SDL_WinRTApp::OnKeyUp);
8336
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   100
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   101
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   102
    m_renderer->Initialize(CoreWindow::GetForCurrentThread());
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   103
}
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   104
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   105
void SDL_WinRTApp::Load(Platform::String^ entryPoint)
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   106
{
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   107
}
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   108
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   109
void SDL_WinRTApp::Run()
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   110
{
8324
285388934ded WinRT: got a C-style main(int,char**) function to be called on app init
David Ludwig <dludwig@pobox.com>
parents: 8323
diff changeset
   111
    if (SDL_WinRT_main)
285388934ded WinRT: got a C-style main(int,char**) function to be called on app init
David Ludwig <dludwig@pobox.com>
parents: 8323
diff changeset
   112
    {
285388934ded WinRT: got a C-style main(int,char**) function to be called on app init
David Ludwig <dludwig@pobox.com>
parents: 8323
diff changeset
   113
        // TODO, WinRT: pass the C-style main() a reasonably realistic
285388934ded WinRT: got a C-style main(int,char**) function to be called on app init
David Ludwig <dludwig@pobox.com>
parents: 8323
diff changeset
   114
        // representation of command line arguments.
285388934ded WinRT: got a C-style main(int,char**) function to be called on app init
David Ludwig <dludwig@pobox.com>
parents: 8323
diff changeset
   115
        int argc = 0;
285388934ded WinRT: got a C-style main(int,char**) function to be called on app init
David Ludwig <dludwig@pobox.com>
parents: 8323
diff changeset
   116
        char **argv = NULL;
285388934ded WinRT: got a C-style main(int,char**) function to be called on app init
David Ludwig <dludwig@pobox.com>
parents: 8323
diff changeset
   117
        SDL_WinRT_main(argc, argv);
285388934ded WinRT: got a C-style main(int,char**) function to be called on app init
David Ludwig <dludwig@pobox.com>
parents: 8323
diff changeset
   118
    }
8331
737dc8a4f49f WinRT: made SDL_PumpEvents() work, in theory
David Ludwig <dludwig@pobox.com>
parents: 8330
diff changeset
   119
}
8324
285388934ded WinRT: got a C-style main(int,char**) function to be called on app init
David Ludwig <dludwig@pobox.com>
parents: 8323
diff changeset
   120
8331
737dc8a4f49f WinRT: made SDL_PumpEvents() work, in theory
David Ludwig <dludwig@pobox.com>
parents: 8330
diff changeset
   121
void SDL_WinRTApp::PumpEvents()
737dc8a4f49f WinRT: made SDL_PumpEvents() work, in theory
David Ludwig <dludwig@pobox.com>
parents: 8330
diff changeset
   122
{
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   123
    if (!m_windowClosed)
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   124
    {
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   125
        if (m_windowVisible)
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   126
        {
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   127
            CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   128
        }
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   129
        else
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   130
        {
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   131
            CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending);
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   132
        }
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   133
    }
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   134
}
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   135
8342
05d7aa70928e WinRT: started work on renderer by getting Direct3D 11.1 to display a single, fullscreen rectangle
David Ludwig <dludwig@pobox.com>
parents: 8336
diff changeset
   136
void SDL_WinRTApp::UpdateWindowFramebuffer(SDL_Surface * surface, SDL_Rect * rects, int numrects)
05d7aa70928e WinRT: started work on renderer by getting Direct3D 11.1 to display a single, fullscreen rectangle
David Ludwig <dludwig@pobox.com>
parents: 8336
diff changeset
   137
{
05d7aa70928e WinRT: started work on renderer by getting Direct3D 11.1 to display a single, fullscreen rectangle
David Ludwig <dludwig@pobox.com>
parents: 8336
diff changeset
   138
    if (!m_windowClosed && m_windowVisible)
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   139
    {
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   140
        m_renderer->Render(surface, rects, numrects);
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   141
        m_renderer->Present(); // This call is synchronized to the display frame rate.
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   142
    }
8342
05d7aa70928e WinRT: started work on renderer by getting Direct3D 11.1 to display a single, fullscreen rectangle
David Ludwig <dludwig@pobox.com>
parents: 8336
diff changeset
   143
}
05d7aa70928e WinRT: started work on renderer by getting Direct3D 11.1 to display a single, fullscreen rectangle
David Ludwig <dludwig@pobox.com>
parents: 8336
diff changeset
   144
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   145
void SDL_WinRTApp::Uninitialize()
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   146
{
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   147
}
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   148
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   149
void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args)
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   150
{
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   151
    m_renderer->UpdateForWindowSizeChange();
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   152
}
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   153
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   154
void SDL_WinRTApp::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   155
{
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   156
    m_windowVisible = args->Visible;
8385
e954dfbf2ecc WinRT: emit SDL_WINDOWEVENT_SHOWN and SDL_WINDOWEVENT_HIDDEN
David Ludwig <dludwig@pobox.com>
parents: 8384
diff changeset
   157
    if (m_sdlWindowData) {
8390
0770debe7b3b WinRT: hack-fixed a bug whereby SDL_UpdateWindowSurface would fail if the app was hidden, then re-shown
David Ludwig <dludwig@pobox.com>
parents: 8386
diff changeset
   158
        SDL_bool wasSDLWindowSurfaceValid = m_sdlWindowData->sdlWindow->surface_valid;
0770debe7b3b WinRT: hack-fixed a bug whereby SDL_UpdateWindowSurface would fail if the app was hidden, then re-shown
David Ludwig <dludwig@pobox.com>
parents: 8386
diff changeset
   159
8385
e954dfbf2ecc WinRT: emit SDL_WINDOWEVENT_SHOWN and SDL_WINDOWEVENT_HIDDEN
David Ludwig <dludwig@pobox.com>
parents: 8384
diff changeset
   160
        if (args->Visible) {
e954dfbf2ecc WinRT: emit SDL_WINDOWEVENT_SHOWN and SDL_WINDOWEVENT_HIDDEN
David Ludwig <dludwig@pobox.com>
parents: 8384
diff changeset
   161
            SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_SHOWN, 0, 0);
e954dfbf2ecc WinRT: emit SDL_WINDOWEVENT_SHOWN and SDL_WINDOWEVENT_HIDDEN
David Ludwig <dludwig@pobox.com>
parents: 8384
diff changeset
   162
        } else {
e954dfbf2ecc WinRT: emit SDL_WINDOWEVENT_SHOWN and SDL_WINDOWEVENT_HIDDEN
David Ludwig <dludwig@pobox.com>
parents: 8384
diff changeset
   163
            SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_HIDDEN, 0, 0);
e954dfbf2ecc WinRT: emit SDL_WINDOWEVENT_SHOWN and SDL_WINDOWEVENT_HIDDEN
David Ludwig <dludwig@pobox.com>
parents: 8384
diff changeset
   164
        }
8390
0770debe7b3b WinRT: hack-fixed a bug whereby SDL_UpdateWindowSurface would fail if the app was hidden, then re-shown
David Ludwig <dludwig@pobox.com>
parents: 8386
diff changeset
   165
0770debe7b3b WinRT: hack-fixed a bug whereby SDL_UpdateWindowSurface would fail if the app was hidden, then re-shown
David Ludwig <dludwig@pobox.com>
parents: 8386
diff changeset
   166
        // HACK: Prevent SDL's window-hide handling code, which currently
0770debe7b3b WinRT: hack-fixed a bug whereby SDL_UpdateWindowSurface would fail if the app was hidden, then re-shown
David Ludwig <dludwig@pobox.com>
parents: 8386
diff changeset
   167
        // triggers a fake window resize (possibly erronously), from
0770debe7b3b WinRT: hack-fixed a bug whereby SDL_UpdateWindowSurface would fail if the app was hidden, then re-shown
David Ludwig <dludwig@pobox.com>
parents: 8386
diff changeset
   168
        // marking the SDL window's surface as invalid.
0770debe7b3b WinRT: hack-fixed a bug whereby SDL_UpdateWindowSurface would fail if the app was hidden, then re-shown
David Ludwig <dludwig@pobox.com>
parents: 8386
diff changeset
   169
        //
0770debe7b3b WinRT: hack-fixed a bug whereby SDL_UpdateWindowSurface would fail if the app was hidden, then re-shown
David Ludwig <dludwig@pobox.com>
parents: 8386
diff changeset
   170
        // A better solution to this probably involves figuring out if the
0770debe7b3b WinRT: hack-fixed a bug whereby SDL_UpdateWindowSurface would fail if the app was hidden, then re-shown
David Ludwig <dludwig@pobox.com>
parents: 8386
diff changeset
   171
        // fake window resize can be prevented.
0770debe7b3b WinRT: hack-fixed a bug whereby SDL_UpdateWindowSurface would fail if the app was hidden, then re-shown
David Ludwig <dludwig@pobox.com>
parents: 8386
diff changeset
   172
        m_sdlWindowData->sdlWindow->surface_valid = wasSDLWindowSurfaceValid;
8385
e954dfbf2ecc WinRT: emit SDL_WINDOWEVENT_SHOWN and SDL_WINDOWEVENT_HIDDEN
David Ludwig <dludwig@pobox.com>
parents: 8384
diff changeset
   173
    }
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   174
}
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   175
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   176
void SDL_WinRTApp::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   177
{
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   178
    m_windowClosed = true;
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   179
}
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   180
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   181
void SDL_WinRTApp::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   182
{
8333
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
   183
    if (m_sdlWindowData)
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
   184
    {
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   185
        SDL_SendMouseButton(m_sdlWindowData->sdlWindow, SDL_PRESSED, SDL_BUTTON_LEFT);
8333
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
   186
    }
8332
ea83d191cc17 WinRT: added mouse button event support
David Ludwig <dludwig@pobox.com>
parents: 8331
diff changeset
   187
}
ea83d191cc17 WinRT: added mouse button event support
David Ludwig <dludwig@pobox.com>
parents: 8331
diff changeset
   188
ea83d191cc17 WinRT: added mouse button event support
David Ludwig <dludwig@pobox.com>
parents: 8331
diff changeset
   189
void SDL_WinRTApp::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
ea83d191cc17 WinRT: added mouse button event support
David Ludwig <dludwig@pobox.com>
parents: 8331
diff changeset
   190
{
8333
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
   191
    if (m_sdlWindowData)
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
   192
    {
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   193
        SDL_SendMouseButton(m_sdlWindowData->sdlWindow, SDL_RELEASED, SDL_BUTTON_LEFT);
8333
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
   194
    }
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   195
}
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   196
8379
1237c440712b WinRT: scaled relative mouse mode values from the native screen size to SDL's window size
David Ludwig <dludwig@pobox.com>
parents: 8378
diff changeset
   197
static inline int _lround(float arg) {
1237c440712b WinRT: scaled relative mouse mode values from the native screen size to SDL's window size
David Ludwig <dludwig@pobox.com>
parents: 8378
diff changeset
   198
    if (arg >= 0.0f) {
1237c440712b WinRT: scaled relative mouse mode values from the native screen size to SDL's window size
David Ludwig <dludwig@pobox.com>
parents: 8378
diff changeset
   199
        return (int)floor(arg + 0.5f);
1237c440712b WinRT: scaled relative mouse mode values from the native screen size to SDL's window size
David Ludwig <dludwig@pobox.com>
parents: 8378
diff changeset
   200
    } else {
1237c440712b WinRT: scaled relative mouse mode values from the native screen size to SDL's window size
David Ludwig <dludwig@pobox.com>
parents: 8378
diff changeset
   201
        return (int)ceil(arg - 0.5f);
1237c440712b WinRT: scaled relative mouse mode values from the native screen size to SDL's window size
David Ludwig <dludwig@pobox.com>
parents: 8378
diff changeset
   202
    }
1237c440712b WinRT: scaled relative mouse mode values from the native screen size to SDL's window size
David Ludwig <dludwig@pobox.com>
parents: 8378
diff changeset
   203
}
1237c440712b WinRT: scaled relative mouse mode values from the native screen size to SDL's window size
David Ludwig <dludwig@pobox.com>
parents: 8378
diff changeset
   204
8378
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   205
void SDL_WinRTApp::OnMouseMoved(MouseDevice^ mouseDevice, MouseEventArgs^ args)
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   206
{
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   207
    if (m_sdlWindowData && m_useRelativeMouseMode) {
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   208
        // DLudwig, 2012-12-28: On some systems, namely Visual Studio's Windows
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   209
        // Simulator, as well as Windows 8 in a Parallels 8 VM, MouseEventArgs'
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   210
        // MouseDelta field often reports very large values.  More information
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   211
        // on this can be found at the following pages on MSDN:
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   212
        //  - http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/a3c789fa-f1c5-49c4-9c0a-7db88d0f90f8
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   213
        //  - https://connect.microsoft.com/VisualStudio/Feedback/details/756515
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   214
        //
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   215
        // The values do not appear to be as large when running on some systems,
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   216
        // most notably a Surface RT.  Furthermore, the values returned by
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   217
        // CoreWindow's PointerMoved event, and sent to this class' OnPointerMoved
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   218
        // method, do not ever appear to be large, even when MouseEventArgs'
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   219
        // MouseDelta is reporting to the contrary.
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   220
        //
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   221
        // On systems with the large-values behavior, it appears that the values
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   222
        // get reported as if the screen's size is 65536 units in both the X and Y
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   223
        // dimensions.  This can be viewed by using Windows' now-private, "Raw Input"
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   224
        // APIs.  (GetRawInputData, RegisterRawInputDevices, WM_INPUT, etc.)
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   225
        //
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   226
        // MSDN's documentation on MouseEventArgs' MouseDelta field (at
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   227
        // http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.input.mouseeventargs.mousedelta ),
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   228
        // does not seem to indicate (to me) that its values should be so large.  It
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   229
        // says that its values should be a "change in screen location".  I could
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   230
        // be misinterpreting this, however a post on MSDN from a Microsoft engineer (see: 
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   231
        // http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/09a9868e-95bb-4858-ba1a-cb4d2c298d62 ),
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   232
        // indicates that these values are in DIPs, which is the same unit used
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   233
        // by CoreWindow's PointerMoved events (via the Position field in its CurrentPoint
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   234
        // property.  See http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.input.pointerpoint.position.aspx
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   235
        // for details.)
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   236
        //
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   237
        // To note, PointerMoved events are sent a 'RawPosition' value (via the
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   238
        // CurrentPoint property in MouseEventArgs), however these do not seem
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   239
        // to exhibit the same large-value behavior.
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   240
        //
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   241
        // The values passed via PointerMoved events can't always be used for relative
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   242
        // mouse motion, unfortunately.  Its values are bound to the cursor's position,
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   243
        // which stops when it hits one of the screen's edges.  This can be a problem in
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   244
        // first person shooters, whereby it is normal for mouse motion to travel far
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   245
        // along any one axis for a period of time.  MouseMoved events do not have the
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   246
        // screen-bounding limitation, and can be used regardless of where the system's
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   247
        // cursor is.
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   248
        //
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   249
        // One possible workaround would be to programmatically set the cursor's
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   250
        // position to the screen's center (when SDL's relative mouse mode is enabled),
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   251
        // however Windows RT does not yet seem to have the ability to set the cursor's
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   252
        // position via a public API.  Win32 did this via an API call, SetCursorPos,
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   253
        // however WinRT makes this function be private.  Apps that use it won't get
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   254
        // approved for distribution in the Windows Store.  I've yet to be able to find
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   255
        // a suitable, store-friendly counterpart for WinRT.
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   256
        //
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   257
        // There may be some room for a workaround whereby OnPointerMoved's values
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   258
        // are compared to the values from OnMouseMoved in order to detect
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   259
        // when this bug is active.  A suitable transformation could then be made to
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   260
        // OnMouseMoved's values.  For now, however, the system-reported values are sent
8379
1237c440712b WinRT: scaled relative mouse mode values from the native screen size to SDL's window size
David Ludwig <dludwig@pobox.com>
parents: 8378
diff changeset
   261
        // to SDL with minimal transformation: from native screen coordinates (in DIPs)
1237c440712b WinRT: scaled relative mouse mode values from the native screen size to SDL's window size
David Ludwig <dludwig@pobox.com>
parents: 8378
diff changeset
   262
        // to SDL window coordinates.
8378
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   263
        //
8379
1237c440712b WinRT: scaled relative mouse mode values from the native screen size to SDL's window size
David Ludwig <dludwig@pobox.com>
parents: 8378
diff changeset
   264
        const Point mouseDeltaInDIPs((float)args->MouseDelta.X, (float)args->MouseDelta.Y);
1237c440712b WinRT: scaled relative mouse mode values from the native screen size to SDL's window size
David Ludwig <dludwig@pobox.com>
parents: 8378
diff changeset
   265
        const Point mouseDeltaInSDLWindowCoords = TransformCursor(mouseDeltaInDIPs);
1237c440712b WinRT: scaled relative mouse mode values from the native screen size to SDL's window size
David Ludwig <dludwig@pobox.com>
parents: 8378
diff changeset
   266
        SDL_SendMouseMotion(
1237c440712b WinRT: scaled relative mouse mode values from the native screen size to SDL's window size
David Ludwig <dludwig@pobox.com>
parents: 8378
diff changeset
   267
            m_sdlWindowData->sdlWindow,
1237c440712b WinRT: scaled relative mouse mode values from the native screen size to SDL's window size
David Ludwig <dludwig@pobox.com>
parents: 8378
diff changeset
   268
            1,
1237c440712b WinRT: scaled relative mouse mode values from the native screen size to SDL's window size
David Ludwig <dludwig@pobox.com>
parents: 8378
diff changeset
   269
            _lround(mouseDeltaInSDLWindowCoords.X),
1237c440712b WinRT: scaled relative mouse mode values from the native screen size to SDL's window size
David Ludwig <dludwig@pobox.com>
parents: 8378
diff changeset
   270
            _lround(mouseDeltaInSDLWindowCoords.Y));
8378
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   271
    }
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   272
}
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   273
8372
e6c3e06ba940 WinRT: fixed incorrect cursor positions when using non-native screen resolutions
David Ludwig <dludwig@pobox.com>
parents: 8367
diff changeset
   274
// Applies necessary geometric transformations to raw cursor positions:
e6c3e06ba940 WinRT: fixed incorrect cursor positions when using non-native screen resolutions
David Ludwig <dludwig@pobox.com>
parents: 8367
diff changeset
   275
Point SDL_WinRTApp::TransformCursor(Point rawPosition)
e6c3e06ba940 WinRT: fixed incorrect cursor positions when using non-native screen resolutions
David Ludwig <dludwig@pobox.com>
parents: 8367
diff changeset
   276
{
e6c3e06ba940 WinRT: fixed incorrect cursor positions when using non-native screen resolutions
David Ludwig <dludwig@pobox.com>
parents: 8367
diff changeset
   277
    if ( ! m_sdlWindowData || ! m_sdlWindowData->sdlWindow ) {
e6c3e06ba940 WinRT: fixed incorrect cursor positions when using non-native screen resolutions
David Ludwig <dludwig@pobox.com>
parents: 8367
diff changeset
   278
        return rawPosition;
e6c3e06ba940 WinRT: fixed incorrect cursor positions when using non-native screen resolutions
David Ludwig <dludwig@pobox.com>
parents: 8367
diff changeset
   279
    }
e6c3e06ba940 WinRT: fixed incorrect cursor positions when using non-native screen resolutions
David Ludwig <dludwig@pobox.com>
parents: 8367
diff changeset
   280
    CoreWindow ^ nativeWindow = CoreWindow::GetForCurrentThread();
e6c3e06ba940 WinRT: fixed incorrect cursor positions when using non-native screen resolutions
David Ludwig <dludwig@pobox.com>
parents: 8367
diff changeset
   281
    Point outputPosition;
e6c3e06ba940 WinRT: fixed incorrect cursor positions when using non-native screen resolutions
David Ludwig <dludwig@pobox.com>
parents: 8367
diff changeset
   282
    outputPosition.X = rawPosition.X * (((float32)m_sdlWindowData->sdlWindow->w) / nativeWindow->Bounds.Width);
e6c3e06ba940 WinRT: fixed incorrect cursor positions when using non-native screen resolutions
David Ludwig <dludwig@pobox.com>
parents: 8367
diff changeset
   283
    outputPosition.Y = rawPosition.Y * (((float32)m_sdlWindowData->sdlWindow->h) / nativeWindow->Bounds.Height);
e6c3e06ba940 WinRT: fixed incorrect cursor positions when using non-native screen resolutions
David Ludwig <dludwig@pobox.com>
parents: 8367
diff changeset
   284
    return outputPosition;
e6c3e06ba940 WinRT: fixed incorrect cursor positions when using non-native screen resolutions
David Ludwig <dludwig@pobox.com>
parents: 8367
diff changeset
   285
}
e6c3e06ba940 WinRT: fixed incorrect cursor positions when using non-native screen resolutions
David Ludwig <dludwig@pobox.com>
parents: 8367
diff changeset
   286
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   287
void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   288
{
8378
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   289
    if (m_sdlWindowData && ! m_useRelativeMouseMode)
8333
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
   290
    {
8372
e6c3e06ba940 WinRT: fixed incorrect cursor positions when using non-native screen resolutions
David Ludwig <dludwig@pobox.com>
parents: 8367
diff changeset
   291
        Point transformedPoint = TransformCursor(args->CurrentPoint->Position);
e6c3e06ba940 WinRT: fixed incorrect cursor positions when using non-native screen resolutions
David Ludwig <dludwig@pobox.com>
parents: 8367
diff changeset
   292
        SDL_SendMouseMotion(m_sdlWindowData->sdlWindow, 0, (int)transformedPoint.X, (int)transformedPoint.Y);
8333
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
   293
    }
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   294
}
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   295
8393
1e602670ab25 WinRT: got backslash keys working, at least on Win8 in a Parallels 8 VM
David Ludwig <dludwig@pobox.com>
parents: 8392
diff changeset
   296
static SDL_Scancode WinRT_Official_Keycodes[] = {
8336
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   297
    SDL_SCANCODE_UNKNOWN, // VirtualKey.None -- 0
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   298
    SDL_SCANCODE_UNKNOWN, // VirtualKey.LeftButton -- 1
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   299
    SDL_SCANCODE_UNKNOWN, // VirtualKey.RightButton -- 2
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   300
    SDL_SCANCODE_CANCEL, // VirtualKey.Cancel -- 3
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   301
    SDL_SCANCODE_UNKNOWN, // VirtualKey.MiddleButton -- 4
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   302
    SDL_SCANCODE_UNKNOWN, // VirtualKey.XButton1 -- 5
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   303
    SDL_SCANCODE_UNKNOWN, // VirtualKey.XButton2 -- 6
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   304
    SDL_SCANCODE_UNKNOWN, // -- 7
8386
7673e6a03628 WinRT: added a keyboard mapping for the Backspace key
David Ludwig <dludwig@pobox.com>
parents: 8385
diff changeset
   305
    SDL_SCANCODE_BACKSPACE, // VirtualKey.Back -- 8
8336
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   306
    SDL_SCANCODE_TAB, // VirtualKey.Tab -- 9
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   307
    SDL_SCANCODE_UNKNOWN, // -- 10
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   308
    SDL_SCANCODE_UNKNOWN, // -- 11
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   309
    SDL_SCANCODE_CLEAR, // VirtualKey.Clear -- 12
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   310
    SDL_SCANCODE_RETURN, // VirtualKey.Enter -- 13
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   311
    SDL_SCANCODE_UNKNOWN, // -- 14
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   312
    SDL_SCANCODE_UNKNOWN, // -- 15
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   313
    SDL_SCANCODE_LSHIFT, // VirtualKey.Shift -- 16
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   314
    SDL_SCANCODE_LCTRL, // VirtualKey.Control -- 17
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   315
    SDL_SCANCODE_MENU, // VirtualKey.Menu -- 18
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   316
    SDL_SCANCODE_PAUSE, // VirtualKey.Pause -- 19
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   317
    SDL_SCANCODE_CAPSLOCK, // VirtualKey.CapitalLock -- 20
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   318
    SDL_SCANCODE_UNKNOWN, // VirtualKey.Kana or VirtualKey.Hangul -- 21
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   319
    SDL_SCANCODE_UNKNOWN, // -- 22
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   320
    SDL_SCANCODE_UNKNOWN, // VirtualKey.Junja -- 23
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   321
    SDL_SCANCODE_UNKNOWN, // VirtualKey.Final -- 24
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   322
    SDL_SCANCODE_UNKNOWN, // VirtualKey.Hanja or VirtualKey.Kanji -- 25
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   323
    SDL_SCANCODE_UNKNOWN, // -- 26
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   324
    SDL_SCANCODE_ESCAPE, // VirtualKey.Escape -- 27
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   325
    SDL_SCANCODE_UNKNOWN, // VirtualKey.Convert -- 28
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   326
    SDL_SCANCODE_UNKNOWN, // VirtualKey.NonConvert -- 29
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   327
    SDL_SCANCODE_UNKNOWN, // VirtualKey.Accept -- 30
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   328
    SDL_SCANCODE_UNKNOWN, // VirtualKey.ModeChange -- 31  (maybe SDL_SCANCODE_MODE ?)
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   329
    SDL_SCANCODE_SPACE, // VirtualKey.Space -- 32
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   330
    SDL_SCANCODE_PAGEUP, // VirtualKey.PageUp -- 33
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   331
    SDL_SCANCODE_PAGEDOWN, // VirtualKey.PageDown -- 34
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   332
    SDL_SCANCODE_END, // VirtualKey.End -- 35
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   333
    SDL_SCANCODE_HOME, // VirtualKey.Home -- 36
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   334
    SDL_SCANCODE_LEFT, // VirtualKey.Left -- 37
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   335
    SDL_SCANCODE_UP, // VirtualKey.Up -- 38
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   336
    SDL_SCANCODE_RIGHT, // VirtualKey.Right -- 39
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   337
    SDL_SCANCODE_DOWN, // VirtualKey.Down -- 40
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   338
    SDL_SCANCODE_SELECT, // VirtualKey.Select -- 41
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   339
    SDL_SCANCODE_UNKNOWN, // VirtualKey.Print -- 42  (maybe SDL_SCANCODE_PRINTSCREEN ?)
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   340
    SDL_SCANCODE_EXECUTE, // VirtualKey.Execute -- 43
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   341
    SDL_SCANCODE_UNKNOWN, // VirtualKey.Snapshot -- 44
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   342
    SDL_SCANCODE_INSERT, // VirtualKey.Insert -- 45
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   343
    SDL_SCANCODE_DELETE, // VirtualKey.Delete -- 46
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   344
    SDL_SCANCODE_HELP, // VirtualKey.Help -- 47
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   345
    SDL_SCANCODE_0, // VirtualKey.Number0 -- 48
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   346
    SDL_SCANCODE_1, // VirtualKey.Number1 -- 49
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   347
    SDL_SCANCODE_2, // VirtualKey.Number2 -- 50
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   348
    SDL_SCANCODE_3, // VirtualKey.Number3 -- 51
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   349
    SDL_SCANCODE_4, // VirtualKey.Number4 -- 52
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   350
    SDL_SCANCODE_5, // VirtualKey.Number5 -- 53
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   351
    SDL_SCANCODE_6, // VirtualKey.Number6 -- 54
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   352
    SDL_SCANCODE_7, // VirtualKey.Number7 -- 55
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   353
    SDL_SCANCODE_8, // VirtualKey.Number8 -- 56
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   354
    SDL_SCANCODE_9, // VirtualKey.Number9 -- 57
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   355
    SDL_SCANCODE_UNKNOWN, // -- 58
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   356
    SDL_SCANCODE_UNKNOWN, // -- 59
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   357
    SDL_SCANCODE_UNKNOWN, // -- 60
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   358
    SDL_SCANCODE_UNKNOWN, // -- 61
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   359
    SDL_SCANCODE_UNKNOWN, // -- 62
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   360
    SDL_SCANCODE_UNKNOWN, // -- 63
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   361
    SDL_SCANCODE_UNKNOWN, // -- 64
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   362
    SDL_SCANCODE_A, // VirtualKey.A -- 65
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   363
    SDL_SCANCODE_B, // VirtualKey.B -- 66
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   364
    SDL_SCANCODE_C, // VirtualKey.C -- 67
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   365
    SDL_SCANCODE_D, // VirtualKey.D -- 68
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   366
    SDL_SCANCODE_E, // VirtualKey.E -- 69
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   367
    SDL_SCANCODE_F, // VirtualKey.F -- 70
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   368
    SDL_SCANCODE_G, // VirtualKey.G -- 71
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   369
    SDL_SCANCODE_H, // VirtualKey.H -- 72
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   370
    SDL_SCANCODE_I, // VirtualKey.I -- 73
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   371
    SDL_SCANCODE_J, // VirtualKey.J -- 74
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   372
    SDL_SCANCODE_K, // VirtualKey.K -- 75
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   373
    SDL_SCANCODE_L, // VirtualKey.L -- 76
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   374
    SDL_SCANCODE_M, // VirtualKey.M -- 77
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   375
    SDL_SCANCODE_N, // VirtualKey.N -- 78
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   376
    SDL_SCANCODE_O, // VirtualKey.O -- 79
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   377
    SDL_SCANCODE_P, // VirtualKey.P -- 80
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   378
    SDL_SCANCODE_Q, // VirtualKey.Q -- 81
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   379
    SDL_SCANCODE_R, // VirtualKey.R -- 82
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   380
    SDL_SCANCODE_S, // VirtualKey.S -- 83
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   381
    SDL_SCANCODE_T, // VirtualKey.T -- 84
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   382
    SDL_SCANCODE_U, // VirtualKey.U -- 85
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   383
    SDL_SCANCODE_V, // VirtualKey.V -- 86
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   384
    SDL_SCANCODE_W, // VirtualKey.W -- 87
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   385
    SDL_SCANCODE_X, // VirtualKey.X -- 88
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   386
    SDL_SCANCODE_Y, // VirtualKey.Y -- 89
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   387
    SDL_SCANCODE_Z, // VirtualKey.Z -- 90
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   388
    SDL_SCANCODE_UNKNOWN, // VirtualKey.LeftWindows -- 91  (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_LGUI ?)
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   389
    SDL_SCANCODE_UNKNOWN, // VirtualKey.RightWindows -- 92  (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_RGUI ?)
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   390
    SDL_SCANCODE_APPLICATION, // VirtualKey.Application -- 93
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   391
    SDL_SCANCODE_UNKNOWN, // -- 94
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   392
    SDL_SCANCODE_SLEEP, // VirtualKey.Sleep -- 95
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   393
    SDL_SCANCODE_KP_0, // VirtualKey.NumberPad0 -- 96
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   394
    SDL_SCANCODE_KP_1, // VirtualKey.NumberPad1 -- 97
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   395
    SDL_SCANCODE_KP_2, // VirtualKey.NumberPad2 -- 98
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   396
    SDL_SCANCODE_KP_3, // VirtualKey.NumberPad3 -- 99
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   397
    SDL_SCANCODE_KP_4, // VirtualKey.NumberPad4 -- 100
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   398
    SDL_SCANCODE_KP_5, // VirtualKey.NumberPad5 -- 101
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   399
    SDL_SCANCODE_KP_6, // VirtualKey.NumberPad6 -- 102
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   400
    SDL_SCANCODE_KP_7, // VirtualKey.NumberPad7 -- 103
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   401
    SDL_SCANCODE_KP_8, // VirtualKey.NumberPad8 -- 104
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   402
    SDL_SCANCODE_KP_9, // VirtualKey.NumberPad9 -- 105
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   403
    SDL_SCANCODE_KP_MULTIPLY, // VirtualKey.Multiply -- 106
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   404
    SDL_SCANCODE_KP_PLUS, // VirtualKey.Add -- 107
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   405
    SDL_SCANCODE_UNKNOWN, // VirtualKey.Separator -- 108
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   406
    SDL_SCANCODE_KP_MINUS, // VirtualKey.Subtract -- 109
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   407
    SDL_SCANCODE_UNKNOWN, // VirtualKey.Decimal -- 110  (maybe SDL_SCANCODE_DECIMALSEPARATOR, SDL_SCANCODE_KP_DECIMAL, or SDL_SCANCODE_KP_PERIOD ?)
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   408
    SDL_SCANCODE_KP_DIVIDE, // VirtualKey.Divide -- 111
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   409
    SDL_SCANCODE_F1, // VirtualKey.F1 -- 112
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   410
    SDL_SCANCODE_F2, // VirtualKey.F2 -- 113
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   411
    SDL_SCANCODE_F3, // VirtualKey.F3 -- 114
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   412
    SDL_SCANCODE_F4, // VirtualKey.F4 -- 115
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   413
    SDL_SCANCODE_F5, // VirtualKey.F5 -- 116
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   414
    SDL_SCANCODE_F6, // VirtualKey.F6 -- 117
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   415
    SDL_SCANCODE_F7, // VirtualKey.F7 -- 118
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   416
    SDL_SCANCODE_F8, // VirtualKey.F8 -- 119
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   417
    SDL_SCANCODE_F9, // VirtualKey.F9 -- 120
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   418
    SDL_SCANCODE_F10, // VirtualKey.F10 -- 121
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   419
    SDL_SCANCODE_F11, // VirtualKey.F11 -- 122
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   420
    SDL_SCANCODE_F12, // VirtualKey.F12 -- 123
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   421
    SDL_SCANCODE_F13, // VirtualKey.F13 -- 124
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   422
    SDL_SCANCODE_F14, // VirtualKey.F14 -- 125
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   423
    SDL_SCANCODE_F15, // VirtualKey.F15 -- 126
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   424
    SDL_SCANCODE_F16, // VirtualKey.F16 -- 127
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   425
    SDL_SCANCODE_F17, // VirtualKey.F17 -- 128
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   426
    SDL_SCANCODE_F18, // VirtualKey.F18 -- 129
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   427
    SDL_SCANCODE_F19, // VirtualKey.F19 -- 130
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   428
    SDL_SCANCODE_F20, // VirtualKey.F20 -- 131
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   429
    SDL_SCANCODE_F21, // VirtualKey.F21 -- 132
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   430
    SDL_SCANCODE_F22, // VirtualKey.F22 -- 133
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   431
    SDL_SCANCODE_F23, // VirtualKey.F23 -- 134
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   432
    SDL_SCANCODE_F24, // VirtualKey.F24 -- 135
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   433
    SDL_SCANCODE_UNKNOWN, // -- 136
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   434
    SDL_SCANCODE_UNKNOWN, // -- 137
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   435
    SDL_SCANCODE_UNKNOWN, // -- 138
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   436
    SDL_SCANCODE_UNKNOWN, // -- 139
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   437
    SDL_SCANCODE_UNKNOWN, // -- 140
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   438
    SDL_SCANCODE_UNKNOWN, // -- 141
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   439
    SDL_SCANCODE_UNKNOWN, // -- 142
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   440
    SDL_SCANCODE_UNKNOWN, // -- 143
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   441
    SDL_SCANCODE_NUMLOCKCLEAR, // VirtualKey.NumberKeyLock -- 144
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   442
    SDL_SCANCODE_SCROLLLOCK, // VirtualKey.Scroll -- 145
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   443
    SDL_SCANCODE_UNKNOWN, // -- 146
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   444
    SDL_SCANCODE_UNKNOWN, // -- 147
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   445
    SDL_SCANCODE_UNKNOWN, // -- 148
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   446
    SDL_SCANCODE_UNKNOWN, // -- 149
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   447
    SDL_SCANCODE_UNKNOWN, // -- 150
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   448
    SDL_SCANCODE_UNKNOWN, // -- 151
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   449
    SDL_SCANCODE_UNKNOWN, // -- 152
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   450
    SDL_SCANCODE_UNKNOWN, // -- 153
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   451
    SDL_SCANCODE_UNKNOWN, // -- 154
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   452
    SDL_SCANCODE_UNKNOWN, // -- 155
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   453
    SDL_SCANCODE_UNKNOWN, // -- 156
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   454
    SDL_SCANCODE_UNKNOWN, // -- 157
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   455
    SDL_SCANCODE_UNKNOWN, // -- 158
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   456
    SDL_SCANCODE_UNKNOWN, // -- 159
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   457
    SDL_SCANCODE_LSHIFT, // VirtualKey.LeftShift -- 160
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   458
    SDL_SCANCODE_RSHIFT, // VirtualKey.RightShift -- 161
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   459
    SDL_SCANCODE_LCTRL, // VirtualKey.LeftControl -- 162
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   460
    SDL_SCANCODE_RCTRL, // VirtualKey.RightControl -- 163
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   461
    SDL_SCANCODE_MENU, // VirtualKey.LeftMenu -- 164
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   462
    SDL_SCANCODE_MENU, // VirtualKey.RightMenu -- 165
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   463
};
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   464
8393
1e602670ab25 WinRT: got backslash keys working, at least on Win8 in a Parallels 8 VM
David Ludwig <dludwig@pobox.com>
parents: 8392
diff changeset
   465
static std::unordered_map<int, SDL_Scancode> WinRT_Unofficial_Keycodes;
1e602670ab25 WinRT: got backslash keys working, at least on Win8 in a Parallels 8 VM
David Ludwig <dludwig@pobox.com>
parents: 8392
diff changeset
   466
8336
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   467
static SDL_Scancode
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   468
TranslateKeycode(int keycode)
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   469
{
8393
1e602670ab25 WinRT: got backslash keys working, at least on Win8 in a Parallels 8 VM
David Ludwig <dludwig@pobox.com>
parents: 8392
diff changeset
   470
    if (WinRT_Unofficial_Keycodes.empty()) {
1e602670ab25 WinRT: got backslash keys working, at least on Win8 in a Parallels 8 VM
David Ludwig <dludwig@pobox.com>
parents: 8392
diff changeset
   471
        /* Set up a table of undocumented (by Microsoft), WinRT-specific,
1e602670ab25 WinRT: got backslash keys working, at least on Win8 in a Parallels 8 VM
David Ludwig <dludwig@pobox.com>
parents: 8392
diff changeset
   472
           key codes: */
1e602670ab25 WinRT: got backslash keys working, at least on Win8 in a Parallels 8 VM
David Ludwig <dludwig@pobox.com>
parents: 8392
diff changeset
   473
        // TODO, WinRT: move content declarations of WinRT_Unofficial_Keycodes into a C++11 initializer list, when possible
8394
a7ce6d2c7c9b WinRT: made the grave/tilde key work
David Ludwig <dludwig@pobox.com>
parents: 8393
diff changeset
   474
        WinRT_Unofficial_Keycodes[220] = SDL_SCANCODE_GRAVE;
8393
1e602670ab25 WinRT: got backslash keys working, at least on Win8 in a Parallels 8 VM
David Ludwig <dludwig@pobox.com>
parents: 8392
diff changeset
   475
        WinRT_Unofficial_Keycodes[222] = SDL_SCANCODE_BACKSLASH;
1e602670ab25 WinRT: got backslash keys working, at least on Win8 in a Parallels 8 VM
David Ludwig <dludwig@pobox.com>
parents: 8392
diff changeset
   476
    }
1e602670ab25 WinRT: got backslash keys working, at least on Win8 in a Parallels 8 VM
David Ludwig <dludwig@pobox.com>
parents: 8392
diff changeset
   477
8391
7206be6ff8d5 WinRT: made use of Win32 key codes if and when a documented WinRT key code can't be found
David Ludwig <dludwig@pobox.com>
parents: 8390
diff changeset
   478
    /* Try to get a documented, WinRT, 'VirtualKey' first (as documented at
7206be6ff8d5 WinRT: made use of Win32 key codes if and when a documented WinRT key code can't be found
David Ludwig <dludwig@pobox.com>
parents: 8390
diff changeset
   479
       http://msdn.microsoft.com/en-us/library/windows/apps/windows.system.virtualkey.aspx ).
8392
8e0ccdaadf7a WinRT: minor comment change to keyboard code
David Ludwig <dludwig@pobox.com>
parents: 8391
diff changeset
   480
       If that fails, fall back to a Win32 virtual key.
8391
7206be6ff8d5 WinRT: made use of Win32 key codes if and when a documented WinRT key code can't be found
David Ludwig <dludwig@pobox.com>
parents: 8390
diff changeset
   481
    */
7206be6ff8d5 WinRT: made use of Win32 key codes if and when a documented WinRT key code can't be found
David Ludwig <dludwig@pobox.com>
parents: 8390
diff changeset
   482
    // TODO, WinRT: try filling out the WinRT keycode table as much as possible, using the Win32 table for interpretation hints
8393
1e602670ab25 WinRT: got backslash keys working, at least on Win8 in a Parallels 8 VM
David Ludwig <dludwig@pobox.com>
parents: 8392
diff changeset
   483
    //SDL_Log("WinRT TranslateKeycode, keycode=%d\n", (int)keycode);
8336
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   484
    SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
8393
1e602670ab25 WinRT: got backslash keys working, at least on Win8 in a Parallels 8 VM
David Ludwig <dludwig@pobox.com>
parents: 8392
diff changeset
   485
    if (keycode < SDL_arraysize(WinRT_Official_Keycodes)) {
1e602670ab25 WinRT: got backslash keys working, at least on Win8 in a Parallels 8 VM
David Ludwig <dludwig@pobox.com>
parents: 8392
diff changeset
   486
        scancode = WinRT_Official_Keycodes[keycode];
1e602670ab25 WinRT: got backslash keys working, at least on Win8 in a Parallels 8 VM
David Ludwig <dludwig@pobox.com>
parents: 8392
diff changeset
   487
    }
1e602670ab25 WinRT: got backslash keys working, at least on Win8 in a Parallels 8 VM
David Ludwig <dludwig@pobox.com>
parents: 8392
diff changeset
   488
    if (scancode == SDL_SCANCODE_UNKNOWN) {
1e602670ab25 WinRT: got backslash keys working, at least on Win8 in a Parallels 8 VM
David Ludwig <dludwig@pobox.com>
parents: 8392
diff changeset
   489
        if (WinRT_Unofficial_Keycodes.find(keycode) != WinRT_Unofficial_Keycodes.end()) {
1e602670ab25 WinRT: got backslash keys working, at least on Win8 in a Parallels 8 VM
David Ludwig <dludwig@pobox.com>
parents: 8392
diff changeset
   490
            scancode = WinRT_Unofficial_Keycodes[keycode];
1e602670ab25 WinRT: got backslash keys working, at least on Win8 in a Parallels 8 VM
David Ludwig <dludwig@pobox.com>
parents: 8392
diff changeset
   491
        }
8336
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   492
    }
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   493
    if (scancode == SDL_SCANCODE_UNKNOWN) {
8391
7206be6ff8d5 WinRT: made use of Win32 key codes if and when a documented WinRT key code can't be found
David Ludwig <dludwig@pobox.com>
parents: 8390
diff changeset
   494
        if (keycode < SDL_arraysize(windows_scancode_table)) {
7206be6ff8d5 WinRT: made use of Win32 key codes if and when a documented WinRT key code can't be found
David Ludwig <dludwig@pobox.com>
parents: 8390
diff changeset
   495
            scancode = windows_scancode_table[keycode];
7206be6ff8d5 WinRT: made use of Win32 key codes if and when a documented WinRT key code can't be found
David Ludwig <dludwig@pobox.com>
parents: 8390
diff changeset
   496
        }
7206be6ff8d5 WinRT: made use of Win32 key codes if and when a documented WinRT key code can't be found
David Ludwig <dludwig@pobox.com>
parents: 8390
diff changeset
   497
    }
7206be6ff8d5 WinRT: made use of Win32 key codes if and when a documented WinRT key code can't be found
David Ludwig <dludwig@pobox.com>
parents: 8390
diff changeset
   498
    if (scancode == SDL_SCANCODE_UNKNOWN) {
8336
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   499
        SDL_Log("WinRT TranslateKeycode, unknown keycode=%d\n", (int)keycode);
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   500
    }
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   501
    return scancode;
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   502
}
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   503
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   504
void SDL_WinRTApp::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   505
{
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   506
#if 0
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   507
    SDL_Log("key down, handled=%s, ext?=%s, released?=%s, menu key down?=%s, repeat count=%d, scan code=%d, was down?=%s, vkey=%d\n",
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   508
        (args->Handled ? "1" : "0"),
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   509
        (args->KeyStatus.IsExtendedKey ? "1" : "0"),
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   510
        (args->KeyStatus.IsKeyReleased ? "1" : "0"),
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   511
        (args->KeyStatus.IsMenuKeyDown ? "1" : "0"),
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   512
        args->KeyStatus.RepeatCount,
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   513
        args->KeyStatus.ScanCode,
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   514
        (args->KeyStatus.WasKeyDown ? "1" : "0"),
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   515
        args->VirtualKey);
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   516
    //args->Handled = true;
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   517
    //VirtualKey vkey = args->VirtualKey;
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   518
#endif
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   519
    SDL_SendKeyboardKey(SDL_PRESSED, TranslateKeycode((int)args->VirtualKey));
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   520
}
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   521
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   522
void SDL_WinRTApp::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   523
{
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   524
#if 0
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   525
    SDL_Log("key up, handled=%s, ext?=%s, released?=%s, menu key down?=%s, repeat count=%d, scan code=%d, was down?=%s, vkey=%d\n",
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   526
        (args->Handled ? "1" : "0"),
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   527
        (args->KeyStatus.IsExtendedKey ? "1" : "0"),
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   528
        (args->KeyStatus.IsKeyReleased ? "1" : "0"),
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   529
        (args->KeyStatus.IsMenuKeyDown ? "1" : "0"),
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   530
        args->KeyStatus.RepeatCount,
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   531
        args->KeyStatus.ScanCode,
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   532
        (args->KeyStatus.WasKeyDown ? "1" : "0"),
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   533
        args->VirtualKey);
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   534
    //args->Handled = true;
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   535
#endif
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   536
    SDL_SendKeyboardKey(SDL_RELEASED, TranslateKeycode((int)args->VirtualKey));
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   537
}
0b9aa42be7ae WinRT: added key event support for most WinRT/VirtualKey-based keys
David Ludwig <dludwig@pobox.com>
parents: 8335
diff changeset
   538
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   539
void SDL_WinRTApp::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   540
{
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   541
    CoreWindow::GetForCurrentThread()->Activate();
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   542
}
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   543
8383
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   544
static int SDLCALL RemoveAppSuspendAndResumeEvents(void * userdata, SDL_Event * event)
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   545
{
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   546
    if (event->type == SDL_WINDOWEVENT)
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   547
    {
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   548
        switch (event->window.event)
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   549
        {
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   550
            case SDL_WINDOWEVENT_MINIMIZED:
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   551
            case SDL_WINDOWEVENT_RESTORED:
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   552
                // Return 0 to indicate that the event should be removed from the
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   553
                // event queue:
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   554
                return 0;
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   555
            default:
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   556
                break;
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   557
        }
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   558
    }
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   559
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   560
    // Return 1 to indicate that the event should stay in the event queue:
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   561
    return 1;
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   562
}
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   563
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   564
void SDL_WinRTApp::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   565
{
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   566
    // Save app state asynchronously after requesting a deferral. Holding a deferral
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   567
    // indicates that the application is busy performing suspending operations. Be
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   568
    // aware that a deferral may not be held indefinitely. After about five seconds,
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   569
    // the app will be forced to exit.
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   570
    SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   571
    create_task([this, deferral]()
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   572
    {
8383
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   573
        // Send a window-minimized event immediately to observers.
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   574
        // CoreDispatcher::ProcessEvents, which is the backbone on which
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   575
        // SDL_WinRTApp::PumpEvents is built, will not return to its caller
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   576
        // once it sends out a suspend event.  Any events posted to SDL's
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   577
        // event queue won't get received until the WinRT app is resumed.
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   578
        // SDL_AddEventWatch() may be used to receive app-suspend events on
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   579
        // WinRT.
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   580
        //
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   581
        // In order to prevent app-suspend events from being received twice:
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   582
        // first via a callback passed to SDL_AddEventWatch, and second via
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   583
        // SDL's event queue, the event will be sent to SDL, then immediately
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   584
        // removed from the queue.
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   585
        if (m_sdlWindowData)
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   586
        {
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   587
            SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0);   // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently)
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   588
            SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   589
        }
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   590
        deferral->Complete();
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   591
    });
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   592
}
8383
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   593
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   594
void SDL_WinRTApp::OnResuming(Platform::Object^ sender, Platform::Object^ args)
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   595
{
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   596
    // Restore any data or state that was unloaded on suspend. By default, data
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   597
    // and state are persisted when resuming from suspend. Note that this event
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   598
    // does not occur if the app was previously terminated.
8383
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   599
    if (m_sdlWindowData)
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   600
    {
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   601
        SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_RESTORED, 0, 0);    // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently)
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   602
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   603
        // Remove the app-resume event from the queue, as is done with the
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   604
        // app-suspend event.
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   605
        //
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   606
        // TODO, WinRT: consider posting this event to the queue even though
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   607
        // its counterpart, the app-suspend event, effectively has to be
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   608
        // processed immediately.
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   609
        SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
1f415392ccf0 WinRT: send window 'minimized' and 'restored' events for app-suspend and app-resume. Use SDL_AddEventWatch() to receive these.
David Ludwig <dludwig@pobox.com>
parents: 8379
diff changeset
   610
    }
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   611
}
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   612
8329
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
   613
SDL_DisplayMode SDL_WinRTApp::GetMainDisplayMode()
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
   614
{
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
   615
    SDL_DisplayMode mode;
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
   616
    SDL_zero(mode);
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
   617
    mode.format = SDL_PIXELFORMAT_RGB888;
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
   618
    mode.w = (int) CoreWindow::GetForCurrentThread()->Bounds.Width;
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
   619
    mode.h = (int) CoreWindow::GetForCurrentThread()->Bounds.Height;
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
   620
    mode.refresh_rate = 0;  // TODO, WinRT: see if refresh rate data is available, or relevant (for WinRT apps)
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
   621
    mode.driverdata = NULL;
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
   622
    return mode;
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
   623
}
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
   624
8335
4f41add2ff00 WinRT: fixed bug whereby attempting to create a 2nd window (which intentionall fails, for now) would cause mouse input to stop working
David Ludwig <dludwig@pobox.com>
parents: 8334
diff changeset
   625
const SDL_WindowData * SDL_WinRTApp::GetSDLWindowData() const
4f41add2ff00 WinRT: fixed bug whereby attempting to create a 2nd window (which intentionall fails, for now) would cause mouse input to stop working
David Ludwig <dludwig@pobox.com>
parents: 8334
diff changeset
   626
{
4f41add2ff00 WinRT: fixed bug whereby attempting to create a 2nd window (which intentionall fails, for now) would cause mouse input to stop working
David Ludwig <dludwig@pobox.com>
parents: 8334
diff changeset
   627
    return m_sdlWindowData;
4f41add2ff00 WinRT: fixed bug whereby attempting to create a 2nd window (which intentionall fails, for now) would cause mouse input to stop working
David Ludwig <dludwig@pobox.com>
parents: 8334
diff changeset
   628
}
4f41add2ff00 WinRT: fixed bug whereby attempting to create a 2nd window (which intentionall fails, for now) would cause mouse input to stop working
David Ludwig <dludwig@pobox.com>
parents: 8334
diff changeset
   629
8334
09b0670fece4 WinRT: explicitly allowed only one window at a time, pending multimonitor support (in SDL/WinRT)
David Ludwig <dludwig@pobox.com>
parents: 8333
diff changeset
   630
bool SDL_WinRTApp::HasSDLWindowData() const
09b0670fece4 WinRT: explicitly allowed only one window at a time, pending multimonitor support (in SDL/WinRT)
David Ludwig <dludwig@pobox.com>
parents: 8333
diff changeset
   631
{
09b0670fece4 WinRT: explicitly allowed only one window at a time, pending multimonitor support (in SDL/WinRT)
David Ludwig <dludwig@pobox.com>
parents: 8333
diff changeset
   632
    return (m_sdlWindowData != NULL);
09b0670fece4 WinRT: explicitly allowed only one window at a time, pending multimonitor support (in SDL/WinRT)
David Ludwig <dludwig@pobox.com>
parents: 8333
diff changeset
   633
}
09b0670fece4 WinRT: explicitly allowed only one window at a time, pending multimonitor support (in SDL/WinRT)
David Ludwig <dludwig@pobox.com>
parents: 8333
diff changeset
   634
8378
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   635
void SDL_WinRTApp::SetRelativeMouseMode(bool enable)
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   636
{
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   637
    m_useRelativeMouseMode = enable;
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   638
}
357a8e1166e5 WinRT: added support for SDL_SetRelativeMouseMode
David Ludwig <dludwig@pobox.com>
parents: 8376
diff changeset
   639
8333
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
   640
void SDL_WinRTApp::SetSDLWindowData(const SDL_WindowData* windowData)
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
   641
{
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
   642
    m_sdlWindowData = windowData;
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
   643
}
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
   644
8367
df577bb2f2d7 WinRT: allow windows in non-native screen sizes. Scaling is applied for such.
David Ludwig <dludwig@pobox.com>
parents: 8350
diff changeset
   645
void SDL_WinRTApp::ResizeMainTexture(int w, int h)
df577bb2f2d7 WinRT: allow windows in non-native screen sizes. Scaling is applied for such.
David Ludwig <dludwig@pobox.com>
parents: 8350
diff changeset
   646
{
df577bb2f2d7 WinRT: allow windows in non-native screen sizes. Scaling is applied for such.
David Ludwig <dludwig@pobox.com>
parents: 8350
diff changeset
   647
    m_renderer->ResizeMainTexture(w, h);
df577bb2f2d7 WinRT: allow windows in non-native screen sizes. Scaling is applied for such.
David Ludwig <dludwig@pobox.com>
parents: 8350
diff changeset
   648
}
df577bb2f2d7 WinRT: allow windows in non-native screen sizes. Scaling is applied for such.
David Ludwig <dludwig@pobox.com>
parents: 8350
diff changeset
   649
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   650
IFrameworkView^ Direct3DApplicationSource::CreateView()
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   651
{
8329
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
   652
    // TODO, WinRT: see if this function (CreateView) can ever get called
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
   653
    // more than once.  For now, just prevent it from ever assigning
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
   654
    // SDL_WinRTGlobalApp more than once.
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
   655
    SDL_assert(!SDL_WinRTGlobalApp);
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
   656
    SDL_WinRTApp ^ app = ref new SDL_WinRTApp();
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
   657
    if (!SDL_WinRTGlobalApp)
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
   658
    {
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
   659
        SDL_WinRTGlobalApp = app;
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
   660
    }
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8324
diff changeset
   661
    return app;
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   662
}
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   663
8324
285388934ded WinRT: got a C-style main(int,char**) function to be called on app init
David Ludwig <dludwig@pobox.com>
parents: 8323
diff changeset
   664
__declspec(dllexport) int SDL_WinRT_RunApplication(SDL_WinRT_MainFunction mainFunction)
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   665
{
8324
285388934ded WinRT: got a C-style main(int,char**) function to be called on app init
David Ludwig <dludwig@pobox.com>
parents: 8323
diff changeset
   666
    SDL_WinRT_main = mainFunction;
285388934ded WinRT: got a C-style main(int,char**) function to be called on app init
David Ludwig <dludwig@pobox.com>
parents: 8323
diff changeset
   667
    auto direct3DApplicationSource = ref new Direct3DApplicationSource();
8384
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   668
    CoreApplication::Run(direct3DApplicationSource);
bc7a52629e1e WinRT: converted tabs to spaces in src/video/windowsrt/*
David Ludwig <dludwig@pobox.com>
parents: 8383
diff changeset
   669
    return 0;
8322
839cd578a474 WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   670
}