Exemplo n.º 1
0
void
COSXScreen::enter()
{
	showCursor();

	if (m_isPrimary) {
		CGSetLocalEventsSuppressionInterval(0.0);
		
		// enable global hotkeys
		//setGlobalHotKeysEnabled(true);
	}
	else {
		// reset buttons
		m_buttonState.reset();

		// avoid suppression of local hardware events
		// [email protected]
		CGSetLocalEventsFilterDuringSupressionState(
								kCGEventFilterMaskPermitAllEvents,
								kCGEventSupressionStateSupressionInterval);
		CGSetLocalEventsFilterDuringSupressionState(
								(kCGEventFilterMaskPermitLocalKeyboardEvents |
								kCGEventFilterMaskPermitSystemDefinedEvents),
								kCGEventSupressionStateRemoteMouseDrag);
	}

	// now on screen
	m_isOnScreen = true;
}
Exemplo n.º 2
0
bool
COSXScreen::leave()
{
    hideCursor();
    
	if (m_isPrimary) {
		// warp to center
		//warpCursor(m_xCenter, m_yCenter);
		
		// This used to be necessary to get smooth mouse motion on other screens,
		// but now is just to avoid a hesitating cursor when transitioning to
		// the primary (this) screen.
		CGSetLocalEventsSuppressionInterval(0.0001);
		
		// disable global hotkeys
		//setGlobalHotKeysEnabled(false);
	}
	else {
		// warp the mouse to the cursor center
		//fakeMouseMove(m_xCenter, m_yCenter);

		// FIXME -- prepare to show cursor if it moves

		// take keyboard focus	
		// FIXME
	}

	// now off screen
	m_isOnScreen = false;

	return true;
}
Exemplo n.º 3
0
BOOL LLWindowMacOSX::setCursorPosition(const LLCoordWindow position)
{
	BOOL result = FALSE;
	LLCoordScreen screen_pos;

	if (!convertCoords(position, &screen_pos))
	{
		return FALSE;
	}

	CGPoint newPosition;

	//	LL_INFOS() << "setCursorPosition(" << screen_pos.mX << ", " << screen_pos.mY << ")" << LL_ENDL;

	newPosition.x = screen_pos.mX;
	newPosition.y = screen_pos.mY;

	CGSetLocalEventsSuppressionInterval(0.0);
	if(CGWarpMouseCursorPosition(newPosition) == noErr)
	{
		result = TRUE;
	}

	// Under certain circumstances, this will trigger us to decouple the cursor.
	adjustCursorDecouple(true);

	// trigger mouse move callback
	LLCoordGL gl_pos;
	convertCoords(position, &gl_pos);
	mCallbacks->handleMouseMove(this, gl_pos, (MASK)0);

	return result;
}
GHOST_TSuccess GHOST_SystemCarbon::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y)
{
	float xf = (float)x, yf = (float)y;

	CGAssociateMouseAndMouseCursorPosition(false);
	CGSetLocalEventsSuppressionInterval(0);
	CGWarpMouseCursorPosition(CGPointMake(xf, yf));
	CGAssociateMouseAndMouseCursorPosition(true);

//this doesn't work properly, see game engine mouse-look scripts
//	CGWarpMouseCursorPosition(CGPointMake(xf, yf));
	// this call below sends event, but empties other events (like shift)
	// CGPostMouseEvent(CGPointMake(xf, yf), TRUE, 1, FALSE, 0);

	return GHOST_kSuccess;
}
Exemplo n.º 5
0
void init(){
#if (defined WIN32 || defined _MSC_VER)

#else
    #ifdef __APPLE__
		CGSetLocalEventsSuppressionInterval(0.0);
	#else
		#ifdef __linux__ 
		//LINUX
		#else
		//unsupported
		printf("Warning: Platform might not be supported! \n");
		printf("Warning: The platforms: Windows NT, Mac OS X (>=10.7) and Linux are supported"\n);
		#endif
	#endif
#endif
}
Exemplo n.º 6
0
bool
COSXScreen::leave()
{
	if (m_isPrimary) {
		// warp to center
		warpCursor(m_xCenter, m_yCenter);

		// capture events
		HideWindow(m_hiddenWindow);
		ShowWindow(m_userInputWindow);
		RepositionWindow(m_userInputWindow,
							m_userInputWindow, kWindowCenterOnMainScreen);
		SetUserFocusWindow(m_userInputWindow);

		// The OS will coalesce some events if they are similar enough in a
		// short period of time this is bad for us since we need every event
		// to send it over to other machines.  So disable it.		
		SetMouseCoalescingEnabled(false, NULL);
		CGSetLocalEventsSuppressionInterval(0.0001);

		// disable global hotkeys
		//setGlobalHotKeysEnabled(false);
	}
	else {
		// hide cursor
		if (!m_cursorHidden) {
//			CGDisplayHideCursor(m_displayID);
			m_cursorHidden = true;
		}

		// warp the mouse to the cursor center
		fakeMouseMove(m_xCenter, m_yCenter);

		// FIXME -- prepare to show cursor if it moves

		// take keyboard focus	
		// FIXME
	}

	// now off screen
	m_isOnScreen = false;

	return true;
}
Exemplo n.º 7
0
void init(){
    glShadeModel(GL_SMOOTH);
    glEnable (GL_BLEND);
    glEnable(GL_LINE_SMOOTH);
    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
    glBlendFunc (GL_SRC_ALPHA, GL_ONE);
    glEnable(GL_POLYGON_SMOOTH);
    glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
    
    glEnable(GL_CULL_FACE);
    glCullFace(GL_BACK);

    boidsList = new BoidController();
    boidsList->addBoids(500);
    //get rid of that pesky delay on a mac
    CGSetLocalEventsSuppressionInterval(0.0);
    setCamera();
    initLight();
}
Exemplo n.º 8
0
void start(bool centerMouse) {

    m_centerMouse = centerMouse;

    if(m_centerMouse)
    {
        // Recenter mouse
#ifdef __APPLE__
        CGSetLocalEventsSuppressionInterval(0);
        mCenterPoint.x = m_screenCenter[0];
        mCenterPoint.y = m_screenCenter[1];
        CGWarpMouseCursorPosition(mCenterPoint);
#elif __LINUX__
        display = XOpenDisplay(0);
        rootWindow = DefaultRootWindow(display);
        XWarpPointer(display, None, rootWindow, 0, 0, 0, 0, m_screenCenter[0], m_screenCenter[1]);
//        qApp->setOverrideCursor(QCursor(Qt::BlankCursor));
#endif
    }

    peerWindow = new PeerWindow(
                cinder::Vec2f(0,cinder::app::getWindowHeight()*0.875),
                cinder::Rectf(cinder::Vec2f(0,0),cinder::Vec2f(15*43,30)),
                cinder::ColorA(0.25,0.25,0.25,0.425)
                );
    chatWindow = new ChatWindow(
                cinder::Vec2f(cinder::app::getWindowWidth()*0.2,cinder::app::getWindowHeight()*0.2),
                cinder::Rectf(cinder::Vec2f(0,0),cinder::Vec2f(cinder::app::getWindowWidth()*0.6,cinder::app::getWindowHeight()*0.55)),
                cinder::ColorA(0.25,0.25,0.25,0.425)
                );
    chatEntry = new ChatEntry(
                cinder::Vec2f(cinder::app::getWindowWidth()*0.2,cinder::app::getWindowHeight()*0.85),
                cinder::Rectf(cinder::Vec2f(0,0),cinder::Vec2f(cinder::app::getWindowWidth()*0.6,cinder::app::getWindowHeight()*0.15)),
                cinder::ColorA(0.25,0.25,0.25,0.425)
                );
//    scoreWindow = new Score(
//                cinder::Vec2f(cinder::app::getWindowWidth()*0.6,cinder::app::getWindowHeight()*0.6),
//                cinder::Rectf(cinder::Vec2f(0,0),cinder::Vec2f(cinder::app::getWindowWidth()*0.2,cinder::app::getWindowHeight()*0.4)),
//                cinder::ColorA(0.25,0.25,0.25,0.425)
//                );
}
Exemplo n.º 9
0
void
COSXScreen::enter()
{
	if (m_isPrimary) {
		// stop capturing input, watch jump zones
		HideWindow( m_userInputWindow );
		ShowWindow( m_hiddenWindow );

		SetMouseCoalescingEnabled(true, NULL);

		CGSetLocalEventsSuppressionInterval(0.0);

		// enable global hotkeys
		//setGlobalHotKeysEnabled(true);
	}
	else {
		// show cursor
		if (m_cursorHidden) {
//			CGDisplayShowCursor(m_displayID);
			m_cursorHidden = false;
		}

		// reset buttons
		for (UInt32 i = 0; i < sizeof(m_buttons) / sizeof(m_buttons[0]); ++i) {
			m_buttons[i] = false;
		}

		// avoid suppression of local hardware events
		// [email protected]
		CGSetLocalEventsFilterDuringSupressionState(
								kCGEventFilterMaskPermitAllEvents,
								kCGEventSupressionStateSupressionInterval);
		CGSetLocalEventsFilterDuringSupressionState(
								(kCGEventFilterMaskPermitLocalKeyboardEvents |
								kCGEventFilterMaskPermitSystemDefinedEvents),
								kCGEventSupressionStateRemoteMouseDrag);
	}

	// now on screen
	m_isOnScreen = true;
}
Exemplo n.º 10
0
void
COSXScreen::enter()
{
	showCursor();

	if (m_isPrimary) {
		CGSetLocalEventsSuppressionInterval(0.0);
		
		// enable global hotkeys
		//setGlobalHotKeysEnabled(true);
	}
	else {
		// reset buttons
		m_buttonState.reset();

		// patch by Yutaka Tsutano
		// wakes the client screen
		// http://synergy-foss.org/spit/issues/details/3287#c12
		io_registry_entry_t entry = IORegistryEntryFromPath(
			kIOMasterPortDefault,
			"IOService:/IOResources/IODisplayWrangler");
		if (entry != MACH_PORT_NULL) {
			IORegistryEntrySetCFProperty(entry, CFSTR("IORequestIdle"), kCFBooleanFalse);
			IOObjectRelease(entry);
		}

		// avoid suppression of local hardware events
		// [email protected]
		CGSetLocalEventsFilterDuringSupressionState(
								kCGEventFilterMaskPermitAllEvents,
								kCGEventSupressionStateSupressionInterval);
		CGSetLocalEventsFilterDuringSupressionState(
								(kCGEventFilterMaskPermitLocalKeyboardEvents |
								kCGEventFilterMaskPermitSystemDefinedEvents),
								kCGEventSupressionStateRemoteMouseDrag);
	}

	// now on screen
	m_isOnScreen = true;
}
Exemplo n.º 11
0
int main( int argc, char **argv ) {

  // OS X suppresses events after mouse warp.  This resets the suppression 
  // interval to 0 so that events will not be suppressed. This also found
  // at http://stackoverflow.com/questions/728049/
  // glutpassivemotionfunc-and-glutwarpmousepointer
#ifdef __APPLE__
  CGSetLocalEventsSuppressionInterval( 0.0 );
#endif

  glutInit( &argc, argv );
  glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH );
  glutInitWindowSize( 0, 0 );
  glutCreateWindow( "Linear Interpolation Morphing Demo" );
  glutFullScreen();
  glutSetCursor( GLUT_CURSOR_NONE );

  GLEW_INIT();
  init();

  /* Register our Callbacks */
  glutDisplayFunc( display );
  glutKeyboardFunc( keyboard );
  glutKeyboardUpFunc( keylift );
  glutSpecialFunc( keyboard_ctrl );
  glutMouseFunc( mouse );
  glutMotionFunc( mouseroll );
  glutPassiveMotionFunc( mouselook );
  glutIdleFunc( idle );
  glutReshapeFunc( resizeEvent );

  /* PULL THE TRIGGER */
  glutMainLoop();
  return EXIT_SUCCESS;

}
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// Carbon_EnableMouse
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// Controls whether our Carbon event handler will handle mouse events or
// ignore them totally. Used around dialogs, similar to InputSprocket.
// If mouse events are enabled, we eat all the events we can handle, which
// means that they don't get passed back to the system.
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
void Carbon_EnableMouse( Boolean inState ) {
    int i;

    // set the state
    sMouseEnabled = inState;

    if ( inState ) {
        CGPoint newPoint;
        CGRect bounds;
        CGDirectDisplayID displayID;

        displayID = (CGDirectDisplayID) macPrefs.displayID;
        if ( displayID == 0 ) {
            displayID = kCGDirectMainDisplay;
        }

        bounds = CGDisplayBounds( displayID );

        // FIXME: this is hosed when you're running in a window .. that stuff is working with the display

        // If we're capturing the mouse, pin cursor to center of selected display.
        newPoint.x = bounds.origin.x + ( bounds.size.width / 2 );
        newPoint.y = bounds.origin.y + ( bounds.size.height / 2 );

        CGSetLocalEventsSuppressionInterval( 0.0 );
        CGWarpMouseCursorPosition( newPoint );
    }

    CGAssociateMouseAndMouseCursorPosition( !inState );

    // reset our internal states to default values
    sMouseDelta.h = sMouseDelta.v = 0;
    sMouseWheelDelta = 0;
    for ( i = 0; i < MAX_BUTTONS; i++ )
        sMouseButtons[i] = 0;
}
Exemplo n.º 13
0
/**
 * Initialize GLEW, GLUT and our Engine.
 */
