How to Rotate the Screen for a TX2000 Tablet PC

TX2500, TX2z, TM2t & other Tablet PCs

Last Updated: May 13, 2012

Preliminaries
The Rotation HOW TO assumes the Wacom digitizer is working on your tablet PC. Either because the release default wacom.ko (the usb kernel driver/module) and xserver-xorg-input-wacom (the xf86-input-wacom X driver and xsetwacom) package work for your tablet PC (check Synaptic Package Manager or Software Sources) or you have successfully compiled and installed the Wacom drivers using the LinuxWacom HOW TO or the Bamboo P&T HOW TO. Configuration for Lucid is through the 10-wacom.conf and for Maverick and up it is the 50-wacom.conf. Although you can still use the xorg.conf if you prefer.

There has been a change to the Wacom input tool device naming convention. To get your devices to rotate enter xinput list in a terminal. In the output find the "device name", e.g.:

that correspond to the input tools you have. For a tablet PC these would be stylus, eraser (if you have one), and touch (if you have it). Then substitute the longer more descriptive "device name" (with the quotes) in for stylus, eraser, and touch in the script's xsetwacom commands. For example:

Code:

xsetwacom set stylus rotate ccw

becomes

Code:

xsetwacom set "Wacom ISDv4 93 Pen stylus" rotate ccw

You can also use the ID numbers if you are not hot plugging devices, otherwise the ID #'s can change. Starting with xf86-input-wacom-0.11.0 the xsetwacom Rotate parameter has been made tablet wide so you need to only rotate the parent device. This means for a serial (ISDV4) tablet PC the only xsetwacom Rotate command you need is for the stylus, and the others (eraser and touch) can be left out of the script. For usb tablet PCs with touch you need both the stylus and the touch lines in the script because they are exported from the kernel as two separate devices.

There is a bug using the Lucid default wacom.ko (from linuxwacom version 0.8.4-1(?)). Stylus and touch are the same in the xinput list output, namely "Wacom ISDv4 93", for TX2500 & TX2000's. So for at least touch use the ID number. If you've compiled and installed linuxwacom 0.8.6-2 (or up) or the input-wacom wacom.ko this bug is fixed.

Summary
The first method below invokes the xrandr command line interface to find the screen orientation in the output of the server system's current state. Then the script uses the appropriate xrandr and xsetwacom commands to rotate the screen and input tools. Method 2 provides automatic rotation through a shell script if your tablet PC and the system software support it. Method three does the same but through a Python gtk application that adds other features besides automatic rotation. The fourth method relies on a C daemon and a shell command. "Implementing a Script" describes how to make your script executable, how methods 1 & 4 can be implemented by a Launcher (which can be placed in a panel or a dock) or alternatively bound to a hardware key. Appendix 1 has a little bit on enabling rotation in your video driver (if needed) and appendix 2 discusses how to enable tablet PC bezel buttons. Appendix 3 shows you how to set up a HP Elitebook's thumb scroll bezel button.

Method 1: "xrandr -q --verbose" & grep
This is a “general” script that works for both the TX2000 and TX2500 and other tablet pc's. This script relies on the output of xrandr -q --verbose, which gives current screen state. One line of the output includes current screen orientation. They all seem, regardless of video chipset or driver, to have a common current screen orientation line which shares a common term and format. This allows one script/command line to deal with all.

So this script should work for any Tablet PC that has a line similar to the following in it's xrandr -q --verbose output:

This will cause the screen to rotate through 360 degrees counter-clockwise in four 90 degree steps.

A TX2000 or TX2500 screen is hinged to swivel 180 degrees in only one direction before locking down in tablet mode. From landscape to portrait mode in other words. So the script only needs to rotate the screen orientation 90 degrees to portrait and then 90 degrees back to landscape mode. Since a right handed person holds the tablet in the left arm (most like the battery pointing to the right as a handle) the following simplified script serves.

You will need to place the script into a text file, name it, and make it executable. See a) Script in Implementing a Script with a Launcher or Key Binding below.
* Thank you to martinjochimsen and manu7irl for helping to validate method 1 for the TX2500.

