コード例 #1
0
ファイル: sdl_input.c プロジェクト: raedwulf/etlegacy
static void IN_ActivateMouse(void)
{
	if (!mouseAvailable || !SDL_WasInit(SDL_INIT_VIDEO))
	{
		return;
	}

	if (!mouseActive)
	{
		IN_GrabMouse(qtrue, qtrue);

		IN_GobbleMotionEvents();
	}

	// in_nograb makes no sense in fullscreen mode
	if (!cls.glconfig.isFullscreen)
	{
		if (in_nograb->modified || !mouseActive)
		{
			if (in_nograb->integer)
			{
				IN_GrabMouse(qfalse, qtrue);
			}
			else
			{
				IN_GrabMouse(qtrue, qtrue);
			}

			in_nograb->modified = qfalse;
		}
	}

	mouseActive = qtrue;
}
コード例 #2
0
/*
===============
IN_DeactivateMouse
===============
*/
static void IN_DeactivateMouse( void )
{
    if( !SDL_WasInit( SDL_INIT_VIDEO ) )
        return;

    // Always show the cursor when the mouse is disabled,
    // but not when fullscreen
    if( !Cvar_VariableIntegerValue("r_fullscreen") )
        SDL_ShowCursor( 1 );

    if( !mouseAvailable )
        return;

    if( mouseActive )
    {
        IN_GobbleMotionEvents( );

        SDL_SetWindowGrab( SDL_window, 0 );
        SDL_SetRelativeMouseMode( SDL_FALSE );

        // Don't warp the mouse unless the cursor is within the window
        if( SDL_GetWindowFlags( SDL_window ) & SDL_WINDOW_MOUSE_FOCUS )
            SDL_WarpMouseInWindow( SDL_window, cls.glconfig.vidWidth / 2, cls.glconfig.vidHeight / 2 );

        mouseActive = qfalse;
    }
}
コード例 #3
0
static void IN_DeactivateMouse(void)
{
	if (!SDL_WasInit(SDL_INIT_VIDEO))
	{
		return;
	}

	SDL_SetRelativeMouseMode( SDL_FALSE );
	// Always show the cursor when the mouse is disabled,
	// but not when fullscreen
	if (!Cvar_VariableIntegerValue("r_fullscreen"))
		SDL_ShowCursor(1);

	if (!mouseAvailable)
	{
		return;
	}

	if (mouseActive)
	{
		IN_GobbleMotionEvents();
		SDL_SetWindowGrab( SDLvidscreen, SDL_FALSE );
		mouseActive = qfalse;
	}
}
コード例 #4
0
/*
===============
IN_ActivateMouse
===============
*/
static void IN_ActivateMouse( void )
{
    if (!mouseAvailable || !SDL_WasInit( SDL_INIT_VIDEO ) )
        return;

    if( !mouseActive )
    {
        SDL_SetRelativeMouseMode( SDL_TRUE );
        SDL_SetWindowGrab( SDL_window, 1 );

        IN_GobbleMotionEvents( );
    }

    // in_nograb makes no sense in fullscreen mode
    if( !Cvar_VariableIntegerValue("r_fullscreen") )
    {
        if( in_nograb->modified || !mouseActive )
        {
            if( in_nograb->integer )
                SDL_SetWindowGrab( SDL_window, 0 );
            else
                SDL_SetWindowGrab( SDL_window, 1 );

            in_nograb->modified = qfalse;
        }
    }

    mouseActive = qtrue;
}
コード例 #5
0
ファイル: sdl_input.cpp プロジェクト: Kangz/Unvanquished
/*
===============
IN_ActivateMouse
===============
*/
static void IN_ActivateMouse() {
    if (!mouseAvailable || !SDL_WasInit(SDL_INIT_VIDEO)) {
        return;
    }

    if (!mouseActive) {
        SDL_ShowCursor(0);

        SDL_SetRelativeMouseMode(SDL_TRUE);
        SDL_SetWindowGrab(window, SDL_TRUE);

        IN_GobbleMotionEvents();
    }

    // in_nograb makes no sense in fullscreen mode
    if (!cls.glconfig.isFullscreen) {
        if (in_nograb->modified || !mouseActive) {
            if (in_nograb->integer) {
                SDL_SetWindowGrab(window, SDL_FALSE);
            } else {
                SDL_SetWindowGrab(window, SDL_TRUE);
            }

            in_nograb->modified = false;
        }
    }

    mouseActive = true;
}
コード例 #6
0
ファイル: sdl_input.c プロジェクト: SHOVELL/Unvanquished
/*
===============
IN_DeactivateMouse
===============
*/
void IN_DeactivateMouse( void )
{
	if ( !SDL_WasInit( SDL_INIT_VIDEO ) )
	{
		return;
	}

	// Always show the cursor when the mouse is disabled,
	// but not when fullscreen
	if ( !Cvar_VariableIntegerValue( "r_fullscreen" ) )
	{
		SDL_ShowCursor( 1 );
	}

	if ( !mouseAvailable )
	{
		return;
	}

#ifdef MACOS_X_ACCELERATION_HACK

	if ( mouseActive ) // mac os x mouse accel hack
	{
		if ( originalMouseSpeed != -1.0 )
		{
			io_connect_t mouseDev = IN_GetIOHandle();

			if ( mouseDev != 0 )
			{
				Com_DPrintf( "restoring mouse acceleration to: %f\n", originalMouseSpeed );

				if ( IOHIDSetAccelerationWithKey( mouseDev, CFSTR( kIOHIDMouseAccelerationType ), originalMouseSpeed ) != kIOReturnSuccess )
				{
					Com_DPrintf( "Could not re-enable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n" );
				}

				IOServiceClose( mouseDev );
			}
			else
			{
				Com_DPrintf( "Could not re-enable mouse acceleration (failed at IO_GetIOHandle).\n" );
			}
		}
	}

#endif

	if ( mouseActive )
	{
		IN_GobbleMotionEvents();

		SDL_WM_GrabInput( SDL_GRAB_OFF );

		// Don't warp the mouse unless the cursor is within the window
		//if( SDL_GetAppState( ) & SDL_APPMOUSEFOCUS )
		//SDL_WarpMouse( cls.glconfig.vidWidth / 2, cls.glconfig.vidHeight / 2 );

		mouseActive = qfalse;
	}
}
コード例 #7
0
/*
===============
IN_DeactivateMouse
===============
*/
void IN_DeactivateMouse( void )
{
	if( !SDL_WasInit( SDL_INIT_VIDEO ) )
		return;

	// Always show the cursor when the mouse is disabled,
	// but not when fullscreen
	if( !r_fullscreen->integer )
	{
		if( ( Key_GetCatcher( ) == KEYCATCH_UI ) &&
				( SDL_GetAppState( ) & (SDL_APPMOUSEFOCUS|SDL_APPINPUTFOCUS) ) == (SDL_APPMOUSEFOCUS|SDL_APPINPUTFOCUS) )
			SDL_ShowCursor( 0 );
		else
			SDL_ShowCursor( 1 );
	}

	if( !mouseAvailable )
		return;

#ifdef MACOS_X_ACCELERATION_HACK
	if (mouseActive) // mac os x mouse accel hack
	{
		if(originalMouseSpeed != -1.0)
		{
			io_connect_t mouseDev = IN_GetIOHandle();
			if(mouseDev != 0)
			{
				Com_Printf("restoring mouse acceleration to: %f\n", originalMouseSpeed);
				if(IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), originalMouseSpeed) != kIOReturnSuccess)
					Com_Printf("Could not re-enable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
				IOServiceClose(mouseDev);
			}
			else
				Com_Printf("Could not re-enable mouse acceleration (failed at IO_GetIOHandle).\n");
		}
	}