void Engine::init( int *argc, char *argv[], const char *title ) {

#ifdef WII
  Engine::instance()->wiiInit();
#endif

  // OS X suppresses events after mouse warp.  This resets the suppression
  // interval to 0 so that events will not be suppressed. This also found
  // at http://stackoverflow.com/questions/728049/
  // glutpassivemotionfunc-and-glutwarpmousepointer
#ifdef __APPLE__
  CGSetLocalEventsSuppressionInterval( 0.0 );
#endif
  Util::InitRelativePaths(*argc, argv);
  glutInit( argc, argv );
  glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH );
  glutInitWindowSize( 500, 500 );
  glutCreateWindow( title );

  char *gtfs = getenv( "GLUT_FULLSCREEN" );
  if (gtfs && (strncmp(gtfs, "TRUE", 4) == 0)) {
    Engine::instance()->setFullScreen();
  }

  glutSetCursor( GLUT_CURSOR_NONE );

  GLEW_INIT();

  /* Register our Callbacks */
  instance()->unregisterDisplayFunc();
  glutDisplayFunc(Engine::display);
  glutKeyboardFunc( engineKeyboard );
  glutKeyboardUpFunc( engineKeylift );
  glutSpecialFunc( engineSpecialKeyboard );
  glutMouseFunc( engineMouse );
  glutMotionFunc( engineMouseMotion );
  glutPassiveMotionFunc( EngineMousePassive );
  glutIdleFunc( Engine::idle );
  glutReshapeFunc( engineResize );

  float glsl_vers;
  sscanf( (char *)glGetString( GL_SHADING_LANGUAGE_VERSION ), "%f", &glsl_vers );

  gprint( PRINT_DEBUG, "GL_VENDOR: %s\n", glGetString( GL_VENDOR ) );
  gprint( PRINT_DEBUG, "GL_RENDERER: %s\n", glGetString( GL_RENDERER ) );
  gprint( PRINT_DEBUG, "GL_VERSION: %s\n", glGetString( GL_VERSION ) );
  gprint( PRINT_DEBUG, "GL_SHADING_LANGUAGE_VERSION: %f\n", glsl_vers );

  glEnable( GL_DEPTH_TEST );
  glClearColor( 0.0, 0.0, 0.0, 1.0 );

  Engine *eng = Engine::instance();

  eng->glslVersion( glsl_vers );

  // Conjure up a default shader program to use until told otherwise.
  GLuint defaultProgram = Angel::InitShader( "./shaders/vEngine.glsl", 
					     "./shaders/fEngine.glsl" );
  eng->switchShader( defaultProgram );

  // Set the Camera List to use this shader,
  // And add, by default, a camera.
  eng->cams()->shader( defaultProgram );
  eng->cams()->addCamera( "defaultCamera" );
  eng->cams()->next();

  eng->rootScene()->shader( defaultProgram );

  // Set it up so that once the glut_mainloop exits,
  // It returns control to the application so we can cleanup ourselves.
#ifndef __APPLE__
  glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION );
#endif

}