当前位置: 首页>>代码示例>>C++>>正文


C++ SDL_GetRelativeMouseState函数代码示例

本文整理汇总了C++中SDL_GetRelativeMouseState函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_GetRelativeMouseState函数的具体用法?C++ SDL_GetRelativeMouseState怎么用?C++ SDL_GetRelativeMouseState使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SDL_GetRelativeMouseState函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: I_ReadMouse

static void I_ReadMouse(void)
{
    int x, y;
    event_t ev;

#if SDL_VERSION_ATLEAST(1, 3, 0)
    SDL_GetRelativeMouseState(0, &x, &y);
#else
    SDL_GetRelativeMouseState(&x, &y);
#endif

    if (x != 0 || y != 0) 
    {
        ev.type = ev_mouse;
        ev.data1 = mouse_button_state;
        ev.data2 = AccelerateMouse(x);

        if (!novert)
        {
            ev.data3 = -AccelerateMouse(y);
        }
        else
        {
            ev.data3 = 0;
        }
        
        D_PostEvent(&ev);
    }

    if (MouseShouldBeGrabbed())
    {
        CenterMouse();
    }
}
开发者ID:twipley,项目名称:chocolate-doom,代码行数:34,代码来源:i_video.c

示例2: srv_get_mouse_movement

void srv_get_mouse_movement()
{
	srv_mouse_button = SDL_GetRelativeMouseState(&srv_micky_x, &srv_micky_y);
	if (MouseRude)
	{
		SDL_WarpMouse(width/2,height/2);
		srv_Events();
		srv_crap_button = SDL_GetRelativeMouseState(&srv_crap_x, &srv_crap_y);
	}
}
开发者ID:hiro2233,项目名称:libspmp8k-1,代码行数:10,代码来源:sdlmouse.c

示例3: CenterMouse

static void CenterMouse(void)
{
    // Warp the the screen center

    SDL_WarpMouse(screen->w / 2, screen->h / 2);

    // Clear any relative movement caused by warping

    SDL_PumpEvents();
#if SDL_VERSION_ATLEAST(1, 3, 0)
    SDL_GetRelativeMouseState(0, NULL, NULL);
#else
    SDL_GetRelativeMouseState(NULL, NULL);
#endif
}
开发者ID:twipley,项目名称:chocolate-doom,代码行数:15,代码来源:i_video.c

示例4: sdl_send_mouse_event

static void sdl_send_mouse_event(int dz)
{
    int dx, dy, state, buttons;
    state = SDL_GetRelativeMouseState(&dx, &dy);
    buttons = 0;
    if (state & SDL_BUTTON(SDL_BUTTON_LEFT))
        buttons |= MOUSE_EVENT_LBUTTON;
    if (state & SDL_BUTTON(SDL_BUTTON_RIGHT))
        buttons |= MOUSE_EVENT_RBUTTON;
    if (state & SDL_BUTTON(SDL_BUTTON_MIDDLE))
        buttons |= MOUSE_EVENT_MBUTTON;

    if (kbd_mouse_is_absolute()) {
        if (!absolute_enabled) {
            sdl_hide_cursor();
            if (gui_grab) {
                sdl_grab_end();
            }
            absolute_enabled = 1;
        }

        SDL_GetMouseState(&dx, &dy);
        dx = dx * 0x7FFF / width;
        dy = dy * 0x7FFF / height;
    } else if (absolute_enabled) {
        sdl_show_cursor();
        absolute_enabled = 0;
    }

    kbd_mouse_event(dx, dy, dz, buttons);
}
开发者ID:pacificIT,项目名称:winkvm,代码行数:31,代码来源:sdl.c

示例5: UpdateGrab

static void UpdateGrab(void)
{
    static boolean currently_grabbed = false;
    boolean grab;

    grab = MouseShouldBeGrabbed();

    if (screensaver_mode)
    {
        // Hide the cursor in screensaver mode

        SetShowCursor(false);
    }
    else if (grab && !currently_grabbed)
    {
        SetShowCursor(false);
        CenterMouse();
    }
    else if (!grab && currently_grabbed)
    {
        SetShowCursor(true);

        // When releasing the mouse from grab, warp the mouse cursor to
        // the bottom-right of the screen. This is a minimally distracting
        // place for it to appear - we may only have released the grab
        // because we're at an end of level intermission screen, for
        // example.

        SDL_WarpMouse(screen->w - 16, screen->h - 16);
        SDL_GetRelativeMouseState(NULL, NULL);
    }

    currently_grabbed = grab;

}
开发者ID:twipley,项目名称:chocolate-doom,代码行数:35,代码来源:i_video.c

