| 1 | package SDL2::misc { | ||
| 2 | use strictures 2; | ||
| 3 | use SDL2::Utils; | ||
| 4 | # | ||
| 5 | use SDL2::stdinc; | ||
| 6 | # | ||
| 7 | attach misc => { SDL_OpenURL => [ ['string'], 'int' ] }; | ||
| 8 | |||
| 9 | =encoding utf-8 | ||
| 10 | |||
| 11 | =head1 NAME | ||
| 12 | |||
| 13 | SDL2::misc - SDL API functions that don't fit elsewhere | ||
| 14 | |||
| 15 | =head1 SYNOPSIS | ||
| 16 | |||
| 17 | use SDL2 qw[:misc]; | ||
| 18 | SDL_OpenURL( 'https://github.com/' ); | ||
| 19 | |||
| 20 | =head1 DESCRIPTION | ||
| 21 | |||
| 22 | SDL2::misc contains functions that don't fit anywhere else. | ||
| 23 | |||
| 24 | =head1 Functions | ||
| 25 | |||
| 26 | These may be imported by name or with the C<:misc> tag. | ||
| 27 | |||
| 28 | =head2 C<SDL_OpenURL( ... )> | ||
| 29 | |||
| 30 | Open a URL/URI in the browser or other appropriate external application. | ||
| 31 | |||
| 32 | Open a URL in a separate, system-provided application. How this works will vary | ||
| 33 | wildly depending on the platform. This will likely launch what makes sense to | ||
| 34 | handle a specific URL's protocol (a web browser for C<http://>, etc), but it | ||
| 35 | might also be able to launch file managers for directories and other things. | ||
| 36 | |||
| 37 | What happens when you open a URL varies wildly as well: your game window may | ||
| 38 | lose focus (and may or may not lose focus if your game was fullscreen or | ||
| 39 | grabbing input at the time). On mobile devices, your app will likely move to | ||
| 40 | the background or your process might be paused. Any given platform may or may | ||
| 41 | not handle a given URL. | ||
| 42 | |||
| 43 | If this is unimplemented (or simply unavailable) for a platform, this will fail | ||
| 44 | with an error. A successful result does not mean the URL loaded, just that we | ||
| 45 | launched _something_ to handle it (or at least believe we did). | ||
| 46 | |||
| 47 | All this to say: this function can be useful, but you should definitely test it | ||
| 48 | on every platform you target. | ||
| 49 | |||
| 50 | Expected parameters include: | ||
| 51 | |||
| 52 | =over | ||
| 53 | |||
| 54 | =item C<url> - a valid URL/URI to open. Use C<file:///full/path/to/file> for local files, if supported. | ||
| 55 | |||
| 56 | =back | ||
| 57 | |||
| 58 | Returns C<0> on success, or C<-1> on error; call C<SDL_GetError( )> for more | ||
| 59 | information. | ||
| 60 | |||
| 61 | =head1 LICENSE | ||
| 62 | |||
| 63 | Copyright (C) Sanko Robinson. | ||
| 64 | |||
| 65 | This library is free software; you can redistribute it and/or modify it under | ||
| 66 | the terms found in the Artistic License 2. Other copyrights, terms, and | ||
| 67 | conditions may apply to data transmitted through this module. | ||
| 68 | |||
| 69 | =head1 AUTHOR | ||
| 70 | |||
| 71 | Sanko Robinson E<lt>sanko@cpan.orgE<gt> | ||
| 72 | |||
| 73 | =begin stopwords | ||
| 74 | |||
| 75 | fullscreen non-fullscreen high-dpi borderless resizable draggable taskbar | ||
| 76 | tooltip popup subwindow macOS iOS NSHighResolutionCapable videomode screensaver | ||
| 77 | wgl lifespan vsync glX framebuffer framerate | ||
| 78 | |||
| 79 | =end stopwords | ||
| 80 | |||
| 81 | =cut | ||
| 82 | |||
| 83 | }; | ||
| 84 | 1; |