Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
WinRT: emit SDL_MOUSEWHEEL events
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLudwig committed Feb 10, 2013
1 parent 6c6bc7f commit fa64b30
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/video/windowsrt/SDL_WinRTApp.cpp
Expand Up @@ -88,6 +88,9 @@ void SDL_WinRTApp::SetWindow(CoreWindow^ window)
window->PointerReleased +=
ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerReleased);

window->PointerWheelChanged +=
ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerWheelChanged);

window->PointerMoved +=
ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerMoved);

Expand Down Expand Up @@ -245,9 +248,10 @@ static void
WINRT_LogPointerEvent(const string & header, PointerEventArgs ^ args)
{
PointerPoint ^ pt = args->CurrentPoint;
SDL_Log("%s: Position={%f,%f}, FrameId=%d, PointerId=%d, PointerUpdateKind=%s\n",
SDL_Log("%s: Position={%f,%f}, MouseWheelDelta=%d, FrameId=%d, PointerId=%d, PointerUpdateKind=%s\n",
header.c_str(),
pt->Position.X, pt->Position.Y,
pt->Properties->MouseWheelDelta,
pt->FrameId,
pt->PointerId,
WINRT_ConvertPointerUpdateKindToString(args->CurrentPoint->Properties->PointerUpdateKind));
Expand Down Expand Up @@ -281,6 +285,17 @@ void SDL_WinRTApp::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
}
}

void SDL_WinRTApp::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ args)
{
#if 0
WINRT_LogPointerEvent("wheel changed", args);
#endif

if (m_sdlWindowData) {
SDL_SendMouseWheel(m_sdlWindowData->sdlWindow, 0, args->CurrentPoint->Properties->MouseWheelDelta);
}
}

static inline int _lround(float arg) {
if (arg >= 0.0f) {
return (int)floor(arg + 0.5f);
Expand Down
1 change: 1 addition & 0 deletions src/video/windowsrt/SDL_WinRTApp.h
Expand Up @@ -39,6 +39,7 @@ ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFramewo
void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
void OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
void OnPointerWheelChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
void OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
void OnMouseMoved(Windows::Devices::Input::MouseDevice^ mouseDevice, Windows::Devices::Input::MouseEventArgs^ args);
void OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
Expand Down

0 comments on commit fa64b30

Please sign in to comment.