Skip to content

Commit

Permalink
Add simple support for relative positioning devices in from_real_devi…
Browse files Browse the repository at this point in the history
…ce.pl
  • Loading branch information
vi committed Feb 28, 2012
1 parent 495c666 commit da4891e
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions from_real_device.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;

Expand Down

0 comments on commit da4891e

Please sign in to comment.