src/video/winrt/SDL_winrtpointerinput.cpp
author David Ludwig <dludwig@pobox.com>
Mon, 02 Sep 2013 15:29:46 -0400
changeset 8516 f3e0e381bdcd
parent 8515 bc6cf9201dab
child 8521 cefdaf414ead
permissions -rw-r--r--
WinRT: renamed a mouse-related header file for naming-consistency's sake
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
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     3
  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
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.
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    20
*/
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    21
#include "SDL_config.h"
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"
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    35
#include "../../events/SDL_mouse_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
    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
}
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    38
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    39
/* File-specific globals: */
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    40
static SDL_TouchID WINRT_TouchID = 1;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    41
static unsigned int WINRT_LeftFingerDown = 0;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    42
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    43
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    44
void
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    45
WINRT_InitTouch(_THIS)
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    46
{
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    47
    SDL_AddTouch(WINRT_TouchID, "");
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    48
}
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    49
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    50
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    51
// Applies necessary geometric transformations to raw cursor positions:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    52
Windows::Foundation::Point
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    53
WINRT_TransformCursorPosition(SDL_Window * window, Windows::Foundation::Point rawPosition)
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    54
{
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    55
    using namespace Windows::UI::Core;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    56
    using namespace Windows::Graphics::Display;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    57
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    58
    if (!window) {
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    59
        return rawPosition;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    60
    }
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    61
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    62
    SDL_WindowData * windowData = (SDL_WindowData *) window->driverdata;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    63
    if (windowData->coreWindow == nullptr) {
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    64
        // For some reason, the window isn't associated with a CoreWindow.
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    65
        // This might end up being the case as XAML support is extended.
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    66
        // For now, if there's no CoreWindow attached to the SDL_Window,
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    67
        // don't do any transforms.
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    68
        return rawPosition;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    69
    }
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    70
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    71
    // The CoreWindow can only be accessed on certain thread(s).
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    72
    SDL_assert(CoreWindow::GetForCurrentThread() != nullptr);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    73
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    74
    CoreWindow ^ nativeWindow = windowData->coreWindow.Get();
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    75
    Windows::Foundation::Point outputPosition;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    76
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    77
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    78
    outputPosition.X = rawPosition.X * (((float32)window->w) / nativeWindow->Bounds.Width);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    79
    outputPosition.Y = rawPosition.Y * (((float32)window->h) / nativeWindow->Bounds.Height);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    80
#else
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    81
    switch (DisplayProperties::CurrentOrientation)
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    82
    {
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    83
        case DisplayOrientations::Portrait:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    84
            outputPosition.X = rawPosition.X * (((float32)window->w) / nativeWindow->Bounds.Width);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    85
            outputPosition.Y = rawPosition.Y * (((float32)window->h) / nativeWindow->Bounds.Height);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    86
            break;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    87
        case DisplayOrientations::PortraitFlipped:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    88
            outputPosition.X = (float32)window->w - rawPosition.X * (((float32)window->w) / nativeWindow->Bounds.Width);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    89
            outputPosition.Y = (float32)window->h - rawPosition.Y * (((float32)window->h) / nativeWindow->Bounds.Height);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    90
            break;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    91
        case DisplayOrientations::Landscape:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    92
            outputPosition.X = rawPosition.Y * (((float32)window->w) / nativeWindow->Bounds.Height);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    93
            outputPosition.Y = (float32)window->h - rawPosition.X * (((float32)window->h) / nativeWindow->Bounds.Width);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    94
            break;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    95
        case DisplayOrientations::LandscapeFlipped:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    96
            outputPosition.X = (float32)window->w - rawPosition.Y * (((float32)window->w) / nativeWindow->Bounds.Height);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    97
            outputPosition.Y = rawPosition.X * (((float32)window->h) / nativeWindow->Bounds.Width);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    98
            break;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    99
        default:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   100
            break;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   101
    }
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   102
#endif
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   103
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   104
    return outputPosition;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   105
}
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   106
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   107
static inline int
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   108
_lround(float arg)
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   109
{
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   110
    if (arg >= 0.0f) {
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   111
        return (int)floor(arg + 0.5f);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   112
    } else {
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   113
        return (int)ceil(arg - 0.5f);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   114
    }
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   115
}
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   116
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   117
void
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   118
WINRT_ProcessMouseMovedEvent(SDL_Window * window, Windows::Devices::Input::MouseEventArgs ^args)
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   119
{
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   120
    if (!window || !WINRT_UsingRelativeMouseMode) {
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   121
        return;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   122
    }
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   123
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   124
    // DLudwig, 2012-12-28: On some systems, namely Visual Studio's Windows
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   125
    // Simulator, as well as Windows 8 in a Parallels 8 VM, MouseEventArgs'
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   126
    // MouseDelta field often reports very large values.  More information
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   127
    // on this can be found at the following pages on MSDN:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   128
    //  - http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/a3c789fa-f1c5-49c4-9c0a-7db88d0f90f8
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   129
    //  - https://connect.microsoft.com/VisualStudio/Feedback/details/756515
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   130
    //
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   131
    // The values do not appear to be as large when running on some systems,
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   132
    // most notably a Surface RT.  Furthermore, the values returned by
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   133
    // CoreWindow's PointerMoved event, and sent to this class' OnPointerMoved
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   134
    // method, do not ever appear to be large, even when MouseEventArgs'
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   135
    // MouseDelta is reporting to the contrary.
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   136
    //
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   137
    // On systems with the large-values behavior, it appears that the values
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   138
    // get reported as if the screen's size is 65536 units in both the X and Y
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   139
    // dimensions.  This can be viewed by using Windows' now-private, "Raw Input"
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   140
    // APIs.  (GetRawInputData, RegisterRawInputDevices, WM_INPUT, etc.)
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   141
    //
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   142
    // MSDN's documentation on MouseEventArgs' MouseDelta field (at
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   143
    // http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.input.mouseeventargs.mousedelta ),
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   144
    // does not seem to indicate (to me) that its values should be so large.  It
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   145
    // says that its values should be a "change in screen location".  I could
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   146
    // be misinterpreting this, however a post on MSDN from a Microsoft engineer (see: 
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   147
    // http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/09a9868e-95bb-4858-ba1a-cb4d2c298d62 ),
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   148
    // indicates that these values are in DIPs, which is the same unit used
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   149
    // by CoreWindow's PointerMoved events (via the Position field in its CurrentPoint
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   150
    // property.  See http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.input.pointerpoint.position.aspx
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   151
    // for details.)
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   152
    //
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   153
    // To note, PointerMoved events are sent a 'RawPosition' value (via the
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   154
    // CurrentPoint property in MouseEventArgs), however these do not seem
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   155
    // to exhibit the same large-value behavior.
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   156
    //
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   157
    // The values passed via PointerMoved events can't always be used for relative
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   158
    // mouse motion, unfortunately.  Its values are bound to the cursor's position,
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   159
    // which stops when it hits one of the screen's edges.  This can be a problem in
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   160
    // first person shooters, whereby it is normal for mouse motion to travel far
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   161
    // along any one axis for a period of time.  MouseMoved events do not have the
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   162
    // screen-bounding limitation, and can be used regardless of where the system's
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   163
    // cursor is.
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   164
    //
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   165
    // One possible workaround would be to programmatically set the cursor's
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   166
    // position to the screen's center (when SDL's relative mouse mode is enabled),
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   167
    // however WinRT does not yet seem to have the ability to set the cursor's
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   168
    // position via a public API.  Win32 did this via an API call, SetCursorPos,
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   169
    // however WinRT makes this function be private.  Apps that use it won't get
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   170
    // approved for distribution in the Windows Store.  I've yet to be able to find
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   171
    // a suitable, store-friendly counterpart for WinRT.
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   172
    //
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   173
    // There may be some room for a workaround whereby OnPointerMoved's values
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   174
    // are compared to the values from OnMouseMoved in order to detect
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   175
    // when this bug is active.  A suitable transformation could then be made to
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   176
    // OnMouseMoved's values.  For now, however, the system-reported values are sent
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   177
    // to SDL with minimal transformation: from native screen coordinates (in DIPs)
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   178
    // to SDL window coordinates.
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   179
    //
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   180
    const Windows::Foundation::Point mouseDeltaInDIPs((float)args->MouseDelta.X, (float)args->MouseDelta.Y);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   181
    const Windows::Foundation::Point mouseDeltaInSDLWindowCoords = WINRT_TransformCursorPosition(window, mouseDeltaInDIPs);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   182
    SDL_SendMouseMotion(
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   183
        window,
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   184
        0,
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   185
        1,
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   186
        _lround(mouseDeltaInSDLWindowCoords.X),
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   187
        _lround(mouseDeltaInSDLWindowCoords.Y));
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   188
}
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   189
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   190
Uint8
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   191
WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt)
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   192
{
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   193
    using namespace Windows::UI::Input;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   194
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   195
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   196
    return SDL_BUTTON_LEFT;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   197
#else
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   198
    switch (pt->Properties->PointerUpdateKind)
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   199
    {
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   200
        case PointerUpdateKind::LeftButtonPressed:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   201
        case PointerUpdateKind::LeftButtonReleased:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   202
            return SDL_BUTTON_LEFT;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   203
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   204
        case PointerUpdateKind::RightButtonPressed:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   205
        case PointerUpdateKind::RightButtonReleased:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   206
            return SDL_BUTTON_RIGHT;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   207
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   208
        case PointerUpdateKind::MiddleButtonPressed:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   209
        case PointerUpdateKind::MiddleButtonReleased:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   210
            return SDL_BUTTON_MIDDLE;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   211
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   212
        case PointerUpdateKind::XButton1Pressed:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   213
        case PointerUpdateKind::XButton1Released:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   214
            return SDL_BUTTON_X1;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   215
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   216
        case PointerUpdateKind::XButton2Pressed:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   217
        case PointerUpdateKind::XButton2Released:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   218
            return SDL_BUTTON_X2;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   219
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   220
        default:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   221
            break;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   222
    }
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   223
#endif
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   224
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   225
    return 0;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   226
}
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   227
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   228
//const char *
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   229
//WINRT_ConvertPointerUpdateKindToString(Windows::UI::Input::PointerUpdateKind kind)
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   230
//{
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   231
//    using namespace Windows::UI::Input;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   232
//
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   233
//    switch (kind)
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   234
//    {
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   235
//        case PointerUpdateKind::Other:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   236
//            return "Other";
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   237
//        case PointerUpdateKind::LeftButtonPressed:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   238
//            return "LeftButtonPressed";
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   239
//        case PointerUpdateKind::LeftButtonReleased:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   240
//            return "LeftButtonReleased";
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   241
//        case PointerUpdateKind::RightButtonPressed:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   242
//            return "RightButtonPressed";
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   243
//        case PointerUpdateKind::RightButtonReleased:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   244
//            return "RightButtonReleased";
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   245
//        case PointerUpdateKind::MiddleButtonPressed:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   246
//            return "MiddleButtonPressed";
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   247
//        case PointerUpdateKind::MiddleButtonReleased:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   248
//            return "MiddleButtonReleased";
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   249
//        case PointerUpdateKind::XButton1Pressed:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   250
//            return "XButton1Pressed";
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   251
//        case PointerUpdateKind::XButton1Released:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   252
//            return "XButton1Released";
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   253
//        case PointerUpdateKind::XButton2Pressed:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   254
//            return "XButton2Pressed";
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   255
//        case PointerUpdateKind::XButton2Released:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   256
//            return "XButton2Released";
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   257
//    }
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   258
//
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   259
//    return "";
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   260
//}
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   261
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   262
static bool
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   263
WINRT_IsTouchEvent(Windows::UI::Input::PointerPoint ^pointerPoint)
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   264
{
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   265
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   266
    return true;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   267
#else
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   268
    using namespace Windows::Devices::Input;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   269
    switch (pointerPoint->PointerDevice->PointerDeviceType) {
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   270
        case PointerDeviceType::Touch:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   271
        case PointerDeviceType::Pen:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   272
            return true;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   273
        default:
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   274
            return false;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   275
    }
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   276
#endif
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   277
}
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   278
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   279
void
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   280
WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   281
{
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   282
    if (!window || WINRT_UsingRelativeMouseMode) {
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   283
        return;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   284
    }
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   285
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   286
    Windows::Foundation::Point transformedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   287
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   288
    if (pointerPoint->PointerId == WINRT_LeftFingerDown) {
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   289
        SDL_SendMouseMotion(window, 0, 0, (int)transformedPoint.X, (int)transformedPoint.Y);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   290
    }
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   291
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   292
    if (WINRT_IsTouchEvent(pointerPoint)) {
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   293
        SDL_SendTouchMotion(
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   294
            WINRT_TouchID,
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   295
            (SDL_FingerID) pointerPoint->PointerId,
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   296
            transformedPoint.X,
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   297
            transformedPoint.Y,
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   298
            pointerPoint->Properties->Pressure);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   299
    }
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   300
}
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   301
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   302
void
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   303
WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   304
{
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   305
    if (!window) {
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   306
        return;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   307
    }
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   308
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   309
    // FIXME: This may need to accumulate deltas up to WHEEL_DELTA
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   310
    short motion = pointerPoint->Properties->MouseWheelDelta / WHEEL_DELTA;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   311
    SDL_SendMouseWheel(window, 0, 0, motion);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   312
}
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   313
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   314
void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   315
{
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   316
    if (!window) {
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   317
        return;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   318
    }
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   319
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   320
    Windows::Foundation::Point transformedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   321
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   322
    if (WINRT_LeftFingerDown == pointerPoint->PointerId) {
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   323
        Uint8 button = WINRT_GetSDLButtonForPointerPoint(pointerPoint);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   324
        if (button) {
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   325
            SDL_SendMouseButton(window, 0, SDL_RELEASED, button);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   326
        }
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   327
        WINRT_LeftFingerDown = 0;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   328
    }
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   329
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   330
    if (WINRT_IsTouchEvent(pointerPoint)) {
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   331
        SDL_SendTouch(
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   332
            WINRT_TouchID,
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   333
            (SDL_FingerID) pointerPoint->PointerId,
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   334
            SDL_FALSE,
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   335
            transformedPoint.X,
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   336
            transformedPoint.Y,
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   337
            pointerPoint->Properties->Pressure);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   338
    }
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   339
}
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   340
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   341
void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   342
{
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   343
    if (!window) {
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   344
        return;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   345
    }
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   346
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   347
    Windows::Foundation::Point transformedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   348
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   349
    if (!WINRT_LeftFingerDown) {
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   350
        Uint8 button = WINRT_GetSDLButtonForPointerPoint(pointerPoint);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   351
        if (button) {
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   352
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   353
            SDL_SendMouseMotion(window, 0, 0, (int)transformedPoint.X, (int)transformedPoint.Y);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   354
#endif
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   355
            SDL_SendMouseButton(window, 0, SDL_PRESSED, button);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   356
        }
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   357
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   358
        WINRT_LeftFingerDown = pointerPoint->PointerId;
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   359
    }
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   360
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   361
    if (WINRT_IsTouchEvent(pointerPoint)) {
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   362
        SDL_SendTouch(
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   363
            WINRT_TouchID,
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   364
            (SDL_FingerID) pointerPoint->PointerId,
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   365
            SDL_TRUE,
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   366
            transformedPoint.X,
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   367
            transformedPoint.Y,
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   368
            pointerPoint->Properties->Pressure);
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   369
    }
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   370
}
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   371
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   372
#endif // SDL_VIDEO_DRIVER_WINRT