Device-HID
view release on metacpan or search on metacpan
Lvalue subroutine that can be used to set whether the module "croak"
in Carps on failure.
Default value is 0.
renew_on_timeout
$dev->renew_on_timeout;
Closes HIDAPI handle and opens a new one transparently at read_data
timeout and retries reading. When read_data returns successfully the
first time, renew_on_timeout is reset and timeout is set to undef,
but can be manually adjusted.
For reasons unknown to me, Valve's Steam controller needs a couple of
hid_open calls before hid_read manages to read data. None of the
prior hid_open calls fail, they just block indefinitely. For devices
that ought to report periodically what they're up to, set the timeout
in new to a sensible value and call renew_on_timeout on the handle.
The following hid_read will then be retried till data can be read.
lib/Device/HID.pm view on Meta::CPAN
sub autodie : lvalue {
my $self = shift;
return $self->{autodie};
}
=item renew_on_timeout
$dev->renew_on_timeout;
Closes HIDAPI handle and opens a new one transparently at C<read_data> timeout and retries reading. When C<read_data> returns successfully the first time, C<renew_on_timeout> is reset and timeout is set to C<undef>, but can be manually adjusted.
For reasons unknown to me, Valve's Steam controller needs a couple of C<hid_open> calls before C<hid_read> manages to read data. None of the prior C<hid_open> calls fail, they just block indefinitely. For devices that ought to report periodically wha...
=cut
sub renew_on_timeout {
my $self = shift;
$self->{renew} = 1;
defined $self->{timeout} or croak "Thou shalt not call renew_on_timeout when timeout is not in sight.";
( run in 0.701 second using v1.01-cache-2.11-cpan-0a6323c29d9 )