#!/bin/bash # # The script is designed to be launched by fjbtndrv backend and should be placed in ~/.fjbtndrv/scripts or /fjbtndrv # It changes the evdev properties of touchscreen depending on ACTION and ORIENTATION using xinput. # # Author : draco31.fr # Contact : see http://doc.ubuntu-fr.org/utilisateurs/draco31.fr # Licence : GNU GPLv3 (see http://www.gnu.org/copyleft/gpl.html ) # script="$(basename $0)" logfile="/var/log/${script}.log" DEBUG=${DEBUG:=no} do_log() { if [ "$1" == yes ] then { echo "$2" | tee -a $logfile 1>&2 } fi } find_touchscreen() { IFS=$'\n' do_log "$DEBUG" "Searching device ..." local device_name for device in $(xinput list --name-only) do do_log "$DEBUG" "... Testing device $device" output="$(xinput list-props "$device" 2>/dev/null | grep 'Evdev Axis Calibration' --label="$device" -H)" if [ $? -eq 0 ] then do_log "$DEBUG" "Device found : $output" device_name="$device" break fi done do_log "yes" "Touchscreen device : $device_name" if [ -n "$device_name" ] then { echo $device_name return 0 } else return 1 fi } do_log "$DEBUG" "$(date) > ${script} : ACTION='$ACTION' ORIENTATION='$ORIENTATION' TOUCHSCREEN='$TOUCHSCREEN_DEVICE'" if [ "$ACTION" == "rotated" ] then { if [ -z "$TOUCHSCREEN_DEVICE" ] then declare -x TOUCHSCREEN_DEVICE="$(find_touchscreen)" export TOUCHSCREEN_DEVICE fi declare -i AxisX=0 declare -i AxisY=0 declare -i SwapAxes=0 case "$ORIENTATION" in "normal") # Keep initial values ;; "inverted") # Invert Axis AxisX=1 AxisY=1 # Keep X/Y orientation ;; "left") # inverse AxisX AxisX=1 # Rotate Axes SwapAxes=1 ;; "right") # inverse axes #AxisX=0 AxisY=1 # Rotate Axes SwapAxes=1 ;; *) do_log "yes" "Unknown ORIENTATION='$ORIENTATION'" exit 1 ;; esac do_log "yes" "Changing properties of device '$TOUCHSCREEN_DEVICE' : AxisX=$AxisX AxisY=$AxisY SwapAxes=$SwapAxes" xinput set-prop "$TOUCHSCREEN_DEVICE" 262 $AxisX $AxisY xinput set-prop "$TOUCHSCREEN_DEVICE" 264 $SwapAxes } fi exit 0