Script to detect a Touchscreen?

Under development: PCMCIA, wireless, etc.
Post Reply
Message
Author
User avatar
peebee
Posts: 4370
Joined: Sun 21 Sep 2008, 12:31
Location: Worcestershire, UK
Contact:

Script to detect a Touchscreen?

#1 Post by peebee »

Is there a way to detect that a touchscreen is present from a script test?
ImageLxPup = Puppy + LXDE
Main version used daily: LxPupSc; Assembler of UPups, ScPup & ScPup64, LxPup, LxPupSc & LxPupSc64

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#2 Post by jamesbond »

With a recent enough udev, you can do this it like this:

Code: Select all

sed '/Sysfs=/!d; s/.*=//' /proc/bus/input/devices | xargs -I '{}' udevadm info --path='{}'  | grep TOUCHSCREEN
or even better, just grep the udev data directory (or somewhere else), just do

Code: Select all

grep TOUCHSCREEN /run/udev/data/*
The first method allows you do detect the touchscreen device (if you re-write the xargs with while loop). This method just detects presence.

Or you can also do

Code: Select all

xinput list | grep -i touchscreen
but this one seems to be less reliable because not all devices identify themselves as "touchscreen" (e.g this case). If this works however you get the benefit of knowing exactly the X input device that represents the touchscreen, which you can manipulate further with xinput itself.

Hope that helps.
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

rokytnji
Posts: 2262
Joined: Tue 20 Jan 2009, 15:54

#3 Post by rokytnji »


User avatar
peebee
Posts: 4370
Joined: Sun 21 Sep 2008, 12:31
Location: Worcestershire, UK
Contact:

#4 Post by peebee »

Thanks for the replies - the reason that I asked the question is that gcmartin has requested an edit to xorg.conf to make touchscreens work better on LxPup64 and I thought it would be better to make the edit conditional on there being a touchscreen present.

I don't have a touchscreen myself but I've tried the suggestions so far on my system and also GCM has told me what outputs he gets on a touchscreen laptop.

So far I can't really see how to make a touchscreen_present test....

Code: Select all

if [ $touchscreen_present ]; then
  edit xorg.conf
fi
Googling, I've seen a suggestion that the contents of:
/sys/class/hidraw/hidraw*/device/uevent
might provide an indication - can anybody with a touchscreen look into their files (for some reason you must use leafpad to see the contents - they don't display in geany) and post the result for the touchscreen?

Many thanks
peebee
ImageLxPup = Puppy + LXDE
Main version used daily: LxPupSc; Assembler of UPups, ScPup & ScPup64, LxPup, LxPupSc & LxPupSc64

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#5 Post by greengeek »

I seem to recall not all touchscreens use hiddraw. Can't offer any info to explain this but I'll look back through my info and see if I can find some links.

EDIT :I know it's not what you asked for, but I thought I'd post the output of the code rokyntji suggested above:
(from my Toshiba M700 which has a touchscreen but which I havent tried to get working yet). Pretty sure my touchscreen is a usb connected HID device. (I don't have the HIDDRAW directory you suggested above)

Code: Select all

# dmesg | grep usb 
[    0.000000] Kernel command line: video=640x480 psubdir=b3skype_beta pmedia=usbflash pfix=fsck
[    0.120186] usbcore: registered new interface driver usbfs
[    0.120186] usbcore: registered new interface driver hub
[    0.120186] usbcore: registered new device driver usb
[    0.716716] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    0.716719] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    0.716722] usb usb1: Product: EHCI Host Controller
[    0.716724] usb usb1: Manufacturer: Linux 3.4.52 ehci_hcd
[    0.716726] usb usb1: SerialNumber: 0000:00:1a.7
[    0.730035] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002
[    0.730039] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    0.730041] usb usb2: Product: EHCI Host Controller
[    0.730043] usb usb2: Manufacturer: Linux 3.4.52 ehci_hcd
[    0.730045] usb usb2: SerialNumber: 0000:00:1d.7
[    0.730394] usb usb3: New USB device found, idVendor=1d6b, idProduct=0001
[    0.730397] usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    0.730399] usb usb3: Product: UHCI Host Controller
[    0.730402] usb usb3: Manufacturer: Linux 3.4.52 uhci_hcd
[    0.730404] usb usb3: SerialNumber: 0000:00:1a.0
[    0.730672] usb usb4: New USB device found, idVendor=1d6b, idProduct=0001
[    0.730675] usb usb4: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    0.730677] usb usb4: Product: UHCI Host Controller
[    0.730679] usb usb4: Manufacturer: Linux 3.4.52 uhci_hcd
[    0.730681] usb usb4: SerialNumber: 0000:00:1a.1
[    0.730943] usb usb5: New USB device found, idVendor=1d6b, idProduct=0001
[    0.730945] usb usb5: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    0.730948] usb usb5: Product: UHCI Host Controller
[    0.730950] usb usb5: Manufacturer: Linux 3.4.52 uhci_hcd
[    0.730952] usb usb5: SerialNumber: 0000:00:1d.0
[    0.731217] usb usb6: New USB device found, idVendor=1d6b, idProduct=0001
[    0.731220] usb usb6: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    0.731222] usb usb6: Product: UHCI Host Controller
[    0.731224] usb usb6: Manufacturer: Linux 3.4.52 uhci_hcd
[    0.731227] usb usb6: SerialNumber: 0000:00:1d.1
[    0.731480] usb usb7: New USB device found, idVendor=1d6b, idProduct=0001
[    0.731483] usb usb7: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    0.731485] usb usb7: Product: UHCI Host Controller
[    0.731487] usb usb7: Manufacturer: Linux 3.4.52 uhci_hcd
[    0.731490] usb usb7: SerialNumber: 0000:00:1d.2
[    0.731802] usbcore: registered new interface driver usb-storage
[    0.731845] usbcore: registered new interface driver libusual
[    0.731856] usbcore: registered new interface driver ums-alauda
[    0.731868] usbcore: registered new interface driver ums-datafab
[    0.731879] usbcore: registered new interface driver ums_eneub6250
[    0.731890] usbcore: registered new interface driver ums-freecom
[    0.731901] usbcore: registered new interface driver ums-isd200
[    0.731913] usbcore: registered new interface driver ums-jumpshot
[    0.731928] usbcore: registered new interface driver ums-realtek
[    0.731939] usbcore: registered new interface driver ums-sddr09
[    0.731951] usbcore: registered new interface driver ums-sddr55
[    0.731962] usbcore: registered new interface driver ums-usbat
[    0.731980] usbcore: registered new interface driver ldusb
[    0.737779] usbcore: registered new interface driver usbhid
[    0.737780] usbhid: USB HID core driver
[    1.023354] usb 1-4: new high-speed USB device number 2 using ehci_hcd
[    1.160410] usb 1-4: New USB device found, idVendor=04f2, idProduct=b008
[    1.160413] usb 1-4: New USB device strings: Mfr=2, Product=1, SerialNumber=3
[    1.160416] usb 1-4: Product: Chicony USB 2.0 Camera
[    1.160418] usb 1-4: Manufacturer: Chicony Electronics Co., Ltd.
[    1.160420] usb 1-4: SerialNumber: SN0001
[    1.373345] usb 2-5: new high-speed USB device number 3 using ehci_hcd
[    1.498414] usb 2-5: New USB device found, idVendor=8564, idProduct=1000
[    1.498417] usb 2-5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    1.498420] usb 2-5: Product: Mass Storage Device
[    1.498422] usb 2-5: Manufacturer: JetFlash
[    1.498424] usb 2-5: SerialNumber: 23BHNQDCK7CJC7RW
[    1.498733] scsi5 : usb-storage 2-5:1.0
[    1.723344] usb 6-1: new full-speed USB device number 2 using uhci_hcd
[    1.881219] usb 6-1: New USB device found, idVendor=08ff, idProduct=1600
[    1.881222] usb 6-1: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[    1.881225] usb 6-1: Product: Fingerprint Sensor
[   35.573378] usb 6-2: new full-speed USB device number 3 using uhci_hcd
[   35.748272] usb 6-2: New USB device found, idVendor=0930, idProduct=0508
[   35.748276] usb 6-2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[   35.953722] usbcore: registered new interface driver btusb
[   36.078782] input: Chicony USB 2.0 Camera as /devices/pci0000:00/0000:00:1a.7/usb1/1-4/1-4:1.0/input/input8
[   36.078849] usbcore: registered new interface driver uvcvideo
# 
Last edited by greengeek on Sat 28 Mar 2015, 20:05, edited 1 time in total.

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#6 Post by jamesbond »

