#!/usr/bin/perl -w #this came from http://samengstrom.com/p1510 use X11::GUITest ("SetEventSendDelay","MoveMouseAbs","PressMouseButton","ClickMouseButton","ReleaseMouseButton","IsMouseButtonPressed",":CONST"); use strict; use warnings; $|=1; use constant SCREEN=>(1024,600); use constant DIGITIZER=>(30.78,30.06); use constant TOPLEFT=>(0.73,1.19); #use constant BOTTOMRIGHT=>(31.51,31.25); my $prevx=8; my $prevy=0; sub movemouse(@) { my $xmaj=$_[1]; my $xmin=$_[0]; my $ymaj=$_[3]; my $ymin=$_[2]; my $xdec=$xmaj+$xmin/128; my $ydec=$ymaj+$ymin/128; #print $xdec."\t".$ydec; my $x=sprintf("%d",($xdec-(TOPLEFT)[0])*(SCREEN)[0]/(DIGITIZER)[0]); my $y=sprintf("%d",($ydec-(TOPLEFT)[1])*(SCREEN)[1]/(DIGITIZER)[1]); if ($x<0) { $x=0; } if ($y<0) { $y=0; } if ($x>(SCREEN)[0]) { $x=(SCREEN)[0]; } if ($y>(SCREEN)[1]) { $y=(SCREEN)[1]; } if (($x ne $prevx)||($y ne $prevy)) { print "$x\t$y\n"; $prevx=$x; $prevy=$y; MoveMouseAbs($x,$y); } } sub press() { print "press\n"; #print PressMouseButton(M_LEFT); #print ClickMouseButton(M_LEFT); #sleep 1; #print ClickMouseButton(M_LEFT); } sub release() { print "release\n"; #print PressMouseButton(M_LEFT); if (IsMouseButtonPressed(M_LEFT)) { #print ReleaseMouseButton(M_LEFT); } } sub process(\@) { my @block=@{$_[0]}; my $action=$block[0]; movemouse(@block[1..5]); if (!$action) { return; } if ($action==1) { press(); return; } if ($action==2) { release(); return; } } ######################## main SetEventSendDelay(0); system "wacdump /dev/ttyS0"; sleep 1; open FILEH,"/dev/ttyS0"; my $last=0; my @block=(); my @pending=(); while(read(FILEH,my $data,1)) { #print $c." "; #$c++; #next; my $o=ord($data); if ($o>130) { @block=(); if ($o==136) { push @block,1; } elsif ($o==138) { push @block,2; } else { push @block,0; } #print "\n$o\t";# } else { push @block,$o; #print "$o\t"; if (@block==5) { process(@block); } } $last=$o; } close FILEH;