#endif

	if( mouseActive )
	{
		IN_GobbleMotionEvents( );

		SDL_WM_GrabInput( SDL_GRAB_OFF );

		// Don't warp the mouse unless the cursor is within the window
		if( SDL_GetAppState( ) & SDL_APPMOUSEFOCUS )
		{
			int x, y;
			x = glConfig.vidWidth / 2, y = glConfig.vidHeight / 2;
			SDL_WarpMouse( x, y );
		}

		mouseActive = qfalse;
	}
}
コード例 #8
0
ファイル: sdl_input.cpp プロジェクト: Kangz/Unvanquished
/*
===============
IN_DeactivateMouse
===============
*/
void IN_DeactivateMouse(bool showCursor) {
    if (!SDL_WasInit(SDL_INIT_VIDEO)) {
        return;
    }

    // Show the cursor when the mouse is disabled,
    // but not when fullscreen
    SDL_ShowCursor(showCursor);

    if (!mouseAvailable) {
        return;
    }

    if (mouseActive) {
        IN_GobbleMotionEvents();

        SDL_SetWindowGrab(window, SDL_FALSE);
        SDL_SetRelativeMouseMode(SDL_FALSE);

        IN_GobbleMotionEvents();
        mouseActive = false;
    }
}
コード例 #9
0
ファイル: sdl_input.c プロジェクト: raedwulf/etlegacy
static void IN_DeactivateMouse(void)
{
	if (!SDL_WasInit(SDL_INIT_VIDEO))
	{
		return;
	}

	// Always show the cursor when the mouse is disabled,
	// but not when fullscreen
	if (!cls.glconfig.isFullscreen)
	{
#if 0
		if ((Key_GetCatcher() == KEYCATCH_UI) &&
		    screen == SDL_GetMouseFocus())
		{
			// TODO: (SDL_GetAppState() & SDL_APPMOUSEFOCUS))
			IN_GrabMouse(qtrue, qtrue);
		}
		else
#endif
		{
			IN_GrabMouse(qfalse, qfalse);
		}
	}

	if (!mouseAvailable)
	{
		return;
	}

	if (mouseActive)
	{
		IN_GobbleMotionEvents();
		IN_GrabMouse(qfalse, qfalse);

		// Don't warp the mouse unless the cursor is within the window
		if (SDL_GetWindowFlags(mainScreen) & SDL_WINDOW_MOUSE_FOCUS)
		{
			SDL_WarpMouseInWindow(mainScreen, cls.glconfig.vidWidth / 2, cls.glconfig.vidHeight / 2);
		}

		mouseActive = qfalse;
	}
}
コード例 #10
0
ファイル: sdl_input.c プロジェクト: raedwulf/etlegacy
void IN_Frame(void)
{
	qboolean loading;

	//IN_JoyMove();

	// If not DISCONNECTED (main menu) or ACTIVE (in game), we're loading
	loading = (cls.state != CA_DISCONNECTED && cls.state != CA_ACTIVE);

	if (!cls.glconfig.isFullscreen && (Key_GetCatcher() & KEYCATCH_CONSOLE))
	{
		// Console is down in windowed mode
		IN_DeactivateMouse();
	}
	else if (!cls.glconfig.isFullscreen && loading)
	{
		// Loading in windowed mode
		IN_DeactivateMouse();
	}
	else if (com_minimized->integer || com_unfocused->integer)
	{
		// Window not got focus
		IN_DeactivateMouse();
	}
	else
	{
		if (loading)
		{
			// Just eat up all the mouse events that are not used anyway
			IN_GobbleMotionEvents();
		}

		IN_ActivateMouse();
	}

	// in case we had to delay actual restart of video system...
	if ((vidRestartTime != 0) && (vidRestartTime < Sys_Milliseconds()))
	{
		vidRestartTime = 0;
		Cbuf_AddText("vid_restart\n");
	}

	IN_ProcessEvents();
}
コード例 #11
0
ファイル: sdl_input.c プロジェクト: chitmo/openarena-engine
/*
===============
IN_DeactivateMouse
===============
*/
static void IN_DeactivateMouse( void )
{
	if( !SDL_WasInit( SDL_INIT_VIDEO ) )
		return;

	// Always show the cursor when the mouse is disabled,
	// but not when fullscreen
	if( !Cvar_VariableIntegerValue("r_fullscreen") )
		SDL_ShowCursor( 1 );

	if( !mouseAvailable )
		return;

#ifdef MACOS_X_ACCELERATION_HACK
	if (mouseActive) // mac os x mouse accel hack
	{
		if(originalMouseSpeed != -1.0)
		{
			io_connect_t mouseDev = IN_GetIOHandle();
			if(mouseDev != 0)
			{
				Com_Printf("restoring mouse acceleration to: %f\n", originalMouseSpeed);
				if(IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), originalMouseSpeed) != kIOReturnSuccess)
					Com_Printf("Could not re-enable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
				IOServiceClose(mouseDev);
			}
			else
				Com_Printf("Could not re-enable mouse acceleration (failed at IO_GetIOHandle).\n");
		}
	}
