src/video/winrt/SDL_winrtpointerinput.cpp
author David Ludwig <dludwig@pobox.com>
Sat, 22 Nov 2014 21:13:46 -0500
changeset 9226 bea2e725e29a
parent 9220 1cb6ac648db7
child 9257 6f41196c2d6b
permissions -rw-r--r--
Fixed bug 2726 - WinRT touches not setting 'which' field in virtual mouse events This patch makes sure that any SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP, and SDL_MOUSEMOTION events, as triggered by a touch event in a WinRT app, set the event's 'which' field to SDL_TOUCH_MOUSEID. Previously, this was getting set to the same value as events from a real mouse, '0'. Thanks to Diego for providing information on this bug, and to Tamas Hamor for sending over a patch!
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8515
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     1
/*
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     2
  Simple DirectMedia Layer
8615
097646deaef2 Fixed the copyright date on files contributed by David Ludwig
Sam Lantinga <slouken@libsdl.org>
parents: 8609
diff changeset
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
8515
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     4
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     5
  This software is provided 'as-is', without any express or implied
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     7
  arising from the use of this software.
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     8
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    11
  freely, subject to the following restrictions:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    12
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    14
     claim that you wrote the original software. If you use this software
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    16
     appreciated but is not required.
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    18
     misrepresented as being the original software.
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    20
*/
8609
d59f0f12bf07 Fixed compiling Windows RT code on Visual Studio 2013
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
    21
#include "../../SDL_internal.h"
8515
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    22
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    23
#if SDL_VIDEO_DRIVER_WINRT
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    24
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    25
/* SDL includes */
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    26
#include "SDL_winrtevents_c.h"
8516
f3e0e381bdcd WinRT: renamed a mouse-related header file for naming-consistency's sake
David Ludwig <dludwig@pobox.com>
parents: 8515
diff changeset
    27
#include "SDL_winrtmouse_c.h"
8515
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    28
#include "SDL_winrtvideo_cpp.h"
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    29
#include "SDL_assert.h"
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    30
#include "SDL_system.h"
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    31
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    32
extern "C" {
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    33
#include "../SDL_sysvideo.h"
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    34
#include "../../events/SDL_events_c.h"
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    35
#include "../../events/SDL_mouse_c.h"
8515
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    36
#include "../../events/SDL_touch_c.h"
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    37
}
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    38
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    39
/* File-specific globals: */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    40
static SDL_TouchID WINRT_TouchID = 1;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    41
static unsigned int WINRT_LeftFingerDown = 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    42
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    43
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    44
void
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    45
WINRT_InitTouch(_THIS)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    46
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    47
    SDL_AddTouch(WINRT_TouchID, "");
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    48
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    49
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    50
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    51
//
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    52
// Applies necessary geometric transformations to raw cursor positions:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    53
//
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    54
Windows::Foundation::Point
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    55
WINRT_TransformCursorPosition(SDL_Window * window,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    56
                              Windows::Foundation::Point rawPosition,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    57
                              WINRT_CursorNormalizationType normalization)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    58
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    59
    using namespace Windows::UI::Core;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    60
    using namespace Windows::Graphics::Display;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    61
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    62
    if (!window) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    63
        return rawPosition;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    64
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    65
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    66
    SDL_WindowData * windowData = (SDL_WindowData *) window->driverdata;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    67
    if (windowData->coreWindow == nullptr) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    68
        // For some reason, the window isn't associated with a CoreWindow.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    69
        // This might end up being the case as XAML support is extended.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    70
        // For now, if there's no CoreWindow attached to the SDL_Window,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    71
        // don't do any transforms.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    72
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    73
        // TODO, WinRT: make sure touch input coordinate ranges are correct when using XAML support
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    74
        return rawPosition;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    75
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    76
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    77
    // The CoreWindow can only be accessed on certain thread(s).
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    78
    SDL_assert(CoreWindow::GetForCurrentThread() != nullptr);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    79
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    80
    CoreWindow ^ nativeWindow = windowData->coreWindow.Get();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    81
    Windows::Foundation::Point outputPosition;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    82
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    83
    // Compute coordinates normalized from 0..1.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    84
    // If the coordinates need to be sized to the SDL window,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    85
    // we'll do that after.
8756
d35c6e6ccbb4 Fixed bug: touch input on WinPhone 8.0 was wrong, in some cases
David Ludwig <dludwig@pobox.com>
parents: 8747
diff changeset
    86
#if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (NTDDI_VERSION > NTDDI_WIN8)
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    87
    outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    88
    outputPosition.Y = rawPosition.Y / nativeWindow->Bounds.Height;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    89
