WinRT: added mouse button event support
authorDavid Ludwig <dludwig@pobox.com>
Sun, 28 Oct 2012 20:47:33 -0400
changeset 8332 ea83d191cc17
parent 8331 737dc8a4f49f
child 8333 49973bfb8d23
WinRT: added mouse button event support
src/video/windowsrt/SDL_WinRTApp.cpp
src/video/windowsrt/SDL_WinRTApp.h
src/video/windowsrt/SDL_winrtvideo.cpp
--- a/src/video/windowsrt/SDL_WinRTApp.cpp	Sun Oct 28 20:04:26 2012 -0400
+++ b/src/video/windowsrt/SDL_WinRTApp.cpp	Sun Oct 28 20:47:33 2012 -0400
@@ -5,6 +5,8 @@
 #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
@@ -68,6 +70,9 @@
 	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);
 
@@ -129,7 +134,14 @@
 
 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)
--- a/src/video/windowsrt/SDL_WinRTApp.h	Sun Oct 28 20:04:26 2012 -0400
+++ b/src/video/windowsrt/SDL_WinRTApp.h	Sun Oct 28 20:47:33 2012 -0400
@@ -33,6 +33,7 @@
 	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:
--- a/src/video/windowsrt/SDL_winrtvideo.cpp	Sun Oct 28 20:04:26 2012 -0400
+++ b/src/video/windowsrt/SDL_winrtvideo.cpp	Sun Oct 28 20:47:33 2012 -0400
@@ -41,6 +41,8 @@
 #include "SDL_winrtevents_c.h"
 #include "SDL_winrtframebuffer_c.h"
 
+extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
+
 #define WINRTVID_DRIVER_NAME "dummy"
 
 /* Initialization/Query functions */
@@ -96,8 +98,6 @@
     WINRT_Available, WINRT_CreateDevice
 };
 
-extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
-
 int
 WINRT_VideoInit(_THIS)
 {