mercredi 20 août 2014

OSX Mouse warping in window


Vote count:

0




I'm using SDL2.0.3 on OSX. There is SDL_WINDOW_FULLSCREEN_DESKTOP instead of SDL_WINDOW_FULLSCREEN flag. It's not working properly (I get small window in left bottom corner and rest of screen is black) so I need to manually set openGL's viewport. That may be important information because "real" cursor position is not what user see (I'm drawing cursor manually). I want to lock mouse in my window which is 1024x768. That code works almost perfect:



NSPoint mouseWarpLocation = NSMakePoint(fmin(app->screenWidth, app->mouseX), fmin(app->screenHeight, app->mouseY));
CGWarpMouseCursorPosition(mouseWarpLocation);
app->mouseX = mouseWarpLocation.x;
app->mouseY = mouseWarpLocation.y;


app->mouseX, app->mouseY are taken from SDL_GetMouseState(). Almost because it warps cursor as I want but I cannot move cursor properly when I'm touching 1024 (or 768 vertically) limit. For example when I move cursor from <1024,100> to <1030,200> i get something like <1024,110>. I think I'm warping mouse in reaction for first event (few pixels move?) and I'm overwriting next mouse events. I cannot use SDL_SetRelativeMouseMode() because with SDL_WINDOW_FULLSCREEN_DESKTOP flag window's size is much more than 1024x768 and SDL is locking mouse in that bigger area instead of 1024x768.



asked 1 min ago







OSX Mouse warping in window

Aucun commentaire:

Enregistrer un commentaire