src/video/winrt/SDL_winrtmouse.cpp
author David Ludwig <dludwig@pobox.com>
Wed, 28 Aug 2013 16:14:27 -0400
changeset 8511 326b43e1276b
parent 8505 a76a3842c9eb
child 8512 5b345a756965
permissions -rw-r--r--
WinRT: made simulated-mouse (via touch) input work on Windows Phone in Portrait mode

Proper SDL_MOUSE* event support for non-Portrait orientations in Windows Phone is pending.
dludwig@8500
     1
/*
dludwig@8500
     2
  Simple DirectMedia Layer
dludwig@8500
     3
  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
dludwig@8500
     4
dludwig@8500
     5
  This software is provided 'as-is', without any express or implied
dludwig@8500
     6
  warranty.  In no event will the authors be held liable for any damages
dludwig@8500
     7
  arising from the use of this software.
dludwig@8500
     8
dludwig@8500
     9
  Permission is granted to anyone to use this software for any purpose,
dludwig@8500
    10
  including commercial applications, and to alter it and redistribute it
dludwig@8500
    11
  freely, subject to the following restrictions:
dludwig@8500
    12
dludwig@8500
    13
  1. The origin of this software must not be misrepresented; you must not
dludwig@8500
    14
     claim that you wrote the original software. If you use this software
dludwig@8500
    15
     in a product, an acknowledgment in the product documentation would be
dludwig@8500
    16
     appreciated but is not required.
dludwig@8500
    17
  2. Altered source versions must be plainly marked as such, and must not be
dludwig@8500
    18
     misrepresented as being the original software.
dludwig@8500
    19
  3. This notice may not be removed or altered from any source distribution.
dludwig@8500
    20
*/
dludwig@8500
    21
dludwig@8500
    22
#include "SDL_config.h"
dludwig@8500
    23
dludwig@8500
    24
#if SDL_VIDEO_DRIVER_WINRT
dludwig@8500
    25
dludwig@8500
    26
/*
dludwig@8500
    27
 * Windows includes:
dludwig@8500
    28
 */
dludwig@8500
    29
#include <Windows.h>
dludwig@8500
    30
using namespace Windows::UI::Core;
dludwig@8500
    31
using Windows::UI::Core::CoreCursor;
dludwig@8500
    32
dludwig@8500
    33
/*
dludwig@8500
    34
 * SDL includes:
dludwig@8500
    35
 */
dludwig@8500
    36
extern "C" {
dludwig@8500
    37
#include "SDL_assert.h"
dludwig@8500
    38
#include "../../events/SDL_mouse_c.h"
dludwig@8500
    39
#include "../SDL_sysvideo.h"
dludwig@8500
    40
#include "SDL_events.h"
dludwig@8500
    41
#include "SDL_log.h"
dludwig@8500
    42
}
dludwig@8500
    43
dludwig@8500
    44
#include "../../core/winrt/SDL_winrtapp.h"
dludwig@8500
    45
#include "SDL_winrtmouse.h"
dludwig@8500
    46
dludwig@8500
    47
dludwig@8500
    48
static SDL_bool WINRT_UseRelativeMouseMode = SDL_FALSE;
dludwig@8500
    49
dludwig@8500
    50
dludwig@8500
    51
static SDL_Cursor *
dludwig@8500
    52
WINRT_CreateSystemCursor(SDL_SystemCursor id)
dludwig@8500
    53
{
dludwig@8500
    54
    SDL_Cursor *cursor;
dludwig@8500
    55
    CoreCursorType cursorType = CoreCursorType::Arrow;
dludwig@8500
    56
dludwig@8500
    57
    switch(id)
dludwig@8500
    58
    {
dludwig@8500
    59
    default:
dludwig@8500
    60
        SDL_assert(0);
dludwig@8500
    61
        return NULL;
dludwig@8500
    62
    case SDL_SYSTEM_CURSOR_ARROW:     cursorType = CoreCursorType::Arrow; break;
dludwig@8500
    63
    case SDL_SYSTEM_CURSOR_IBEAM:     cursorType = CoreCursorType::IBeam; break;
dludwig@8500
    64
    case SDL_SYSTEM_CURSOR_WAIT:      cursorType = CoreCursorType::Wait; break;
dludwig@8500
    65
    case SDL_SYSTEM_CURSOR_CROSSHAIR: cursorType = CoreCursorType::Cross; break;
dludwig@8500
    66
    case SDL_SYSTEM_CURSOR_WAITARROW: cursorType = CoreCursorType::Wait; break;
dludwig@8500
    67
    case SDL_SYSTEM_CURSOR_SIZENWSE:  cursorType = CoreCursorType::SizeNorthwestSoutheast; break;
dludwig@8500
    68
    case SDL_SYSTEM_CURSOR_SIZENESW:  cursorType = CoreCursorType::SizeNortheastSouthwest; break;
dludwig@8500
    69
    case SDL_SYSTEM_CURSOR_SIZEWE:    cursorType = CoreCursorType::SizeWestEast; break;
dludwig@8500
    70
    case SDL_SYSTEM_CURSOR_SIZENS:    cursorType = CoreCursorType::SizeNorthSouth; break;
dludwig@8500
    71
    case SDL_SYSTEM_CURSOR_SIZEALL:   cursorType = CoreCursorType::SizeAll; break;
dludwig@8500
    72
    case SDL_SYSTEM_CURSOR_NO:        cursorType = CoreCursorType::UniversalNo; break;
dludwig@8500
    73
    case SDL_SYSTEM_CURSOR_HAND:      cursorType = CoreCursorType::Hand; break;
dludwig@8500
    74
    }
dludwig@8500
    75
dludwig@8500
    76
    cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor));
dludwig@8500
    77
    if (cursor) {
dludwig@8500
    78
        /* Create a pointer to a COM reference to a cursor.  The extra
dludwig@8500
    79
           pointer is used (on top of the COM reference) to allow the cursor
dludwig@8500
    80
           to be referenced by the SDL_cursor's driverdata field, which is
dludwig@8500
    81
           a void pointer.
dludwig@8500
    82
        */
dludwig@8500
    83
        CoreCursor ^* theCursor = new CoreCursor^(nullptr);
dludwig@8500
    84
        *theCursor = ref new CoreCursor(cursorType, 0);
dludwig@8500
    85
        cursor->driverdata = (void *) theCursor;
dludwig@8500
    86
    } else {
dludwig@8500
    87
        SDL_OutOfMemory();
dludwig@8500
    88
    }
dludwig@8500
    89
dludwig@8500
    90
    return cursor;
dludwig@8500
    91
}
dludwig@8500
    92
dludwig@8500
    93
static SDL_Cursor *
dludwig@8500
    94
WINRT_CreateDefaultCursor()
dludwig@8500
    95
{
dludwig@8500
    96
    return WINRT_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
dludwig@8500
    97
}
dludwig@8500
    98
dludwig@8500
    99
static void
dludwig@8500
   100
WINRT_FreeCursor(SDL_Cursor * cursor)
dludwig@8500
   101
{
dludwig@8500
   102
    if (cursor->driverdata) {
dludwig@8500
   103
        CoreCursor ^* theCursor = (CoreCursor ^*) cursor->driverdata;
dludwig@8500
   104
        *theCursor = nullptr;       // Release the COM reference to the CoreCursor
dludwig@8500
   105
        delete theCursor;           // Delete the pointer to the COM reference
dludwig@8500
   106
    }
dludwig@8500
   107
    SDL_free(cursor);
dludwig@8500
   108
}
dludwig@8500
   109
dludwig@8500
   110
static int
dludwig@8500
   111
WINRT_ShowCursor(SDL_Cursor * cursor)
dludwig@8500
   112
{
dludwig@8505
   113
    // TODO, WinRT, XAML: make WINRT_ShowCursor work when XAML support is enabled.
dludwig@8505
   114
    if ( ! CoreWindow::GetForCurrentThread()) {
dludwig@8505
   115
        return 0;
dludwig@8505
   116
    }
dludwig@8505
   117
dludwig@8500
   118
    if (cursor) {
dludwig@8500
   119
        CoreCursor ^* theCursor = (CoreCursor ^*) cursor->driverdata;
dludwig@8500
   120
        CoreWindow::GetForCurrentThread()->PointerCursor = *theCursor;
dludwig@8500
   121
    } else {
dludwig@8500
   122
        CoreWindow::GetForCurrentThread()->PointerCursor = nullptr;
dludwig@8500
   123
    }
dludwig@8500
   124
    return 0;
dludwig@8500
   125
}
dludwig@8500
   126