Method 2: Tablet PC Automatic Rotation Script
Red_Lion got auto-magic rotation working. He developed a script that uses the 'tablet' signal ('dock' for the original unpatched HP-WMI) of HP-WMI as a trigger to provide rotation. While the following script was developed for HP tablet pc's, Lenovo ThinkPads (and very likely other tablet pc's) should be able to use it too with a minor modification.

Determine your "device names" with xinput list entered in a terminal. Then substitute them for stylus, eraser, and touch (if you have it) in the following shell script using the quotes around the "device name". Only use the xsetwacom commands for the devices you have.

Notice the script assumes you have CellWriter installed. You can substitute the onscreen keyboard of your choice or comment out or remove the lines.

Save it in "/home/yourusername/" as ".automagic_rotation.sh" (without the quotes), or whatever you want to name it. Make the file executable and add it to your Startup Applications. See a) Script in Implementing a Script with a Launcher or Key Binding below.

Using these examples, if your tablet pc Brand & model also reports the swivel hinge state, you should be able to modify the script to work for you.

See:
The original Auto-magic Rotation Script HOW TO at post #225.
MisteR2's original instructions, the hp-wmi patch, and .fdi for it in posts #104 and #106 on this thread.
MisteR2's new instructions and attachments (with new files) at post #206.
Red_Lion's first post of the auto-magic rotation script in post #576 on the "Info and help for HP TX2500 Series".

Method 3: The Magick Rotation application for Dell, HP, and Lenovo tablet pc's. It automatically rotates screen orientation and devices/tools that use the Wacom or evdev drivers. Versions have worked in Arch, Fedora, Gentoo, Mandriva, and openSUSE among others.

MisteR2 tracked down the swivel hinge signal to the HP-WMI kernel module, solving the mystery of no detectable signal. This sits on top of WMI, which is the Windows Management Instrumentation mapper device. WMI is a proprietary extension to ACPI that exposes parts of the ACPI firmware and is available for some BIOS's. Matthew Garrett (the module maintainer) has separated out the swivel hinge signal from the docking event (on MisteR2's request) for us and provided a patch. The patch is called hp-wmi.diff.txt and is in post #106. It creates a new event called 'tablet' as opposed to 'dock' and will be included in the hp-wmi kernel module for the 2.6.31 (Karmic). Red_Lion then got auto-magic rotation actually working with his first script. He also wrote the first version of the Magick Rotation applet in Python gtk. Not only did it automatically rotate the screen orientation (along with the input tools) when you pivoted the screen to tablet mode it also allowed for handy shell commands.

Magick Rotation 1.5 applet released (10-9-11) is on Launchpad: https://launchpad.net/magick-rotation This version adds support for Oneiric (11.10) . In addition to automatic rotation and selection of rotation direction it offers other features such as a touch toggle function and display of an onscreen keyboard when rotated. Magick Rotation works for HP & Dell tablet pc's if they have auto-magic rotation in Windows (a swivel hinge switch sends a signal) and their bios supports WMI (and hence hp-wmi or dell-wmi). It works for Lenovo tablets if they have the thinkpad_acpi and hence it's hotkey support.Note: Dell XT & XT2 users. The dell-wmi from the kernel does not report the swivel hinge switch state. To get a dell-wmi that works correctly see the MagickExtras folder in the magick-rotation folder. Instructions are there or in a FAQ at the Launchpad site. Or also see post #1339.

CellWriter is included by default; the commands show it in portrait and hide it in landscape. The Cairo (or Glx) Dock commands are to close the dock and restart it after rotation so it resizes correctly. This is no longer necessary with recent versions. The gconftool command resizes the top panel to a larger size (from the default 24) in portrait so it is more touch friendly. For the bottom panel just substitute bottom_panel_screen0 for top_panel_screen0. To verify what your default panel size is use Configuration Editor (you may have to make it visible through System > Preferences > Main Menu). Go to Applications > System Tools > Configuration Editor. Then look in apps > panel > default_setup > toplevels, then top_panel or bottom_panel.

Method 4: The wacomrotate daemon
Tom Jaeger, developer of EasyStroke, came up with an elegant solution. He wrote a daemon in C called wacomrotate that detects current screen orientation and automatically rotates the Wacom input tools stylus, eraser, and touch to the same orientation.

