Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed bug 1813 - MouseMotion relative values do not respect renderer …
Browse files Browse the repository at this point in the history
…LogicalSize

driedfruit

A trivial issue, the xrel and yrel values of MouseMotion event struct are not adjusted to renderer logical size.
  • Loading branch information
slouken committed Jul 21, 2013
1 parent 0d4a665 commit e51fc48
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/render/SDL_render.c
Expand Up @@ -151,6 +151,16 @@ SDL_RendererEventWatch(void *userdata, SDL_Event *event)
event->motion.y -= renderer->viewport.y;
event->motion.x = (int)(event->motion.x / renderer->scale.x);
event->motion.y = (int)(event->motion.y / renderer->scale.y);
if (event->motion.xrel > 0) {
event->motion.xrel = SDL_max(1, (int)(event->motion.xrel / renderer->scale.x));
} else if (event->motion.xrel < 0) {
event->motion.xrel = SDL_min(-1, (int)(event->motion.xrel / renderer->scale.x));
}
if (event->motion.yrel > 0) {
event->motion.yrel = SDL_max(1, (int)(event->motion.yrel / renderer->scale.y));
} else if (event->motion.yrel < 0) {
event->motion.yrel = SDL_min(-1, (int)(event->motion.yrel / renderer->scale.y));
}
}
} else if (event->type == SDL_MOUSEBUTTONDOWN ||
event->type == SDL_MOUSEBUTTONUP) {
Expand Down

0 comments on commit e51fc48

Please sign in to comment.