dludwig@8500
   127
static int
dludwig@8500
   128
WINRT_SetRelativeMouseMode(SDL_bool enabled)
dludwig@8500
   129
{
dludwig@8500
   130
    WINRT_UseRelativeMouseMode = enabled;
dludwig@8500
   131
    return 0;
dludwig@8500
   132
}
dludwig@8500
   133
dludwig@8500
   134
void
dludwig@8500
   135
WINRT_InitMouse(_THIS)
dludwig@8500
   136
{
dludwig@8500
   137
    SDL_Mouse *mouse = SDL_GetMouse();
dludwig@8500
   138
dludwig@8500
   139
    /* DLudwig, Dec 3, 2012: WinRT does not currently provide APIs for
dludwig@8500
   140
       the following features, AFAIK:
dludwig@8500
   141
        - custom cursors  (multiple system cursors are, however, available)
dludwig@8500
   142
        - programmatically moveable cursors
dludwig@8500
   143
    */
dludwig@8500
   144
dludwig@8500
   145
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
dludwig@8500
   146
    //mouse->CreateCursor = WINRT_CreateCursor;
dludwig@8500
   147
    mouse->CreateSystemCursor = WINRT_CreateSystemCursor;
dludwig@8500
   148
    mouse->ShowCursor = WINRT_ShowCursor;
dludwig@8500
   149
    mouse->FreeCursor = WINRT_FreeCursor;
dludwig@8500
   150
    //mouse->WarpMouse = WINRT_WarpMouse;
dludwig@8500
   151
    mouse->SetRelativeMouseMode = WINRT_SetRelativeMouseMode;
dludwig@8500
   152
dludwig@8500
   153
    SDL_SetDefaultCursor(WINRT_CreateDefaultCursor());
dludwig@8500
   154
#endif
dludwig@8500
   155
}
dludwig@8500
   156
dludwig@8500
   157
void
dludwig@8500
   158
WINRT_QuitMouse(_THIS)
dludwig@8500
   159
{
dludwig@8500
   160
}
dludwig@8500
   161
dludwig@8489
   162
// Applies necessary geometric transformations to raw cursor positions:
dludwig@8511
   163
Windows::Foundation::Point
dludwig@8511
   164
WINRT_TransformCursorPosition(SDL_Window * window, Windows::Foundation::Point rawPosition)
dludwig@8489
   165
{
dludwig@8489
   166
    if (!window) {
dludwig@8489
   167
        return rawPosition;
dludwig@8489
   168
    }
dludwig@8489
   169
    CoreWindow ^ nativeWindow = CoreWindow::GetForCurrentThread();
dludwig@8489
   170
    Windows::Foundation::Point outputPosition;
dludwig@8489
   171
    outputPosition.X = rawPosition.X * (((float32)window->w) / nativeWindow->Bounds.Width);
dludwig@8489
   172
    outputPosition.Y = rawPosition.Y * (((float32)window->h) / nativeWindow->Bounds.Height);
dludwig@8489
   173
    return outputPosition;
dludwig@8500
   174
}
dludwig@8500
   175
dludwig@8489
   176
static inline int
dludwig@8489
   177
_lround(float arg)
dludwig@8489
   178
{
dludwig@8489
   179
    if (arg >= 0.0f) {
dludwig@8489
   180
        return (int)floor(arg + 0.5f);
dludwig@8489
   181
    } else {
dludwig@8489
   182
        return (int)ceil(arg - 0.5f);
dludwig@8489
   183
    }
dludwig@8500
   184
}
dludwig@8500
   185
dludwig@8500
   186
void
dludwig@8500
   187