Go to Tom's repository and download the appropriate deb package that contains his C daemon for your release and install type i.e. 32-bit v.s. 64-bit. For e.g., if you have a 64-bit install of Lucid it would be “wacomrotate_0.3.1_amd64.deb” dated 4-13-10. For a 32-bit install of Maverick it would be “wacomrotate_0.3.1-0thjaeger1_i386.deb” dated 9-15-10, etc. Save to desktop. Then double-click on it and let the deb package installer install it. It will automatically install itself into Startup Applications so that it is auto-started at boot. If you grabbed the wrong deb by mistake the Debian Installer will tell you so and refuse to install the package.

He also supplied the following command line command to be used in conjunction with his wacomrotate daemon.
For right handed Portrait rotation use:

Code:

xrandr -q | grep -q '+\w* (' && xrandr -o right || xrandr -o normal

or for left handed Portrait rotation use:

Code:

xrandr -q | grep -q '+\w* (' && xrandr -o left || xrandr -o normal

You'll want to put the command into a Launcher or create a Key Binding as described below.

Implementing a Script with a Launcher or Key Bindinga) Script
1) Open Text Editor (gedit) and create a new .txt file.
2) Into it place the script of your choice. Obviously if you're going to use the wacomrotate daemon you'll need Tom's command (or you can skip this and with his command go straight to the key binding method below).
3) Name the script and Save the script as .yourscriptname.sh. The period in front of the name is makes it a hidden file. This is useful if you place the file in your /home/yourusername directory. That will help prevent directory clutter. If you decide to create a folder/directory bin (/home/yourusername/bin) for your scripts you probably won't want to make it hidden.
4) Now you need to make the script file executable. Right click on the text file and choose Properties. In the Permissions tab check the “Allow executing file as a program” and close. Or in a terminal:

Code:

chmod +x ~/.yourscriptname.sh

5) The Tablet PC Automatic Rotation Script needs to be set up to auto-start. Go to System->Preferences->Startup Applications and click on Add and for the command enter /home/yourusername/.automagic_rotation.sh. And title it “Auto-magic Rotation” or whatever you like.

b) Launcher: for methods 1 & 4
1) Next create a launcher on the desktop by right clicking on it and choosing Create Launcher... Give it a name and in the Command box type the path to the text file you made executable i.e. /home/yourusername/Desktop/.yourscriptname.sh.Note: when you clean up the Desktop and move the script to say, /home/yourusername or /home/yourusername/bin directory, remember to change the path in the Launcher's command box to reflect the new path.
2) Double click on the launcher's icon and watch the screen rotate! Check that your stylus, eraser, and touch are oriented and working correctly. Double click again and rotate back.
3) If you want, move the launcher to a panel or to a dock, like Cairo-dock, and then a single click will rotate the screen.

c) Button/key Binding: for methods 1 & 4. To further integrate screen rotation into your tablet PC you can do a key binding to a key, preferably a bezel button. A bezel button is one of the buttons on the edge of the screen still accessible in tablet mode.
While a HP TX2000 is used as an example on how to set up the bezel buttons, most of the information should generalize to other tablet PC's. For further explanation see Appendix 2 below. With the TX2000 only 2 bezel buttons ever worked, see Miscellaneous Notes below. And starting with Lucid the DVD button also stopped working, leaving only the "Q" button.
1) To get the DVD button working again and launching the mediaplayer as it did before Lucid edit the hewlett-packard keymap in /lib/udev/keymaps with:

Code:

gksudo gedit /lib/udev/keymaps/hewlett-packard

like so:

Code:

#0x08e dvd
0x08e media

2) To assign the "Q" button to the XF86Launch5 KeySym first edit the hewlett-packard-pavilion keymap in /lib/udev/keymaps using:

Code:

gksudo gedit /lib/udev/keymaps/hewlett-packard-pavilion

And make the following change:

Code:

#0x88 media # FIXME: quick play
0x88

Now edit rc.local in /etc:

Code:

gksudo gedit /etc/rc.local

and add:

Code:

setkeycodes e008 184

