PDA

View Full Version : Option key modifier?




Cactus Dan
Oct 10, 2010, 10:41 AM
Howdy,

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

I have a 3 button mouse (middle is wheel+button), and I'm trying to get viewport navigation in a little SDL/OpenGL 3D application to work by holding the option key down and dragging the left mouse button to rotate, and the right mouse button to zoom. The problem is the option key modifies the left mouse button to simulate a middle mouse button, and I'm going to later want the option key + middle mouse button to be used to move the view.

I could use the control key (which works) but it's the option key that is the industry standard in cross platform 3D applications for viewport navigation.

The ideal thing would be to only disable the option key modifier when the mouse is in the viewport window.

Any ideas?

Adios,
Cactus Dan



Cactus Dan
Oct 11, 2010, 02:17 PM
Howdy,

OK, I've found out that the problem is in the SDL library. It defaults to option key + left button simulating a middle button and command key + left button simulating a right button.

Now the question is how can I get the real mouse button state so I can compare the result to the SDL mouse button state result, and what Mac OS call do I need to use to do this?

Here is my current code in the main while loop:
while(!done)
{
SDL_GetMouseState(&state.x, &state.y);
state.LeftButtonDown = SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT);
state.MiddleButtonDown = SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_MIDDLE);
state.RightButtonDown = SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT);

drawScene();

SDL_Event event;
while(SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_QUIT:
done = 1;
break;
}

keys = SDL_GetKeyState(NULL);

if(keys[SDLK_LALT])
{
optionKeyDown = true; // global variable

// insert code to get the real mouse button state

}
else optionKeyDown = false;
}

if(updateNavigation())
done = 1;
}

Can someone point me in the right direction?

I can envision the code to insert into the above code would be:
if(state.MiddleButtonDown && getRealButtonState() == 1)
{
state.LeftButtonDown = 1;
state.MiddleButtonDown = 0;
}

... but I'm not sure how to write the "getRealButtonState" function. :confused:

Adios,
Cactus Dan