WINRT_ProcessMouseMovedEvent(SDL_Window * window, Windows::Devices::Input::MouseEventArgs ^args)
dludwig@8500
   188
{
dludwig@8500
   189
    if (!window || !WINRT_UseRelativeMouseMode) {
dludwig@8500
   190
        return;
dludwig@8500
   191
    }
dludwig@8500
   192
dludwig@8489
   193
    // DLudwig, 2012-12-28: On some systems, namely Visual Studio's Windows
dludwig@8489
   194
    // Simulator, as well as Windows 8 in a Parallels 8 VM, MouseEventArgs'
dludwig@8489
   195
    // MouseDelta field often reports very large values.  More information
dludwig@8489
   196
    // on this can be found at the following pages on MSDN:
dludwig@8489
   197
    //  - http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/a3c789fa-f1c5-49c4-9c0a-7db88d0f90f8
dludwig@8489
   198
    //  - https://connect.microsoft.com/VisualStudio/Feedback/details/756515
dludwig@8489
   199
    //
dludwig@8489
   200
    // The values do not appear to be as large when running on some systems,
dludwig@8489
   201
    // most notably a Surface RT.  Furthermore, the values returned by
dludwig@8489
   202
    // CoreWindow's PointerMoved event, and sent to this class' OnPointerMoved
dludwig@8489
   203
    // method, do not ever appear to be large, even when MouseEventArgs'
dludwig@8489
   204
    // MouseDelta is reporting to the contrary.
dludwig@8489
   205
    //
dludwig@8489
   206
    // On systems with the large-values behavior, it appears that the values
dludwig@8489
   207
    // get reported as if the screen's size is 65536 units in both the X and Y
dludwig@8489
   208
    // dimensions.  This can be viewed by using Windows' now-private, "Raw Input"
dludwig@8489
   209
    // APIs.  (GetRawInputData, RegisterRawInputDevices, WM_INPUT, etc.)
dludwig@8489
   210
    //
dludwig@8489
   211
    // MSDN's documentation on MouseEventArgs' MouseDelta field (at
dludwig@8489
   212
    // http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.input.mouseeventargs.mousedelta ),
dludwig@8489
   213
    // does not seem to indicate (to me) that its values should be so large.  It
dludwig@8489
   214
    // says that its values should be a "change in screen location".  I could
dludwig@8489
   215
    // be misinterpreting this, however a post on MSDN from a Microsoft engineer (see: 
dludwig@8489
   216
    // http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/09a9868e-95bb-4858-ba1a-cb4d2c298d62 ),
dludwig@8489
   217
    // indicates that these values are in DIPs, which is the same unit used
dludwig@8489
   218
    // by CoreWindow's PointerMoved events (via the Position field in its CurrentPoint
dludwig@8489
   219
    // property.  See http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.input.pointerpoint.position.aspx
dludwig@8489
   220
    // for details.)
dludwig@8489
   221
    //
dludwig@8489
   222
    // To note, PointerMoved events are sent a 'RawPosition' value (via the
dludwig@8489
   223
    // CurrentPoint property in MouseEventArgs), however these do not seem
dludwig@8489
   224
    // to exhibit the same large-value behavior.
dludwig@8489
   225
    //
dludwig@8489
   226
    // The values passed via PointerMoved events can't always be used for relative
dludwig@8489
   227
    // mouse motion, unfortunately.  Its values are bound to the cursor's position,
dludwig@8489
   228
    // which stops when it hits one of the screen's edges.  This can be a problem in
dludwig@8489
   229
    // first person shooters, whereby it is normal for mouse motion to travel far
dludwig@8489
   230
    // along any one axis for a period of time.  MouseMoved events do not have the
dludwig@8489
   231
    // screen-bounding limitation, and can be used regardless of where the system's
dludwig@8489
   232
    // cursor is.
dludwig@8489
   233
    //
dludwig@8489
   234
    // One possible workaround would be to programmatically set the cursor's
dludwig@8489
   235
    // position to the screen's center (when SDL's relative mouse mode is enabled),
dludwig@8500
   236
    // however WinRT does not yet seem to have the ability to set the cursor's
dludwig@8489
   237
    // position via a public API.  Win32 did this via an API call, SetCursorPos,
dludwig@8489
   238
    // however WinRT makes this function be private.  Apps that use it won't get
dludwig@8489
   239
    // approved for distribution in the Windows Store.  I've yet to be able to find
dludwig@8489
   240
    // a suitable, store-friendly counterpart for WinRT.
dludwig@8489
   241
    //
dludwig@8489
   242
    // There may be some room for a workaround whereby OnPointerMoved's values
dludwig@8489
   243
    // are compared to the values from OnMouseMoved in order to detect
dludwig@8489
   244
    // when this bug is active.  A suitable transformation could then be made to
dludwig@8489
   245
    // OnMouseMoved's values.  For now, however, the system-reported values are sent
dludwig@8489
   246
    // to SDL with minimal transformation: from native screen coordinates (in DIPs)
dludwig@8489
   247
    // to SDL window coordinates.
dludwig@8489
   248
    //
dludwig@8489
   249
    const Windows::Foundation::Point mouseDeltaInDIPs((float)args->MouseDelta.X, (float)args->MouseDelta.Y);
dludwig@8511
   250
    const Windows::Foundation::Point mouseDeltaInSDLWindowCoords = WINRT_TransformCursorPosition(window, mouseDeltaInDIPs);
dludwig@8489
   251
    SDL_SendMouseMotion(
dludwig@8489
   252
        window,
dludwig@8489
   253
        0,
dludwig@8489
   254
        1,
dludwig@8489
   255
        _lround(mouseDeltaInSDLWindowCoords.X),
dludwig@8489
   256
        _lround(mouseDeltaInSDLWindowCoords.Y));
dludwig@8500
   257
}
dludwig@8500
   258
