mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-01 09:27:39 +00:00
mouse: Make pointer warp emulation via relative mode available to all platforms
Move the Wayland pointer warp emulation code up to the SDL mouse layer, and activate it when a client attempts to warp a hidden mouse cursor when the hint is set. testrelative adds the ability to test the warp emulation activation/deactivation with the --warp parameter and 'c' key for toggling cursor visibility.
This commit is contained in:
parent
92667e3066
commit
66eb2ea443
8 changed files with 212 additions and 122 deletions
|
@ -2190,6 +2190,36 @@ extern "C" {
|
|||
*/
|
||||
#define SDL_HINT_MOUSE_DOUBLE_CLICK_TIME "SDL_MOUSE_DOUBLE_CLICK_TIME"
|
||||
|
||||
/**
|
||||
* A variable controlling whether warping a hidden mouse cursor will activate
|
||||
* relative mouse mode.
|
||||
*
|
||||
* When this hint is set and the mouse cursor is hidden, SDL will emulate mouse
|
||||
* warps using relative mouse mode. This can provide smoother and more reliable
|
||||
* mouse motion for some older games, which continuously calculate the distance
|
||||
* travelled by the mouse pointer and warp it back to the center of the window,
|
||||
* rather than using relative mouse motion.
|
||||
*
|
||||
* Note that relative mouse mode may have different mouse acceleration behavior
|
||||
* than pointer warps.
|
||||
*
|
||||
* If your game or application needs to warp the mouse cursor while hidden for
|
||||
* other purposes, such as drawing a software cursor, it should disable this hint.
|
||||
*
|
||||
* The variable can be set to the following values:
|
||||
*
|
||||
* - "0": Attempts to warp the mouse will always be made.
|
||||
* - "1": Some mouse warps will be emulated by forcing relative mouse mode. (default)
|
||||
*
|
||||
* If not set, this is automatically enabled unless an application uses
|
||||
* relative mouse mode directly.
|
||||
*
|
||||
* This hint can be set anytime.
|
||||
*
|
||||
* \since This hint is available since SDL 3.0.0.
|
||||
*/
|
||||
#define SDL_HINT_MOUSE_EMULATE_WARP_WITH_RELATIVE "SDL_MOUSE_EMULATE_WARP_WITH_RELATIVE"
|
||||
|
||||
/**
|
||||
* Allow mouse click events when clicking to focus an SDL window.
|
||||
*
|
||||
|
@ -3063,34 +3093,6 @@ extern "C" {
|
|||
*/
|
||||
#define SDL_HINT_VIDEO_WAYLAND_ALLOW_LIBDECOR "SDL_VIDEO_WAYLAND_ALLOW_LIBDECOR"
|
||||
|
||||
/**
|
||||
* Enable or disable hidden mouse pointer warp emulation, needed by some older
|
||||
* games.
|
||||
*
|
||||
* Wayland requires the pointer confinement protocol to warp the mouse, but
|
||||
* that is just a hint that the compositor is free to ignore, and warping the
|
||||
* the pointer to or from regions outside of the focused window is prohibited.
|
||||
* When this hint is set and the pointer is hidden, SDL will emulate mouse
|
||||
* warps using relative mouse mode. This is required for some older games
|
||||
* (such as Source engine games), which warp the mouse to the centre of the
|
||||
* screen rather than using relative mouse motion. Note that relative mouse
|
||||
* mode may have different mouse acceleration behaviour than pointer warps.
|
||||
*
|
||||
* The variable can be set to the following values:
|
||||
*
|
||||
* - "0": Attempts to warp the mouse will be made, if the appropriate protocol
|
||||
* is available.
|
||||
* - "1": Some mouse warps will be emulated by forcing relative mouse mode.
|
||||
*
|
||||
* If not set, this is automatically enabled unless an application uses
|
||||
* relative mouse mode directly.
|
||||
*
|
||||
* This hint can be set anytime.
|
||||
*
|
||||
* \since This hint is available since SDL 3.0.0.
|
||||
*/
|
||||
#define SDL_HINT_VIDEO_WAYLAND_EMULATE_MOUSE_WARP "SDL_VIDEO_WAYLAND_EMULATE_MOUSE_WARP"
|
||||
|
||||
/**
|
||||
* A variable controlling whether video mode emulation is enabled under
|
||||
* Wayland.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue