The KDE display widget rotation is broken. Don’t use it on the X61. I’ve submitted a bug report to KDE.
The following script works, but, Opensuse has “fixed” the tablet buttons and events so well that none of the old ways of controlling tablet buttons & events works anymore. Here’s a script that make everything work fine, but, I just can’t invoke it with tablet button presses or the tablet position. I’m going to start an independent thread to see if anyone here can solve this little mystery.
This script was ripped from someone named dmg & fixed to work with the bastardization that is now xsetwacom & xrandr. You can rotate like “./x61_rotate 0” for landscpe “./x61_rotate 3” for the normal tablet position and “./x61_rotate -” or “+” to rotate stepwise. It works on KDE 4.6.3 and doesn’t crash. Make sure that xsetwacom & xrandr are in the appropriate places vis-a-vis this script. The keycodes section is still borked. If anyone can fix it, feel free.
Save as x61_rotate; chmod u+x ./x61_rotate
#!/usr/bin/perl
use strict;
my $wacomDevice = ‘“Serial Wacom Tablet stylus”’;
my %rotation = (
“normal” => 0,
“right” => 1,
“inverted” => 2,
“left” => 3,
);
my @rotationInv = (
“normal”,
“right”,
“inverted”,
“left”
);
#98 => up
#100=> left
#103 =>right
#100=>down
Set the thumb-toggle on tablet display depending on orientation
my @keycodesComplete = (
“0x71 103 0x6f 108 0x6e 105 0x6d 106”,
“0x71 105 0x6f 106 0x6e 108 0x6d 103”,
“0x71 108 0x6f 103 0x6e 106 0x6d 105”,
“0x71 106 0x6f 105 0x6e 103 0x6d 108”);
my @keycodes = (‘111’, ‘113’,‘116’,‘114’);
my @mapKeys = (‘Up’, ‘Left’, ‘Down’, ‘Right’);
Translate current rotation into the rotation values of this script
my $current = Find_Display_Rotation();
my @wacom = (’“NONE”’, ‘“CW”’, ‘“HALF”’, ‘“CCW”’);
Get input
my $next = $ARGV[0];
The + is rotation clockwise, - rotation counterclockwise
The 0-3 correspond to %rotation & @wacom arrays
if ($next >= 0 || $next <= 3) {
$current = $next;
}
elsif ($next eq “-”) {
$current --;
} elsif ($next eq “+” ) {
$current ++;
} elsif ($next eq “”) {
$current ++;
} else {
$current = $next;
}
$current %=4;
print "Setting to : $current
";
die “invalid current $current]” unless $current >= 0 and $current <4;
set xrandr
print "Setting $rotationInv$current]
";
print xrandr -display :0.0 -o $rotationInv$current]
;
#print xrandr -display :0.0 --output LVDS --pos 0x0
;
#print “xsetwacom --set $wacomDevice Rotate $wacom$current]”;
print xsetwacom --set $wacomDevice Rotate $wacom$current]
;
#print xmodmap -e 'keycode 146 = Menu'
;
#print sawfish-client --display :0.0 -e '(dmg-move-current-window-inside)'
;
#Set_Wacom_Tablet();
This command would set the thumb toggle buttons based on rotation
but it seems to be working out of the box in Opensuse KDE
The only key that needs to be set it the rotate button.
set_keys($current);
exit;
sub Set_Wacom_Tablet
{
my ($currentRotation) = @_;
# x1, y1, x2, y2
my @coor = ( -27, 47, 18509, 24701);
my @where = (“topx”, “topy”, “bottomx”, “bottomy”);
my $command = “/usr/bin/xsetwacom”;
if ($current %2 == 1) {
for my $i (0..3) {
print `$command set eraser $where$i] '$coor$i]'`;
print `$command set stylus $where$i] '$coor$i]'`;
}
}
}
sub Find_Display_Rotation
{
my $mode = /usr/bin/xrandr --verbose| grep LVDS
;
if ($mode =~ / +([a-z]+) +\(/) {
} else {
print STDERR "UNable to detect mode $mode
";
die;
}
die "($mode) ($1) " if ($1 ne “right” and
$1 ne “left” and
$1 ne “inverted” and
$1 ne “normal”);
return $rotation{$1};
}
sub set_keys
{
my ($rotation) = @_;
my ($a) = $keycodesComplete$rotation];
print /bin/setkeycodes $a
;
}