We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5381

Summary: WinRT: Mouse events not woring correctly
Product: SDL Reporter: Paul Cunningham <paul.cunningham>
Component: eventsAssignee: Sam Lantinga <slouken>
Status: WAITING --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: flibitijibibo
Version: 2.0.12   
Hardware: x86   
OS: Windows 10   

Description Paul Cunningham 2020-12-06 08:43:13 UTC
I've noticed an issue with the mouse on SDL WinRT.

If a mouse button is held, other mouse button events do not get fired / handled.
e.g.

Hold MOUSE1 - SDL_MOUSEBUTTONDOWN (1) fired correctly
Hold MOUSE2 - no event fired

The following situation IS handled correctly...
Hold MOUSE1 - SDL_MOUSEBUTTONDOWN (1) fired correctly
Release MOUSE1 - SDL_MOUSEBUTTONUP (1) fired correctly

Hold MOUSE2 - SDL_MOUSEBUTTONDOWN (3) fired correctly
Release MOUSE1 - SDL_MOUSEBUTTONUP (3) fired correctly

private static SDL.SDL_EventFilter _winRTEvents = WinRTEvents;
private static unsafe int WinRTEvents(IntPtr userdata, IntPtr evtPtr)
{
	SDL.SDL_Event* evt = (SDL.SDL_Event*)evtPtr;
	switch (evt->type)
	{
		case SDL.SDL_EventType.SDL_MOUSEBUTTONDOWN:
			Debug.WriteLine($"WinRT event handler SDL_MOUSEBUTTONDOWN {evt->button.button}");
			break;

		case SDL.SDL_EventType.SDL_MOUSEBUTTONUP:
			Debug.WriteLine($"WinRT event handler SDL_MOUSEBUTTONUP {evt->button.button}");
			break;

		case SDL.SDL_EventType.SDL_APP_TERMINATING:
			Debug.WriteLine("WinRT event handler SDL_APP_TERMINATING -> Exiting()");
			break;

		case SDL.SDL_EventType.SDL_APP_WILLENTERBACKGROUND:
			Debug.WriteLine("WinRT event handler SDL_APP_WILLENTERBACKGROUND -> Suspending()");
			break;

		case SDL.SDL_EventType.SDL_APP_WILLENTERFOREGROUND:
			Debug.WriteLine("WinRT event handler SDL_APP_WILLENTERFOREGROUND -> Resuming()");
			break;
	}

	return 1;
}

public void Run(LaunchOptions launchOptions)
{
	_launchOptions = launchOptions;

	SDL.SDL_SetHint("SDL_WINRT_HANDLE_BACK_BUTTON", "1");
	SDL.SDL_AddEventWatch(_winRTEvents, IntPtr.Zero);
	SDL.SDL_main_func mainFunction = FakeMain;
	SDL.SDL_WinRTRunApp(mainFunction, IntPtr.Zero);
}

Issue happens with / without the custom event filter

This is a WinRT / UWP project running on Windows 10 Home 10.0.19041 Build 19041

SDL is used via FNA Core (DEBUG / x64)
FNA source up to date as at Nov 14, 2020
FNA dependences (FNA3D, etc) built from source on Nov29, 2020
SDL version 2.0.12 (stable)


FNA issue https://github.com/FNA-XNA/FNA/issues/338
Comment 2 Sam Lantinga 2020-12-07 16:56:48 UTC
I don't have a WinRT environment to test, do you have a working patch for me to review?
Comment 3 Paul Cunningham 2020-12-08 08:49:43 UTC
Hi Sam,

I don't unfortuantely but I'll try and get it set up so I can debug and see if I can figure out what the issue is.

Paul