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

Commit

Permalink
WinRT: added mouse button event support
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLudwig committed Oct 29, 2012
1 parent 6720dba commit 6d9be94
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
14 changes: 13 additions & 1 deletion src/video/windowsrt/SDL_WinRTApp.cpp
Expand Up @@ -5,6 +5,8 @@ extern "C" {
#include "SDL_assert.h"
#include "SDL_stdinc.h"
#include "../SDL_sysvideo.h"
#include "../../events/SDL_mouse_c.h"
#include "SDL_events.h"
}

// HACK, DLudwig: The C-style main() will get loaded via the app's
Expand Down Expand Up @@ -68,6 +70,9 @@ void SDL_WinRTApp::SetWindow(CoreWindow^ window)
window->PointerPressed +=
ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerPressed);

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

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

Expand Down Expand Up @@ -129,7 +134,14 @@ void SDL_WinRTApp::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)

void SDL_WinRTApp::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
{
// Insert your code here.
// TODO, WinRT: consider attaching the SDL_Window to the mouse down button event
SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT);
}

void SDL_WinRTApp::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
{
// TODO, WinRT: consider attaching the SDL_Window to the mouse up button event
SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT);
}

void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
Expand Down
1 change: 1 addition & 0 deletions src/video/windowsrt/SDL_WinRTApp.h
Expand Up @@ -33,6 +33,7 @@ ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFramewo
void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args);
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 OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);

private:
Expand Down
4 changes: 2 additions & 2 deletions src/video/windowsrt/SDL_winrtvideo.cpp
Expand Up @@ -41,6 +41,8 @@ extern "C" {
#include "SDL_winrtevents_c.h"
#include "SDL_winrtframebuffer_c.h"

extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;

#define WINRTVID_DRIVER_NAME "dummy"

/* Initialization/Query functions */
Expand Down Expand Up @@ -96,8 +98,6 @@ VideoBootStrap WINRT_bootstrap = {
WINRT_Available, WINRT_CreateDevice
};

extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;

int
WINRT_VideoInit(_THIS)
{
Expand Down

0 comments on commit 6d9be94

Please sign in to comment.