blib/lib/SDL2/system.pm untested

filter: Statementstmt 0.0% 0 / 58 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod n/a totaltotal 0.0% 0 / 78 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package SDL2::system 0.01 {
2 use SDL2::Utils;
3 use experimental 'signatures';
4 #
5 use SDL2::stdinc;
6 use SDL2::keyboard;
7 use SDL2::render;
8 use SDL2::video;
9 #
10 # From Perl::osnames
11 my $linux = $^O
12 =~ qr/\A(?:aix|android|bsdos|bitrig|dgux|dynixptx|cygwin|darwin|dragonfly|freebsd|gnu|gnukfreebsd|hpux|interix|iphoneos|irix|linux|machten|midnightbsd|mirbsd|msys|netbsd|next|nto|openbsd|qnx|sco|sco_sv|solaris|sunos|svr4|svr5|unicos|unicosmk)\z/;
13 my $macos = $^O eq 'darwin';
14 my $ios = $^O eq 'iphoneos';
15 my $android = $^O eq 'android';
16 my $winrt = 0;
17 my $win32 = $^O eq 'MSWin32';
18 #
19 if ($win32) {
20  
21 package SDL2::IDirect3DDevice9 {
22 use SDL2::Utils;
23 our $TYPE = has();
24 };
25  
26 package SDL2::ID3D11Device {
27 use SDL2::Utils;
28 our $TYPE = has();
29 };
30  
31 #(void *userdata, void *hWnd, unsigned int message, Uint64 wParam, Sint64 lParam);
32 ffi->type( '(opaque,opaque,uint,uint64,sint64)->void' => 'SDL_WindowsMessageHook' );
33 attach system => {
34 SDL_SetWindowsMessageHook => [
35 [ 'SDL_WindowsMessageHook', 'opaque' ] => sub ( $inner, $callback, $userdata = () )
36 {
37 my $cb = ffi->closure(
38 sub ( $ud, $hWnd, $msg, $wP, $lP ) {
39 $callback->( $userdata, $hWnd, $msg, $wP, $lP );
40 }
41 );
42 $cb->sticky;
43 $inner->( $cb, $userdata );
44 }
45 ],
46 SDL_Direct3D9GetAdapterIndex => [ ['int'], 'int' ],
47 SDL_RenderGetD3D9Device => [ ['SDL_Renderer'], 'SDL_IDirect3DDevice9' ],
48 SDL_RenderGetD3D11Device => [ ['SDL_Renderer'], 'SDL_ID3D11Device' ],
49 SDL_DXGIGetOutputInfo => [ [ 'int', 'int*', 'int*' ], 'SDL_bool' ]
50 };
51 }
52 elsif ($macos) {
53 }
54 elsif ($linux) {
55 attach system => { SDL_LinuxSetThreadPriority => [ [ 'sint64', 'int' ], 'int' ] };
56 }
57 elsif ($ios) {
58 ...;
59 }
60 elsif ($android) {
61 ...;
62 }
63 elsif ($winrt) {
64 ...;
65 }
66 attach system => { SDL_IsTablet => [ [], 'SDL_bool' ] };
67  
68 =encoding utf-8
69  
70 =head1 NAME
71  
72 SDL2::system - Platform Specific SDL API Functions
73  
74 =head1 SYNOPSIS
75  
76 use SDL2 qw[:system];
77  
78 =head1 DESCRIPTION
79  
80 Depending on your platform, some of these functions will not be defined. They
81 may be imported by name or with the C<:system> tag.
82  
83 =head1 General
84  
85 These functions are defined for all platforms.
86  
87 =head2 Functions.
88  
89 Platform agnostic functions.
90  
91 =head2 C<SDL_IsTablet( )>
92  
93 Query if the current device is a tablet.
94  
95 If SDL can't determine this, it will return C<SDL_FALSE>.
96  
97 Returns C<SDL_TRUE> if the device is a tablet, C<SDL_FALSE> otherwise.
98  
99 =head1 Windows
100  
101 These functions and defined types will only exist on a system running Windows.
102  
103 =head2 Functions
104  
105 Platform specified functions for Windows.
106  
107 =head2 C<SDL_SetWindowsMessageHook( ... )>
108  
109 Set a callback for every Windows message, run before C<TranslateMessage( )>.
110  
111 Expected parameters include:
112  
113 =over
114  
115 =item C<callback> - the C<SDL_WindowsMessageHook> function to call.
116  
117 =item C<userdata> - a pointer to pass to every iteration of C<callback>
118  
119 =back
120  
121 =head2 C<SDL_Direct3D9GetAdapterIndex( ... )>
122  
123 Get the D3D9 adapter index that matches the specified display index.
124  
125 The returned adapter index can be passed to `IDirect3D9::CreateDevice` and
126 controls on which monitor a full screen application will appear.
127  
128 Expected parameters include:
129  
130 =over
131  
132 =item C<displayIndex> - the display index for which to get the D3D9 adapter index
133  
134 =back
135  
136 Returns the D3D9 adapter index on success or a negative error code on failure;
137 call C<SDL_GetError( )> for more information.
138  
139 =head2 C<SDL_RenderGetD3D9Device( ... )>
140  
141 Get the D3D9 device associated with a renderer.
142  
143 Once you are done using the device, you should release it to avoid a resource
144 leak.
145  
146 Expected parameters include:
147  
148 =over
149  
150 =item C<renderer> the renderer from which to get the associated D3D device
151  
152 =back
153  
154 Returns the D3D9 device associated with given renderer or C<undef> if it is not
155 a D3D9 renderer; call C<SDL_GetError( )> for more information.
156  
157 =head2 C<SDL_RenderGetD3D11Device( ... )>
158  
159 Get the D3D11 device associated with a renderer.
160  
161 Once you are done using the device, you should release it to avoid a resource
162 leak.
163  
164 Expected parameters include:
165  
166 =over
167  
168 =item C<renderer> - the renderer from which to get the associated D3D11 device
169  
170 =back
171  
172 Returns the D3D11 device associated with given renderer or C<undef> if it is
173 not a D3D11 renderer; call C<SDL_GetError( )> for more information.
174  
175 =head2 C<SDL_DXGIGetOutputInfo( ... )>
176  
177 Get the DXGI Adapter and Output indices for the specified display index.
178  
179 The DXGI Adapter and Output indices can be passed to C<EnumAdapters> and
180 C<EnumOutputs> respectively to get the objects required to create a DX10 or
181 DX11 device and swap chain.
182  
183 =over
184  
185 =item C<displayIndex> - the display index for which to get both indices
186  
187 =item C<adapterIndex> - a pointer to be filled in with the adapter index
188  
189 =item C<outputIndex> - a pointer to be filled in with the output index
190  
191 =back
192  
193 Returns C<SDL_TRUE> on success or C<SDL_FALSE> on failure; call C<SDL_GetError(
194 )> for more information.
195  
196 =head2 Defined Values and Enumerations
197  
198 These will only be defined on Windows.
199  
200 =head3 C<SDL_WindowsMessageHook>
201  
202 A callback for every Windows message.
203  
204 Parameters to expect include:
205  
206 =over
207  
208 =item C<userdata>
209  
210 =item C<hWnd>
211  
212 =item C<message>
213  
214 =item C<wParam>
215  
216 =item C<lParam>
217  
218 =back
219  
220 =head1 Linux
221  
222 These functions will only exist on a system running Linux.
223  
224 =head2 Functions
225  
226 Sets the UNIX nice value for a thread.
227  
228 This uses C<setpriority( )> if possible, and RealtimeKit if available.
229  
230 Expected parameters include:
231  
232 =over
233  
234 =item C<threadID> - the Unix thread ID to change priority of
235  
236 =item C<priority> - the new, Unix-specific, priority value
237  
238 =back
239  
240 Returns C<0> on success, or C<-1> on error.
241  
242 =head1 iOS
243  
244 The functions related to iOS are not defined. If you somehow manage to get perl
245 running on an iOS device and require these functions, file a bug report at this
246 project's issue tracker and I'll fill in the gaps if you'll assist with
247 testing.
248  
249 =head1 Android
250  
251 The functions related to Android are not defined. If you require these
252 functions, file a bug report at this project's issue tracker and I'll fill in
253 the gaps if you'll assist with testing.
254  
255 =head1 WinRT
256  
257 The functions related to WinRT are not defined. If you somehow manage to get
258 perl running on a device with WinRT and require these functions, file a bug
259 report at this project's issue tracker and I'll fill in the gaps if you'll
260 assist with testing.
261  
262 =head1 LICENSE
263  
264 Copyright (C) Sanko Robinson.
265  
266 This library is free software; you can redistribute it and/or modify it under
267 the terms found in the Artistic License 2. Other copyrights, terms, and
268 conditions may apply to data transmitted through this module.
269  
270 =head1 AUTHOR
271  
272 Sanko Robinson E<lt>sanko@cpan.orgE<gt>
273  
274 =begin stopwords
275  
276 WinRT
277  
278 =end stopwords
279  
280 =cut
281  
282 };
283 1;