New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move mouse handling to core and add MacOS mouse support #55
base: master
Are you sure you want to change the base?
Conversation
Thanks for all the work you put into this! At first glance this looks fine - the only reason this code was in the UI originally was because on the old winforms UI this allowed me to not have platform-specific code for Windows vs Linux, but it had to be changed to platform-specific code to work around issues I had with Avalonia, so putting it in the core is fine. I'm unfortunately pretty busy with RL stuff this week and then away for a couple of weeks after that, so I probably won't have time to review/test/merge this until the last week of April or so. Thanks again for taking the time to improve the macOS build! |
I have enabled Github actions in my fork, and it turns out the GCC-Linux build is failing for this branch. As far as I can see, it does not have any problem with the code itself, but when linking it fails to properly find the X11-library and gives a bunch of errors about not finding X11-functions. This is somewhat odd, as it apparently has no problem finding the headers as it compiles everything fine, and the Clang-builds link just fine. I can see that I still want to mess around with it a bit more (maybe the location of the library is not on the default search path?), but the Linux system I have is on Ubuntu 20 and there GCC fails to compile Mesen at all (as noted in the action file as well) so I am not able to test it locally. I do remember locally compiling things with GCC that need X11 and adding |
Turn out it was a silly issue, forgot that libraries need to go at the end of the link command. GCC compilation now works again |
This was originally intended to just add MacOS mouse support, but ended up changing quite a few things:
IMouseManager
(likeiKeyboardManager
)GlobalMouse*Impl
from the UIEmuAPI.cpp
(like how it is done for keyboard as well)InputApi.cpp
and matching entrypoints in the UIGlobalMouse
in the UIGlobalMouse
Linux
to a new directorySdl
, as these are shared between Linux and MacOSLinux
only when actually compiling for Linux, and add X11-library to linker flags#ifdef __APPLE__
block from code that now no longer gets compiled on MacOSGetPixelScale
, used for the MacOS implementation to work around oddities in Avalonia on Retina-screensThe reason for moving the mouse handling to the core was because being able to just write Obj-C++ (for the MacOS support) was easier, and only having MacOS go through the core felt weird. It also makes it so the core-library is the only library loaded by the UI (it no longer calls into
user32.dll
/libx11.so
) and the Windows/X11 implementation also looks a bit cleaner now that it does not have to go through C#. The other changes pretty much just came up as part of it.I have tested it on Linux and MacOS by compiling with the Makefile, and on Windows by using Visual Studio Community 2023. It compiles, runs and functions on all three.