pods::SDL::Mouse(3pm)

πŸ“¦ version 2.548, in opensuse-leap 16.0

πŸ’– NAME πŸ’–

okay so bestie, welcome to pods::SDL::Mouse(3pm) β€” also known as SDL::Mouse β€” and it's literally the SDL bindings for the Mouse device 🐭✨. Mouse device? SDL? Yes, that's the whole main character energy of this page.

πŸŽ€ CATEGORY πŸŽ€

It's filed under Core, Mouse. Cute, concise, iconic.

✨ CONSTANTS ✨

The constants for SDL::Mouse belong to SDL::Events/SDL::Event, under the export tag of ':state'. That's the lowkey important bit, iykyk 🫢.

πŸ¦‹ METHODS πŸ¦‹

πŸ’… warp_mouse

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

This sets the position of the mouse cursor β€” and yes, it generates a mouse motion event ✨. Even if the mouse is warped to where it currently is, a mouse motion event is still generated. No cap, it really said "motion is motion."

πŸŽ€ set_cursor

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

Sets the currently active cursor to the specified one. See SDL::Cursor for details on cursor objects. If the cursor is currently visible, the change will be immediately represented on the display. Also: set_cursor() can be used to force cursor redraw, if this is desired for any reason. Slay.

πŸ¦‹ get_cursor

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

Gets the currently active mouse cursor. That's it, bestie β€” it's giving simple and effective πŸ’….

πŸ’– show_cursor

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

Toggle whether or not the cursor is shown on the screen. Passing "SDL_ENABLE" displays the cursor and passing "SDL_DISABLE" hides it. The current state of the mouse cursor can be queried by passing "SDL_QUERY"; either "SDL_DISABLE" or "SDL_ENABLE" will be returned. Obsessed with a query-able cursor state, honestly.

And here's the example, exactly as it appears:

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);

🌈 SEE ALSO 🌈

SDL::Cursor β€” go peek at that one too, bestie. It's the cursor manual, and it's right there.

πŸ‘‘ AUTHORS πŸ‘‘

See "AUTHORS" in SDL. That's the whole pointer, fr fr.


mwah πŸ’‹ β€” this page is from perl v5.42.0, dated 2024-05-01, and it's the pods::SDL::Mouse(3pm) manual. Periodt.

πŸ“¦ where this page comes from