dludwig@8511
   259
Uint8
dludwig@8489
   260
WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt)
dludwig@8489
   261
{
dludwig@8489
   262
    using namespace Windows::UI::Input;
dludwig@8489
   263
dludwig@8511
   264
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
dludwig@8511
   265
    return SDL_BUTTON_LEFT;
dludwig@8511
   266
#else
dludwig@8489
   267
    switch (pt->Properties->PointerUpdateKind)
dludwig@8489
   268
    {
dludwig@8489
   269
        case PointerUpdateKind::LeftButtonPressed:
dludwig@8489
   270
        case PointerUpdateKind::LeftButtonReleased:
dludwig@8489
   271
            return SDL_BUTTON_LEFT;
dludwig@8489
   272
dludwig@8489
   273
        case PointerUpdateKind::RightButtonPressed:
dludwig@8489
   274
        case PointerUpdateKind::RightButtonReleased:
dludwig@8489
   275
            return SDL_BUTTON_RIGHT;
dludwig@8489
   276
dludwig@8489
   277
        case PointerUpdateKind::MiddleButtonPressed:
dludwig@8489
   278
        case PointerUpdateKind::MiddleButtonReleased:
dludwig@8489
   279
            return SDL_BUTTON_MIDDLE;
dludwig@8489
   280
dludwig@8489
   281
        case PointerUpdateKind::XButton1Pressed:
dludwig@8489
   282
        case PointerUpdateKind::XButton1Released:
dludwig@8489
   283
            return SDL_BUTTON_X1;
dludwig@8489
   284
dludwig@8489
   285
        case PointerUpdateKind::XButton2Pressed:
dludwig@8489
   286
        case PointerUpdateKind::XButton2Released:
dludwig@8489
   287
            return SDL_BUTTON_X2;
dludwig@8489
   288
dludwig@8489
   289
        default:
dludwig@8489
   290
            break;
dludwig@8489
   291
    }
dludwig@8511
   292
#endif
dludwig@8489
   293
dludwig@8489
   294
    return 0;
dludwig@8489
   295
}
dludwig@8489
   296
dludwig@8511
   297
//const char *
dludwig@8511
   298
//WINRT_ConvertPointerUpdateKindToString(Windows::UI::Input::PointerUpdateKind kind)
dludwig@8511
   299
//{
dludwig@8511
   300
//    using namespace Windows::UI::Input;
dludwig@8511
   301
//
dludwig@8511
   302
//    switch (kind)
dludwig@8511
   303
//    {
dludwig@8511
   304
//        case PointerUpdateKind::Other:
dludwig@8511
   305
//            return "Other";
dludwig@8511
   306
//        case PointerUpdateKind::LeftButtonPressed:
dludwig@8511
   307
//            return "LeftButtonPressed";
dludwig@8511
   308
//        case PointerUpdateKind::LeftButtonReleased:
dludwig@8511
   309
//            return "LeftButtonReleased";
dludwig@8511
   310
