mirror of https://github.com/libsdl-org/SDL.git
forbid transform change while relative mode active
This commit is contained in:
parent
428f0dcd61
commit
5373271a12
|
|
@ -415,13 +415,19 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WarpMouseGlobal(float x, float y);
|
|||
/**
|
||||
* Set a user-defined function by which to transform relative mouse inputs.
|
||||
* This overrides the relative system scale and relative speed scale hints.
|
||||
* Should be called prior to enabling relative mouse mode, fails otherwise.
|
||||
*
|
||||
* \param callback a callback used to transform relative mouse motion,
|
||||
or NULL for default behavior.
|
||||
* \param userdata a pointer that will be passed to `callback`.
|
||||
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||
* information.
|
||||
*
|
||||
* \param callback a callback used to transform relative mouse motion, or NULL for default behavior.
|
||||
* \param userdata a pointer that is passed to `callback`.
|
||||
* \threadsafety This function should only be called on the main thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.2.6.
|
||||
*/
|
||||
extern SDL_DECLSPEC void SDLCALL SDL_SetRelativeMouseTransform(SDL_MouseMotionTransformCallback callback, void *userdata);
|
||||
extern SDL_DECLSPEC bool SDLCALL SDL_SetRelativeMouseTransform(SDL_MouseMotionTransformCallback callback, void *userdata);
|
||||
|
||||
/**
|
||||
* Set relative mouse mode for a window.
|
||||
|
|
|
|||
|
|
@ -1120,11 +1120,15 @@ void SDL_QuitMouse(void)
|
|||
SDL_mice = NULL;
|
||||
}
|
||||
|
||||
void SDL_SetRelativeMouseTransform(SDL_MouseMotionTransformCallback transform, void *userdata)
|
||||
bool SDL_SetRelativeMouseTransform(SDL_MouseMotionTransformCallback transform, void *userdata)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
if (mouse->relative_mode) {
|
||||
return SDL_SetError("Can't set mouse transform while relative mode is active");
|
||||
}
|
||||
mouse->InputTransform = transform;
|
||||
mouse->input_transform_data = userdata;
|
||||
return true;
|
||||
}
|
||||
|
||||
SDL_MouseButtonFlags SDL_GetMouseState(float *x, float *y)
|
||||
|
|
|
|||
Loading…
Reference in New Issue