SDK mouse relative motion, weird results

Posted by zaftcoAgeiha on Game Development See other posts from Game Development or by zaftcoAgeiha
Published on 2012-11-16T16:37:40Z Indexed on 2012/11/16 17:17 UTC
Read the original article Hit count: 134

Filed under:

I have a simple SDL application that tracks the relative change in mouse position

But for some reason, the motion.xrel and motion.yrel give back massive numbers!

my code: SDL_WM_GrabInput(SDL_GRAB_ON); SDL_ShowCursor(false);

while(!quit){
// Draw the scene

if (invalidated == 1){
  on_render();
  invalidated = 0;
}

// And poll for events
SDL_PumpEvents();
SDL_Event event;
while ( SDL_PollEvent(&event) ) {
  switch (event.type) {
    case SDL_KEYDOWN:
    case SDL_KEYUP:
      on_key(event.key);
      break;

    case SDL_MOUSEMOTION:
      std::cerr << event.motion.xrel << ":" << event.motion.yrel << std::endl;
      invalidated = 1;
      break;

    ...

and the printed results are ridiculous:

400:300
-11297:1705
-11215:1268
-10969:940
-10314:-43
-9986:-698
-9331:-1681
-9003:-2227
-8593:-2664
-8020:-3538
-7774:-3647
-7365:-4193
-7283:-4302
-7119:0

any idea why?? System is Ubuntu 12 running in virtual box

© Game Development or respective owner

Related posts about sdl