From da4891eb85471d0341332bb6d52144beb57f57e7 Mon Sep 17 00:00:00 2001 From: Vitaly _Vi Shukela Date: Tue, 28 Feb 2012 04:39:57 +0300 Subject: [PATCH] Add simple support for relative positioning devices in from_real_device.pl --- from_real_device.pl | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/from_real_device.pl b/from_real_device.pl index e10c65f..4bd63df 100755 --- a/from_real_device.pl +++ b/from_real_device.pl @@ -28,13 +28,25 @@ my $need_mouseemu=0; +my $relx = 0; +my $rely = 0; + while (not eof STDIN) { sysread STDIN, $_, 16; my ($sec, $usec, $type, $code, $val) = unpack "LLssl"; #print "type=$type, code=$code, val=$val\n" - #print STDERR "This seems like a keyboard\n" and next if $type == 1; - print STDERR "This is relative pointing device\n" and next if $type == 2; + if ($type == 1) { + print "d 0\n" if $val; + print "u 0\n" unless $val; + } + if ($type == 2) { + # relative positioning + $relx += $val if $code == 0; + $rely += $val if $code == 1; + print "x $relx\ny $rely\nS 0\n"; + next; + } unless ($type == 3) { if($need_mouseemu) { @@ -44,6 +56,7 @@ } print "s $val\n" if $code == 0x2f; + print "T $val\n" if $code == 0x39; print "X $val\n" and $need_mouseemu=1 if $code == 0x35; print "Y $val\n" and $need_mouseemu=1 if $code == 0x36;