Exemplo n.º 1
0
void LLWindowMacOSX::adjustCursorDecouple(bool warpingMouse)
{
	if(mIsMouseClipping && mCursorHidden)
	{
		if(warpingMouse)
		{
			// The cursor should be decoupled.  Make sure it is.
			if(!mCursorDecoupled)
			{
				//			LL_INFOS() << "adjustCursorDecouple: decoupling cursor" << LL_ENDL;
				CGAssociateMouseAndMouseCursorPosition(false);
				mCursorDecoupled = true;
				mCursorIgnoreNextDelta = TRUE;
			}
		}
	}
	else
	{
		// The cursor should not be decoupled.  Make sure it isn't.
		if(mCursorDecoupled)
		{
			//			LL_INFOS() << "adjustCursorDecouple: recoupling cursor" << LL_ENDL;
			CGAssociateMouseAndMouseCursorPosition(true);
			mCursorDecoupled = false;
		}
	}
}
Exemplo n.º 2
0
void Input::mouseVisible(bool visible)
{
    if (visible)
    {
#ifdef __APPLE__
    	CGAssociateMouseAndMouseCursorPosition(TRUE);
	    CGDisplayShowCursor(kCGDirectMainDisplay);
#else
        glfwEnable(GLFW_MOUSE_CURSOR);
        glfwSetMousePos(m_mouseMiddleX, m_mouseMiddleY);
#endif
    }
    else
    {
#ifdef __APPLE__
	    glfwSetMousePos(m_mouseMiddleX, m_mouseMiddleY);
        CGDisplayHideCursor(kCGDirectMainDisplay);
	    CGPoint p;
	    p.x = m_mouseMiddleX;
	    p.y = m_mouseMiddleY;
	    //CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, p);
	    CGWarpMouseCursorPosition(p);
	    CGAssociateMouseAndMouseCursorPosition(FALSE);
#else
        glfwDisable(GLFW_MOUSE_CURSOR);
        glfwSetMousePos(m_mouseMiddleX, m_mouseMiddleY);
#endif
    }
    m_mouseVisible = visible;
}
Exemplo n.º 3
0
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXMouseEventQueue_nGrabMouse(JNIEnv *env, jclass unused, jboolean grab) {
    CGAssociateMouseAndMouseCursorPosition(grab == JNI_TRUE ? FALSE : TRUE);
    if (grab)
        CGDisplayHideCursor(kCGDirectMainDisplay);
    else
        CGDisplayShowCursor(kCGDirectMainDisplay);
}
PsychError SCREENSetMouseHelper(void)
{
    int	screenNumber;
    int xPos, yPos;
    int deviceIdx = -1;
    int detachFromMouse = 0;

    //all subfunctions should have these two lines.
    PsychPushHelp(useString, synopsisString, seeAlsoString);
    if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};

    PsychErrorExit(PsychCapNumInputArgs(5));   //The maximum number of inputs
    PsychErrorExit(PsychCapNumOutputArgs(0));  //The maximum number of outputs

    PsychCopyInScreenNumberArg(1, TRUE, &screenNumber);
    PsychCopyInIntegerArg(2,TRUE, &xPos);
    PsychCopyInIntegerArg(3,TRUE, &yPos);
    PsychCopyInIntegerArg(4,FALSE, &deviceIdx);
    PsychCopyInIntegerArg(5,FALSE, &detachFromMouse);

    // Position the cursor. On OSX this will also automatically attach it
    // to mouse movement:
    PsychPositionCursor(screenNumber, xPos, yPos, deviceIdx);

    #if PSYCH_SYSTEM == PSYCH_OSX
        if (detachFromMouse) CGAssociateMouseAndMouseCursorPosition(false);
    #endif

    return(PsychError_none);
}
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.º 6
0
void
COSXScreen::hideCursor()
{
	LOG((CLOG_DEBUG "hiding cursor"));

	CFStringRef propertyString = CFStringCreateWithCString(
		NULL, "SetsCursorInBackground", kCFStringEncodingMacRoman);

	CGSSetConnectionProperty(
		_CGSDefaultConnection(), _CGSDefaultConnection(),
		propertyString, kCFBooleanTrue);

	CFRelease(propertyString);

	CGError error = CGDisplayHideCursor(m_displayID);
	if (error != kCGErrorSuccess) {
		LOG((CLOG_ERR "failed to hide cursor, error=%d", error));
	}

	// appears to fix "mouse randomly not hiding" bug
	CGAssociateMouseAndMouseCursorPosition(true);

	if (CGCursorIsVisible()) {
		LOG((CLOG_WARN "cursor may be still visible"));
	}

	m_cursorHidden = true;
}
Exemplo n.º 7
0
FREObject setCursorPos(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[])
{
    int tx = 0;
    int ty = 0;
    FREGetObjectAsInt32(argv[0], &tx);
    FREGetObjectAsInt32(argv[1], &ty);

    //as3Print("Set cursor pos \n");//,tx,ty);

    CGPoint point;
    point.x = tx;
    point.y = ty;

    CGAssociateMouseAndMouseCursorPosition(true);
    
    //CGWarpMouseCursorPosition(point);
   // printf("Error : %i\n",error);
    CGDisplayMoveCursorToPoint(CGMainDisplayID(),point);

    CGAssociateMouseAndMouseCursorPosition(true);
    CGEventRef mouse = CGEventCreateMouseEvent (NULL, kCGEventMouseMoved, CGPointMake(tx, ty),0);
    CGEventPost(kCGHIDEventTap, mouse);
    CFRelease(mouse);
    
    
    CGEventRef event = CGEventCreate(NULL);
    CGPoint cursorGet = CGEventGetLocation(event);
    CFRelease(event);
    
    
    
    char msg[256];
    sprintf(msg,"After set, check pos %f %f\n",cursorGet.x, cursorGet.y);
    //as3Print(msg);
    
    FREObject result;
    FRENewObjectFromBool(1, &result);
    //FRENewObjectFromBool(true,&result);
    return result;
}
Exemplo n.º 8
0
void darwinMouseRelease(QWidget *pWidget)
{
    UICocoaApplication::instance()->unregisterForNativeEvents(RT_BIT_32(1)  | /* NSLeftMouseDown */
                                                              RT_BIT_32(2)  | /* NSLeftMouseUp */
                                                              RT_BIT_32(3)  | /* NSRightMouseDown */
                                                              RT_BIT_32(4)  | /* NSRightMouseUp */
                                                              RT_BIT_32(5)  | /* NSMouseMoved */
                                                              RT_BIT_32(6)  | /* NSLeftMouseDragged */
                                                              RT_BIT_32(7)  | /* NSRightMouseDragged */
                                                              RT_BIT_32(25) | /* NSOtherMouseDown */
                                                              RT_BIT_32(26) | /* NSOtherMouseUp */
                                                              RT_BIT_32(27) | /* NSOtherMouseDragged */
                                                              RT_BIT_32(22),  /* NSScrollWheel */
                                                              ::darwinMouseGrabEvents, pWidget);
    CGAssociateMouseAndMouseCursorPosition(true);
}
void FOutputDeviceMacError::HandleError()
{
	// make sure we don't report errors twice
	static int32 CallCount = 0;
	int32 NewCallCount = FPlatformAtomics::InterlockedIncrement(&CallCount);
	if (NewCallCount != 1)
	{
		UE_LOG(LogMac, Error, TEXT("HandleError re-entered.") );
		return;
	}

	// Trigger the OnSystemFailure hook if it exists
	FCoreDelegates::OnHandleSystemError.Broadcast();

	try
	{
		GIsGuarded				= 0;
		GIsRunning				= 0;
		GIsCriticalError		= 1;
		GLogConsole				= NULL;
		GErrorHist[ARRAY_COUNT(GErrorHist)-1]=0;

		// Dump the error and flush the log.
		UE_LOG(LogMac, Log, TEXT("=== Critical error: ===") LINE_TERMINATOR TEXT("%s") LINE_TERMINATOR, GErrorExceptionDescription);
		UE_LOG(LogMac, Log, GErrorHist);

		GLog->Flush();

		// Unhide the mouse.
		while (!CGCursorIsVisible())
		{
			CGDisplayShowCursor(kCGDirectMainDisplay);
		}
		// Release capture and allow mouse to freely roam around.
		CGAssociateMouseAndMouseCursorPosition(true);

		FPlatformMisc::ClipboardCopy(GErrorHist);

		FPlatformMisc::SubmitErrorReport( GErrorHist, EErrorReportMode::Interactive );

		FCoreDelegates::OnShutdownAfterError.Broadcast();
	}
	catch( ... )
	{}
}
Exemplo n.º 10
0
void BaseApp::captureMouse(const bool value){
#ifndef NO_CAPTURE_MOUSE
	if (mouseCaptured != value){
		//static int mouseX, mouseY;
		if (value){
			CGDisplayHideCursor(kCGDirectMainDisplay);

			setCursorPos(width / 2, height / 2);
		} else {
			CGDisplayShowCursor(kCGDirectMainDisplay);

			// TODO: Fix ...
			//setCursorPos(mouseX, mouseY);
		}
		CGAssociateMouseAndMouseCursorPosition(mouseCaptured);

		mouseCaptured = value;
	}
#endif
}
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// 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;
}
void
InputManager::init(size_t p_windowHandle, uint p_width, uint p_height)
{
    std::ostringstream windowHndStr;
    windowHndStr << p_windowHandle;

    OIS::ParamList paramList;
    paramList.insert(std::make_pair(
            std::string("WINDOW"), 
            windowHndStr.str()));

#if defined OIS_WIN32_PLATFORM
    paramList.insert(std::make_pair(
            std::string("w32_mouse"), 
            std::string("DISCL_FOREGROUND" )));
    paramList.insert(std::make_pair(
            std::string("w32_mouse"), 
            std::string("DISCL_NONEXCLUSIVE")));
    paramList.insert(std::make_pair(
            std::string("w32_keyboard"), 
            std::string("DISCL_FOREGROUND")));
    paramList.insert(std::make_pair(
            std::string("w32_keyboard"), 
            std::string("DISCL_NONEXCLUSIVE")));
#elif defined OIS_LINUX_PLATFORM
    paramList.insert(std::make_pair(
            std::string("x11_mouse_grab"), 
            std::string("false")));
    paramList.insert(std::make_pair(
            std::string("x11_mouse_hide"), 
            std::string("false")));
    paramList.insert(std::make_pair(
            std::string("x11_keyboard_grab"), 
            std::string("false")));
    paramList.insert(std::make_pair(
            std::string("XAutoRepeatOn"), 
            std::string("true")));
#elif defined OIS_APPLE_PLATFORM

#endif

    /// @todo TODO: disable key repeat on all platforms

    m_inputManager = OIS::InputManager::createInputSystem(paramList);

    m_keyboard = static_cast<OIS::Keyboard*>(
            m_inputManager->createInputObject(OIS::OISKeyboard, true));
            
    m_keyboard->setEventCallback(this);

    m_mouse = static_cast<OIS::Mouse*>(
        m_inputManager->createInputObject(OIS::OISMouse, true));

    m_mouse->setEventCallback(this);

    const OIS::MouseState& ms = m_mouse->getMouseState();
    ms.width = p_width;
    ms.height = p_height;

#ifdef __MAC__
    CGAssociateMouseAndMouseCursorPosition(TRUE);
    CGDisplayShowCursor(kCGDirectMainDisplay);
#endif

    try 
    {
        m_joystick = static_cast<OIS::JoyStick*>(
                m_inputManager->createInputObject(OIS::OISJoyStick, false));
    }
    catch(...) 
    {
        m_joystick = 0;
    }

    if(m_joystick)
        m_joystick->setEventCallback(this);

    m_initialized = true;
}
Exemplo n.º 13
0
void _glfwPlatformShowMouseCursor( void )
{
    // TO DO: What if we fail here?
    CGDisplayShowCursor( kCGDirectMainDisplay );
    CGAssociateMouseAndMouseCursorPosition( true );
}
Exemplo n.º 14
0
  OisInputListener::OisInputListener(size_t handle, Engine* eventRedirect) :
    InputHandler(handle, eventRedirect),
    mMouse(0),
    mKeyboard(0),
    mInputManager(0),
    mEventRedirect(eventRedirect),
    mHandle(handle)
  {
    LOG(INFO) << "*** Initializing OIS ***";
    OIS::ParamList pl;
    std::ostringstream windowHndStr;

    windowHndStr << handle;
    pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
#if defined OIS_WIN32_PLATFORM
    pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND" )));
    pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
    pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND")));
    pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE")));
#elif defined OIS_LINUX_PLATFORM
    pl.insert(std::make_pair(std::string("x11_mouse_grab"), std::string("false")));
    pl.insert(std::make_pair(std::string("x11_mouse_hide"), std::string("true")));
    pl.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false")));
    pl.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
#endif

#ifdef OIS_APPLE_PLATFORM
    CGDisplayShowCursor(kCGDirectMainDisplay);
    CGAssociateMouseAndMouseCursorPosition(TRUE);
#endif

    mInputManager = OIS::InputManager::createInputSystem( pl );
    mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, true ));
    mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, true ));

    mMouse->setEventCallback(this);
    mKeyboard->setEventCallback(this);

    mKeyMap[OIS::KC_UNASSIGNED] = KeyboardEvent::KC_UNASSIGNED;
    mKeyMap[OIS::KC_ESCAPE] = KeyboardEvent::KC_ESCAPE;
    mKeyMap[OIS::KC_1] = KeyboardEvent::KC_1;
    mKeyMap[OIS::KC_2] = KeyboardEvent::KC_2;
    mKeyMap[OIS::KC_3] = KeyboardEvent::KC_3;
    mKeyMap[OIS::KC_4] = KeyboardEvent::KC_4;
    mKeyMap[OIS::KC_5] = KeyboardEvent::KC_5;
    mKeyMap[OIS::KC_6] = KeyboardEvent::KC_6;
    mKeyMap[OIS::KC_7] = KeyboardEvent::KC_7;
    mKeyMap[OIS::KC_8] = KeyboardEvent::KC_8;
    mKeyMap[OIS::KC_9] = KeyboardEvent::KC_9;
    mKeyMap[OIS::KC_0] = KeyboardEvent::KC_0;
    mKeyMap[OIS::KC_MINUS] = KeyboardEvent::KC_MINUS;
    mKeyMap[OIS::KC_EQUALS] = KeyboardEvent::KC_EQUALS;
    mKeyMap[OIS::KC_BACK] = KeyboardEvent::KC_BACK;
    mKeyMap[OIS::KC_TAB] = KeyboardEvent::KC_TAB;
    mKeyMap[OIS::KC_Q] = KeyboardEvent::KC_Q;
    mKeyMap[OIS::KC_W] = KeyboardEvent::KC_W;
    mKeyMap[OIS::KC_E] = KeyboardEvent::KC_E;
    mKeyMap[OIS::KC_R] = KeyboardEvent::KC_R;
    mKeyMap[OIS::KC_T] = KeyboardEvent::KC_T;
    mKeyMap[OIS::KC_Y] = KeyboardEvent::KC_Y;
    mKeyMap[OIS::KC_U] = KeyboardEvent::KC_U;
    mKeyMap[OIS::KC_I] = KeyboardEvent::KC_I;
    mKeyMap[OIS::KC_O] = KeyboardEvent::KC_O;
    mKeyMap[OIS::KC_P] = KeyboardEvent::KC_P;
    mKeyMap[OIS::KC_LBRACKET] = KeyboardEvent::KC_LBRACKET;
    mKeyMap[OIS::KC_RBRACKET] = KeyboardEvent::KC_RBRACKET;
    mKeyMap[OIS::KC_RETURN] = KeyboardEvent::KC_RETURN;
    mKeyMap[OIS::KC_LCONTROL] = KeyboardEvent::KC_LCONTROL;
    mKeyMap[OIS::KC_A] = KeyboardEvent::KC_A;
    mKeyMap[OIS::KC_S] = KeyboardEvent::KC_S;
    mKeyMap[OIS::KC_D] = KeyboardEvent::KC_D;
    mKeyMap[OIS::KC_F] = KeyboardEvent::KC_F;
    mKeyMap[OIS::KC_G] = KeyboardEvent::KC_G;
    mKeyMap[OIS::KC_H] = KeyboardEvent::KC_H;
    mKeyMap[OIS::KC_J] = KeyboardEvent::KC_J;
    mKeyMap[OIS::KC_K] = KeyboardEvent::KC_K;
    mKeyMap[OIS::KC_L] = KeyboardEvent::KC_L;
    mKeyMap[OIS::KC_SEMICOLON] = KeyboardEvent::KC_SEMICOLON;
    mKeyMap[OIS::KC_APOSTROPHE] = KeyboardEvent::KC_APOSTROPHE;
    mKeyMap[OIS::KC_GRAVE] = KeyboardEvent::KC_GRAVE;
    mKeyMap[OIS::KC_LSHIFT] = KeyboardEvent::KC_LSHIFT;
    mKeyMap[OIS::KC_BACKSLASH] = KeyboardEvent::KC_BACKSLASH;
    mKeyMap[OIS::KC_Z] = KeyboardEvent::KC_Z;
    mKeyMap[OIS::KC_X] = KeyboardEvent::KC_X;
    mKeyMap[OIS::KC_C] = KeyboardEvent::KC_C;
    mKeyMap[OIS::KC_V] = KeyboardEvent::KC_V;
    mKeyMap[OIS::KC_B] = KeyboardEvent::KC_B;
    mKeyMap[OIS::KC_N] = KeyboardEvent::KC_N;
    mKeyMap[OIS::KC_M] = KeyboardEvent::KC_M;
    mKeyMap[OIS::KC_COMMA] = KeyboardEvent::KC_COMMA;
    mKeyMap[OIS::KC_PERIOD] = KeyboardEvent::KC_PERIOD;
    mKeyMap[OIS::KC_SLASH] = KeyboardEvent::KC_SLASH;
    mKeyMap[OIS::KC_RSHIFT] = KeyboardEvent::KC_RSHIFT;
    mKeyMap[OIS::KC_MULTIPLY] = KeyboardEvent::KC_MULTIPLY;
    mKeyMap[OIS::KC_LMENU] = KeyboardEvent::KC_LMENU;
    mKeyMap[OIS::KC_SPACE] = KeyboardEvent::KC_SPACE;
    mKeyMap[OIS::KC_CAPITAL] = KeyboardEvent::KC_CAPITAL;
    mKeyMap[OIS::KC_F1] = KeyboardEvent::KC_F1;
    mKeyMap[OIS::KC_F2] = KeyboardEvent::KC_F2;
    mKeyMap[OIS::KC_F3] = KeyboardEvent::KC_F3;
    mKeyMap[OIS::KC_F4] = KeyboardEvent::KC_F4;
    mKeyMap[OIS::KC_F5] = KeyboardEvent::KC_F5;
    mKeyMap[OIS::KC_F6] = KeyboardEvent::KC_F6;
    mKeyMap[OIS::KC_F7] = KeyboardEvent::KC_F7;
    mKeyMap[OIS::KC_F8] = KeyboardEvent::KC_F8;
    mKeyMap[OIS::KC_F9] = KeyboardEvent::KC_F9;
    mKeyMap[OIS::KC_F10] = KeyboardEvent::KC_F10;
    mKeyMap[OIS::KC_NUMLOCK] = KeyboardEvent::KC_NUMLOCK;
    mKeyMap[OIS::KC_SCROLL] = KeyboardEvent::KC_SCROLL;
    mKeyMap[OIS::KC_NUMPAD7] = KeyboardEvent::KC_NUMPAD7;
    mKeyMap[OIS::KC_NUMPAD8] = KeyboardEvent::KC_NUMPAD8;
    mKeyMap[OIS::KC_NUMPAD9] = KeyboardEvent::KC_NUMPAD9;
    mKeyMap[OIS::KC_SUBTRACT] = KeyboardEvent::KC_SUBTRACT;
    mKeyMap[OIS::KC_NUMPAD4] = KeyboardEvent::KC_NUMPAD4;
    mKeyMap[OIS::KC_NUMPAD5] = KeyboardEvent::KC_NUMPAD5;
    mKeyMap[OIS::KC_NUMPAD6] = KeyboardEvent::KC_NUMPAD6;
    mKeyMap[OIS::KC_ADD] = KeyboardEvent::KC_ADD;
    mKeyMap[OIS::KC_NUMPAD1] = KeyboardEvent::KC_NUMPAD1;
    mKeyMap[OIS::KC_NUMPAD2] = KeyboardEvent::KC_NUMPAD2;
    mKeyMap[OIS::KC_NUMPAD3] = KeyboardEvent::KC_NUMPAD3;
    mKeyMap[OIS::KC_NUMPAD0] = KeyboardEvent::KC_NUMPAD0;
    mKeyMap[OIS::KC_DECIMAL] = KeyboardEvent::KC_DECIMAL;
    mKeyMap[OIS::KC_OEM_102] = KeyboardEvent::KC_OEM_102;
    mKeyMap[OIS::KC_F11] = KeyboardEvent::KC_F11;
    mKeyMap[OIS::KC_F12] = KeyboardEvent::KC_F12;
    mKeyMap[OIS::KC_F13] = KeyboardEvent::KC_F13;
    mKeyMap[OIS::KC_F14] = KeyboardEvent::KC_F14;
    mKeyMap[OIS::KC_F15] = KeyboardEvent::KC_F15;
    mKeyMap[OIS::KC_KANA] = KeyboardEvent::KC_KANA;
    mKeyMap[OIS::KC_ABNT_C1] = KeyboardEvent::KC_ABNT_C1;
    mKeyMap[OIS::KC_CONVERT] = KeyboardEvent::KC_CONVERT;
    mKeyMap[OIS::KC_NOCONVERT] = KeyboardEvent::KC_NOCONVERT;
    mKeyMap[OIS::KC_YEN] = KeyboardEvent::KC_YEN;
    mKeyMap[OIS::KC_ABNT_C2] = KeyboardEvent::KC_ABNT_C2;
    mKeyMap[OIS::KC_NUMPADEQUALS] = KeyboardEvent::KC_NUMPADEQUALS;
    mKeyMap[OIS::KC_PREVTRACK] = KeyboardEvent::KC_PREVTRACK;
    mKeyMap[OIS::KC_AT] = KeyboardEvent::KC_AT;
    mKeyMap[OIS::KC_COLON] = KeyboardEvent::KC_COLON;
    mKeyMap[OIS::KC_UNDERLINE] = KeyboardEvent::KC_UNDERLINE;
    mKeyMap[OIS::KC_KANJI] = KeyboardEvent::KC_KANJI;
    mKeyMap[OIS::KC_STOP] = KeyboardEvent::KC_STOP;
    mKeyMap[OIS::KC_AX] = KeyboardEvent::KC_AX;
    mKeyMap[OIS::KC_UNLABELED] = KeyboardEvent::KC_UNLABELED;
    mKeyMap[OIS::KC_NEXTTRACK] = KeyboardEvent::KC_NEXTTRACK;
    mKeyMap[OIS::KC_NUMPADENTER] = KeyboardEvent::KC_NUMPADENTER;
    mKeyMap[OIS::KC_RCONTROL] = KeyboardEvent::KC_RCONTROL;
    mKeyMap[OIS::KC_MUTE] = KeyboardEvent::KC_MUTE;
    mKeyMap[OIS::KC_CALCULATOR] = KeyboardEvent::KC_CALCULATOR;
    mKeyMap[OIS::KC_PLAYPAUSE] = KeyboardEvent::KC_PLAYPAUSE;
    mKeyMap[OIS::KC_MEDIASTOP] = KeyboardEvent::KC_MEDIASTOP;
    mKeyMap[OIS::KC_VOLUMEDOWN] = KeyboardEvent::KC_VOLUMEDOWN;
    mKeyMap[OIS::KC_VOLUMEUP] = KeyboardEvent::KC_VOLUMEUP;
    mKeyMap[OIS::KC_WEBHOME] = KeyboardEvent::KC_WEBHOME;
    mKeyMap[OIS::KC_NUMPADCOMMA] = KeyboardEvent::KC_NUMPADCOMMA;
    mKeyMap[OIS::KC_DIVIDE] = KeyboardEvent::KC_DIVIDE;
    mKeyMap[OIS::KC_SYSRQ] = KeyboardEvent::KC_SYSRQ;
    mKeyMap[OIS::KC_RMENU] = KeyboardEvent::KC_RMENU;
    mKeyMap[OIS::KC_PAUSE] = KeyboardEvent::KC_PAUSE;
    mKeyMap[OIS::KC_HOME] = KeyboardEvent::KC_HOME;
    mKeyMap[OIS::KC_UP] = KeyboardEvent::KC_UP;
    mKeyMap[OIS::KC_PGUP] = KeyboardEvent::KC_PGUP;
    mKeyMap[OIS::KC_LEFT] = KeyboardEvent::KC_LEFT;
    mKeyMap[OIS::KC_RIGHT] = KeyboardEvent::KC_RIGHT;
    mKeyMap[OIS::KC_END] = KeyboardEvent::KC_END;
    mKeyMap[OIS::KC_DOWN] = KeyboardEvent::KC_DOWN;
    mKeyMap[OIS::KC_PGDOWN] = KeyboardEvent::KC_PGDOWN;
    mKeyMap[OIS::KC_INSERT] = KeyboardEvent::KC_INSERT;
    mKeyMap[OIS::KC_DELETE] = KeyboardEvent::KC_DELETE;
    mKeyMap[OIS::KC_LWIN] = KeyboardEvent::KC_LWIN;
    mKeyMap[OIS::KC_RWIN] = KeyboardEvent::KC_RWIN;
    mKeyMap[OIS::KC_APPS] = KeyboardEvent::KC_APPS;
    mKeyMap[OIS::KC_POWER] = KeyboardEvent::KC_POWER;
    mKeyMap[OIS::KC_SLEEP] = KeyboardEvent::KC_SLEEP;
    mKeyMap[OIS::KC_WAKE] = KeyboardEvent::KC_WAKE;
    mKeyMap[OIS::KC_WEBSEARCH] = KeyboardEvent::KC_WEBSEARCH;
    mKeyMap[OIS::KC_WEBFAVORITES] = KeyboardEvent::KC_WEBFAVORITES;
    mKeyMap[OIS::KC_WEBREFRESH] = KeyboardEvent::KC_WEBREFRESH;
    mKeyMap[OIS::KC_WEBSTOP] = KeyboardEvent::KC_WEBSTOP;
    mKeyMap[OIS::KC_WEBFORWARD] = KeyboardEvent::KC_WEBFORWARD;
    mKeyMap[OIS::KC_WEBBACK] = KeyboardEvent::KC_WEBBACK;
    mKeyMap[OIS::KC_MYCOMPUTER] = KeyboardEvent::KC_MYCOMPUTER;
    mKeyMap[OIS::KC_MAIL] = KeyboardEvent::KC_MAIL;
    mKeyMap[OIS::KC_MEDIASELECT] = KeyboardEvent::KC_MEDIASELECT;

    mModifierMap[OIS::Keyboard::Ctrl] = KeyboardEvent::Ctrl;
    mModifierMap[OIS::Keyboard::Shift] = KeyboardEvent::Shift;
    mModifierMap[OIS::Keyboard::Alt] = KeyboardEvent::Alt;
  }