above the exit 0 line and reboot.
3) Open the CompizConfig Settings Manager (CCSM). You may need to install it first. In General open Commands. Make sure the Enable Commands box is checked. In the Commands tab pick a command line and type in the name and path of the executable rotation script text file and close. If you're running the wacomrotate daemon you can put in Tom's command directly instead of the path to the rotation script.
4) Next select the Key Bindings tab. Pick the Run command line that has the same number as the Command line # you put the rotation script file name (and path) in. Click on the Disabled button to the right of Run command #. Click the Enabled box and then the Grab key combination button. Press the Q button. You should see XF86Launch5 appear. Close CompizConfig.
5) Now press the "Q" bezel button and watch your screen rotate!

Miscellaneous Notes
With HP TX2000's we never got a signal, in xev or anything else, from the two blue led buttons on the bottom right edge of our screen, one of which is the original rotation button. Starting with Karmic we lost the DVD bezel button too. And the Q key (which we were using as a substitute rotation key) became the only active bezel button. It now codes XF86AudioMedia and launches the mediaplayer like the DVD key used to and should do. Presumably this is due to a bug(s) in hp-wmi. Red_Lion looking at his DSDT thinks the "bezel buttons parsing via PNP0C09 method _Q16." PNP0C09 is the Microsoft acpi-compatible embedded controller. A summary of what we have learned so far is in posts #273 & 274 on this thread. There are similar problems with HP's TX2500 and TX2z bezel buttons, again presumably due to the same hp-wmi bug.Bezel Button Update: tipp98 is currently investigating the problem and has made progress! He's provided a summary of his findings to date on post #601. Even more information is available on this linux-acpimailing list thread.

For us HP TX2000, TX2500, & TX2z owners to get auto-magic rotation we needed to detect a signal from our swivel hinge. Nothing came through on xev, or acpi_listen and in /var/log/messages either. Then MisteR2 located the signal to the HP-WMI kernel module.

Appendix 2: Bezel Buttons; using mainly the HP TX2000 as an example
First you want to check if the keys are emitting a keycode. There are several diagnostic tests to look for a keycode among them xev and evtest. Let's use xev. In a terminal type:

Code:

xev

and hit enter. A little box pops up. Press one of the keys/buttons in question and then close the box. The terminal will fill with output. You are looking for keywords like KeyPress, keycode, and keysym. You can copy and paste the output into gedit and then do a find for them. You are looking for the keycode number and the little sections of output that contain it. There should be two, one for the KeyPress event and one for the KeyRelease event. Then repeat for the next key. Remember the keycodes you get from xev are the X keycodes (hence the x in the name, xev = X event). If there are keycodes you should be able to assign them through Xmodmap, xbindkeys, xdotool, etc.

Now if there is no X keycode that is another situation and there are several possibilities.
1) Something is going wrong with the chain: kernel keycode > udev key mapping (keysym assignment) > X keycode. This is what the rest of appendix 2 deals with, a step by step guide to diagnose the chain.

Other possibilities include:
2) The BIOS has changed key assignments and the kernel driver code that is reading the key assignment needs to be changed to reflect that. Examples of that would be the code in hp-wmi.c or thinkpad-acpi.c. The compiled versions of those are the hp-wmi.ko and thinkpad-acpi.ko (ko = kernel object i.e module/driver) you see in /lib/modules/yourcurrentkernel/kernel/drivers/platform/x86. In which case you may need to work with the kernel source code of the appropriate kernel module/driver and change the hex/scan code assignments. Then compile the module to test your changes. Examples of that being done for the dell-wmi.c are in post #1176 and post #1587 of the N-Trig HOW TO.
3) The final possiblity is either a kernel module/driver has never been written or, if one of the current modules is the appropriate driver, the code has never been written for it to support the buttons/keys in question. Fujitsu tablet PCs "enjoy" a special case of this. While the fujitsu-tablet.c (fujitsu-tablet.ko) module which supports the bezel buttons has been written and submitted to the kernel for unknown reasons it has never been accepted. So to obtain the kernel module/driver (which comes in the fjbtndrv package) you need to use either Robert Gerlach's fjbtndrv PPA or SourceForge site and compile it.