#endif

	if( mouseActive )
	{
		IN_GobbleMotionEvents( );

		SDL_WM_GrabInput( SDL_GRAB_OFF );

		mouseActive = qfalse;
	}
}
コード例 #12
0
ファイル: sdl_input.cpp プロジェクト: lmumar/Unvanquished
/*
===============
IN_DeactivateMouse
===============
*/
void IN_DeactivateMouse( qboolean showCursor )
{
	if ( !SDL_WasInit( SDL_INIT_VIDEO ) )
	{
		return;
	}

	// Show the cursor when the mouse is disabled,
	// but not when fullscreen
	if ( !cls.glconfig.isFullscreen || SDL_VERSION_ATLEAST( 2, 0, 0 ) )
	{
		SDL_ShowCursor( showCursor );
	}

	if ( !mouseAvailable )
	{
		return;
	}

	if ( mouseActive )
	{
		IN_GobbleMotionEvents();

		SDL_SetWindowGrab( window, SDL_FALSE );
		SDL_SetRelativeMouseMode( SDL_FALSE );

		if ( uivm )
		{
			// TODO (after no compatibility needed with alpha 9): remove argument
			int mousepos = VM_Call( uivm, UI_MOUSE_POSITION, 0 );
			int cursorx = mousepos & 0xFFFF;
			int cursory = mousepos >> 16;
			SDL_WarpMouseInWindow( window, cursorx, cursory );
		}

		mouseActive = qfalse;
	}
}
コード例 #13
0
ファイル: sdl_input.c プロジェクト: chitmo/openarena-engine
/*
===============
IN_ActivateMouse
===============
*/
static void IN_ActivateMouse( void )
{
	if (!mouseAvailable || !SDL_WasInit( SDL_INIT_VIDEO ) )
		return;

#ifdef MACOS_X_ACCELERATION_HACK
	if (!mouseActive) // mac os x mouse accel hack
	{
		// Save the status of mouse acceleration
		originalMouseSpeed = -1.0; // in case of error
		if(in_disablemacosxmouseaccel->integer)
		{
			io_connect_t mouseDev = IN_GetIOHandle();
			if(mouseDev != 0)
			{
				if(IOHIDGetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), &originalMouseSpeed) == kIOReturnSuccess)
				{
					Com_Printf("previous mouse acceleration: %f\n", originalMouseSpeed);
					if(IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), -1.0) != kIOReturnSuccess)
					{
						Com_Printf("Could not disable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
						Cvar_Set ("in_disablemacosxmouseaccel", 0);
					}
				}
				else
				{
					Com_Printf("Could not disable mouse acceleration (failed at IOHIDGetAccelerationWithKey).\n");
					Cvar_Set ("in_disablemacosxmouseaccel", 0);
				}
				IOServiceClose(mouseDev);
			}
			else
			{
				Com_Printf("Could not disable mouse acceleration (failed at IO_GetIOHandle).\n");
				Cvar_Set ("in_disablemacosxmouseaccel", 0);
			}
		}
	}
#endif

	if( !mouseActive )
	{
		SDL_ShowCursor( 0 );
#ifdef MACOS_X_CURSOR_HACK
		// This is a bug in the current SDL/macosx...have to toggle it a few
		//  times to get the cursor to hide.
		SDL_ShowCursor( 1 );
		SDL_ShowCursor( 0 );
#endif
		SDL_WM_GrabInput( SDL_GRAB_ON );

		IN_GobbleMotionEvents( );
	}

	// in_nograb makes no sense in fullscreen mode
	if( !Cvar_VariableIntegerValue("r_fullscreen") )
	{
		if( in_nograb->modified || !mouseActive )
		{
			if( in_nograb->integer )
				SDL_WM_GrabInput( SDL_GRAB_OFF );
			else
				SDL_WM_GrabInput( SDL_GRAB_ON );

			in_nograb->modified = qfalse;
		}
	}

	mouseActive = qtrue;
}