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 forset_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
- ubuntu stonking: libsdl-perl 2.548-6build1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms