SDL 1.2.14 Mac OS Option key modifier?

Howdy,

How do I disable the option key modifier for the left mouse button?

On Mac OS, holding the option key down is modifying the mouse button event to make the left mouse button behave as though it is a middle mouse button. This is a traditional Mac OS convention that goes back to when the Mac only had a single button mouse. The same thing is applied to the command key, which modifies the mouse button event to make the left mouse button behave as though it is a right mouse button.

Is it something I can disable with an SDL call or does that have to be disabled with a Mac OS call?

Adios,
Cactus Dan

Howdy,

OK, upon further investigation, I may have discovered where the problem is.

In the SDL 1.2.14 source code file “SDL_macevents.c”, in the function “Mac_HandleEvents()”, this section of code is the cause of the problem:

case inContent:
myGlobalToLocal(this, &event.where);
/* Treat command-click as right mouse button */
if ( event.modifiers & optionKey ) {
mouse_button = 2;
} else if ( event.modifiers & cmdKey ) {
mouse_button = 3;
} else {
mouse_button = 1;
}
SDL_PrivateMouseButton(SDL_PRESSED,
mouse_button, event.where.h, event.where.v);
break;

Now the questions are:
Is there an SDL flag that can be set to ignore the above code to modify the button event?
And if not, how can we make a feature request to add that ability in a future release?

A single button mouse on a Mac is rare these days, so we really need the ability to at least check the mouse type and override the above code (unless that’s already in there somewhere?).

Adios,
Cactus Dan

Howdy,

Well, I found the XCode project for the SDL library, commented out those lines of code and compiled it, but that didn’t change anything. The option key modifier is still modifying the left button down event.

I don’t know where else to look. :frowning:

Adios,
Cactus Dan

Howdy,

OK, finally getting back to investigating this issue further, and I’ve made another discovery in the SDL code that may be causing it.

In the file “SDL_QuartzEvents.m” and the function “QZ_PumpEvents()”, there are these lines of code:

Code:
switch (type) {
case NSLeftMouseDown:
if ( SDL_getenv(“SDL_HAS3BUTTONMOUSE”) ) {
DO_MOUSE_DOWN (SDL_BUTTON_LEFT);
} else {
if ( NSCommandKeyMask & current_mods ) {
last_virtual_button = SDL_BUTTON_RIGHT;
DO_MOUSE_DOWN (SDL_BUTTON_RIGHT);
}
else if ( NSAlternateKeyMask & current_mods ) {
last_virtual_button = SDL_BUTTON_MIDDLE;
DO_MOUSE_DOWN (SDL_BUTTON_MIDDLE);
}
else {
DO_MOUSE_DOWN (SDL_BUTTON_LEFT);
}
}
break;

Now if I change that code, forcing it to default to only the left button like this:

Code:
switch (type) {
case NSLeftMouseDown:
DO_MOUSE_DOWN (SDL_BUTTON_LEFT);
/if ( SDL_getenv(“SDL_HAS3BUTTONMOUSE”) ) {
DO_MOUSE_DOWN (SDL_BUTTON_LEFT);
} else {
if ( NSCommandKeyMask & current_mods ) {
last_virtual_button = SDL_BUTTON_RIGHT;
DO_MOUSE_DOWN (SDL_BUTTON_RIGHT);
}
else if ( NSAlternateKeyMask & current_mods ) {
last_virtual_button = SDL_BUTTON_MIDDLE;
DO_MOUSE_DOWN (SDL_BUTTON_MIDDLE);
}
else {
DO_MOUSE_DOWN (SDL_BUTTON_LEFT);
}
}
/
break;

… then it does actually ignore the Option and Command key modifiers when the left mouse button is pressed.

It looks like this line:

Code:
if ( SDL_getenv(“SDL_HAS3BUTTONMOUSE”) )

… has something to do with testing if there is a 3 button mouse, and ignore the Option and Command key modifiers when the left mouse button is pressed.
Is that a correct assumption?
And if so, why is it failing to detect the 3 button mouse?

Adios,
Cactus Dan

Howdy,

OK, GOT IT!

The solution is to not change any code in the SDL library, but simply add this line:

Code:
SDL_putenv(const_cast<char*>(“SDL_HAS3BUTTONMOUSE”));

… to my SDL initialize function to set that up in the environment.

Just curious why there’s no easy to find information for this in the SDL documentation?

Adios,
Cactus Dan