Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

WinRT: fixed incorrect cursor positions when using non-native screen …

…resolutions
  • Loading branch information
DavidLudwig committed Nov 26, 2012
1 parent 07813ef commit da239edfb975a281740a72d0656d820a84f5d5be
Showing with 16 additions and 1 deletion.
  1. +15 −1 src/video/windowsrt/SDL_WinRTApp.cpp
  2. +1 −0 src/video/windowsrt/SDL_WinRTApp.h
@@ -167,11 +167,25 @@ void SDL_WinRTApp::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
}
}

// Applies necessary geometric transformations to raw cursor positions:
Point SDL_WinRTApp::TransformCursor(Point rawPosition)
{
if ( ! m_sdlWindowData || ! m_sdlWindowData->sdlWindow ) {
return rawPosition;
}
CoreWindow ^ nativeWindow = CoreWindow::GetForCurrentThread();
Point outputPosition;
outputPosition.X = rawPosition.X * (((float32)m_sdlWindowData->sdlWindow->w) / nativeWindow->Bounds.Width);
outputPosition.Y = rawPosition.Y * (((float32)m_sdlWindowData->sdlWindow->h) / nativeWindow->Bounds.Height);
return outputPosition;
}

void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
{
if (m_sdlWindowData)
{
SDL_SendMouseMotion(m_sdlWindowData->sdlWindow, 0, (int)args->CurrentPoint->Position.X, (int)args->CurrentPoint->Position.Y);
Point transformedPoint = TransformCursor(args->CurrentPoint->Position);
SDL_SendMouseMotion(m_sdlWindowData->sdlWindow, 0, (int)transformedPoint.X, (int)transformedPoint.Y);
}
}

@@ -28,6 +28,7 @@ ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFramewo
void SetSDLWindowData(const SDL_WindowData * windowData);
void UpdateWindowFramebuffer(SDL_Surface * surface, SDL_Rect * rects, int numrects);
void ResizeMainTexture(int w, int h);
Windows::Foundation::Point TransformCursor(Windows::Foundation::Point rawPosition);

protected:
// Event Handlers.

0 comments on commit da239ed

Please sign in to comment.