示例6: I_ReadMouse

//
// Read the change in mouse state to generate mouse motion events
//
// This is to combine all mouse movement for a tic into one mouse
// motion event.
void I_ReadMouse(void)
{
    int x, y;
    event_t ev;

    SDL_GetRelativeMouseState(&x, &y);

    if (x != 0 || y != 0) 
    {
        ev.type = ev_mouse;
        ev.data1 = mouse_button_state;
        ev.data2 = AccelerateMouse(x);

        if (!novert)
        {
            ev.data3 = -AccelerateMouse(y);
        }
        else
        {
            ev.data3 = 0;
        }

        // XXX: undefined behaviour since event is scoped to
        // this function
        D_PostEvent(&ev);
    }
}
开发者ID:Azarien,项目名称:chocolate-doom,代码行数:32,代码来源:i_input.c

示例7: inputHanding

// FUNCTION ======	inputHanding
void inputHanding(){
    float posstep = 0.1;
	SDL_Event event;
	while(SDL_PollEvent(&event)){
		if( event.type == SDL_KEYDOWN ){
            switch( event.key.keysym.sym ){
                case SDLK_ESCAPE: quit(); break;
                case SDLK_w: modelPos[1] +=posstep; break;
                case SDLK_s: modelPos[1] -=posstep; break;
                case SDLK_a: modelPos[0] +=posstep; break;
                case SDLK_d: modelPos[0] -=posstep; break;
                case SDLK_q: modelPos[2] +=posstep*10; break;
                case SDLK_e: modelPos[2] -=posstep*10; break;
                //case SDLK_r:  world.fireProjectile( warrior1 ); break;
            }
		}
		if( event.type == SDL_QUIT){ quit();  };
	}

	int dmx,dmy;
	SDL_GetMouseState( &mouseX, &mouseY );
    Uint32 buttons = SDL_GetRelativeMouseState( &dmx, &dmy);
    //printf( " %i %i \n", mx,my );
    float mouseRotSpeed = 0.01;
    if ( buttons & SDL_BUTTON(SDL_BUTTON_RIGHT)) {
        Quat4f q; q.fromTrackball( 0, 0, -dmx*mouseRotSpeed, dmy*mouseRotSpeed );
        //printf( " %i %i  (%3.3f,%3.3f,%3.3f,%3.3f) \n", dmx,dmy, q.x,q.y,q.z,q.w );
        //qCamera.qmul_T( q );
        qCamera.qmul( q );
        //qCamera.normalize();
    }
}
开发者ID:ProkopHapala,项目名称:SimpleSimulationEngine,代码行数:33,代码来源:test_MeshOGL3.cpp

示例8: checkMouse

void
checkMouse (data_t * gfx, mouse_t * mouse, int *sel, int nops, int off)
{
  int rx = 0, ry = 0;
  int no = MIN (gfx->mMaxOps, nops);

  mouse->clicked = SDL_GetMouseState (&(mouse->x), &(mouse->y));

  if (mouse->x >= gfx->menuX
      && mouse->x < gfx->menuX + gfx->menuW
      && mouse->y >= gfx->menuY
      && mouse->y < gfx->menuY + SFont_TextHeight (gfx->menufont) * no)
    {

      if (((mouse->clicked = SDL_GetRelativeMouseState (&rx, &ry)) || rx != 0
	   || ry != 0))
	*sel =
	  (mouse->y - gfx->menuY) / SFont_TextHeight (gfx->menufont) + off;

      if (!mouse->clicked)
	setMouseState (mouse, M_OVER);
      else
	setMouseState (mouse, M_DOWN);
    }
  else
    {
      if (!mouse->clicked)
	setMouseState (mouse, M_IDLE);
      else
	setMouseState (mouse, M_DOWN);
    }
}
开发者ID:arximboldi,项目名称:gnujump,代码行数:32,代码来源:menu-system.c

