aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorribet2010-06-07 15:29:05 +0000
committerribet2010-06-07 15:29:05 +0000
commita62ebdae26bc28e8a5a76fd989b1b76ee72c1ca5 (patch)
treebe59c39299477e154bb0b638ee994faf4bd3b628 /src
parent8489ecd3e999606b663647a2596314a36f2fa2d2 (diff)
downloadmtc-a62ebdae26bc28e8a5a76fd989b1b76ee72c1ca5.zip
mtc-a62ebdae26bc28e8a5a76fd989b1b76ee72c1ca5.tar.gz
mtc-a62ebdae26bc28e8a5a76fd989b1b76ee72c1ca5.tar.bz2
mtc-a62ebdae26bc28e8a5a76fd989b1b76ee72c1ca5.tar.xz
Version adaptée pour squeeze
Diffstat (limited to 'src')
-rw-r--r--src/MTools/Adapters/WacomAdapter.pm199
1 files changed, 134 insertions, 65 deletions
diff --git a/src/MTools/Adapters/WacomAdapter.pm b/src/MTools/Adapters/WacomAdapter.pm
index 204b97f..2f86c27 100644
--- a/src/MTools/Adapters/WacomAdapter.pm
+++ b/src/MTools/Adapters/WacomAdapter.pm
@@ -39,9 +39,11 @@ sub new {
bless $self, $class;
$self -> {__pointer_status} = 0;
$self -> {__ivy} = new MTools::MIvy ($adresse, $ivy_name);
- $self -> {__ivy} -> binding ('pad_event device_id='.$wacom_adresse.' button=(.*) status=(.*) time=(.*)', [\&wacom_event, $self, 'buttons']);
- $self -> {__ivy} -> binding ('slider_event device_id='.$wacom_adresse.' value=(.*) side=(.*) time=(.*)', [\&wacom_event, $self, 'sliders']);
- $self -> {__ivy} -> binding ('pointer_event device_id='.$wacom_adresse.' x=(.*) y=(.*) presure=(.*) tilt_x=(.*) tilt_y=(.*) wheel=(.*) predicted_x=(.*) predicted_y=(.*) type=(.*) serial_number=(.*) time=(.*)', [\&wacom_event, $self, 'pointers']);
+ #$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']);
+ #$self -> {__ivy} -> binding ('pointer_event device_id='.$wacom_adresse.' x=(.*) y=(.*) presure=(.*) tilt_x=(.*) tilt_y=(.*) wheel=(.*) predicted_x=(.*) predicted_y=(.*) type=(.*) serial_number=(.*) time=(.*)', [\&wacom_event, $self, 'pointers']);
+ $self -> {__ivy} -> binding ('InputMoveEvent '.$wacom_adresse.' Abs_X=(.*) Abs_Y=(\S+) .*Abs_Rotary_X=(.*) Abs_Rotary_Y=(\S+) .*Abs_Wheel=(.*) Abs_Pressure=(\S+) .*Abs_Tilt_X=(.*) Abs_Tilt_Y=(.*) Abs_Tool_Type=(.*) unknown=(.*) time=(.*)', [\&wacom_event_pointers, $self]);
return $self;
}
@@ -90,70 +92,137 @@ 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";
+}
+
+################################################################################
+sub wacom_event_pointers {
+ my ($agent, $self, $x, $y, $rotary_x, $rotary_y, $wheel, $presure, $tilt_x, $tilt_y, $type, $serial_number, $time) = @_;
+ #if ($time == 0) {
+# $value = 'Release';
+# $self -> {__pointer_status} = 0;
+# }
+ #else {
+# if ($self -> {__pointer_status}) {
+# $value = 'Motion';
+# }
+# else {
+# $value = 'Press';
+# $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";
+}
+
+###############################################################################
sub wacom_event {
- my ($agent, $self, $type, $value, $status, $time, @others) = @_;
- my @callbacks = ();
- my @args = ();
- if ($type eq 'sliders')
- {
- my $nb = 0;
- if ($value != 0)
- {
- while ($value != 1)
- {
- $value = $value / 2;
- $nb ++;
- }
- $nb++;
- }
- $value = $nb;
- }
- if ($type eq 'pointers')
- {
- $status = $others [5];
- if ($status =~ /(.*)_(.*)_(.*)_(.*)/)
- {
- $status = $3;
- }
- elsif ($status =~ /(.*)_(.*)_(.*)/)
- {
- $status = $2;
- }
- if ($time == 0)
- {
- $value = 'Release';
- $self -> {__pointer_status} = 0;
- }
- else
- {
- if ($self -> {__pointer_status})
- {
- $value = 'Motion';
- }
- else
- {
- $value = 'Press';
- $self -> {__pointer_status} = 1;
- }
- }
- }
- if (defined $self -> {$type} -> {all})
- {
- push (@callbacks, @{$self -> {$type} -> {all}});
- }
- if (defined $self -> {$type} -> {$status} -> {all})
- {
- push (@callbacks, @{$self -> {$type} -> {$status} -> {all}});
- }
- if (defined $self -> {$type} -> {$status} -> {$value})
- {
- push (@callbacks, @{$self -> {$type} -> {$status} -> {$value}});
- }
- for (my $i = 0; $i < @callbacks; $i ++)
- {
- executer ($callbacks[$i], $value, $status, $type);
- }
+ my ($agent, $self, $type, $value, $status, $time, @others) = @_;
+ my @callbacks = ();
+ my @args = ();
+ if ($type eq 'sliders')
+ {
+ my $nb = 0;
+ if ($value != 0)
+ {
+ while ($value != 1)
+ {
+ $value = $value / 2;
+ $nb ++;
+ }
+ $nb++;
+ }
+ $value = $nb;
+ }
+ if ($type eq 'pointers')
+ {
+ $status = $others [5];
+ if ($status =~ /(.*)_(.*)_(.*)_(.*)/)
+ {
+ $status = $3;
+ }
+ elsif ($status =~ /(.*)_(.*)_(.*)/)
+ {
+ $status = $2;
+ }
+ if ($time == 0)
+ {
+ $value = 'Release';
+ $self -> {__pointer_status} = 0;
+ }
+ else
+ {
+ if ($self -> {__pointer_status})
+ {
+ $value = 'Motion';
+ }
+ else
+ {
+ $value = 'Press';
+ $self -> {__pointer_status} = 1;
+ }
+ }
+ }
+ if (defined $self -> {$type} -> {all})
+ {
+ push (@callbacks, @{$self -> {$type} -> {all}});
+ }
+ if (defined $self -> {$type} -> {$status} -> {all})
+ {
+ push (@callbacks, @{$self -> {$type} -> {$status} -> {all}});
+ }
+ if (defined $self -> {$type} -> {$status} -> {$value})
+ {
+ push (@callbacks, @{$self -> {$type} -> {$status} -> {$value}});
+ }
+ for (my $i = 0; $i < @callbacks; $i ++)
+ {
+ executer ($callbacks[$i], $value, $status, $type);
+ }
}
+###################################################################################
+sub compute_callbacks {
+ my ($self, $type, $fields) = @_;
+ my @callbacks = ();
+ if (defined $self -> {$type} -> {all}) {
+ push (@callbacks, @{$self -> {$type} -> {all}});
+ }
+ if (defined $self -> {$type} -> {$fields->{state}} -> {all}) {
+ push (@callbacks, @{$self -> {$type} -> {$fields->{state}} -> {all}});
+ }
+ if (defined $self -> {$type} -> {$fields->{state}} -> {$fields->{num}}) {
+ push (@callbacks, @{$self -> {$type} -> {$fields->{state}} -> {$fields->{num}}});
+ }
+ for (my $i = 0; $i < @callbacks; $i ++) {
+ executer ($callbacks[$i],$fields);
+ }
+}
1;