lgblgblgb / xemu

Emulations (running on Linux/Unix/Windows/macOS, utilizing SDL2) of some - mainly - 8 bit machines, including the Commodore LCD, Commodore 65, and the MEGA65 as well.
https://github.com/lgblgblgb/xemu/wiki
GNU General Public License v2.0
201 stars 31 forks source link

MacOS: ctrl + click should generate right click event (trackpad of modern Mac notebooks lacks right click alone) #358

Closed dansanderson closed 1 year ago

dansanderson commented 1 year ago

Describe the bug Most of the Xemu interface is in the menu that appears when you right-click on the window. On a modern Mac laptop, a trackpad only has a single button, and right-click actions are implemented in the operating system as Ctrl+click. Xemu 20220613133247-master does not recognize Ctrl+click for opening the menu.

An external two-button mouse works fine. This only applies to the Mac laptop trackpad.

Used version of the project

CREATED: travis@lgb on Darwin 18.7.0 at Mon Jun 13 11:35:27 GMT 2022
CREATED: clang 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.33.8) 64LE for osx
VERSION: https://github.com/lgblgblgb/xemu.git master e6cd11f51fe6356dfb1cf569e6d4fe7906eb95b3 20220613133247 official-build
EMULATE: MEGA65 (mega65): xmega65 (../../build/bin/xmega65.native) for mega65 on osx (native) using cc

To Reproduce

  1. Find an (Intel) Macbook or Macbook Pro. Install and run Xemu.
  2. Control+click on the window. Nothing happens.

Expected behavior Right-click menu should appear with Control+click.

Computer/Device (please complete the following information):

lgblgblgb commented 1 year ago

@dansanderson Thanks for the report. I don't use Mac (or Windows), only Linux, so it's indeed really important to have feedback on my Mac and Windows ports of Xemu, since personally I don't use those systems, I only made it possible Xemu to be able to run on them. Mac is interesting, kind of "it has nothing", it has no right mouse button, no Insert key on the keyboard, and I heard millions of problems like that, what Mac has at all? ;-P Ok, sorry, it was the joke part (or at least meant to be that ... my odd sense of humor), I could not resist, please forget it.

Now more seriously: how can I test this at all without any modern notebook Mac? I have a donated Mac Mini (2018) for this purpose, but surely it's not a notebook, has no apple specific peripherals etc, only standard PC keyboard/mouse, I can test with on demand. If you have any idea, please comment. Surely I should be able to test this somehow to see if I can come up with some fix, and if it fixes the problem at all.

By the way, it can be even outside-of-Xemu problem, as I rely on SDL2, so if it does not pass that ctrl+click as right click, then it's an SDL2 bug (but to be fair, I can try to work around it, even if it's ugly ...).

lgblgblgb commented 1 year ago

@dansanderson By the way, just google'ing for "SDL mac right click", I can find similar reports even on various games using SDL2 it seems.

However I've just found this:

https://wiki.libsdl.org/SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK

A hint that specifies whether ctrl+click should generate a right-click event on Mac By default holding ctrl while left clicking will not generate a right click event when on Mac

Aha ... So it's not default in SDL, but I should request this feature myself ... Interesting. If it's all true, the fix is trivial.

lgblgblgb commented 1 year ago

The commit above should handle to activation of the SDL2 workaround. Though, to be honest, I had no chance yet to test on a real Mac, and even if test, I cannot tell it helps on a real Apple notebook with touchpad only ...

I close this now, @dansanderson please comment or re-open if you think it does not fix the problem. Thank you!