示例9: VGUI_CursorSelect

void VGUI_CursorSelect(enum VGUI_DefaultCursor cursor )
{
	qboolean oldstate = host.mouse_visible;
	if( cls.key_dest != key_game || cl.refdef.paused )
		return;
#ifdef XASH_SDL
	
	switch( cursor )
	{
		case dc_user:
		case dc_none:
			host.mouse_visible = false;
			break;
		default:
		host.mouse_visible = true;
		SDL_SetRelativeMouseMode( SDL_FALSE );
		SDL_SetCursor( s_pDefaultCursor[cursor] );
		break;
	}
	if( host.mouse_visible )
	{
		SDL_ShowCursor( true );
	}
	else
	{
		SDL_ShowCursor( false );
		if( oldstate )
			SDL_GetRelativeMouseState( 0, 0 );
	}
	//SDL_SetRelativeMouseMode(false);
#endif
}
开发者ID:Reedych,项目名称:xash3d,代码行数:32,代码来源:vgui_draw.c

示例10: SDL_GetRelativeMouseState

void CInput::MouseRelative(float *x, float *y)
{
	if(!m_InputGrabbed)
		return;

	int nx = 0, ny = 0;
	float Sens = g_Config.m_InpMousesens/100.0f;

	SDL_GetRelativeMouseState(&nx,&ny);

	vec2 j = vec2(0.0f, 0.0f);

	if(m_pJoystick)
	{
		const float Max = 50.0f;
		j.x = static_cast<float>(SDL_JoystickGetAxis(m_pJoystick, g_Config.m_JoystickX)) / 32768.0f * Max;
		j.y = static_cast<float>(SDL_JoystickGetAxis(m_pJoystick, g_Config.m_JoystickY)) / 32768.0f * Max;
		const float Len = length(j);

		if (Len <= g_Config.m_JoystickTolerance) {
			j = vec2(0.0f, 0.0f);
		} else {
			const vec2 nj = Len > 0.0f ? j / Len : vec2(0.0f, 0.0f);
			j = nj * fminf(Len, Max) - nj * g_Config.m_JoystickTolerance;
		}
	}

	*x = (nx + j.x)*Sens;
	*y = (ny + j.y)*Sens;
}
开发者ID:BotoX,项目名称:teeworlds,代码行数:30,代码来源:input.cpp

示例11: sysdep_display_update_mouse

void sysdep_display_update_mouse(void)
{
   int i;
   int x,y;
   Uint8 buttons;

   if(sdl_always_use_mouse || (sdl_input_grabbed == SDL_GRAB_ON) ||
      sysdep_display_params.fullscreen)
   {
     buttons = SDL_GetRelativeMouseState( &x, &y);
     sysdep_display_mouse_data[0].deltas[0] = x;
     sysdep_display_mouse_data[0].deltas[1] = y;
     for(i=0;i<SYSDEP_DISPLAY_MOUSE_BUTTONS;i++) {
        sysdep_display_mouse_data[0].buttons[i] = buttons & (0x01 << i);
     }
   }
   else
   {
     sysdep_display_mouse_data[0].deltas[0] = 0;
     sysdep_display_mouse_data[0].deltas[1] = 0;
     for(i=0;i<SYSDEP_DISPLAY_MOUSE_BUTTONS;i++) {
        sysdep_display_mouse_data[0].buttons[i] = 0;
     }
   }
}
开发者ID:CrouchingLlama,项目名称:openlase-mame,代码行数:25,代码来源:SDL.c

