mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-02-02 07:01:00 +00:00
parent
aa188048f1
commit
0918903f3c
|
@ -314,6 +314,17 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
#define SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE "SDL_MOUSE_RELATIVE_SPEED_SCALE"
|
#define SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE "SDL_MOUSE_RELATIVE_SPEED_SCALE"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief A variable controlling whether relative mouse motion is affected by renderer scaling
|
||||||
|
*
|
||||||
|
* This variable can be set to the following values:
|
||||||
|
* "0" - Relative motion is unaffected by DPI or renderer's logical size
|
||||||
|
* "1" - Relative motion is scaled according to DPI scaling and logical size
|
||||||
|
*
|
||||||
|
* By default relative mouse deltas are affected by DPI and renderer scaling
|
||||||
|
*/
|
||||||
|
#define SDL_HINT_MOUSE_RELATIVE_SCALING "SDL_MOUSE_RELATIVE_SCALING"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A variable controlling whether relative mouse mode is implemented using mouse warping
|
* \brief A variable controlling whether relative mouse mode is implemented using mouse warping
|
||||||
*
|
*
|
||||||
|
|
|
@ -660,13 +660,13 @@ SDL_RendererEventWatch(void *userdata, SDL_Event *event)
|
||||||
event->motion.y -= (int)(viewport.y * renderer->dpi_scale.y);
|
event->motion.y -= (int)(viewport.y * renderer->dpi_scale.y);
|
||||||
event->motion.x = (int)(event->motion.x / (scale.x * renderer->dpi_scale.x));
|
event->motion.x = (int)(event->motion.x / (scale.x * renderer->dpi_scale.x));
|
||||||
event->motion.y = (int)(event->motion.y / (scale.y * renderer->dpi_scale.y));
|
event->motion.y = (int)(event->motion.y / (scale.y * renderer->dpi_scale.y));
|
||||||
if (event->motion.xrel != 0) {
|
if (event->motion.xrel != 0 && renderer->relative_scaling) {
|
||||||
float rel = renderer->xrel + event->motion.xrel / (scale.x * renderer->dpi_scale.x);
|
float rel = renderer->xrel + event->motion.xrel / (scale.x * renderer->dpi_scale.x);
|
||||||
float trunc = SDL_truncf(rel);
|
float trunc = SDL_truncf(rel);
|
||||||
renderer->xrel = rel - trunc;
|
renderer->xrel = rel - trunc;
|
||||||
event->motion.xrel = trunc;
|
event->motion.xrel = trunc;
|
||||||
}
|
}
|
||||||
if (event->motion.yrel != 0) {
|
if (event->motion.yrel != 0 && renderer->relative_scaling) {
|
||||||
float rel = renderer->yrel + event->motion.yrel / (scale.y * renderer->dpi_scale.y);
|
float rel = renderer->yrel + event->motion.yrel / (scale.y * renderer->dpi_scale.y);
|
||||||
float trunc = SDL_truncf(rel);
|
float trunc = SDL_truncf(rel);
|
||||||
renderer->yrel = rel - trunc;
|
renderer->yrel = rel - trunc;
|
||||||
|
@ -875,6 +875,8 @@ SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderer->relative_scaling = SDL_GetHintBoolean(SDL_HINT_MOUSE_RELATIVE_SCALING, SDL_TRUE);
|
||||||
|
|
||||||
if (SDL_GetWindowFlags(window) & (SDL_WINDOW_HIDDEN|SDL_WINDOW_MINIMIZED)) {
|
if (SDL_GetWindowFlags(window) & (SDL_WINDOW_HIDDEN|SDL_WINDOW_MINIMIZED)) {
|
||||||
renderer->hidden = SDL_TRUE;
|
renderer->hidden = SDL_TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -189,6 +189,9 @@ struct SDL_Renderer
|
||||||
/* The pixel to point coordinate scale */
|
/* The pixel to point coordinate scale */
|
||||||
SDL_FPoint dpi_scale;
|
SDL_FPoint dpi_scale;
|
||||||
|
|
||||||
|
/* Whether or not to scale relative mouse motion */
|
||||||
|
SDL_bool relative_scaling;
|
||||||
|
|
||||||
/* Remainder from scaled relative motion */
|
/* Remainder from scaled relative motion */
|
||||||
float xrel;
|
float xrel;
|
||||||
float yrel;
|
float yrel;
|
||||||
|
|
Loading…
Reference in a new issue