aboutsummaryrefslogtreecommitdiff
path: root/src/MTools/Adapters/WacomAdapter.pm
diff options
context:
space:
mode:
Diffstat (limited to 'src/MTools/Adapters/WacomAdapter.pm')
-rw-r--r--src/MTools/Adapters/WacomAdapter.pm89
1 files changed, 63 insertions, 26 deletions
diff --git a/src/MTools/Adapters/WacomAdapter.pm b/src/MTools/Adapters/WacomAdapter.pm
index 5f71d3a..1adc909 100644
--- a/src/MTools/Adapters/WacomAdapter.pm
+++ b/src/MTools/Adapters/WacomAdapter.pm
@@ -20,6 +20,7 @@ use strict;
use MTools qw(!binding);
use MTools::MObjet;
use MTools::MIvy;
+use MTools::MTimer;
use vars qw /@ISA/;
BEGIN
@@ -37,8 +38,23 @@ sub new {
$wacom_adresse = 'default';
}
bless $self, $class;
+ $self -> recordProperty ('compress_move', 1);
+ $self -> plisten ('compress_move',
+ sub {
+ my ($src, $key, $val) = @_;
+ if ($val == 0)
+ {
+ if ($self->{__timer}->is_running()) {
+ $self->callback();
+ $self->{__timer}->stop();
+ }
+ }
+ });
+
$self -> {__pointer_status} = 0;
$self -> {__ivy} = new MTools::MIvy ($adresse, $ivy_name);
+ $self -> {__datas} = undef;
+ $self -> {__timer} = new MTools::MTimer(1,0,[\&callback,$self]);
#$self -> {__ivy} -> binding ('pad_event device_id='.$wacom_adresse.' button=(.*) status=(.*) time=(.*)', [\&wacom_event, $self, 'buttons']);
$self -> {__ivy} -> binding ('^InputButtonEvent '.$wacom_adresse.' num=(.*) state=(.*) Abs_X=(.*) Abs_Y=(\S+) .*Abs_Wheel=(.*) Abs_Pressure=(\S+) .*Abs_Tilt_X=(.*) Abs_Tilt_Y=(.*) Abs_Tool_Type=(.*) unknown=(.*) time=(.*)',[\&wacom_event_buttons, $self]);
#$self -> {__ivy} -> binding ('slider_event device_id='.$wacom_adresse.' value=(.*) side=(.*) time=(.*)', [\&wacom_event, $self, 'sliders']);
@@ -95,18 +111,25 @@ sub binding {
################################################################################
sub wacom_event_buttons {
my ($agent, $self, $num, $state, $x, $y, $wheel, $presure, $tilt_x, $tilt_y, $type, $serial_number, $time) = @_;
- $self->compute_callbacks('buttons',{num => $num,
- state => $state,
- X => $x,
- Y => $y,
- wheel => $wheel,
- presure => $presure,
- tilt_x => $tilt_x,
- tilt_y => $tilt_y,
- type => $type,
- serial_number => $serial_number,
- time => $time});
- print STDERR "\nwacom_event_buttons $num,$state\n\n";
+
+ if ($self->{__timer}->is_running()) {
+ $self->compute_callbacks('pointers', $self->{__datas});
+ $self->{__datas} = undef;
+ $self->{__timer}->stop();
+ }
+ $self->compute_callbacks('buttons',
+ {num => $num,
+ state => $state,
+ X => $x,
+ Y => $y,
+ wheel => $wheel,
+ presure => $presure,
+ tilt_x => $tilt_x,
+ tilt_y => $tilt_y,
+ type => $type,
+ serial_number => $serial_number,
+ time => $time});
+ $zinc->idletasks();
}
################################################################################
@@ -125,20 +148,26 @@ sub wacom_event_pointers {
# $self -> {__pointer_status} = 1;
# }
# }
- $self->compute_callbacks('pointers',{num => '',
- state => int $type,
- X => $x,
- Y => $y,
- rotary_X => $rotary_x,
- rotary_Y => $rotary_y,
- wheel => $wheel,
- presure => $presure,
- tilt_x => $tilt_x,
- tilt_y => $tilt_y,
- type => $type,
- serial_number => $serial_number,
- time => $time});
- print STDERR "\nwacom_event_pointers $type\n\n";
+ $self -> {__datas} = {num => '',
+ state => int $type,
+ X => $x,
+ Y => $y,
+ rotary_X => $rotary_x,
+ rotary_Y => $rotary_y,
+ wheel => $wheel,
+ presure => $presure,
+ tilt_x => $tilt_x,
+ tilt_y => $tilt_y,
+ type => $type,
+ serial_number => $serial_number,
+ time => $time};
+ if ($self->mget('compress_move')) {
+ if (!$self->{__timer}->is_running()) {
+ $self->{__timer}->start();
+ }
+ } else {
+ $self->callback();
+ }
}
###############################################################################
@@ -208,6 +237,14 @@ sub wacom_event {
}
###################################################################################
+sub callback {
+ my ($self) = @_;
+ $self->compute_callbacks('pointers', $self->{__datas});
+ $self->{__datas} = undef;
+ $zinc->idletasks();
+}
+
+###################################################################################
sub compute_callbacks {
my ($self, $type, $fields) = @_;
my @callbacks = ();