Linux-Joystick

 view release on metacpan or  search on metacpan

Joystick.pm  view on Meta::CPAN

933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
Sets or clears non-blocking mode. Takes one scalar parameter, which
is treated as a boolean: a true value turns on non-blocking I/O, and
a false value turns it off. It doesn't hurt anything to attempt to set
the same mode that's already in use, and you can switch between the I/O
modes as many times as you want.
 
setNonblocking uses an fcntl() call to change the file descriptor's mode,
so it doesn't close and reopen the device. Remember that when you're in
non-blocking mode, all calls to nextEvent immediately return. When there's
no input, the event returned will be undef. Also remember not to busy-wait
on events! If you find yourself using 99% of the CPU according to `top',
you need to restructure your code so that it works in blocking mode. If
you can't do this (e.g. because you're reading from a network socket as
well as a joystick), at least use a call like select(undef, undef, undef,
0.01) to yield the CPU so that other processes can run.  An even better
idea would be to stay in blocking mode, but use the fileHandle method
to get the joystick's file handle, then select() on both the joystick
and network filehandles. This way, the kernel will put your process to
sleep until there's some input available on one stream or the other.



( run in 0.471 second using v1.01-cache-2.11-cpan-5f2e87ce722 )