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 3358

Summary: SDL detects right-click events as left-click with Wacom devices in OS X
Product: SDL Reporter: duane_moody
Component: eventsAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED ABANDONED QA Contact: Sam Lantinga <slouken>
Severity: critical    
Priority: P2 CC: philipp.wiesemann
Version: 2.0.4   
Hardware: x86   
OS: Mac OS X 10.10   

Description duane_moody 2016-06-11 18:46:50 UTC
In both Blender 2.77 and GZDoom (SDL based apps), SDL misreads right-click events as left-click when using a Wacom tablet/stylus, effectively making right-click impossible. This is the case even when one of the physical tablet buttons is mapped to generate right-click. 

My guess is that SDL is reading the event at too low a level since other applications not built on SDL don't reproduce this problem (i.e. the Wacom driver's doing what it's supposed to).

https://github.com/alexey-lysiuk/gzdoom-osx/releases/tag/0.2.0
Comment 1 duane_moody 2016-06-11 22:29:24 UTC
    retval |= (cocoaButtons & (1 << 0)) ? SDL_BUTTON_LMASK : 0;
    retval |= (cocoaButtons & (1 << 1)) ? SDL_BUTTON_RMASK : 0;
    retval |= (cocoaButtons & (1 << 2)) ? SDL_BUTTON_MMASK : 0;
    retval |= (cocoaButtons & (1 << 3)) ? SDL_BUTTON_X1MASK : 0;
    retval |= (cocoaButtons & (1 << 4)) ? SDL_BUTTON_X2MASK : 0;


I'm throwing out a guess that the above snippet from SDL_cocoamouse.m's Cocoa_GetGlobalMouseState() which tests pressedMouseButtons is incorrect in how it compares cocoaButtons against the button bitmasks, each statement will always evaluate to false, and as a result will always return 0 (SDL_BUTTON_LMASK). 

Following the example in https://webkit.googlesource.com/WebKit/+/master/Source/WebKit2/Shared/mac/WebEventFactory.mm the equivalent codeblock would be 

    retval |= (cocoaButtons = 1 << 0) ? SDL_BUTTON_LMASK : 0;
    retval |= (cocoaButtons = 1 << 1) ? SDL_BUTTON_RMASK : 0;
    retval |= (cocoaButtons = 1 << 2) ? SDL_BUTTON_MMASK : 0;
    retval |= (cocoaButtons = 1 << 3) ? SDL_BUTTON_X1MASK : 0;
    retval |= (cocoaButtons = 1 << 4) ? SDL_BUTTON_X2MASK : 0;

Hopefully the ternary logic and/or the |= assignation aren't the problem here.
Comment 2 Philipp Wiesemann 2016-06-12 15:21:18 UTC
SDL_GetGlobalMouseState() seems not used in the linked source of GZDoom.
Comment 3 Philipp Wiesemann 2016-06-12 15:25:40 UTC
An it seems not to use SDL 2. :)
Comment 4 duane_moody 2016-06-22 00:04:48 UTC
(In reply to Philipp Wiesemann from comment #3)
> An it seems not to use SDL 2. :)

I stand corrected, GZDoom uses 1.2.15 but the error involving tablet events is consistent between 1.2.x and 2.x. 

https://www.renpy.org/latest.html
The Ren'Py 6.99.10 SDK for OS X contains Renpy.app: when run, select The Question from the Projects menu and then click Launch Project to start the demo.

Right-clicking anywhere on the screen should bring up a screen for saving game progress. Using a tablet, it only progresses the text as left-click would. Renpy.app uses SDL2 2.0.0. 

Older SDL games using SDL 1.2 such as Battle for Wesnoth demonstrate the issue; in contrast no Wx- or Qt-based applications do. I can only reproduce the error with SDL-based software. 

My apologies for being so far unable to pinpoint the underlying cause.
Comment 5 Ryan C. Gordon 2018-08-06 21:20:23 UTC
Hello, and sorry if you're getting dozens of copies of this message by email.

We are closing out bugs that appear to be abandoned in some form. This can happen for lots of reasons: we couldn't reproduce it, conversation faded out, the bug was noted as fixed in a comment but we forgot to mark it resolved, the report is good but the fix is impractical, we fixed it a long time ago without realizing there was an associated report, etc.

Individually, any of these bugs might have a better resolution (such as WONTFIX or WORKSFORME or INVALID) but we've added a new resolution of ABANDONED to make this easily searchable and make it clear that it's not necessarily unreasonable to revive a given bug report.

So if this bug is still a going concern and you feel it should still be open: please feel free to reopen it! But unless you respond, we'd like to consider these bugs closed, as many of them are several years old and overwhelming our ability to prioritize recent issues.

(please note that hundred of bug reports were sorted through here, so we apologize for any human error. Just reopen the bug in that case!)

Thanks,
--ryan.