Jump to content
  • Advertisement
Sign in to follow this  

Choppy SDL mouse input

This topic is 4816 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here is my camera rotate-by-mouse function:
void Camera::setViewByMouse(dimension2d<unsigned int> screenSize, vector2di vMousePos) {				
	int middleX = screenSize.width  >> 1;			
	int middleY = screenSize.height >> 1;				
	float angleY = 0.0f;							
	float angleZ = 0.0f;							
	static float currentRotX = 0.0f;
	if((vMousePos.x == middleX) && (vMousePos.y == middleY)) 
	angleY = (float)((middleX - vMousePos.x))/1000.0f;		
	angleZ = (float)((middleY - vMousePos.y))/1000.0f;		

	currentRotX -= angleZ;  

	if(currentRotX > 1.45f) {
		currentRotX = 1.45f;
	else if(currentRotX < -1.45f) {
		currentRotX = -1.45f;
	else {
		vector3df vAxis = (m_vTarget - m_vPos).crossProduct(m_vUp);

		rotateView(angleZ, vAxis.x, vAxis.y, vAxis.z);
		rotateView(angleY, 0, 1, 0);
	SDL_WarpMouse(middleX, middleY);

I get the cursor location with (in a seperate class):

	           	m_vMousePos.x = event.motion.x;

				m_vMousePos.y = event.motion.y;

But the results are very choppy. The framerate is over 100 the whole time, so it has nothing to do with the framerate. Any ideas?

Share this post

Link to post
Share on other sites
Comment out the SDL_WarpMouse(middleX, middleY); and see if the same problem persits with the choppiness (yes I know this doesn't make it work like it's supposed to anymore).

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!