peebee wrote:gcmartin has requested ...
Okay, I see clearly now :lol:
So far I can't really see how to make a touchscreen_present test....

Code: Select all

if [ $touchscreen_present ]; then
  edit xorg.conf
fi
All the 3 codes I suggested above is meant exactly for that, e.g.

Code: Select all

if grep -q TOUCHSCREEN /run/udev/data/*; then
 edit xorg
fi
.
Googling, I've seen a suggestion that the contents of:
/sys/class/hidraw/hidraw*/device/uevent
might provide an indication - can anybody with a touchscreen look into their files (for some reason you must use leafpad to see the contents - they don't display in geany) and post the result for the touchscreen.
Here is the result of "cat /sys/class/hidraw/hidraw*/device/uevent" on a touchscreen laptop. I would have thought that gcmartin already volunteered this information himself ...

Code: Select all

DRIVER=hid-generic
HID_ID=0003:000003EB:0000880F
HID_NAME=Atmel Atmel maXTouch Digitizer
HID_PHYS=usb-0000:00:14.0-3/input1
HID_UNIQ=
MODALIAS=hid:b0003g0001v000003EBp0000880F
DRIVER=hid-generic
HID_ID=0003:0000046D:0000C52F
HID_NAME=Logitech USB Receiver
HID_PHYS=usb-0000:00:14.0-7/input0
HID_UNIQ=
MODALIAS=hid:b0003g0001v0000046Dp0000C52F
DRIVER=hid-generic
HID_ID=0003:0000046D:0000C52F
HID_NAME=Logitech USB Receiver
HID_PHYS=usb-0000:00:14.0-7/input1
HID_UNIQ=
MODALIAS=hid:b0003g0001v0000046Dp0000C52F
DRIVER=hid-multitouch
HID_ID=0003:000003EB:0000880F
HID_NAME=Atmel Atmel maXTouch Digitizer
HID_PHYS=usb-0000:00:14.0-3/input0
HID_UNIQ=
MODALIAS=hid:b0003g0004v000003EBp0000880F
As you can see, it is not helpful. That maxtouch can easily represents a touchpad, a digitizer, or a touchscreen. Since udev is already doing a better job at testing for touchscreen, just check it from udev.

cheers!

PS: If you don't mind me asking, what exactly is the xorg edit that gcmartin is asking?
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#7 Post by greengeek »

Heres my output using jamesbonds suggestions
(ok I'm probably misunderstanding how to use them...)

Code: Select all

# sed '/Sysfs=/!d; s/.*=//' /proc/bus/input/devices | xargs -I '{}' udevadm info --path='{}'  | grep TOUCHSCREEN
missing option
missing option
missing option
missing option
missing option
missing option
missing option
missing option
missing option
missing option
missing option
missing option
missing option
# grep TOUCHSCREEN /run/udev/data/*
# 
# xinput list | grep -i touchscreen
bash: xinput: command not found
EDIT : I'm using Slacko 5.6 derivative

EDIT 2 : Seems as if my touchscreen is two things in one - it has a pen that is basically a wacom digitizer and also a finger operated touch interface that I havent found much info on yet. So not your standard modern touchscreen.
(Found a comment about the touch digitizer side of things:
Quote: "BTW: The Toshiba has the digitizer on a serial interface at 0x338, I needed setserial /dev/ttyS0 port 0x338 autoconfig to get a usable port")
Last edited by greengeek on Sat 28 Mar 2015, 20:28, edited 1 time in total.

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#8 Post by 01micko »

The real solution is to have no xorg.conf at all and let Xorg discover and configure the touchscreen itself. That said, all of puppy's scipts that run at startup are very dependent on xorg.conf being present. That might have been ok in the old days but xorg has had the ability to run without xorg.conf since 1.4 (iirc - and that was before the lucid days). The method used to boot straight to desktop now is a bit of a kludge with a script xorgwizard-automatic running which relies on a pre-configured xorg.conf with minimal settings but allowing xorg to choose resolution.

So at woof level, lots of scripts need rewriting. Off the top of my head:
  • /etc/rc.d/{rc.sysinit,rc.update,rc.country} (keyboard stuff needs to be moved to a file in /etc/X11/xorg.conf.d/)
    xorgwizard
    xwin
    xinitrc
    xorgwizard-automatic (dump it)
..and probably more.

This really needs to be done, especially with newer hardware coming out.

EDIT:
Of course utilities like xinput, and xsetwacom must be included too, which have traditionally been left out.
Puppy Linux Blog - contact me for access

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#9 Post by mavrothal »

01micko wrote:This really needs to be done,
Any volunteers? :P :D
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#10 Post by 01micko »

Probably need to create a temporary branch because stability could take a while. I did some prelim work some time ago. I'll dig it out soon.
Puppy Linux Blog - contact me for access

User avatar
peebee
Posts: 4370
Joined: Sun 21 Sep 2008, 12:31
Location: Worcestershire, UK
Contact:

#11 Post by peebee »

Hi Everybody

I feel like I maybe tweaked a tiger's tail :oops: with what I thought was a simple request - many thanks to all you big guns for jumping in and making suggestions.

I'm going to retire gracefully behind a big rock until the tiger has stopped twitching I think!

@jamesbond - this is the edit which gcm pointed me too - his request was to make LxPup64 as touchscreen ready OOTB as possible (easily).

I think I will advise him that the manual edit option is the best I can suggest for now, although I may offer a small fix pet that does the edit for you.

Cheers and thanks
peebee
ImageLxPup = Puppy + LXDE
Main version used daily: LxPupSc; Assembler of UPups, ScPup & ScPup64, LxPup, LxPupSc & LxPupSc64

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#12 Post by 01micko »

peebee wrote:I feel like I maybe tweaked a tiger's tail
'Twas a tale in requisite of a testicular tweak.

(apologies to Ladies for uncouth verbiage)
Puppy Linux Blog - contact me for access

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#13 Post by jamesbond »

@greengeek - the error for the first command is probably busybox xargs (busybox too old and/or full xargs not installed); or udev too old. The second error is because xinput is not installed.

@peebee: thanks for the link. That link is explained by Mick the 5 posts above this one; adding "autoadddevices true" is the first step in removing xorg.conf altogether. That line basically tells xorg to depend on udev find out available input devices (and their types), so so you have to make sure that udev is running and working. It has an impact beyond touchscreens: all your existing keyboard/mouse xorg.conf settings *will be ignored* if you enable that line; instead things should be configured with an "InputClass" section. On the other hand, it gives you the benefit of "hotplugging" - which you can try yourself with a secondary USB keyboard (you can't use secondary USB mouse to test - secondary mouse will work even when hotplugging is disabled, but not secondary keynoard). No touchscreen is needed for these tests.

Anyway, the point is that you don't want to enable this for all users without the proper test.

As a note, Fatdog went "xorg.conf"-less 4 years ago (520 beta7), and we never looked back (you can set up xorg.conf in Fatdog, it does have xorgwizard, but only used for exceptional cases).
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

gcmartin

#14 Post by gcmartin »

Hi, I have had no access ability over the past days to PUP via browser. In a rush on Saturday, I did send results to @PeeBee.

I am unaware of the implications of what was done by @TaZoC in his LightHouse64, but, he seemingly did something such that LightHouse64 does not have tracking issues in any way with its operation on touchscreen PCs or non-touchscreen PCs in my use over the years.

In fact, @TaZoC may have done something which extends what @JamesBond alludes to or is in concert with what @01Micko presents. I am not astute enough to know the difference between what they share and whether that is line with what @TaZoC actually did for community use. I do know of what @01Micko did to allow tracking to positively track touch movements in Slacko64 and with @PeeBee's work.

FYI only. If there is a need for any info I can collect that would be helpful here, feel free to request. I have HP BIOS Touchscreen laptop and I have a UEFI DELL Touch AIO currently available for any collection needs.

scsijon
Posts: 1596
Joined: Thu 24 May 2007, 03:59
Location: the australian mallee
Contact:

#15 Post by scsijon »

not sure if still wanted,

But with my new acer w5 (with touchscreen) and barry's april64, it just worked 'out of the box'.

I did note that in the notebooks setup, help, it did mention that i2c was needed to be on in the kernel and that is also needed for the latest set of touchpads, not just the touchscreens (mine is a ELAN).

However, even windows has a 'training' utility to get the 'finger or touchpen' to allign with the 'pointer' and that takes some time to do, i've yet to find a linux equivalent though.

stemsee

#16 Post by stemsee »

@scsijon

Alignment not needed on Fatdog nor Lighthouse, the cursor is always under your finger! I don't know why this cannot be acheived on 32bit pups!!! Frustrating.

Post Reply