AAC-Pvoice
view release on metacpan or search on metacpan
lib/AAC/Pvoice/Input.pm view on Meta::CPAN
{
my $self = shift;
EVT_MOUSE_EVENTS($self->{window}, \&_iconcontrol)
if $self->{window}->{config}->Read('Device') eq 'icon';
}
sub _initmonitor
{
my $self = shift;
# The event for the adremo device
$self->{window}->{adremotimer} = Wx::Timer->new($self->{window},my $tid = Wx::NewId());
EVT_TIMER($self->{window}, $tid, \&_monitorport);
}
sub _initautoscan
{
my $self = shift;
$self->{window}->{onebuttontimer} = Wx::Timer->new($self->{window},my $obtid = Wx::NewId());
EVT_TIMER($self->{window}, $obtid, sub{my $self = shift; $self->{input}->{next}->() if $self->{input}->{next}});
}
sub StartMonitor
{
my $self = shift;
$self->{window}->{adremotimer}->Start($self->{window}->{Interval}, 0) # 0 is continuous
if $self->{window}->{adremotimer};
}
sub QuitMonitor
{
my $self = shift;
# stop the timer for the port monitor
$self->{window}->{adremotimer}->Stop() if $self->{window}->{adremotimer} && $self->{window}->{adremotimer}->IsRunning;
}
sub StartAutoscan
{
my $self = shift;
$self->{window}->{onebuttontimer}->Start($self->{window}->{OneButtonInterval}, 0) # 0 is continuous
if $self->{window}->{onebuttontimer};
}
sub QuitAutoscan
{
my $self = shift;
$self->{window}->{onebuttontimer}->Stop() if $self->{window}->{onebuttontimer} && $self->{window}->{onebuttontimer}->IsRunning;
}
sub PauseMonitor
{
my $self = shift;
my $bool = shift;
return unless $self->{window}->{config}->Read('Device') eq 'adremo';
$self->QuitMonitor if $bool;
$self->StartMonitor unless $bool;
}
lib/AAC/Pvoice/Input.pm view on Meta::CPAN
return if $self->{pause};
$self->{input}->{select}->() if $event->LeftUp;
$self->{input}->{next}->() if $event->RightUp &&
not $self->{config}->ReadInt('Buttons') == 1;
}
#----------------------------------------------------------------------
# This sub is used to monitor the parallel port for the adremo device
sub _monitorport
{
# BEWARE: $self is the wxWindow subclass the timer
# belongs to!
my ($self, $event) = @_;
# do nothing if the device is not adremo or
# if we're already running
return if ($self->{monitorrun} ||
(not $self->{input}->{next}) ||
(not $self->{input}->{select}) ||
$self->{pause});
# set the flag that we're checking the port
$self->{monitorrun} = 1;
lib/AAC/Pvoice/Input.pm view on Meta::CPAN
AAC::Pvoice::Input allows one or two button operation of an AAC::Pvoice based
application.
The module uses Device::ParallelPort, so it should be able to run
on Win32 as well as Linux platforms.
=head1 USAGE
=head2 new($window)
This constructor takes the window (AAC::Pvoice::Panel typically) on which
the events and timer will be called as a parameter.
If the configuration (read using Wx::ConfigBase::Get) has a key called
'Device' (which can be set to 'icon', 'keys' , 'mouse' or 'adremo') is set to 'adremo', it
will start polling the parallel port every x milliseconds, where x is the
value of the configuration key 'Interval'. This setting is only useful if you connect
an "Adremo" electrical wheelchair to the parallel port of your PC (for more
information see http://www.adremo.nl).
If the key 'Device' is set to 'icon' it will respond to the left and right
mouse button, and if it's set to 'keys' it will respond to the configuration
keys 'SelectKey' and 'NextKey' (which are the keyboard codes for the 'select'
and 'next' events respectively.
lib/AAC/Pvoice/Input.pm view on Meta::CPAN
to 1, and it will automatically invoke the subroutine you pass to Next()
at an interval of the value set in the configuration key OneButtonInterval (set in milliseconds).
The default for is to operate in two button mode, and if OneButtonInterval is not
set, it will use a default of 2000 milliseconds if "Buttons" is set to 1.
=head2 newchild($window)
This semi-constructor takes the window (usually a child of the panel you
passed to the new() constructor, on which the events will be called as a parameter.
It doesn't start the timers for polling the parallel port and automatic
invocation of the Next() subroutine, because those timers otherwise would
be started multiple times.
Apart from starting those timers, this method works exactly like the new()
=head2 Next(sub)
This method takes a coderef as parameter. This coderef will be invoked when
the 'Next' event happens.
If the Device (see 'new') is set to 'icon', and a right mousebutton is
clicked, a 'Next' event is generated.
If the Device is set to 'adremo' and the headsupport of the wheelchair
is moved to the right, that will also generate a 'Next' event.
lib/AAC/Pvoice/Input.pm view on Meta::CPAN
$sublosefocus is the coderef that should be invoked when the $window
loses focus (EVT_LEAVE).
=head2 StartMonitor
This method will start polling the the parallel port for input of the Adremo
Electrical Wheelchair.
=head2 QuitMonitor
This method will stop the timer that monitors the parallel port.
=head2 PauseMonitor($bool)
This method will pause ($bool is set to 1) or restart ($bool is set to 0)
the timer that monitors the parallel port.
=head2 StartAutoscan
This method will start the timer that invokes the Next() event every n milliseconds.
=head2 QuitAutoscan
This method will stop the timer that invokes the Next() method.
=head2 PauseAutoscan($bool)
This method will pause ($bool is set to 1) or restart ($bool is set to 0)
the timer that invokes the Next() method.
=head1 BUGS
probably a lot, patches welcome!
=head1 AUTHOR
lib/AAC/Pvoice/Panel.pm view on Meta::CPAN
=head2 BackspaceText
This method removes the last text added to the speech *and* displaytext.
Make sure that both speechtext and displaytext have the same amount of
text added, because it just pops off the last item from both lists and
updates the textrow.
=head2 PauseInput($bool)
This method makes sure that the timers that are used for the input (using
AAC::Pvoice::Input) are paused if $bool is set to 1. If $bool is 0, they're
restarted.
=head1 BUGS
probably a lot, patches welcome!
=head1 AUTHOR
( run in 1.150 second using v1.01-cache-2.11-cpan-49f99fa48dc )