Skip to content

Commit da4891e

Browse files
committed
Add simple support for relative positioning devices in from_real_device.pl
1 parent 495c666 commit da4891e

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

from_real_device.pl

+15-2
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,25 @@
2828

2929
my $need_mouseemu=0;
3030

31+
my $relx = 0;
32+
my $rely = 0;
33+
3134
while (not eof STDIN) {
3235
sysread STDIN, $_, 16;
3336
my ($sec, $usec, $type, $code, $val) = unpack "LLssl";
3437
#print "type=$type, code=$code, val=$val\n"
3538

36-
#print STDERR "This seems like a keyboard\n" and next if $type == 1;
37-
print STDERR "This is relative pointing device\n" and next if $type == 2;
39+
if ($type == 1) {
40+
print "d 0\n" if $val;
41+
print "u 0\n" unless $val;
42+
}
43+
if ($type == 2) {
44+
# relative positioning
45+
$relx += $val if $code == 0;
46+
$rely += $val if $code == 1;
47+
print "x $relx\ny $rely\nS 0\n";
48+
next;
49+
}
3850

3951
unless ($type == 3) {
4052
if($need_mouseemu) {
@@ -44,6 +56,7 @@
4456
}
4557

4658
print "s $val\n" if $code == 0x2f;
59+
print "T $val\n" if $code == 0x39;
4760
print "X $val\n" and $need_mouseemu=1 if $code == 0x35;
4861
print "Y $val\n" and $need_mouseemu=1 if $code == 0x36;
4962

0 commit comments

Comments
 (0)