#else
8757
aeeeb47a5a77 WinRT: display-information code cleanups
David Ludwig <dludwig@pobox.com>
parents: 8756
diff changeset
    90
    switch (WINRT_DISPLAY_PROPERTY(CurrentOrientation))
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    91
    {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    92
        case DisplayOrientations::Portrait:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    93
            outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    94
            outputPosition.Y = rawPosition.Y / nativeWindow->Bounds.Height;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    95
            break;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    96
        case DisplayOrientations::PortraitFlipped:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    97
            outputPosition.X = 1.0f - (rawPosition.X / nativeWindow->Bounds.Width);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    98
            outputPosition.Y = 1.0f - (rawPosition.Y / nativeWindow->Bounds.Height);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
    99
            break;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   100
        case DisplayOrientations::Landscape:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   101
            outputPosition.X = rawPosition.Y / nativeWindow->Bounds.Height;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   102
            outputPosition.Y = 1.0f - (rawPosition.X / nativeWindow->Bounds.Width);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   103
            break;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   104
        case DisplayOrientations::LandscapeFlipped:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   105
            outputPosition.X = 1.0f - (rawPosition.Y / nativeWindow->Bounds.Height);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   106
            outputPosition.Y = rawPosition.X / nativeWindow->Bounds.Width;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   107
            break;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   108
        default:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   109
            break;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   110
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   111
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   112
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   113
    if (normalization == TransformToSDLWindowSize) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   114
        outputPosition.X *= ((float32) window->w);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   115
        outputPosition.Y *= ((float32) window->h);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   116
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   117
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   118
    return outputPosition;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   119
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   120
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   121
static inline int
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   122
_lround(float arg)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   123
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   124
    if (arg >= 0.0f) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   125
        return (int)floor(arg + 0.5f);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   126
    } else {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   127
        return (int)ceil(arg - 0.5f);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   128
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   129
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   130
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   131
Uint8
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   132
WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   133
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   134
    using namespace Windows::UI::Input;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   135
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   136
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   137
    return SDL_BUTTON_LEFT;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   138
#else
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   139
    switch (pt->Properties->PointerUpdateKind)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   140
    {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   141
        case PointerUpdateKind::LeftButtonPressed:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   142
        case PointerUpdateKind::LeftButtonReleased:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   143
            return SDL_BUTTON_LEFT;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   144
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   145
        case PointerUpdateKind::RightButtonPressed:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   146
        case PointerUpdateKind::RightButtonReleased:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   147
            return SDL_BUTTON_RIGHT;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   148
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   149
        case PointerUpdateKind::MiddleButtonPressed:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   150
        case PointerUpdateKind::MiddleButtonReleased:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   151
            return SDL_BUTTON_MIDDLE;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   152
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   153
        case PointerUpdateKind::XButton1Pressed:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   154
        case PointerUpdateKind::XButton1Released:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   155
            return SDL_BUTTON_X1;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   156
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   157
        case PointerUpdateKind::XButton2Pressed:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   158
        case PointerUpdateKind::XButton2Released:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   159
            return SDL_BUTTON_X2;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   160
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   161
        default:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   162
            break;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   163
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   164
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   165
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   166
    return 0;
8515
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   167
}
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   168
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   169
//const char *
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   170
//WINRT_ConvertPointerUpdateKindToString(Windows::UI::Input::PointerUpdateKind kind)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   171
//{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   172
//    using namespace Windows::UI::Input;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   173
//
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   174
//    switch (kind)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   175
//    {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   176
//        case PointerUpdateKind::Other:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   177
//            return "Other";
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   178
//        case PointerUpdateKind::LeftButtonPressed:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   179
//            return "LeftButtonPressed";
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   180
//        case PointerUpdateKind::LeftButtonReleased:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   181
//            return "LeftButtonReleased";
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   182
//        case PointerUpdateKind::RightButtonPressed:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   183
//            return "RightButtonPressed";
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   184
//        case PointerUpdateKind::RightButtonReleased:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   185
//            return "RightButtonReleased";
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   186
//        case PointerUpdateKind::MiddleButtonPressed:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   187
//            return "MiddleButtonPressed";
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   188
//        case PointerUpdateKind::MiddleButtonReleased:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   189
//            return "MiddleButtonReleased";
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   190
//        case PointerUpdateKind::XButton1Pressed:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   191
//            return "XButton1Pressed";
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   192
//        case PointerUpdateKind::XButton1Released:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   193
//            return "XButton1Released";
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   194
//        case PointerUpdateKind::XButton2Pressed:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   195
//            return "XButton2Pressed";
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   196
//        case PointerUpdateKind::XButton2Released:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   197
//            return "XButton2Released";
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   198
//    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   199
//
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   200
//    return "";
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   201
//}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   202
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   203
static bool
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   204
WINRT_IsTouchEvent(Windows::UI::Input::PointerPoint ^pointerPoint)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   205
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   206
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   207
    return true;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   208
#else
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   209
    using namespace Windows::Devices::Input;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   210
    switch (pointerPoint->PointerDevice->PointerDeviceType) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   211
        case PointerDeviceType::Touch:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   212
        case PointerDeviceType::Pen:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   213
            return true;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   214
        default:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   215
            return false;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   216
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   217
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   218
}
8521
cefdaf414ead WinRT: minor code cleanup regarding events
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   219
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   220
void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   221
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   222
    if (!window) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   223
        return;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   224
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   225
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   226
    Uint8 button = WINRT_GetSDLButtonForPointerPoint(pointerPoint);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   227
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   228
    if ( ! WINRT_IsTouchEvent(pointerPoint)) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   229
        SDL_SendMouseButton(window, 0, SDL_PRESSED, button);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   230
    } else {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   231
        Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   232
        Windows::Foundation::Point windowPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, TransformToSDLWindowSize);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   233
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   234
        if (!WINRT_LeftFingerDown) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   235
            if (button) {
9226
bea2e725e29a Fixed bug 2726 - WinRT touches not setting 'which' field in virtual mouse events
David Ludwig <dludwig@pobox.com>
parents: 9220
diff changeset
   236
                SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, (int)windowPoint.X, (int)windowPoint.Y);
bea2e725e29a Fixed bug 2726 - WinRT touches not setting 'which' field in virtual mouse events
David Ludwig <dludwig@pobox.com>
parents: 9220
diff changeset
   237
                SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_PRESSED, button);
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   238
            }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   239
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   240
            WINRT_LeftFingerDown = pointerPoint->PointerId;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   241
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   242
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   243
        SDL_SendTouch(
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   244
            WINRT_TouchID,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   245
            (SDL_FingerID) pointerPoint->PointerId,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   246
            SDL_TRUE,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   247
            normalizedPoint.X,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   248
            normalizedPoint.Y,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   249
            pointerPoint->Properties->Pressure);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   250
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   251
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   252
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   253
void
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   254
WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   255
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   256
    if (!window || WINRT_UsingRelativeMouseMode) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   257
        return;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   258
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   259
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   260
    Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   261
    Windows::Foundation::Point windowPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, TransformToSDLWindowSize);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   262
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   263
    if ( ! WINRT_IsTouchEvent(pointerPoint)) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   264
        SDL_SendMouseMotion(window, 0, 0, (int)windowPoint.X, (int)windowPoint.Y);
9220
1cb6ac648db7 WinRT: fixed multi-touch bug whereby 2nd, 3rd, etc. fingers weren't moving
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   265
    } else {
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   266
        if (pointerPoint->PointerId == WINRT_LeftFingerDown) {
9226
bea2e725e29a Fixed bug 2726 - WinRT touches not setting 'which' field in virtual mouse events
David Ludwig <dludwig@pobox.com>
parents: 9220
diff changeset
   267
            SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, (int)windowPoint.X, (int)windowPoint.Y);
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   268
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   269
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   270
        SDL_SendTouchMotion(
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   271
            WINRT_TouchID,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   272
            (SDL_FingerID) pointerPoint->PointerId,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   273
            normalizedPoint.X,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   274
            normalizedPoint.Y,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   275
            pointerPoint->Properties->Pressure);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   276
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   277
}
8521
cefdaf414ead WinRT: minor code cleanup regarding events
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   278
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   279
void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   280
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   281
    if (!window) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   282
        return;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   283
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   284
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   285
    Uint8 button = WINRT_GetSDLButtonForPointerPoint(pointerPoint);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   286
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   287
    if (!WINRT_IsTouchEvent(pointerPoint)) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   288
        SDL_SendMouseButton(window, 0, SDL_RELEASED, button);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   289
    } else {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   290
        Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   291
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   292
        if (WINRT_LeftFingerDown == pointerPoint->PointerId) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   293
            if (button) {
9226
bea2e725e29a Fixed bug 2726 - WinRT touches not setting 'which' field in virtual mouse events
David Ludwig <dludwig@pobox.com>
parents: 9220
diff changeset
   294
                SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_RELEASED, button);
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   295
            }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   296
            WINRT_LeftFingerDown = 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   297
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   298
    
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   299
        SDL_SendTouch(
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   300
            WINRT_TouchID,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   301
            (SDL_FingerID) pointerPoint->PointerId,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   302
            SDL_FALSE,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   303
            normalizedPoint.X,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   304
            normalizedPoint.Y,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   305
            pointerPoint->Properties->Pressure);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   306
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   307
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   308
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   309
void
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   310
WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   311
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   312
    if (!window) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   313
        return;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   314
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   315
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   316
    // FIXME: This may need to accumulate deltas up to WHEEL_DELTA
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   317
    short motion = pointerPoint->Properties->MouseWheelDelta / WHEEL_DELTA;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   318
    SDL_SendMouseWheel(window, 0, 0, motion);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   319
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   320
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   321
void
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   322
WINRT_ProcessMouseMovedEvent(SDL_Window * window, Windows::Devices::Input::MouseEventArgs ^args)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   323
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   324
    if (!window || !WINRT_UsingRelativeMouseMode) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   325
        return;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   326
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   327
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   328
    // DLudwig, 2012-12-28: On some systems, namely Visual Studio's Windows
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   329
    // Simulator, as well as Windows 8 in a Parallels 8 VM, MouseEventArgs'
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   330
    // MouseDelta field often reports very large values.  More information
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   331
    // on this can be found at the following pages on MSDN:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   332
    //  - http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/a3c789fa-f1c5-49c4-9c0a-7db88d0f90f8
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   333
    //  - https://connect.microsoft.com/VisualStudio/Feedback/details/756515
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   334
    //
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   335
    // The values do not appear to be as large when running on some systems,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   336
    // most notably a Surface RT.  Furthermore, the values returned by
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   337
    // CoreWindow's PointerMoved event, and sent to this class' OnPointerMoved
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   338
    // method, do not ever appear to be large, even when MouseEventArgs'
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   339
    // MouseDelta is reporting to the contrary.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   340
    //
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   341
    // On systems with the large-values behavior, it appears that the values
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   342
    // get reported as if the screen's size is 65536 units in both the X and Y
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   343
    // dimensions.  This can be viewed by using Windows' now-private, "Raw Input"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   344
    // APIs.  (GetRawInputData, RegisterRawInputDevices, WM_INPUT, etc.)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   345
    //
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   346
    // MSDN's documentation on MouseEventArgs' MouseDelta field (at
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   347
    // http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.input.mouseeventargs.mousedelta ),
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   348
    // does not seem to indicate (to me) that its values should be so large.  It
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   349
    // says that its values should be a "change in screen location".  I could
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   350
    // be misinterpreting this, however a post on MSDN from a Microsoft engineer (see: 
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   351
    // http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/09a9868e-95bb-4858-ba1a-cb4d2c298d62 ),
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   352
    // indicates that these values are in DIPs, which is the same unit used
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   353
    // by CoreWindow's PointerMoved events (via the Position field in its CurrentPoint
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   354
    // property.  See http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.input.pointerpoint.position.aspx
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   355
    // for details.)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   356
    //
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   357
    // To note, PointerMoved events are sent a 'RawPosition' value (via the
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   358
    // CurrentPoint property in MouseEventArgs), however these do not seem
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   359
    // to exhibit the same large-value behavior.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   360
    //
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   361
    // The values passed via PointerMoved events can't always be used for relative
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   362
    // mouse motion, unfortunately.  Its values are bound to the cursor's position,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   363
    // which stops when it hits one of the screen's edges.  This can be a problem in
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   364
    // first person shooters, whereby it is normal for mouse motion to travel far
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   365
    // along any one axis for a period of time.  MouseMoved events do not have the
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   366
    // screen-bounding limitation, and can be used regardless of where the system's
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   367
    // cursor is.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   368
    //
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   369
    // One possible workaround would be to programmatically set the cursor's
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   370
    // position to the screen's center (when SDL's relative mouse mode is enabled),
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   371
    // however WinRT does not yet seem to have the ability to set the cursor's
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   372
    // position via a public API.  Win32 did this via an API call, SetCursorPos,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   373
    // however WinRT makes this function be private.  Apps that use it won't get
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   374
    // approved for distribution in the Windows Store.  I've yet to be able to find
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   375
    // a suitable, store-friendly counterpart for WinRT.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   376
    //
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   377
    // There may be some room for a workaround whereby OnPointerMoved's values
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   378
    // are compared to the values from OnMouseMoved in order to detect
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   379
    // when this bug is active.  A suitable transformation could then be made to
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   380
    // OnMouseMoved's values.  For now, however, the system-reported values are sent
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   381
    // to SDL with minimal transformation: from native screen coordinates (in DIPs)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   382
    // to SDL window coordinates.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   383
    //
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   384
    const Windows::Foundation::Point mouseDeltaInDIPs((float)args->MouseDelta.X, (float)args->MouseDelta.Y);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   385
    const Windows::Foundation::Point mouseDeltaInSDLWindowCoords = WINRT_TransformCursorPosition(window, mouseDeltaInDIPs, TransformToSDLWindowSize);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   386
    SDL_SendMouseMotion(
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   387
        window,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   388
        0,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   389
        1,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   390
        _lround(mouseDeltaInSDLWindowCoords.X),
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8542
diff changeset
   391
        _lround(mouseDeltaInSDLWindowCoords.Y));
8521
cefdaf414ead WinRT: minor code cleanup regarding events
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   392
}
8515
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   393
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   394
#endif // SDL_VIDEO_DRIVER_WINRT