示例12: SDL_GetRelativeMouseState

    void Player::handleEvent(SDL_Event e, SDL_Renderer *r, cpSpace *space, Skillmanager *sManager, cpVect & moveVect) {
        //Rotation
        if( e.type == SDL_MOUSEMOTION) {
            int x,y;
            SDL_GetRelativeMouseState(&x,&y);
            if( x<-1 )
                rotLeft();
            if( x>1 )
                rotRight();
        }

        //If the right button was pressed
        if ( e.type == SDL_MOUSEBUTTONDOWN && e.button.button == SDL_BUTTON_RIGHT ) {
            Rpressed = true;
        } else if ( e.type == SDL_MOUSEBUTTONUP && e.button.button == SDL_BUTTON_RIGHT ) {
                Rpressed = false;
                mVel = cpvzero;
        }

        //If the left button was pressed
        if ( e.type == SDL_MOUSEBUTTONDOWN && e.button.button == SDL_BUTTON_LEFT ) {
            Lpressed = true;
        } else if ( e.type == SDL_MOUSEBUTTONUP && e.button.button == SDL_BUTTON_LEFT ) {
            Lpressed = false;
        }

        // If q was pressed
        if ( (e.type == SDL_KEYDOWN) && (e.key.keysym.sym == SDLK_q)) {
                if (sManager->cdCheck(1) == 1 ) {
                    sManager->resetCd(1);
                    mVectp = cpvmult(vectorForward(),50);
                    moveVect = cpvadd(moveVect,mVectp);
                }
        }
    }
开发者ID:phaikawl,项目名称:projectx1,代码行数:35,代码来源:player.cpp

示例13: IN_Accumulate

/*
===========
IN_Accumulate
===========
*/
void CL_DLLEXPORT IN_Accumulate(void)
{
	//only accumulate mouse if we are not moving the camera with the mouse
	if(!iMouseInUse && !g_iVisibleMouse)
	{
		if(mouseactive)
		{
#ifdef _WIN32
			if(!m_bRawInput)
			{
				if(!m_bMouseThread)
				{
					GetCursorPos(&current_pos);

					mx_accum += current_pos.x - gEngfuncs.GetWindowCenterX();
					my_accum += current_pos.y - gEngfuncs.GetWindowCenterY();
				}
			}
			else
#endif
			{
				int deltaX, deltaY;
				SDL_GetRelativeMouseState(&deltaX, &deltaY);
				mx_accum += deltaX;
				my_accum += deltaY;
			}
			// force the mouse to the center, so there's room to move
			IN_ResetMouse();
		}
	}
}
开发者ID:Sh1ft0x0EF,项目名称:HLSDKRevamp,代码行数:36,代码来源:InputWin32.cpp

示例14: IN_SkipRelativeMouseMove

/**
 * Skips relative mouse movement for current frame.
 * We need to ignore the movement event generated when
 * mouse cursor is warped to window centre for the first time.
 */
static void IN_SkipRelativeMouseMove( void )
{
	if( mouse_relative ) {
		SDL_GetRelativeMouseState( &mx, &my );
		mx = my = 0;
	}
}
开发者ID:Clever-Boy,项目名称:qfusion,代码行数:12,代码来源:sdl_input.c

示例15: Look

void Controls::Look(Player *pPlayer)
{
	int mouse_dx, mouse_dy;
	//float dAngle, dAzimuth;
	
	int MAX_MOUSE_MOTION = 40;
	
	(Uint8)SDL_GetRelativeMouseState(&mouse_dx, &mouse_dy);	
	
	if (mouse_dx>MAX_MOUSE_MOTION)
		mouse_dx = MAX_MOUSE_MOTION;
	else if (mouse_dx<-MAX_MOUSE_MOTION) 
		mouse_dx = -MAX_MOUSE_MOTION;
	
	if (mouse_dy>MAX_MOUSE_MOTION) 
		mouse_dy = MAX_MOUSE_MOTION;
	else if (mouse_dy<-MAX_MOUSE_MOTION) 
		mouse_dy = -MAX_MOUSE_MOTION;
	
	//mouse sensitivity is currently hard-coded..
	// TO DO: ensure that the sensitivity is such that, given the screen size,
	// the cross-hairs can move by less than a pixel relative to the furthest squares
	//dAngle   = 0.5e-3f * 2.0*M_PI*(float)mouse_dx;	
	//dAzimuth = -0.5e-3f * 2.0*M_PI*(float)mouse_dy;	
	
	int dims[2];
	SDLview::Instance()->getViewDims(dims);
	
	pPlayer->MoveCrossHairs(  static_cast<float>(mouse_dx) / static_cast<float>(dims[0]),
							 -static_cast<float>(mouse_dy) / static_cast<float>(dims[1]) );

}
开发者ID:portsmouth,项目名称:the-sentinel-game,代码行数:32,代码来源:Controls.cpp


注:本文中的SDL_GetRelativeMouseState函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。