Commit afcdc4f4 authored by dscho's avatar dscho

add timing

parent 06a401f8
......@@ -9,10 +9,12 @@ $output="my_script";
$server="localhost";
$port=5900;
$listen_port=5923;
$timing=0;
if(!GetOptions(
"script:s" => \$output,
"listen:i" => \$listen_port
"listen:i" => \$listen_port,
"timing" => \$timing
) || $#ARGV!=0) {
print STDERR "Usage: $ARGV0 [--script output_name] [--listen listen_port] server[:port]\n";
exit 2;
......@@ -20,6 +22,11 @@ if(!GetOptions(
$output=~s/\.pl$//;
if ($timing) {
use Time::HiRes qw(time);
$starttime=-1;
}
$server=$ARGV[0];
if($server=~/^(.*):(\d+)$/) {
......@@ -55,6 +62,9 @@ open OUT, ">$output.pl";
print OUT "#!/usr/bin/perl\n";
print OUT "\n";
print OUT "use nacro;\n";
if ($timing) {
print OUT "use Time::HiRes;"
}
print OUT "\n";
print OUT "\$x_origin=0; \$y_origin=0;\n";
print OUT "\$vnc=nacro::initvnc(\"$server\",$port,$listen_port);\n";
......@@ -64,6 +74,16 @@ $image_counter=1;
$magickey=0;
$x_origin=0; $y_origin=0;
sub writetiming () {
if ($timing) {
$now=time();
if ($starttime>0) {
print OUT "nacro::process(\$vnc," . ($now - $starttime) . ");\n";
}
$starttime=$now;
}
}
while(1) {
$result=nacro::waitforinput($vnc,999999);
if($result==0) {
......@@ -77,6 +97,7 @@ while(1) {
$keysym=nacro::getkeysym($vnc);
$keydown=nacro::getkeydown($vnc);
if(nacro::sendkey($vnc,$keysym,$keydown)) {
writetiming();
print OUT "nacro::sendkey(\$vnc,$keysym,$keydown);\n";
}
if($keysym==0xffe3 || $keysym==0xffe4) {
......@@ -98,6 +119,7 @@ while(1) {
$buttons=nacro::getbuttons($vnc);
if(nacro::sendmouse($vnc,$x,$y,$buttons)) {
$x-=$x_origin; $y-=$y_origin;
writetiming();
print OUT "nacro::sendmouse(\$vnc,\$x_origin"
. ($x>=0?"+":"")."$x,\$y_origin"
. ($y>=0?"+":"")."$y,$buttons);\n";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment