pods::SDL::Mouse(3pm)

πŸ¦‹ NAME πŸ¦‹

okay bestie, so you're looking at SDL::Mouse β€” the SDL bindings for the mouse device, from the fine folks in User Contributed Perl Documentation, section 3pm of the pods:: manual (pods::SDL::Mouse(3pm), if you're being formal πŸ’…). It's literally your whole mouse situation, handled. 🐭✨


πŸŽ€ CATEGORY πŸŽ€

Core, Mouse. That's the whole vibe check β€” it's core, and it's about the mouse. periodt.


⭐ CONSTANTS ⭐

The constants for SDL::Mouse don't even live here, no cap β€” they belong to SDL::Events/SDL::Event, tucked under the export tag ':state'. So if you're out here like "where are my constants 😭", that's where. Import :state and you're slaying. 🫢


🌸 METHODS 🌸

πŸ’– warp_mouse

SDL::Mouse::warp_mouse( $x, $y );

Set the position of the mouse cursor. Simple as. But listen β€” it generates a mouse motion event. And the way that even if you warp the mouse to exactly where it already is, it still generates a mouse motion event? yeah. iconic but also lowkey a thing you need to remember. it's giving "I moved but I didn't move." πŸ’«

πŸ’– set_cursor

SDL::Mouse::set_cursor( $cursor_object );

Sets the currently active cursor to the one you specified. Need the lore on cursor objects? go peek at SDL::Cursor, it's got you. If the cursor is currently visible, the change shows up on the display immediately β€” no waiting, no drama. And plot twist: set_cursor() can also be used to force a cursor redraw, if that's something you want for any reason. handy. πŸŽ€

πŸ’– get_cursor

my $cursor_object = SDL::Mouse::get_cursor;

Gets the currently active mouse cursor. That's it, that's the method. short queen. πŸ‘‘

πŸ’– show_cursor

my $return = SDL::Mouse::show_cursor( $state );

Toggle whether or not the cursor shows up on screen. Pass SDL_ENABLE and the cursor appears πŸ’–. Pass SDL_DISABLE and it dips out πŸ™ˆ. Wanna know the current state without changing anything? pass SDL_QUERY and you'll get back either SDL_DISABLE or SDL_ENABLE β€” no guessing required.


and here's a whole lil demo so you can see it in the wild, bestie, run it and watch the cursor do its thing:

use SDL;
use SDL::Mouse;
use SDL::Video;
use SDL::Events ':state'; #For the constants

SDL::init(SDL_INIT_VIDEO);
SDL::Video::set_video_mode(640, 480, 16, SDL_SWSURFACE);

printf("Cursor is %s\n", SDL::Mouse::show_cursor(SDL_QUERY) ? 'visible' : 'not visible');

sleep(3);

SDL::Mouse::show_cursor(SDL_DISABLE);
printf("Cursor is %s\n", SDL::Mouse::show_cursor(SDL_QUERY) ? 'visible' : 'not visible');

sleep(3);

SDL::Mouse::show_cursor(SDL_ENABLE);
printf("Cursor is %s\n", SDL::Mouse::show_cursor(SDL_QUERY) ? 'visible' : 'not visible');

sleep(3);

like?? it literally prints whether your cursor is visible, hides it, checks again, shows it, checks again. three sleep(3) breaks so your eyes can keep up. 10/10 tutorial energy. πŸ”₯


🌈 SEE ALSO 🌈

  • SDL::Cursor β€” go read it, it's the cursor object lore you need for set_cursor. iykyk πŸ¦‹

πŸ’œ AUTHORS πŸ’œ

See "AUTHORS" in SDL. (they're all listed over there, go give them their flowers 🌸)


okay that's the whole page!! now go forth and warp some mice πŸ’…βœ¨

perl v5.42.3 Β· 2026-08-19 Β· pods::SDL::Mouse(3pm) β€” mwah, that's the version, the date, and the manual, all wrapped up with a bow πŸŽ€πŸ«Ά

πŸ“¦ where this page comes from