Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
WinRT: fixed incorrect cursor positions when using non-native screen …
- Loading branch information
Showing
with
16 additions
and
1 deletion.
-
+15
−1
src/video/windowsrt/SDL_WinRTApp.cpp
-
+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. |
|
|