Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Cactus Dan

macrumors member
Original poster
Aug 8, 2010
30
0
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

macrumors member
Original poster
Aug 8, 2010
30
0
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:
Code:
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:
Code:
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.