Exemplo n.º 15
0
void _glfwPlatformHideMouseCursor( void )
{
    // TO DO: What if we fail here?
    CGDisplayHideCursor( kCGDirectMainDisplay );
    CGAssociateMouseAndMouseCursorPosition( false );
}
Exemplo n.º 16
0
void _glfwPlatformHideMouseCursor( void )
{
    CGDisplayHideCursor( kCGDirectMainDisplay );
    CGAssociateMouseAndMouseCursorPosition( false );
}
Exemplo n.º 17
0
void _glfwPlatformShowMouseCursor( void )
{
    CGDisplayShowCursor( kCGDirectMainDisplay );
    CGAssociateMouseAndMouseCursorPosition( true );
}
Exemplo n.º 18
0
void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecursor)
{
	if (!mouse_avail || !window)
		relative = hidecursor = false;

	if (relative)
	{
		if(vid_usingmouse && (vid_usingnoaccel != !!apple_mouse_noaccel.integer))
			VID_SetMouse(false, false, false); // ungrab first!
		if (!vid_usingmouse)
		{
			Rect winBounds;
			CGPoint winCenter;

			SelectWindow(window);

			// Put the mouse cursor at the center of the window
			GetWindowBounds (window, kWindowContentRgn, &winBounds);
			winCenter.x = (winBounds.left + winBounds.right) / 2;
			winCenter.y = (winBounds.top + winBounds.bottom) / 2;
			CGWarpMouseCursorPosition(winCenter);

			// Lock the mouse pointer at its current position
			CGAssociateMouseAndMouseCursorPosition(false);

			// Save the status of mouse acceleration
			originalMouseSpeed = -1.0; // in case of error
			if(apple_mouse_noaccel.integer)
			{
				io_connect_t mouseDev = IN_GetIOHandle();
				if(mouseDev != 0)
				{
					if(IOHIDGetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), &originalMouseSpeed) == kIOReturnSuccess)
					{
						Con_DPrintf("previous mouse acceleration: %f\n", originalMouseSpeed);
						if(IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), -1.0) != kIOReturnSuccess)
						{
							Con_Print("Could not disable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
							Cvar_SetValueQuick(&apple_mouse_noaccel, 0);
						}
					}
					else
					{
						Con_Print("Could not disable mouse acceleration (failed at IOHIDGetAccelerationWithKey).\n");
						Cvar_SetValueQuick(&apple_mouse_noaccel, 0);
					}
					IOServiceClose(mouseDev);
				}
				else
				{
					Con_Print("Could not disable mouse acceleration (failed at IO_GetIOHandle).\n");
					Cvar_SetValueQuick(&apple_mouse_noaccel, 0);
				}
			}

			vid_usingmouse = true;
			vid_usingnoaccel = !!apple_mouse_noaccel.integer;
		}
	}
	else
	{
		if (vid_usingmouse)
		{
			if(originalMouseSpeed != -1.0)
			{
				io_connect_t mouseDev = IN_GetIOHandle();
				if(mouseDev != 0)
				{
					Con_DPrintf("restoring mouse acceleration to: %f\n", originalMouseSpeed);
					if(IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), originalMouseSpeed) != kIOReturnSuccess)
						Con_Print("Could not re-enable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
					IOServiceClose(mouseDev);
				}
				else
					Con_Print("Could not re-enable mouse acceleration (failed at IO_GetIOHandle).\n");
			}

			CGAssociateMouseAndMouseCursorPosition(true);

			vid_usingmouse = false;
		}
	}

	if (vid_usinghidecursor != hidecursor)
	{
		vid_usinghidecursor = hidecursor;
		if (hidecursor)
			CGDisplayHideCursor(CGMainDisplayID());
		else
			CGDisplayShowCursor(CGMainDisplayID());
	}
}
Exemplo n.º 19
0
void Mouse::warpMousePos(const cinder::Vec2i& pos) {
  CGAssociateMouseAndMouseCursorPosition(0);
  CGWarpMouseCursorPosition(Monitor::getInstance().getCenterCG());
  CGAssociateMouseAndMouseCursorPosition(1);
}