mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-25 20:48:24 +01:00
635 lines
30 KiB
C#
635 lines
30 KiB
C#
// <auto-generated/>
|
|
// Generated by Brutal.Sdl.Generate; do not edit by hand.
|
|
#nullable enable
|
|
|
|
namespace Brutal.SdlApi
|
|
{
|
|
public static unsafe partial class Sdl
|
|
{
|
|
public static unsafe partial class Mouse
|
|
{
|
|
/// <summary>
|
|
/// Return whether a mouse is currently connected.
|
|
/// </summary>
|
|
/// <returns>true if a mouse is connected, false otherwise.</returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetMice"/>
|
|
public static bool HasMouse() => PInvoke.HasMouse() != 0;
|
|
|
|
/// <summary>
|
|
/// Ergonomic wrapper over <c>SDL_GetMice</c>.
|
|
/// </summary>
|
|
/// <exception cref="SdlException">The SDL call failed; the message carries the
|
|
/// <c>SDL_GetError</c> text.</exception>
|
|
/// <remarks>
|
|
/// SDL returns a freshly <c>SDL_malloc</c>'d buffer for this call; the returned array is a managed copy,
|
|
/// and the native buffer is freed with <c>SDL_free</c> before this method returns.
|
|
/// </remarks>
|
|
public static uint[] GetMice()
|
|
{
|
|
int count;
|
|
var ptr = PInvoke.GetMice(&count);
|
|
if (ptr is null)
|
|
throw SdlException.FromError("SDL_GetMice failed");
|
|
try
|
|
{
|
|
return new ReadOnlySpan<uint>(ptr, count).ToArray();
|
|
}
|
|
finally
|
|
{
|
|
PInvoke.Free(ptr);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the name of a mouse.
|
|
/// </summary>
|
|
/// <param name="instance_id">the mouse instance ID.</param>
|
|
/// <returns>
|
|
/// the name of the selected mouse, or NULL on failure; call
|
|
/// SDL_GetError() for more information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// This function returns "" if the mouse doesn't have a name.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetMice"/>
|
|
public static string? GetMouseNameForID(uint instance_id) => PInvoke.GetMouseNameForID(instance_id);
|
|
|
|
/// <summary>
|
|
/// Ergonomic wrapper over <c>SDL_GetMouseFocus</c>.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <b>Borrowed handle:</b> the returned handle is owned by SDL (or by another object) and must not be
|
|
/// disposed. Do not call <see cref="System.IDisposable.Dispose"/> on it; doing so would free a resource
|
|
/// this call does not own. A null handle is returned on failure.
|
|
/// </remarks>
|
|
public static SdlWindow GetMouseFocus() => PInvoke.GetMouseFocus();
|
|
|
|
/// <summary>
|
|
/// Query SDL's cache for the synchronous mouse button state and the
|
|
/// window-relative SDL-cursor position.
|
|
/// </summary>
|
|
/// <param name="x">
|
|
/// a pointer to receive the SDL-cursor's x-position from the focused
|
|
/// window's top left corner, can be NULL if unused.
|
|
/// </param>
|
|
/// <param name="y">
|
|
/// a pointer to receive the SDL-cursor's y-position from the focused
|
|
/// window's top left corner, can be NULL if unused.
|
|
/// </param>
|
|
/// <returns>
|
|
/// a 32-bit bitmask of the button state that can be bitwise-compared
|
|
/// against the SDL_BUTTON_MASK(X) macro.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// This function returns the cached synchronous state as SDL understands it
|
|
/// from the last pump of the event queue.
|
|
/// </para>
|
|
/// <para>
|
|
/// To query the platform for immediate asynchronous state, use
|
|
/// SDL_GetGlobalMouseState.
|
|
/// </para>
|
|
/// <para>
|
|
/// Passing non-NULL pointers to <c>x</c> or <c>y</c> will write the destination with
|
|
/// respective x or y coordinates relative to the focused window.
|
|
/// </para>
|
|
/// <para>
|
|
/// In Relative Mode, the SDL-cursor's position usually contradicts the
|
|
/// platform-cursor's position as manually calculated from
|
|
/// SDL_GetGlobalMouseState() and SDL_GetWindowPosition.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGlobalMouseState"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetRelativeMouseState"/>
|
|
public static SdlMouseButtonFlags GetMouseState(out float x, out float y)
|
|
{
|
|
x = default;
|
|
y = default;
|
|
fixed (float* xPtr = &x)
|
|
{
|
|
fixed (float* yPtr = &y)
|
|
{
|
|
return PInvoke.GetMouseState(xPtr, yPtr);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Query the platform for the asynchronous mouse button state and the
|
|
/// desktop-relative platform-cursor position.
|
|
/// </summary>
|
|
/// <param name="x">
|
|
/// a pointer to receive the platform-cursor's x-position from the
|
|
/// desktop's top left corner, can be NULL if unused.
|
|
/// </param>
|
|
/// <param name="y">
|
|
/// a pointer to receive the platform-cursor's y-position from the
|
|
/// desktop's top left corner, can be NULL if unused.
|
|
/// </param>
|
|
/// <returns>
|
|
/// a 32-bit bitmask of the button state that can be bitwise-compared
|
|
/// against the SDL_BUTTON_MASK(X) macro.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// This function immediately queries the platform for the most recent
|
|
/// asynchronous state, more costly than retrieving SDL's cached state in
|
|
/// SDL_GetMouseState().
|
|
/// </para>
|
|
/// <para>
|
|
/// Passing non-NULL pointers to <c>x</c> or <c>y</c> will write the destination with
|
|
/// respective x or y coordinates relative to the desktop.
|
|
/// </para>
|
|
/// <para>
|
|
/// In Relative Mode, the platform-cursor's position usually contradicts the
|
|
/// SDL-cursor's position as manually calculated from SDL_GetMouseState() and
|
|
/// SDL_GetWindowPosition.
|
|
/// </para>
|
|
/// <para>
|
|
/// This function can be useful if you need to track the mouse outside of a
|
|
/// specific window and SDL_CaptureMouse() doesn't fit your needs. For example,
|
|
/// it could be useful if you need to track the mouse while dragging a window,
|
|
/// where coordinates relative to a window might not be in sync at all times.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.CaptureMouse"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetMouseState"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGlobalMouseState"/>
|
|
public static SdlMouseButtonFlags GetGlobalMouseState(out float x, out float y)
|
|
{
|
|
x = default;
|
|
y = default;
|
|
fixed (float* xPtr = &x)
|
|
{
|
|
fixed (float* yPtr = &y)
|
|
{
|
|
return PInvoke.GetGlobalMouseState(xPtr, yPtr);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Query SDL's cache for the synchronous mouse button state and accumulated
|
|
/// mouse delta since last call.
|
|
/// </summary>
|
|
/// <param name="x">
|
|
/// a pointer to receive the x mouse delta accumulated since last
|
|
/// call, can be NULL if unused.
|
|
/// </param>
|
|
/// <param name="y">
|
|
/// a pointer to receive the y mouse delta accumulated since last
|
|
/// call, can be NULL if unused.
|
|
/// </param>
|
|
/// <returns>
|
|
/// a 32-bit bitmask of the button state that can be bitwise-compared
|
|
/// against the SDL_BUTTON_MASK(X) macro.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// This function returns the cached synchronous state as SDL understands it
|
|
/// from the last pump of the event queue.
|
|
/// </para>
|
|
/// <para>
|
|
/// To query the platform for immediate asynchronous state, use
|
|
/// SDL_GetGlobalMouseState.
|
|
/// </para>
|
|
/// <para>
|
|
/// Passing non-NULL pointers to <c>x</c> or <c>y</c> will write the destination with
|
|
/// respective x or y deltas accumulated since the last call to this function
|
|
/// (or since event initialization).
|
|
/// </para>
|
|
/// <para>
|
|
/// This function is useful for reducing overhead by processing relative mouse
|
|
/// inputs in one go per-frame instead of individually per-event, at the
|
|
/// expense of losing the order between events within the frame (e.g. quickly
|
|
/// pressing and releasing a button within the same frame).
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetMouseState"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGlobalMouseState"/>
|
|
public static SdlMouseButtonFlags GetRelativeMouseState(out float x, out float y)
|
|
{
|
|
x = default;
|
|
y = default;
|
|
fixed (float* xPtr = &x)
|
|
{
|
|
fixed (float* yPtr = &y)
|
|
{
|
|
return PInvoke.GetRelativeMouseState(xPtr, yPtr);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Move the mouse cursor to the given position within the window.
|
|
/// </summary>
|
|
/// <param name="window">
|
|
/// the window to move the mouse into, or NULL for the current
|
|
/// mouse focus.
|
|
/// </param>
|
|
/// <param name="x">the x coordinate within the window.</param>
|
|
/// <param name="y">the y coordinate within the window.</param>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// This function generates a mouse motion event if relative mode is not
|
|
/// enabled. If relative mode is enabled, you can force mouse events for the
|
|
/// warp by setting the SDL_HINT_MOUSE_RELATIVE_WARP_MOTION hint.
|
|
/// </para>
|
|
/// <para>
|
|
/// Note that this function will appear to succeed, but not actually move the
|
|
/// mouse when used over Microsoft Remote Desktop.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.WarpMouseGlobal"/>
|
|
public static void WarpMouseInWindow(SdlWindow window, float x, float y) =>
|
|
PInvoke.WarpMouseInWindow(window, x, y);
|
|
|
|
/// <summary>
|
|
/// Move the mouse to the given position in global screen space.
|
|
/// </summary>
|
|
/// <param name="x">the x coordinate.</param>
|
|
/// <param name="y">the y coordinate.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// This function generates a mouse motion event.
|
|
/// </para>
|
|
/// <para>
|
|
/// A failure of this function usually means that it is unsupported by a
|
|
/// platform.
|
|
/// </para>
|
|
/// <para>
|
|
/// Note that this function will appear to succeed, but not actually move the
|
|
/// mouse when used over Microsoft Remote Desktop.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.WarpMouseInWindow"/>
|
|
public static bool WarpMouseGlobal(float x, float y) => PInvoke.WarpMouseGlobal(x, y) != 0;
|
|
|
|
/// <summary>
|
|
/// Set relative mouse mode for a window.
|
|
/// </summary>
|
|
/// <param name="window">the window to change.</param>
|
|
/// <param name="enabled">true to enable relative mode, false to disable.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// While the window has focus and relative mouse mode is enabled, the cursor
|
|
/// is hidden, the mouse position is constrained to the window, and SDL will
|
|
/// report continuous relative mouse motion even if the mouse is at the edge of
|
|
/// the window.
|
|
/// </para>
|
|
/// <para>
|
|
/// If you'd like to keep the mouse position fixed while in relative mode you
|
|
/// can use SDL_SetWindowMouseRect(). If you'd like the cursor to be at a
|
|
/// specific location when relative mode ends, you should use
|
|
/// SDL_WarpMouseInWindow() before disabling relative mode.
|
|
/// </para>
|
|
/// <para>
|
|
/// This function will flush any pending mouse motion for this window.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetWindowRelativeMouseMode"/>
|
|
public static bool SetWindowRelativeMouseMode(SdlWindow window, bool enabled) =>
|
|
PInvoke.SetWindowRelativeMouseMode(window, enabled ? (byte)1 : (byte)0) != 0;
|
|
|
|
/// <summary>
|
|
/// Query whether relative mouse mode is enabled for a window.
|
|
/// </summary>
|
|
/// <param name="window">the window to query.</param>
|
|
/// <returns>true if relative mode is enabled for a window or false otherwise.</returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetWindowRelativeMouseMode"/>
|
|
public static bool GetWindowRelativeMouseMode(SdlWindow window) =>
|
|
PInvoke.GetWindowRelativeMouseMode(window) != 0;
|
|
|
|
/// <summary>
|
|
/// Capture the mouse and to track input outside an SDL window.
|
|
/// </summary>
|
|
/// <param name="enabled">true to enable capturing, false to disable.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// Capturing enables your app to obtain mouse events globally, instead of just
|
|
/// within your window. Not all video targets support this function. When
|
|
/// capturing is enabled, the current window will get all mouse events, but
|
|
/// unlike relative mode, no change is made to the cursor and it is not
|
|
/// restrained to your window.
|
|
/// </para>
|
|
/// <para>
|
|
/// This function may also deny mouse input to other windows--both those in
|
|
/// your application and others on the system--so you should use this function
|
|
/// sparingly, and in small bursts. For example, you might want to track the
|
|
/// mouse while the user is dragging something, until the user releases a mouse
|
|
/// button. It is not recommended that you capture the mouse for long periods
|
|
/// of time, such as the entire time your app is running. For that, you should
|
|
/// probably use SDL_SetWindowRelativeMouseMode() or SDL_SetWindowMouseGrab(),
|
|
/// depending on your goals.
|
|
/// </para>
|
|
/// <para>
|
|
/// While captured, mouse events still report coordinates relative to the
|
|
/// current (foreground) window, but those coordinates may be outside the
|
|
/// bounds of the window (including negative values). Capturing is only allowed
|
|
/// for the foreground window. If the window loses focus while capturing, the
|
|
/// capture will be disabled automatically.
|
|
/// </para>
|
|
/// <para>
|
|
/// While capturing is enabled, the current window will have the
|
|
/// <c>SDL_WINDOW_MOUSE_CAPTURE</c> flag set.
|
|
/// </para>
|
|
/// <para>
|
|
/// Please note that SDL will attempt to "auto capture" the mouse while the
|
|
/// user is pressing a button; this is to try and make mouse behavior more
|
|
/// consistent between platforms, and deal with the common case of a user
|
|
/// dragging the mouse outside of the window. This means that if you are
|
|
/// calling SDL_CaptureMouse() only to deal with this situation, you do not
|
|
/// have to (although it is safe to do so). If this causes problems for your
|
|
/// app, you can disable auto capture by setting the
|
|
/// <c>SDL_HINT_MOUSE_AUTO_CAPTURE</c> hint to zero.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGlobalMouseState"/>
|
|
public static bool CaptureMouse(bool enabled) => PInvoke.CaptureMouse(enabled ? (byte)1 : (byte)0) != 0;
|
|
|
|
/// <summary>
|
|
/// Ergonomic wrapper over <c>SDL_CreateCursor</c>. Throws instead of returning a null handle on failure.
|
|
/// </summary>
|
|
/// <param name="data">the color value for each pixel of the cursor.</param>
|
|
/// <param name="mask">the mask value for each pixel of the cursor.</param>
|
|
/// <param name="w">the width of the cursor.</param>
|
|
/// <param name="h">the height of the cursor.</param>
|
|
/// <param name="hot_x">
|
|
/// the x-axis offset from the left of the cursor image to the
|
|
/// mouse x position, in the range of 0 to <c>w</c> - 1.
|
|
/// </param>
|
|
/// <param name="hot_y">
|
|
/// the y-axis offset from the top of the cursor image to the
|
|
/// mouse y position, in the range of 0 to <c>h</c> - 1.
|
|
/// </param>
|
|
/// <returns>The created handle (never a null handle).</returns>
|
|
/// <exception cref="SdlException">The SDL call failed; the message carries the
|
|
/// <c>SDL_GetError</c> text.</exception>
|
|
public static SdlCursor CreateCursor(byte* data, byte* mask, int w, int h, int hot_x, int hot_y)
|
|
{
|
|
SdlCursor result = PInvoke.CreateCursor(data, mask, w, h, hot_x, hot_y);
|
|
if (result.IsNull())
|
|
{
|
|
throw SdlException.FromError("SDL_CreateCursor failed");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ergonomic wrapper over <c>SDL_CreateColorCursor</c>. Throws instead of returning a null handle on
|
|
/// failure.
|
|
/// </summary>
|
|
/// <param name="surface">an SDL_Surface structure representing the cursor image.</param>
|
|
/// <param name="hot_x">the x position of the cursor hot spot.</param>
|
|
/// <param name="hot_y">the y position of the cursor hot spot.</param>
|
|
/// <returns>The created handle (never a null handle).</returns>
|
|
/// <exception cref="SdlException">The SDL call failed; the message carries the
|
|
/// <c>SDL_GetError</c> text.</exception>
|
|
public static SdlCursor CreateColorCursor(SdlSurface* surface, int hot_x, int hot_y)
|
|
{
|
|
SdlCursor result = PInvoke.CreateColorCursor(surface, hot_x, hot_y);
|
|
if (result.IsNull())
|
|
{
|
|
throw SdlException.FromError("SDL_CreateColorCursor failed");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ergonomic wrapper over <c>SDL_CreateAnimatedCursor</c>. Throws instead of returning a null handle on
|
|
/// failure.
|
|
/// </summary>
|
|
/// <param name="frames">an array of cursor images composing the animation.</param>
|
|
/// <param name="frame_count">the number of frames in the sequence.</param>
|
|
/// <param name="hot_x">the x position of the cursor hot spot.</param>
|
|
/// <param name="hot_y">the y position of the cursor hot spot.</param>
|
|
/// <returns>The created handle (never a null handle).</returns>
|
|
/// <exception cref="SdlException">The SDL call failed; the message carries the
|
|
/// <c>SDL_GetError</c> text.</exception>
|
|
public static SdlCursor CreateAnimatedCursor(
|
|
SdlCursorFrameInfo* frames,
|
|
int frame_count,
|
|
int hot_x,
|
|
int hot_y
|
|
)
|
|
{
|
|
SdlCursor result = PInvoke.CreateAnimatedCursor(frames, frame_count, hot_x, hot_y);
|
|
if (result.IsNull())
|
|
{
|
|
throw SdlException.FromError("SDL_CreateAnimatedCursor failed");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ergonomic wrapper over <c>SDL_CreateSystemCursor</c>. Throws instead of returning a null handle on
|
|
/// failure.
|
|
/// </summary>
|
|
/// <param name="id">an SDL_SystemCursor enum value.</param>
|
|
/// <returns>The created handle (never a null handle).</returns>
|
|
/// <exception cref="SdlException">The SDL call failed; the message carries the
|
|
/// <c>SDL_GetError</c> text.</exception>
|
|
public static SdlCursor CreateSystemCursor(SdlSystemCursor id)
|
|
{
|
|
SdlCursor result = PInvoke.CreateSystemCursor(id);
|
|
if (result.IsNull())
|
|
{
|
|
throw SdlException.FromError("SDL_CreateSystemCursor failed");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set the active cursor.
|
|
/// </summary>
|
|
/// <param name="cursor">a cursor to make active.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// This function sets the currently active cursor to the specified one. If the
|
|
/// cursor is currently visible, the change will be immediately represented on
|
|
/// the display. SDL_SetCursor(NULL) can be used to force cursor redraw, if
|
|
/// this is desired for any reason.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetCursor"/>
|
|
public static bool SetCursor(SdlCursor cursor) => PInvoke.SetCursor(cursor) != 0;
|
|
|
|
/// <summary>
|
|
/// Ergonomic wrapper over <c>SDL_GetCursor</c>.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <b>Borrowed handle:</b> the returned handle is owned by SDL (or by another object) and must not be
|
|
/// disposed. Do not call <see cref="System.IDisposable.Dispose"/> on it; doing so would free a resource
|
|
/// this call does not own. A null handle is returned on failure.
|
|
/// </remarks>
|
|
public static SdlCursor GetCursor() => PInvoke.GetCursor();
|
|
|
|
/// <summary>
|
|
/// Ergonomic wrapper over <c>SDL_GetDefaultCursor</c>.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <b>Borrowed handle:</b> the returned handle is owned by SDL (or by another object) and must not be
|
|
/// disposed. Do not call <see cref="System.IDisposable.Dispose"/> on it; doing so would free a resource
|
|
/// this call does not own. A null handle is returned on failure.
|
|
/// </remarks>
|
|
public static SdlCursor GetDefaultCursor() => PInvoke.GetDefaultCursor();
|
|
|
|
/// <summary>
|
|
/// Free a previously-created cursor.
|
|
/// </summary>
|
|
/// <param name="cursor">the cursor to free.</param>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// Use this function to free cursor resources created with SDL_CreateCursor(),
|
|
/// SDL_CreateColorCursor() or SDL_CreateSystemCursor().
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.CreateAnimatedCursor"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.CreateColorCursor"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.CreateCursor"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.CreateSystemCursor"/>
|
|
public static void DestroyCursor(SdlCursor cursor) => PInvoke.DestroyCursor(cursor);
|
|
|
|
/// <summary>
|
|
/// Show the cursor.
|
|
/// </summary>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.CursorVisible"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.HideCursor"/>
|
|
public static bool ShowCursor() => PInvoke.ShowCursor() != 0;
|
|
|
|
/// <summary>
|
|
/// Hide the cursor.
|
|
/// </summary>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.CursorVisible"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.ShowCursor"/>
|
|
public static bool HideCursor() => PInvoke.HideCursor() != 0;
|
|
|
|
/// <summary>
|
|
/// Return whether the cursor is currently being shown.
|
|
/// </summary>
|
|
/// <returns>
|
|
/// <c>true</c> if the cursor is being shown, or <c>false</c> if the cursor is
|
|
/// hidden.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.HideCursor"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.ShowCursor"/>
|
|
public static bool CursorVisible() => PInvoke.CursorVisible() != 0;
|
|
}
|
|
}
|
|
}
|