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 4618 - WinRT/UWP: Mouse is unresponsive until adding blank cursor win32 resource to C# project
Summary: WinRT/UWP: Mouse is unresponsive until adding blank cursor win32 resource to ...
Status: CLOSED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: HG 2.1
Hardware: x86_64 Windows 10
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.10
Depends on:
Blocks:
 
Reported: 2019-05-03 17:28 UTC by bodie
Modified: 2019-06-09 21:55 UTC (History)
1 user (show)

See Also:


Attachments
Documentation changes for non-C++ WinRT apps (1.55 KB, patch)
2019-06-09 15:56 UTC, Ethan Lee
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description bodie 2019-05-03 17:28:05 UTC
When building a WinRT/UWP application in C#, the mouse snaps to the center and becomes unresponsive after the window gains focus. This behavior is mentioned in the comments here:

https://hg.libsdl.org/SDL/file/24883e864f7e/src/video/winrt/SDL_winrtmouse.cpp#l125

The workaround suggests adding the included src/main/winrt/SDL2-WinRTResources.rc file to your project. However, the fix for C# applications is a bit of a hassle:

1. Create the SDL2-WinRTResources.res file.
    a. Create a new Visual C++ .dll project in Visual Studio. Name it anything you want, ie. Dummy.dll.
    b. Right click the Project and Add Existing file: src\main\winrt\SDL2-WinRTResources.rc
    c. Build the Project for Release
    d. In Explorer, navigate to the Release folder within the Dummy project folder.
    e. Copy the SDL2-WinRTResources.res file and move it adjacent to your SDL2.dll in your C# project.

2. Add the SDL2-WinRTResources.res to your C# project.
    a. Open your C# Solution in Visual Studio.
    b. Right click your C# Project and select Add Existing Item
    c. Select and add SDL2-WinRTResources.res 
    d. Save All and close your solution in Visual Studio.
    e. Edit your Project.csproj in Notepad.
    f. Inside the first <PropertyGroup> xml block, add the following line

 <Win32Resource>SDL2-WinRTResources.res</Win32Resource>

    g. Save the file and re-open your C# project.
    h. Build and run your project!

This workaround works for me, however, I suggest adding the pre-built SDL2-WinRTResources.res to the repository!
Comment 1 Ryan C. Gordon 2019-05-18 18:48:54 UTC
Tagging a bunch of bugs with "target-2.0.10" so we have a clear list of things to address before a 2.0.10 release.

Please note that "addressing" one of these bugs might mean deciding to defer on it until after 2.0.10, or resolving it as WONTFIX, etc. This is just here to tell us we should look at it carefully, and soon.

If you have new information or feedback on this issue, this is a good time to add it to the conversation, as we're likely to be paying attention to this specific report in the next few days/weeks.

Thanks!

--ryan.
Comment 2 Ryan C. Gordon 2019-05-19 03:53:54 UTC
Tagging a bunch of bugs with "target-2.0.10" so we have a clear list of things to address before a 2.0.10 release.

Please note that "addressing" one of these bugs might mean deciding to defer on it until after 2.0.10, or resolving it as WONTFIX, etc. This is just here to tell us we should look at it carefully, and soon.

If you have new information or feedback on this issue, this is a good time to add it to the conversation, as we're likely to be paying attention to this specific report in the next few days/weeks.

Thanks!

--ryan.
Comment 3 Ethan Lee 2019-05-29 23:50:33 UTC
Turns out this is possible to fix without Visual Studio, it just needs to be added to SDL's documentation. Here's how we wrote it up in FNA's Xbox One docs:

https://github.com/FNA-XNA/FNA/wiki/Appendix-A%3A-FNA-on-Consoles#additional-resources
Comment 4 Ethan Lee 2019-06-09 15:56:20 UTC
Created attachment 3810 [details]
Documentation changes for non-C++ WinRT apps

Attached is a patch to add some quick notes about generating the resource file, as well as the SDL_WinRTRunApp function. This roughly mimics what we have documented in FNA's Xbox notes.
Comment 5 Sam Lantinga 2019-06-09 19:49:28 UTC
Documentation updated, thanks!
https://hg.libsdl.org/SDL/rev/77707a081153
Comment 6 bodie 2019-06-09 21:55:56 UTC
Looks good to me! Closing out.