Skip to content

Consider some sort of mouse cursor customization support. #1156

@bryanedds

Description

@bryanedds

From discord discussion -

Happypig375
Is it possible to hide the OS cursor and draw a custom sprite in place of it?
I suppose the drawing custom sprite part is just static sprite and listening to mouse move events

bryanedds
i'm pretty sure that'd involved the SDL API in some way.
that said, manually drawing a mouse cursor is always going to be more laggy than the OS's hardware cursor.
to implement this without exposing SDL2 details, engine could provide two new properties (both in GameState) -

  1. HideHardwareCursor - hides the hardware cursor, but only while inside the SDL2 window (otherwise set to showen).
  2. CenterMouseCursor - when enabled, resets mouse position to center every frame.
    to implement this without exposing SDL2

Happypig375
Should be the same performance as the rest of game entities I suppose
The mouse cursor isn't going to be any worse than any other entity in the game

bryanedds
the responsiveness of the mouse cursor is special, which is why it receives hardware acceleration. the approach that's probably considered correct is to change the OS cursor's image rather than hiding it and replacing it with a lagging one.
however, if your game isn't twitch-based, it might not matter.
it will probably affect 'feel' tho
these nuances are why we've not bothered supporting any specific approach, leaving it to the user to drive SDL directly through its API to achieve what they really need.
the proper engine API i think would let the user set the mouse cursor's graphic directly while the mouse is over the window.
this should afford both low latency and user customizability.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions