summaryrefslogtreecommitdiffstats
path: root/VisualNaCro/recorder.pl
diff options
context:
space:
mode:
Diffstat (limited to 'VisualNaCro/recorder.pl')
-rw-r--r--VisualNaCro/recorder.pl24
1 files changed, 23 insertions, 1 deletions
diff --git a/VisualNaCro/recorder.pl b/VisualNaCro/recorder.pl
index bbe3f25..3b86e40 100644
--- a/VisualNaCro/recorder.pl
+++ b/VisualNaCro/recorder.pl
@@ -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";