blib/lib/SDL2/touch.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod n/a totaltotal 0.0% 0 / 37 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package SDL2::touch 0.01 {
2 use SDL2::Utils;
3 use SDL2::stdinc;
4 use SDL2::error;
5 use SDL2::video;
6 #
7 ffi->type( 'sint64' => 'SDL_TouchID' );
8 ffi->type( 'sint64' => 'SDL_FingerID' );
9 #
10 enum SDL_TouchDeviceType => [
11 [ SDL_TOUCH_DEVICE_INVALID => -1 ], qw[SDL_TOUCH_DEVICE_DIRECT
12 SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE
13 SDL_TOUCH_DEVICE_INDIRECT_RELATIVE]
14 ];
15 #
16 package SDL2::Finger {
17 use SDL2::Utils;
18 our $TYPE = has
19 id => 'SDL_FingerID',
20 x => 'float',
21 y => 'float',
22 pressure => 'float';
23 };
24 #
25 define touch => [
26 [ SDL_TOUCH_MOUSEID => -1 ], # unsigned 64bit int
27 [ SDL_MOUSE_TOUCHID => -1 ] # signed 64bit int
28 ];
29 #
30 attach touch => {
31 SDL_GetNumTouchDevices => [ [], 'int' ],
32 SDL_GetTouchDevice => [ ['int'], 'SDL_TouchID' ],
33 SDL_GetTouchDeviceType => [ ['SDL_TouchID'], 'SDL_TouchDeviceType' ],
34 SDL_GetNumTouchFingers => [ ['SDL_TouchID'], 'int' ],
35 SDL_GetTouchFinger => [ [ 'SDL_TouchID', 'int' ], 'SDL_Finger' ]
36 };
37  
38 =encoding utf-8
39  
40 =head1 NAME
41  
42 SDL2::touch - SDL Touch Event Handling
43  
44 =head1 SYNOPSIS
45  
46 use SDL2 qw[:touch];
47  
48 =head1 DESCRIPTION
49  
50 SDL2::touch provides functions and defined values that allow for handling
51 simple touch events. These functions may be imported by name or with the
52 C<:touch> tag.
53  
54 =head1 Functions
55  
56 These may be imported by name or with the C<:touch> tag.
57  
58 =head2 C<SDL_GetNumTouchDevices( )>
59  
60 Get the number of registered touch devices.
61  
62 On some platforms SDL first sees the touch device if it was actually used.
63 Therefore C<SDL_GetNumTouchDevices( )> may return C<0> although devices are
64 available. After using all devices at least once the number will be correct.
65  
66 Returns the number of registered touch devices.
67  
68 =head2 C<SDL_GetTouchDevice( ... )>
69  
70 Get the touch ID with the given index.
71  
72 Expected parameters include:
73  
74 =over
75  
76 =item C<index> - the touch device index
77  
78 =back
79  
80 Returns the touch ID with the given index on success or C<0> if the index is
81 invalid; call C<SDL_GetError( )> for more information.
82  
83 =head2 C<SDL_GetTouchDeviceType( ... )>
84  
85 Get the type of the given touch device.
86  
87 Expected parameters include:
88  
89 =over
90  
91 =item C<touchID> - the touch ID to query
92  
93 =back
94  
95 Returns a C<SDL_TouchDeviceType>.
96  
97 =head2 C<SDL_GetNumTouchFingers( ... )>
98  
99 Get the number of active fingers for a given touch device.
100  
101 Expected parameters include:
102  
103 =over
104  
105 =item C<touchID> - the ID of a touch device
106  
107 =back
108  
109 Returns the number of active fingers for a given touch device on success or
110 C<0> on failure; call C<SDL_GetError( )> for more information.
111  
112 =head2 C<SDL_GetTouchFinger( ... )>
113  
114 Get the finger object for specified touch device ID and finger index.
115  
116 The returned resource is owned by SDL and should not be deallocated.
117  
118 Expected parameters include:
119  
120 =over
121  
122 =item C<touchID> - the ID of the requested touch device
123  
124 =item C<index> - the index of the requested finger
125  
126 =back
127  
128 Returns a pointer to the L<SDL2::Finger> object or C<undef> if no object at the
129 given ID and index could be found.
130  
131 =head1 Defined Types, Enumerations, and Values
132  
133 These values may be imported by name or with the given tag.
134  
135 =head2 C<SDL_TouchID>
136  
137 Signed 64-bit integer.
138  
139 =head2 C<SDL_FingerID>
140  
141 Signed 64-bit integer.
142  
143 =head2 C<SDL_TouchDeviceType>
144  
145 Enumeration which may be imported with the C<:touchDeviceType> tag.
146  
147 =over
148  
149 =item C<SDL_TOUCH_DEVICE_INVALID>
150  
151 =item C<SDL_TOUCH_DEVICE_DIRECT> - touch screen with window-relative coordinates
152  
153 =item C<SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE> - trackpad with absolute device coordinates
154  
155 =item C<SDL_TOUCH_DEVICE_INDIRECT_RELATIVE> - trackpad with screen cursor-relative coordinates
156  
157 =back
158  
159 =head2 C<SDL_TOUCH_MOUSEID>
160  
161 Used as the device ID for mouse events simulated with touch input.
162  
163 =head2 C<SDL_MOUSE_TOUCHID>
164  
165 Used as the C<SDL_TouchID> for touch events simulated with mouse input.
166  
167 =head1 LICENSE
168  
169 Copyright (C) Sanko Robinson.
170  
171 This library is free software; you can redistribute it and/or modify it under
172 the terms found in the Artistic License 2. Other copyrights, terms, and
173 conditions may apply to data transmitted through this module.
174  
175 =head1 AUTHOR
176  
177 Sanko Robinson E<lt>sanko@cpan.orgE<gt>
178  
179 =begin stopwords
180  
181 deallocated trackpad
182  
183 =end stopwords
184  
185 =cut
186  
187 };
188 1;