src/video/winrt/SDL_winrtmouse.cpp
author David Ludwig <dludwig@pobox.com>
Tue, 27 Aug 2013 12:20:35 -0400
changeset 8500 f25ef28d61e8
parent 8489 7fd62b320c31
child 8505 a76a3842c9eb
permissions -rw-r--r--
WinRT: more "Windows RT" to "WinRT" renaming
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@8500
   113
    if (cursor) {
dludwig@8500
   114
        CoreCursor ^* theCursor = (CoreCursor ^*) cursor->driverdata;
dludwig@8500
   115
        CoreWindow::GetForCurrentThread()->PointerCursor = *theCursor;
dludwig@8500
   116
    } else {
dludwig@8500
   117
        CoreWindow::GetForCurrentThread()->PointerCursor = nullptr;
dludwig@8500
   118
    }
dludwig@8500
   119
    return 0;
dludwig@8500
   120
}
dludwig@8500
   121
dludwig@8500
   122
static int
dludwig@8500
   123
WINRT_SetRelativeMouseMode(SDL_bool enabled)
dludwig@8500
   124
{
dludwig@8500
   125
    WINRT_UseRelativeMouseMode = enabled;
dludwig@8500
   126
    return 0;
dludwig@8500
   127
}
dludwig@8500
   128
dludwig@8500
   129
void
dludwig@8500
   130
WINRT_InitMouse(_THIS)
dludwig@8500
   131
{
dludwig@8500
   132
    SDL_Mouse *mouse = SDL_GetMouse();
dludwig@8500
   133
dludwig@8500
   134
    /* DLudwig, Dec 3, 2012: WinRT does not currently provide APIs for
dludwig@8500
   135
       the following features, AFAIK:
dludwig@8500
   136
        - custom cursors  (multiple system cursors are, however, available)
dludwig@8500
   137
        - programmatically moveable cursors
dludwig@8500
   138
    */
dludwig@8500
   139
dludwig@8500
   140
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
dludwig@8500
   141
    //mouse->CreateCursor = WINRT_CreateCursor;
dludwig@8500
   142
    mouse->CreateSystemCursor = WINRT_CreateSystemCursor;
dludwig@8500
   143
    mouse->ShowCursor = WINRT_ShowCursor;
dludwig@8500
   144
    mouse->FreeCursor = WINRT_FreeCursor;
dludwig@8500
   145
    //mouse->WarpMouse = WINRT_WarpMouse;
dludwig@8500
   146
    mouse->SetRelativeMouseMode = WINRT_SetRelativeMouseMode;
dludwig@8500
   147
dludwig@8500
   148
    SDL_SetDefaultCursor(WINRT_CreateDefaultCursor());
dludwig@8500
   149
#endif
dludwig@8500
   150
}
dludwig@8500
   151
dludwig@8500
   152
void
dludwig@8500
   153
WINRT_QuitMouse(_THIS)
dludwig@8500
   154
{
dludwig@8500
   155
}
dludwig@8500
   156
dludwig@8489
   157
// Applies necessary geometric transformations to raw cursor positions:
dludwig@8489
   158
static Windows::Foundation::Point
dludwig@8489
   159
TransformCursor(SDL_Window * window, Windows::Foundation::Point rawPosition)
dludwig@8489
   160
{
dludwig@8489
   161
    if (!window) {
dludwig@8489
   162
        return rawPosition;
dludwig@8489
   163
    }
dludwig@8489
   164
    CoreWindow ^ nativeWindow = CoreWindow::GetForCurrentThread();
dludwig@8489
   165
    Windows::Foundation::Point outputPosition;
dludwig@8489
   166
    outputPosition.X = rawPosition.X * (((float32)window->w) / nativeWindow->Bounds.Width);
dludwig@8489
   167
    outputPosition.Y = rawPosition.Y * (((float32)window->h) / nativeWindow->Bounds.Height);
dludwig@8489
   168
    return outputPosition;
dludwig@8500
   169
}
dludwig@8500
   170
dludwig@8489
   171
static inline int
dludwig@8489
   172
_lround(float arg)
dludwig@8489
   173
{
dludwig@8489
   174
    if (arg >= 0.0f) {
dludwig@8489
   175
        return (int)floor(arg + 0.5f);
dludwig@8489
   176
    } else {
dludwig@8489
   177
        return (int)ceil(arg - 0.5f);
dludwig@8489
   178
    }
dludwig@8500
   179
}
dludwig@8500
   180
dludwig@8500
   181
void
dludwig@8500
   182
WINRT_ProcessMouseMovedEvent(SDL_Window * window, Windows::Devices::Input::MouseEventArgs ^args)
dludwig@8500
   183
{
dludwig@8500
   184
    if (!window || !WINRT_UseRelativeMouseMode) {
dludwig@8500
   185
        return;
dludwig@8500
   186
    }
dludwig@8500
   187
dludwig@8489
   188
    // DLudwig, 2012-12-28: On some systems, namely Visual Studio's Windows
dludwig@8489
   189
    // Simulator, as well as Windows 8 in a Parallels 8 VM, MouseEventArgs'
dludwig@8489
   190
    // MouseDelta field often reports very large values.  More information
dludwig@8489
   191
    // on this can be found at the following pages on MSDN:
dludwig@8489
   192
    //  - http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/a3c789fa-f1c5-49c4-9c0a-7db88d0f90f8
dludwig@8489
   193
    //  - https://connect.microsoft.com/VisualStudio/Feedback/details/756515
dludwig@8489
   194
    //
dludwig@8489
   195
    // The values do not appear to be as large when running on some systems,
dludwig@8489
   196
    // most notably a Surface RT.  Furthermore, the values returned by
dludwig@8489
   197
    // CoreWindow's PointerMoved event, and sent to this class' OnPointerMoved
dludwig@8489
   198
    // method, do not ever appear to be large, even when MouseEventArgs'
dludwig@8489
   199
    // MouseDelta is reporting to the contrary.
dludwig@8489
   200
    //
dludwig@8489
   201
    // On systems with the large-values behavior, it appears that the values
dludwig@8489
   202
    // get reported as if the screen's size is 65536 units in both the X and Y
dludwig@8489
   203
    // dimensions.  This can be viewed by using Windows' now-private, "Raw Input"
dludwig@8489
   204
    // APIs.  (GetRawInputData, RegisterRawInputDevices, WM_INPUT, etc.)
dludwig@8489
   205
    //
dludwig@8489
   206
    // MSDN's documentation on MouseEventArgs' MouseDelta field (at
dludwig@8489
   207
    // http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.input.mouseeventargs.mousedelta ),
dludwig@8489
   208
    // does not seem to indicate (to me) that its values should be so large.  It
dludwig@8489
   209
    // says that its values should be a "change in screen location".  I could
dludwig@8489
   210
    // be misinterpreting this, however a post on MSDN from a Microsoft engineer (see: 
dludwig@8489
   211
    // http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/09a9868e-95bb-4858-ba1a-cb4d2c298d62 ),
dludwig@8489
   212
    // indicates that these values are in DIPs, which is the same unit used
dludwig@8489
   213
    // by CoreWindow's PointerMoved events (via the Position field in its CurrentPoint
dludwig@8489
   214
    // property.  See http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.input.pointerpoint.position.aspx
dludwig@8489
   215
    // for details.)
dludwig@8489
   216
    //
dludwig@8489
   217
    // To note, PointerMoved events are sent a 'RawPosition' value (via the
dludwig@8489
   218
    // CurrentPoint property in MouseEventArgs), however these do not seem
dludwig@8489
   219
    // to exhibit the same large-value behavior.
dludwig@8489
   220
    //
dludwig@8489
   221
    // The values passed via PointerMoved events can't always be used for relative
dludwig@8489
   222
    // mouse motion, unfortunately.  Its values are bound to the cursor's position,
dludwig@8489
   223
    // which stops when it hits one of the screen's edges.  This can be a problem in
dludwig@8489
   224
    // first person shooters, whereby it is normal for mouse motion to travel far
dludwig@8489
   225
    // along any one axis for a period of time.  MouseMoved events do not have the
dludwig@8489
   226
    // screen-bounding limitation, and can be used regardless of where the system's
dludwig@8489
   227
    // cursor is.
dludwig@8489
   228
    //
dludwig@8489
   229
    // One possible workaround would be to programmatically set the cursor's
dludwig@8489
   230
    // position to the screen's center (when SDL's relative mouse mode is enabled),
dludwig@8500
   231
    // however WinRT does not yet seem to have the ability to set the cursor's
dludwig@8489
   232
    // position via a public API.  Win32 did this via an API call, SetCursorPos,
dludwig@8489
   233
    // however WinRT makes this function be private.  Apps that use it won't get
dludwig@8489
   234
    // approved for distribution in the Windows Store.  I've yet to be able to find
dludwig@8489
   235
    // a suitable, store-friendly counterpart for WinRT.
dludwig@8489
   236
    //
dludwig@8489
   237
    // There may be some room for a workaround whereby OnPointerMoved's values
dludwig@8489
   238
    // are compared to the values from OnMouseMoved in order to detect
dludwig@8489
   239
    // when this bug is active.  A suitable transformation could then be made to
dludwig@8489
   240
    // OnMouseMoved's values.  For now, however, the system-reported values are sent
dludwig@8489
   241
    // to SDL with minimal transformation: from native screen coordinates (in DIPs)
dludwig@8489
   242
    // to SDL window coordinates.
dludwig@8489
   243
    //
dludwig@8489
   244
    const Windows::Foundation::Point mouseDeltaInDIPs((float)args->MouseDelta.X, (float)args->MouseDelta.Y);
dludwig@8489
   245
    const Windows::Foundation::Point mouseDeltaInSDLWindowCoords = TransformCursor(window, mouseDeltaInDIPs);
dludwig@8489
   246
    SDL_SendMouseMotion(
dludwig@8489
   247
        window,
dludwig@8489
   248
        0,
dludwig@8489
   249
        1,
dludwig@8489
   250
        _lround(mouseDeltaInSDLWindowCoords.X),
dludwig@8489
   251
        _lround(mouseDeltaInSDLWindowCoords.Y));
dludwig@8500
   252
}
dludwig@8500
   253