//        case PointerUpdateKind::RightButtonPressed:
dludwig@8511
   311
//            return "RightButtonPressed";
dludwig@8511
   312
//        case PointerUpdateKind::RightButtonReleased:
dludwig@8511
   313
//            return "RightButtonReleased";
dludwig@8511
   314
//        case PointerUpdateKind::MiddleButtonPressed:
dludwig@8511
   315
//            return "MiddleButtonPressed";
dludwig@8511
   316
//        case PointerUpdateKind::MiddleButtonReleased:
dludwig@8511
   317
//            return "MiddleButtonReleased";
dludwig@8511
   318
//        case PointerUpdateKind::XButton1Pressed:
dludwig@8511
   319
//            return "XButton1Pressed";
dludwig@8511
   320
//        case PointerUpdateKind::XButton1Released:
dludwig@8511
   321
//            return "XButton1Released";
dludwig@8511
   322
//        case PointerUpdateKind::XButton2Pressed:
dludwig@8511
   323
//            return "XButton2Pressed";
dludwig@8511
   324
//        case PointerUpdateKind::XButton2Released:
dludwig@8511
   325
//            return "XButton2Released";
dludwig@8511
   326
//    }
dludwig@8511
   327
//
dludwig@8511
   328
//    return "";
dludwig@8511
   329
//}
dludwig@8500
   330
dludwig@8500
   331
void
dludwig@8505
   332
WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
dludwig@8489
   333
{
dludwig@8489
   334
    if (!window || WINRT_UseRelativeMouseMode) {
dludwig@8489
   335
        return;
dludwig@8489
   336
    }
dludwig@8489
   337
dludwig@8511
   338
    Windows::Foundation::Point transformedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position);
dludwig@8489
   339
    SDL_SendMouseMotion(window, 0, 0, (int)transformedPoint.X, (int)transformedPoint.Y);
dludwig@8500
   340
}
dludwig@8500
   341
dludwig@8500
   342
void
dludwig@8505
   343
WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
dludwig@8489
   344
{
dludwig@8489
   345
    if (!window) {
dludwig@8489
   346
        return;
dludwig@8489
   347
    }
dludwig@8489
   348
dludwig@8489
   349
    // FIXME: This may need to accumulate deltas up to WHEEL_DELTA
dludwig@8505
   350
    short motion = pointerPoint->Properties->MouseWheelDelta / WHEEL_DELTA;
dludwig@8489
   351
    SDL_SendMouseWheel(window, 0, 0, motion);
dludwig@8500
   352
}
dludwig@8500
   353
dludwig@8505
   354
void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
dludwig@8489
   355
{
dludwig@8489
   356
    if (!window) {
dludwig@8489
   357
        return;
dludwig@8489
   358
    }
dludwig@8489
   359
dludwig@8505
   360
    Uint8 button = WINRT_GetSDLButtonForPointerPoint(pointerPoint);
dludwig@8489
   361
    if (button) {
dludwig@8489
   362
        SDL_SendMouseButton(window, 0, SDL_RELEASED, button);
dludwig@8489
   363
    }
dludwig@8500
   364
}
dludwig@8500
   365
dludwig@8505
   366
void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
dludwig@8489
   367
{
dludwig@8489
   368
    if (!window) {
dludwig@8489
   369
        return;
dludwig@8489
   370
    }
dludwig@8489
   371
dludwig@8505
   372
    Uint8 button = WINRT_GetSDLButtonForPointerPoint(pointerPoint);
dludwig@8489
   373
    if (button) {
dludwig@8511
   374
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
dludwig@8511
   375
        Windows::Foundation::Point transformedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position);
dludwig@8511
   376
        SDL_SendMouseMotion(window, 0, 0, (int)transformedPoint.X, (int)transformedPoint.Y);
dludwig@8511
   377
#endif
dludwig@8489
   378
        SDL_SendMouseButton(window, 0, SDL_PRESSED, button);
dludwig@8489
   379
    }
dludwig@8500
   380
}
dludwig@8500
   381
dludwig@8500
   382
#endif /* SDL_VIDEO_DRIVER_WINRT */
dludwig@8500
   383
dludwig@8500
   384
/* vi: set ts=4 sw=4 expandtab: */