a) kernel codes The first step is to find the bezel button's kernel scan codes. Enter a console with <ctrl-alt-F1>; to get back to X enter <ctrl-alt-F7>. Then enter showkey -s in the console and press the bezel buttons. Only the scan code from the Q key (none of the other 3 do anything) appears: 0xe0 0x6d 0xe0 0xed. Next find the kernel keycodes by entering showkey -k and press the buttons which shows (the two bottom buttons do nothing): DVD button = 389 and Q button = 226. So the bezel button assignments from the kernel are:

The keys and their corresponding key codes are defined in input.h at /usr/include/linux.

b) udev codes Now using the README at /usr/share/doc/udev/README.keymap.txt let's dump the current mapping and determine the udev scan codes and key codes. To do this we need to know the input/event the keyboard is on. Enter in a terminal /lib/udev/findkeyboards. The output shows the keyboard is on event 5.

To determine the udev codes run in a terminal the following command: sudo /lib/udev/keymap -i input/event5 Then press the bezel button(s) or multimedia/function keys of interest. Use esc to exit. If it shows a tendency to scroll away, use: sudo /lib/udev/keymap -i input/event5 | less And after pressing the bezel buttons, again enter esc to exit, and you will see the scan codes and the associated udev key codes. Enter ctrl-z to exit less. The output shows:

Note: to find the corresponding X keycode add 8 to the kernel keycode. See e) below.

c) udev rules and keymaps
In /lib/udev/rules.d you'll see the Hewlett-Packard rules in the 95-keymap.rules file. They will apply all the keymaps that the rules match. The match is made to the Vendor and then the dmi id's product_name and board_version (/sys/class/dmi/id). To determine the last two enter the following two commands:

So the rule matches cause the following hewlett-packard keymaps in /lib/udev/keymaps to be applied: hewlett-packard, hewlett-packard-tablet, hewlett-packard-pavilion, and hewlett-packard-tx2. Looking in them we discover that hewlett-packard contains 0x08e dvd and hewlett-packard-pavilion has 0x88 media. Now we know where the udev codes are coming from.

c) changing udev keymaps
Clearly we can edit and change the rules or the keymaps. While the DVD button seems to be recognized by udev it appears to do nothing and acts broken. Can we get it to do anything? Editing the hewlett-packard keymap in /lib/udev/keymaps like so:

Code:

#0x08e dvd
0x08e media

Results in, after a reboot, the DVD bezel key suddenly working again! And it launches the mediaplayer like it used to do and just like the Q key does now. So we are back to two working bezel buttons. But we don't need both assigned to media so let's remove the media assignment from the Q button. Edit the hewlett-packard-pavilion keymap in /lib/udev/keymaps using:

Dmesg has kindly done the conversion for us and e008 is what we want to use.

Now we need to assign the "Q" button to XF86Launch5 in order to bind it into a rotation script. We've been traditionally using XF86Launch5 to avoid conflicting with any other key assignment. To determine the keycode for XF86Launch5 run this command:

Code:

xmodmap -pke | grep XF86

In the output we see:

keycode 192 = XF86Launch5 NoSymbol XF86Launch5

Notice as the command name xmodmap implies 192 is a X keycode. Recall to get the kernel keycode you need to subtract 8 from the X keycode. So 192 - 8 = 184. Now using 184 enter in rc.local in /etc the following:

Code:

setkeycodes e008 184

above the exit 0 line and reboot. By adding it to rc.local we avoid prefacing it with sudo since rc.local runs before X starts. Now the Q button is assigned to XF86Launch5 and is ready to be bound in CCSM to a rotation script (see "Implementing a Script" c) above). You can verify this by opening up a terminal and running “xev”. A box will pop up. Press the Q bezel button and then close the xev box. In the ouput you will see for the bezel key press XF86Launch5.

TA DA! We're back to where we were pre-Lucid (well OK, Karmic). Two working bezel buttons with DVD calling the music player and Q the rotation script.

e) X keycodes
The Xserver currently doesn't process keycodes greater than 255 due to core protocol limitations. This is why some keys don't generate any events. X also requires an offset of 8 from the kernel key code. Recall there is a list of kernel key values in input.h. To get the corresponding X keycode simply add 8 to the kernel keycode:

f) Xmodmap (method used prior to Lucid)
1) Open up a terminal. Type “xev” and enter. A box will pop up. Press the bezel button and then close the xev box. Then look for the returned keycode value for the bezel key press. (For a HP TX2000 it was keycode 201 for the “Q” key in Intrepid (205 in Hardy)).
2) Open a text file on the desktop. In it enter the keycode e.g. 201:

Code:

keycode 201 = XF86Launch5

where in this example XF86Launch5 is a key label not being used by any other key code. Save the text file as “.Xmodmap” in your home/user/ directory. The Xmodmap will become active on reboot.
After restart open up a terminal and run “xev”. Press the bezel key. You should see the keycode number as before now associated with in our example XF86Launch5.
*thanks to Ayuthia for his assistance

Re: How to Rotate the Screen for a TX2000 Tablet PC

Hi fbdelivers,

The first thing that comes to mind is that your name for "stylus" in xorg.conf is different from "stylus" in the scripts. Check your xorg.conf and look at the stylus name in the "InputDevice" stylus section and in the "ServerLayout" section.

And remember in xorg.conf it's case specific. In other words "Stylus" is not the same as "stylus". Probably best to change the script name unless you want to get into checking your .xinitrc's.

Re: How to Rotate the Screen for a TX2000 Tablet PC

Hi Favux

How is the calibration for the stylus working when you have rotated your screen?
Mine is off with at least half a centimeter, but is perfect when the screen is normal.
Did you also use Xournal? Do you have pressure sensitivity in that program (or in any programs)?
Mine is the same in both GIMP and Xournal meaning NO sensitivity. It would be great to have some kind of sensitivity when I fx. is using the onscreen keyboard in Cellwriter. As it is now, it is impossible to use. You can only wright reeeaaalllllyyyyy sssslllloooowwwwwllllyyy to be sure you hit the right letter!!!

Re: How to Rotate the Screen for a TX2000 Tablet PC

Hi martin,

My calibration is the same rotated or unrotated. Have you tried calibrating when rotated? I added wacomcpl the my System>Preferences menu using System>Preferences>Main Menu. I called it Wacom Tablet Calibration and in the command box put "wacomcpl". This way it is easy to calibrate it rotated. But to be honest I haven't needed to do this. Hopefully that's all you need to do, and we haven't found a problem with "radeon"!

Yes I have pressure sensitivity in Xournal, Gimp, and Inkscape.

First I'd suggest you go to the Linux Wacom Project's Using Xsetwacom HOWTO at:

if you haven't already. Lots of good info., esp. on using terminal to check your pressure sensitivity, etc. Remember the tool names are case sensitive so stylus is not the same as Stylus. Check your xorg.conf if you don't remember. This gives you access to settings that aren't necessarily in wacomcpl.

Xournal: in Options do you have Xinput checked? Do you have pressure sensitivity checked?

Inkscape: Have you gone to File>Input Devices and configured stylus, eraser, and touch?

Lots of good info. but to set up Gimp you want the hotlink Pressure Sensitivity under Enabling Gimp Pressure Sensitivity. When it says File>Preferences it means Edit>Preferences. Also the Device Status dialog is located in Windows>Dockable Dialogs>Device Status. Just follow the steps and you should have your stylus, eraser, and pressure working in short order. Hope this helps.

Re: How to Rotate the Screen for a TX2000 Tablet PC

Hey martin,

Another thought. I have noticed occasionally, if I've opened a program in one orientation and then rotate to another orientation, things can be off. It mainly, or exclusively, happens in Gimp. So I guess I just have developed a habit of only opening the program once I'm in the orientation I want. I really wasn't aware I was doing that until just now.

Re: How to Rotate the Screen for a TX2000 Tablet PC

No, i didn't have pressure sensitivity checked in xournal - and now it works! Thanks.
I now remember that you earlier gave me the links for the Wacom sites. I only remember that I didn't understand much! I'll take another look.
Have you tried the keyboard in Cellwriter (or the keyboard in Onboard)? Is it easy to write with?
I will try to calibrate the stylus when the screen is rotated and see what happens.
Thanks for the quick reply.