dludwig@8489
   254
static Uint8
dludwig@8489
   255
WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt)
dludwig@8489
   256
{
dludwig@8489
   257
    using namespace Windows::UI::Input;
dludwig@8489
   258
dludwig@8489
   259
    switch (pt->Properties->PointerUpdateKind)
dludwig@8489
   260
    {
dludwig@8489
   261
        case PointerUpdateKind::LeftButtonPressed:
dludwig@8489
   262
        case PointerUpdateKind::LeftButtonReleased:
dludwig@8489
   263
            return SDL_BUTTON_LEFT;
dludwig@8489
   264
dludwig@8489
   265
        case PointerUpdateKind::RightButtonPressed:
dludwig@8489
   266
        case PointerUpdateKind::RightButtonReleased:
dludwig@8489
   267
            return SDL_BUTTON_RIGHT;
dludwig@8489
   268
dludwig@8489
   269
        case PointerUpdateKind::MiddleButtonPressed:
dludwig@8489
   270
        case PointerUpdateKind::MiddleButtonReleased:
dludwig@8489
   271
            return SDL_BUTTON_MIDDLE;
dludwig@8489
   272
dludwig@8489
   273
        case PointerUpdateKind::XButton1Pressed:
dludwig@8489
   274
        case PointerUpdateKind::XButton1Released:
dludwig@8489
   275
            return SDL_BUTTON_X1;
dludwig@8489
   276
dludwig@8489
   277
        case PointerUpdateKind::XButton2Pressed:
dludwig@8489
   278
        case PointerUpdateKind::XButton2Released:
dludwig@8489
   279
            return SDL_BUTTON_X2;
dludwig@8489
   280
dludwig@8489
   281
        default:
dludwig@8489
   282
            break;
dludwig@8489
   283
    }
dludwig@8489
   284
dludwig@8489
   285
    return 0;
dludwig@8489
   286
}
dludwig@8489
   287
