PDA

View Full Version : Mouse!



pran1
04-14-2004, 04:01 AM
Hi! I was wondering if someone could help me here. I have drwan a mouse cursor and I am using up arrow key to move it apasrt from the windows mouse. But till the time I dont move the windows mouse the cursors dont actually move apart is there anyways I can make them interactive.

void Mouse_motion(int x, int y)
{

mouse_current_x = x;
mouse_current_y = y ;
glutPostRedisplay ( );
//printf("x = %d, y = %d", x,y);
}

Mouse_Cursor(mouse_current_x - arrow_x , mouse_current_y - arrow_x, 0);

What I want to do is if I press the up arrow key the two mice should get separated without me having to move the windows mouse. Is this possible and if yes then how?

Many Thanks
Pran

nexusone
04-14-2004, 05:06 AM
Use the Special keyboard read function:

glutSpecialFunc(void (*func)(int key, int x, int y));

glutSpecialFunc( Arrow_keys );

Code would look something like this:

void Arrow_keys( int key, int x, int y)
{

if (key == GLUT_KEY_LEFT ) mouse_x_offset--;
if (key == GLUT_KEY_RIGHT ) mouse_x_offset++;
if (key == GLUT_KEY_UP ) mouse_y_offset--;
if (key == GLUT_KEY_DOWN ) mouse_y_offset++;

}


Originally posted by pran1:
Hi! I was wondering if someone could help me here. I have drwan a mouse cursor and I am using up arrow key to move it apasrt from the windows mouse. But till the time I dont move the windows mouse the cursors dont actually move apart is there anyways I can make them interactive.

void Mouse_motion(int x, int y)
{

mouse_current_x = x;
mouse_current_y = y ;
glutPostRedisplay ( );
//printf("x = %d, y = %d", x,y);
}

Mouse_Cursor(mouse_current_x - arrow_x , mouse_current_y - arrow_x, 0);

What I want to do is if I press the up arrow key the two mice should get separated without me having to move the windows mouse. Is this possible and if yes then how?

Many Thanks
Pran