Hello all,
!!!! Reposting in this thread upon request from Favux: My TX2z findings from How to Rotate the Screen for a TX2000 Tablet PC thread. !!!!
First of all, thanks to all of you for your efforts & good documentation (although it seems to be getting 'a little' complex).
Special thanks to Favux, rafiyr & Ayuthia.
I have a HP Touchsmart tx2z-1020 w. Vista firmware.
Getting everything:
Code:
- touch with grab (need good N-Trig module)
- stylus with right button (modify '10-wacom.conf' or 'xorg.conf')
- rotation with hinge (event from 'hp-wmi' module & magic rotation)
- rotation with bezel button (???, not possible ATM, use script instead)
- good DSDT for ACPI readings (???, fan,speed,..., for CPU temp: use 'k10temp' module)
- on-screen keyboard (created onboard applet/launcher on panel)(cellwriter does not have <Alt-Gr>)
- touchscreen multi-touch / gestures (Work-in-Progress, patched n-trig w. wacom, 'EasyStroke' program)
- multi-finger / gestures on Synaptics touchpad (Synaptics solution should be coming ~2010-04-20)
- fingerprint reader authentication/PAM/sudo (use 'fprint' along w. disabling 'gksu' screengrab)
- ability to unlock screensaver w. onboard (start 'onboard' & use its setup)(or gconf-editor (apps->gnome-screensaver->embedded_keyboard_...))
- an easy way to recalibrate touchscreen (Work-in-Progress: wacomcpl is not in Lucid (yet?))(evdev vs. wacom?)
....
to work (correctly/well) is quite a challenge. Unfortunately, this would be a deal breaker for most any newbie/MS Win convert.
Here are some of my findings, and a little script I use (I have converted a couple of tx2z to linux).
On one, I have lucid installed (since alpha1).
- I am using the patched hid_ntrig module (input-wacom module not needed anymore).
- My xorg.conf only contains the 'fglrx' section for the ATI video card.
- I modified '10-wacom.conf' to get the stylus button to work.
- Have not tried to get multitouch to work (would like to, but seems to be in a state of flux at the moment).
- Radeon HD 3200 video card w. rotation support (MUCH lower temperature/fan speed w. ATI proprietary 'fglrx' module)
Currently, the stylus ends up being controlled by wacom & touch by evdev.
Both xinput & xsetwacom list devices twice, I have no idea why.
Even though 'hp-wmi' module is loaded, there are no events being generated (in /sys/devices/...) for hinge rotation (nor for bezel button), so automagic screen rotation does not work for me.
I use the script, attached to an applet added to the panel, for a clockwise (my preference) rotation with each click:
Code:
/usr/local/bin/rotator.sh rturn wacom 6 evdev touch
Usage:
Code:
rotator.sh [-v] direction|position method device [...]
where: -v turn on Verbose mode
Direction = (lturn|l)|(rturn|r)|(flip|f)
Turn 90° to the Left or Right, or Flip 180° (inversion), relative to previous position
Orientation = (right|3)|(left|1)|(normal|0|(inverted|2)
Turn the display TO that position
Method: (wacom|evdev)
Device: (stylus|eraser|touch|mttouch|dev#)
The script allows most combinations of method/device because, as I have found out on another TX2z, until the (multiple/competing) drivers/protocols/methods/... for naming/numbering devices settle and are finalized, we can expect surprises as to 'what ends up where'.
It could be improved, ie. adding support for multi-touch device, more error checking / feedback, ...
Hope it helps someone (getting closer to a better "Out Of the Box" experience, and maybe "Just Works" some day).
PEP
Code:
#!/bin/sh
#
# Enhanced rotate shell script, based on rafiyr's http://ubuntuforums.org/showpost.php?p=9133869&postcount=918
# and others (gathered on forums).
# Added rturn & lturn, to rotate screen left/right a quarter turn at a time (mainly
# because default hp-wmi module was not returning an 'event' for the 'Rotate' button
# on the bezel of my tx2z, nor for hinge rotation).
#
# This script can be used as the command in a 'rotate' applet/launcher button manually added
# to the desktop panel (w. 90° rotation to emulate to bezel button (under Windows), or
# possibly 180° flip, with each click of the applet).
# with (for example) command: /usr/local/bin/rotator.sh rturn evdev touch wacom 6
# (assuming you put an executable copy of the script in '/usr/local/bin'
#
# Usage: rotator.sh [-v] direction|position method device [...]
#
# where: -v turn on Verbose mode
# Direction = (lturn|l)|(rturn|r)|(flip|f)
# Turn 90° to the Left or Right, or Flip 180° (inversion), relative to previous position
# Orientation = (right|3)|(left|1)|(normal|0|(inverted|2)
# Turn the display TO that position
# Method: (wacom|evdev)
# Device: (stylus|eraser|touch|mttouch|dev#)
#
print_usage()
{
echo "Usage: `basename $0` [-v] Direction|Orientation Method Device [...]"
echo "\t-v\tturn on Verbose mode"
echo "\tDirection = (lturn|l)|(rturn|r)|(flip|f)"
echo "\t\tTurn 90° Left or Right, or Flip 180° (inversion), relative to previous position"
echo "\tOrientation = (right|3)|(left|1)|(normal|0|(inverted|2)"
echo "\t\tTurn the display TO that position"
echo "\tMethod: (wacom|evdev)"
echo "\tDevice: (stylus|eraser|touch|mttouch|dev#)\n"
exit 1
}
#
# List devices found by both "xinput" (evdev) & "xsetwacom", to 'see'
# who 'gets what', as well as device numbers
#
list_devices()
{
echo "Devices found with xinput:\n"
xinput --list
echo "Devices found with xsetwacom:\n"
xsetwacom --list
}
#
# Figure out the device Number, depending on Method (different naming scheme)
# wacom: "stylus", "eraser", "touch", "mttouch"
# n-trig: "N-Trig Pen", "N-Trig Touchscreen", "N-Trig MultiTouch"
#
get_device_number()
{
#
# If invoked with Wacom method, 1st look for Wacom device names (w. lower DeviceID)
#
if [ $method = "wacom" ]; then
devNum=`xinput --list --short "$1" | cut -c 45-46`
#
# If an actual Wacom device number was not returned (xinput is not always well-behaved,
# i.e. return something), use the corresponding evdev device name
#
if [ "$devNum" = "" ] || [ `echo $devNum | sed 's/^[0-9]*//' | wc -c` -ne 1 ]; then
devNum=`xinput --list --short "$2" | cut -c 45-46`
fi
else
devNum=`xinput --list --short "$2" | cut -c 45-46`
fi
return $devNum
}
#
# Parse the orientation parameter & in case of 'rturn', 'lturn' and 'flip', check the
# current orientation and make sure that the next value is within bound.
#
parse_orientation()
{
case $1 in
rturn | r)
orientNum=$((current_orientation-1))
if [ $orientNum -le "-1" ]; then
orientNum=3
fi
;;
lturn | l)
orientNum=$((current_orientation+1))
if [ $orientNum -ge "4" ]; then
orientNum=0
fi
;;
flip | f)
orientNum=$((current_orientation+2))
if [ $orientNum -eq "4" ]; then
orientNum=0
elif [ $orientNum -eq "5" ]; then
orientNum=1
fi
;;
normal | 0)
orientNum=0
;;
left | 1)
orientNum=1
;;
inverted | 2)
orientNum=2
;;
right | 3)
orientNum=3
;;
* )
echo "!!!! Invalid orientation specified: "$1" !!!!"
print_usage
;;
esac
return $orientNum
}
#
# Actually perform input device rotation, according to selected method.
# Arguments: Method, Device, Orientation, Swap Axes, Axis Inversion X, Axis Inversion Y, Topx, BottomX, TopY, BottomY
#
do_rotation()
{
if [ $1 = "wacom" ]; then
xsetwacom set $2 rotate $3
# xsetwacom set $2 TopX $7
# xsetwacom set $2 BottomX $9
# xsetwacom set $2 TopY $8
# xsetwacom set $2 BottomY ${10}
#
# It would seem possible to use xinput instead, to setup Wacom device?: http://gist.github.com/331086
# Must check which "calibration resolution" to use ...
#xinput set-prop $SCREEN_CODE "Wacom Rotation" 1
#xinput set-prop $SCREEN_CODE "Wacom Tablet Area" 16320, 0, 0, 26112
else
#
# If using "evdev" method, adjust the device (touch/calibration) accordingly
#
xinput set-prop $2 "Evdev Axes Swap" $4
xinput set-prop $2 "Evdev Axis Inversion" $5 $6
xinput set-prop $2 "Evdev Axis Calibration" $7 $8 $9 ${10}
fi
}
#
# ======== Main Program ========
#
if [ $# -eq 0 ]; then
print_usage
fi
#
# If "-v" specified alone, list devices found & exit.
# Otherwise, if enough arguments were passed, go on.
#
if [ "$1" = "-v" ]; then
list_devices
if [ $# -eq 1 ]; then
exit
elif [ $# -lt 4 ]; then
echo "\n`basename $0`: !!!! Not enough parameters specified !!!!"
print_usage
fi
shift
fi
#
# Parse & get current orientation, and do integer conversion (in order to be
# able to (in/de)crement for each 90° rotation, also needed later for 'easier' comparison)
#
current_orientation="$(xrandr -q --verbose | grep 'connected' | egrep -o '\) (normal|left|inverted|right) \(' | egrep -o '(normal|left|inverted|right)')"
parse_orientation $current_orientation
current_orientation=$?
#
# parse & convert the new position
#
parse_orientation $1
orientation=$?
shift
#
# Check if new orientation is different from current one.
#
if [ $orientation -eq $current_orientation ]; then
echo "Nothing to do."
exit
fi
#
# repeat the device rotation/calibration for all devices passed as arguments
#
while [ $# -gt 0 ]
do
# get and (crudely) parse method for errors
method=$1; shift
case $method in
wacom ) ;;
evdev ) ;;
* )
echo "!!!! Invalid method specified: "$method" !!!!"
print_usage
;;
esac
#
# get and (crudely) parse device for errors and convert device name to number
# (also specifying ntrig/evdev device name) unless an acutal device number was passed.
#
device=$1; shift
case $device in
stylus | eraser)
get_device_number $device "N-Trig Pen"
device=$?
;;
touch )
get_device_number $device "N-Trig Touchscreen"
device=$?
;;
mttouch )
get_device_number $device "N-Trig MultiTouch"
device=$?
;;
* )
if [ `echo $device | sed 's/^[0-9]*//' | wc -c` -ne 1 ]; then
echo "!!!! Invalid device specified: "$device" !!!!"
print_usage
fi
;;
esac
#
# Make sure we ended up with a device 'number' (try to catch cases where driver/module
# is not loaded, which can cause lock-up)
#
if [ "$device" = "" ] || [ `echo $device | sed 's/^[0-9]*//' | wc -c` -ne 1 ]; then
print_usage
fi
#
# Set rotation plane/geometry parameters, and if using "wacom"
# method, also perform device/calibration rotation
#
real_topX=0
real_topY=0
real_bottomX=9600
real_bottomY=7200
case $orientation in
0)
do_rotation $method $device "NONE" 0 0 0 $real_topX $real_bottomX $real_topY $real_bottomY
;;
1)
do_rotation $method $device "CCW" 1 1 0 $real_topX $real_bottomY $real_topY $real_bottomX
;;
2 )
do_rotation $method $device "HALF" 0 1 1 $real_topX $real_bottomX $real_topY $real_bottomY
;;
3 )
do_rotation $method $device "CW" 1 0 1 $real_topX $real_bottomY $real_topY $real_bottomX
;;
esac
done
#
# Perform actual rotation of the X display/screen
#
xrandr -o $orientation
Bookmarks