dludwig@8489
   288
static const char *
dludwig@8489
   289
WINRT_ConvertPointerUpdateKindToString(Windows::UI::Input::PointerUpdateKind kind)
dludwig@8489
   290
{
dludwig@8489
   291
    using namespace Windows::UI::Input;
dludwig@8489
   292
dludwig@8489
   293
    switch (kind)
dludwig@8489
   294
    {
dludwig@8489
   295
        case PointerUpdateKind::Other:
dludwig@8489
   296
            return "Other";
dludwig@8489
   297
        case PointerUpdateKind::LeftButtonPressed:
dludwig@8489
   298
            return "LeftButtonPressed";
dludwig@8489
   299
        case PointerUpdateKind::LeftButtonReleased:
dludwig@8489
   300
            return "LeftButtonReleased";
dludwig@8489
   301
        case PointerUpdateKind::RightButtonPressed:
dludwig@8489
   302
            return "RightButtonPressed";
dludwig@8489
   303
        case PointerUpdateKind::RightButtonReleased:
dludwig@8489
   304
            return "RightButtonReleased";
dludwig@8489
   305
        case PointerUpdateKind::MiddleButtonPressed:
dludwig@8489
   306
            return "MiddleButtonPressed";
dludwig@8489
   307
        case PointerUpdateKind::MiddleButtonReleased:
dludwig@8489
   308
            return "MiddleButtonReleased";
dludwig@8489
   309
        case PointerUpdateKind::XButton1Pressed:
dludwig@8489
   310
            return "XButton1Pressed";
dludwig@8489
   311
        case PointerUpdateKind::XButton1Released:
dludwig@8489
   312
            return "XButton1Released";
dludwig@8489
   313
        case PointerUpdateKind::XButton2Pressed:
dludwig@8489
   314
            return "XButton2Pressed";
dludwig@8489
   315
        case PointerUpdateKind::XButton2Released:
dludwig@8489
   316
            return "XButton2Released";
dludwig@8489
   317
    }
dludwig@8489
   318
dludwig@8489
   319
    return "";
dludwig@8489
   320
}
dludwig@8489
   321
dludwig@8489
   322
static void
dludwig@8489
   323
WINRT_LogPointerEvent(const char * header, PointerEventArgs ^ args, Windows::Foundation::Point transformedPoint)
dludwig@8489
   324
{
dludwig@8489
   325
    Windows::UI::Input::PointerPoint ^ pt = args->CurrentPoint;
dludwig@8489
   326
    SDL_Log("%s: Position={%f,%f}, Transformed Pos={%f, %f}, MouseWheelDelta=%d, FrameId=%d, PointerId=%d, PointerUpdateKind=%s\n",
dludwig@8489
   327
        header,
dludwig@8489
   328
        pt->Position.X, pt->Position.Y,
dludwig@8489
   329
        transformedPoint.X, transformedPoint.Y,
dludwig@8489
   330
        pt->Properties->MouseWheelDelta,
dludwig@8489
   331
        pt->FrameId,
dludwig@8489
   332
        pt->PointerId,
dludwig@8489
   333
        WINRT_ConvertPointerUpdateKindToString(args->CurrentPoint->Properties->PointerUpdateKind));
dludwig@8500
   334
}
dludwig@8500
   335
dludwig@8500
   336
