line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package USB::HID::Descriptor::Interface; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
5
|
1
|
|
|
1
|
|
6
|
use base 'USB::Descriptor::Interface'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
112
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
637
|
use USB::HID::Descriptor::Class; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
701
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
USB::HID::Descriptor::Interface - USB HID Interface Descriptor |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
An object representation of a USB HID interface descriptor. Subclass of |
18
|
|
|
|
|
|
|
L. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use USB::HID::Descriptor::Interface; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $interface = USB::HID::Descriptor::Interface->new( description => 'My First Interface' ); |
23
|
|
|
|
|
|
|
$interface->protocol(0); |
24
|
|
|
|
|
|
|
$interface->subclass(0); |
25
|
|
|
|
|
|
|
$interface->endpoints( [ USB::Descriptor::Endpoint->new() ] ); |
26
|
|
|
|
|
|
|
... |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
L represents a USB interface descriptor for a |
31
|
|
|
|
|
|
|
HID class device. When added to the descriptor tree of a |
32
|
|
|
|
|
|
|
L object it can be used to generate the data structures |
33
|
|
|
|
|
|
|
needed to compile the firmware for a USB device. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=over |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item $interface = USB::HID::Descriptor::Interface->new(description=>$description, ...); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Constructs and returns a new L object using the |
42
|
|
|
|
|
|
|
passed options. Each option key is the name of an accessor method. The C |
43
|
|
|
|
|
|
|
option is overriden. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item $interface = USB::HID::Descriptor::Interface->convert($another_interface) |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Converts a L object into a |
48
|
|
|
|
|
|
|
L object and returns it. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=back |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub new |
55
|
|
|
|
|
|
|
{ |
56
|
0
|
|
|
0
|
1
|
|
my ($this, %options) = @_; |
57
|
0
|
|
0
|
|
|
|
my $class = ref($this) || $this; |
58
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(%options); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# Force the interface class to HID |
61
|
0
|
|
|
|
|
|
$self->SUPER::class(0x03); |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
return $self; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Convert a USB::Descriptor::Interface object |
67
|
|
|
|
|
|
|
sub convert |
68
|
|
|
|
|
|
|
{ |
69
|
0
|
|
|
0
|
1
|
|
my ($this, $interface) = @_; |
70
|
0
|
|
0
|
|
|
|
my $class = ref($this) || $this; |
71
|
0
|
0
|
0
|
|
|
|
if( ref($interface) && $interface->isa('USB::Descriptor::Interface') ) |
72
|
|
|
|
|
|
|
{ |
73
|
0
|
|
|
|
|
|
bless $interface, $class; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Force the interface class to HID |
76
|
0
|
|
|
|
|
|
$interface->SUPER::class(0x03); |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
return $interface; |
79
|
|
|
|
|
|
|
} |
80
|
0
|
|
|
|
|
|
undef; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=over |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item $interface->class |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Returns the interface's class (bInterfaceClass). No setting allowed. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item $interface->class_descriptor |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Returns the current class descriptor object. No setting allowed. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item $interface->country |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Get/Set the country code for localized hardware (bCountryCode). Defaults to 0. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item $class->report_bytes |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Returns an array of bytes containing the report descriptor. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item $interface->report |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
A convenience method that wraps a single hash reference in an array and passes |
106
|
|
|
|
|
|
|
it to C. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item $interface->reports |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Get/Set the array of C objects. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item $interface->version |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Get/Set the HID specification release number (bcdHID). Defaults to '1.1.0'. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=back |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# Forward the call to the Class descriptor |
121
|
|
|
|
|
|
|
sub country |
122
|
|
|
|
|
|
|
{ |
123
|
0
|
|
|
0
|
1
|
|
my $s = shift; |
124
|
0
|
0
|
|
|
|
|
$s->class_descriptor->country = shift if scalar @_; |
125
|
0
|
|
|
|
|
|
$s->class_descriptor->country; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# Override class to prevent setting |
129
|
|
|
|
|
|
|
sub class |
130
|
|
|
|
|
|
|
{ |
131
|
0
|
|
|
0
|
1
|
|
my $s = shift; |
132
|
0
|
|
|
|
|
|
$s->SUPER::class; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# Override class_descriptor to prevent setting |
136
|
|
|
|
|
|
|
# Create a new default Class descriptor if one doesn't already exist |
137
|
|
|
|
|
|
|
sub class_descriptor |
138
|
|
|
|
|
|
|
{ |
139
|
0
|
|
|
0
|
1
|
|
my $s = shift; |
140
|
0
|
|
|
|
|
|
my $c = $s->SUPER::class_descriptor; |
141
|
0
|
0
|
|
|
|
|
return $c if ref($c); |
142
|
0
|
|
|
|
|
|
$s->SUPER::class_descriptor(USB::HID::Descriptor::Class->new); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub report_bytes |
146
|
|
|
|
|
|
|
{ |
147
|
0
|
|
|
0
|
1
|
|
my $s = shift; |
148
|
0
|
|
|
|
|
|
$s->class_descriptor->report_bytes; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub report |
152
|
|
|
|
|
|
|
{ |
153
|
0
|
|
|
0
|
1
|
|
my $s = shift; |
154
|
0
|
0
|
|
|
|
|
$s->class_descriptor->report(@_) if @_; |
155
|
0
|
|
|
|
|
|
$s->class_descriptor->report; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
# Forward the call to the Class descriptor |
159
|
|
|
|
|
|
|
sub reports |
160
|
|
|
|
|
|
|
{ |
161
|
0
|
|
|
0
|
1
|
|
my $s = shift; |
162
|
0
|
0
|
|
|
|
|
$s->class_descriptor->reports(@_) if @_; |
163
|
0
|
|
|
|
|
|
$s->class_descriptor->reports; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
# Forward the call to the Class descriptor |
167
|
|
|
|
|
|
|
sub version |
168
|
|
|
|
|
|
|
{ |
169
|
0
|
|
|
0
|
1
|
|
my $s = shift; |
170
|
0
|
0
|
|
|
|
|
$s->class_descriptor->version(shift) if @_; |
171
|
0
|
|
|
|
|
|
$s->class_descriptor->version; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 REPORT DESCRIPTOR ATTRIBUTES |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=over |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=item $interface->page |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Get/Set the B of the interface's report descriptor. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=item $interface->usage |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Get/Set the B of the interface's report descriptor. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=back |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=cut |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub page |
191
|
|
|
|
|
|
|
{ |
192
|
0
|
|
|
0
|
1
|
|
my $s = shift; |
193
|
0
|
0
|
|
|
|
|
$s->class_descriptor->page(@_) if @_; |
194
|
0
|
|
|
|
|
|
$s->class_descriptor->page; |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub usage |
198
|
|
|
|
|
|
|
{ |
199
|
0
|
|
|
0
|
1
|
|
my $s = shift; |
200
|
0
|
0
|
|
|
|
|
$s->class_descriptor->usage(shift) if @_; |
201
|
0
|
|
|
|
|
|
$s->class_descriptor->usage; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
1; |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head1 AUTHOR |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Brandon Fosdick, C<< >> |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head1 BUGS |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
213
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
214
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head1 SUPPORT |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
perldoc USB::HID::Descriptor::Interface |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
You can also look for information at: |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=over 4 |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
L |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
L |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=item * CPAN Ratings |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
L |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=item * Search CPAN |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
L |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=back |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
Copyright 2011 Brandon Fosdick. |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
This program is released under the terms of the BSD License. |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=cut |