void
dludwig@8500
   337
WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Core::PointerEventArgs ^args)
dludwig@8489
   338
{
dludwig@8489
   339
#if LOG_POINTER_EVENTS
dludwig@8489
   340
    WINRT_LogPointerEvent("pointer moved", args, TransformCursor(args->CurrentPoint->Position));
dludwig@8489
   341
#endif
dludwig@8489
   342
dludwig@8489
   343
    if (!window || WINRT_UseRelativeMouseMode) {
dludwig@8489
   344
        return;
dludwig@8489
   345
    }
dludwig@8489
   346
dludwig@8489
   347
    Windows::Foundation::Point transformedPoint = TransformCursor(window, args->CurrentPoint->Position);
dludwig@8489
   348
    SDL_SendMouseMotion(window, 0, 0, (int)transformedPoint.X, (int)transformedPoint.Y);
dludwig@8500
   349
}
dludwig@8500
   350
dludwig@8500
   351
void
dludwig@8489
   352
WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Core::PointerEventArgs ^args)
dludwig@8489
   353
{
dludwig@8489
   354
#if LOG_POINTER_EVENTS
dludwig@8489
   355
    WINRT_LogPointerEvent("wheel changed", args, TransformCursor(args->CurrentPoint->Position));
dludwig@8489
   356
#endif
dludwig@8489
   357
dludwig@8489
   358
    if (!window) {
dludwig@8489
   359
        return;
dludwig@8489
   360
    }
dludwig@8489
   361
dludwig@8489
   362
    // FIXME: This may need to accumulate deltas up to WHEEL_DELTA
dludwig@8489
   363
    short motion = args->CurrentPoint->Properties->MouseWheelDelta / WHEEL_DELTA;
dludwig@8489
   364
    SDL_SendMouseWheel(window, 0, 0, motion);
dludwig@8500
   365
}
dludwig@8500
   366
dludwig@8489
   367
void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Core::PointerEventArgs ^args)
dludwig@8489
   368
{
dludwig@8489
   369
#if LOG_POINTER_EVENTS
dludwig@8489
   370
    WINRT_LogPointerEvent("mouse up", args, TransformCursor(args->CurrentPoint->Position));
dludwig@8489
   371
#endif
dludwig@8489
   372
dludwig@8489
   373
    if (!window) {
dludwig@8489
   374
        return;
dludwig@8489
   375
    }
dludwig@8489
   376
dludwig@8489
   377
    Uint8 button = WINRT_GetSDLButtonForPointerPoint(args->CurrentPoint);
dludwig@8489
   378
    if (button) {
dludwig@8489
   379
        SDL_SendMouseButton(window, 0, SDL_RELEASED, button);
dludwig@8489
   380
    }
dludwig@8500
   381
}
dludwig@8500
   382
dludwig@8489
   383
void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Core::PointerEventArgs ^args)
dludwig@8489
   384
{
dludwig@8489
   385
#if LOG_POINTER_EVENTS
dludwig@8489
   386
    WINRT_LogPointerEvent("mouse down", args, TransformCursor(args->CurrentPoint->Position));
dludwig@8489
   387
#endif
dludwig@8489
   388
dludwig@8489
   389
    if (!window) {
dludwig@8489
   390
        return;
dludwig@8489
   391
    }
dludwig@8489
   392
dludwig@8489
   393
    Uint8 button = WINRT_GetSDLButtonForPointerPoint(args->CurrentPoint);
dludwig@8489
   394
    if (button) {
dludwig@8489
   395
        SDL_SendMouseButton(window, 0, SDL_PRESSED, button);
dludwig@8489
   396
    }
dludwig@8500
   397
}
dludwig@8500
   398
dludwig@8500
   399
#endif /* SDL_VIDEO_DRIVER_WINRT */
dludwig@8500
   400
dludwig@8500
   401
/* vi: set ts=4 sw=4 expandtab: */