Touchscreen not working in android on beagleboard xM - android

I have a custom Android (2.3) running on a Beagleboard xM. Currently we are trying to replace a small resistive touchscreen with a bigger, capacitive one. However we can't seem to get the touch working with our android. (The resistive always worked fine).
The kernel modules are loaded and the driver is running. The driver outputs the correct touch coordinates when the screen is pressed.
/proc/bus/input/devices contains these entries:
I: Bus=0003 Vendor=0eef Product=7458 Version=0210
N: Name="eGalax Inc. eGalaxTouch EXC7200-7458"
P: Phys=usb-ehci-omap.0-2.3/input0
S: Sysfs=/devices/platform/ehci-omap.0/usb1/1-2/1-2.3/1-2.3:1.0/input/input2
U: Uniq=
H: Handlers=
B: EV=1b
B: KEY=421 0 30001 0 0 0 0 0 0 0 0
B: ABS=100 3f
B: MSC=10
I: Bus=0006 Vendor=0eef Product=0020 Version=0001
N: Name="eGalaxTouch Virtual Device for Multi"
P: Phys=
S: Sysfs=/devices/virtual/input/input5
U: Uniq=
H: Handlers=event2
B: EV=b
B: KEY=400 0 0 0 0 0 0 0 0 0 0
B: ABS=6608000 1000003
I: Bus=0006 Vendor=0eef Product=0010 Version=0001
N: Name="eGalaxTouch Virtual Device for Single"
P: Phys=
S: Sysfs=/devices/virtual/input/input6
U: Uniq=
H: Handlers=event3
B: EV=b
B: KEY=30000 0 0 0 0 0 0 0 0
B: ABS=3
which are correct, according to the guide for the device.
When touching the screen android shows this in logcat:
V/EventHub(10978): /dev/input/event2 got: t0=1594, t1=229858, type=0, code=0, v=0
D/InputReader(10978): Input event: device=0x10002 type=0x0 scancode=0 keycode=0 value=0
V/EventHub(10978): /dev/input/touchscreen0 got: t0=1594, t1=235198, type=3, code=53, v=788
D/InputReader(10978): Input event: device=0x10001 type=0x3 scancode=53 keycode=53 value=788
V/EventHub(10978): /dev/input/event2 got: t0=1594, t1=235198, type=3, code=53, v=788
D/InputReader(10978): Input event: device=0x10002 type=0x3 scancode=53 keycode=53 value=788
V/EventHub(10978): /dev/input/touchscreen0 got: t0=1594, t1=235382, type=3, code=54, v=1512
D/InputReader(10978): Input event: device=0x10001 type=0x3 scancode=54 keycode=54 value=1512
V/EventHub(10978): /dev/input/event2 got: t0=1594, t1=235382, type=3, code=54, v=1512
D/InputReader(10978): Input event: device=0x10002 type=0x3 scancode=54 keycode=54 value=1512
V/EventHub(10978): /dev/input/touchscreen0 got: t0=1594, t1=235473, type=3, code=0, v=788
D/InputReader(10978): Input event: device=0x10001 type=0x3 scancode=0 keycode=0 value=788
This also seems to be correct, the code 53 and 54 are for the X and Y coordinates.
However the android UI is not reacting to the touch inputs. Neither is our own app, nor the pointer painter from the development tools. Are the events not forwarded to the input dispatcher? The problem seems to be on the android side, but I cannot figure it out.
I hope someone can help me there or at least tell me where I can find additional information.

Related

How to translate device screen position to sendevent position?

I know about the input tap x y shell command, however, I'm trying to understand how to
perform a click using the sendevent command. I been able to achieve it with the following command:
sendevent /dev/input/event5 3 53 X &&
sendevent /dev/input/event5 3 54 Y &&
sendevent /dev/input/event5 0 2 0 &&
sendevent /dev/input/event5 0 0 0 &&
sendevent /dev/input/event5 0 2 0 &&
sendevent /dev/input/event5 0 0 0
Where X and Y is the position that will be clicked, I'm testing it on the android emulator BlueStacks 5 which the Display Resolution set to 1920x1080.
The code is working and the click is fired, however, I couldn't understand how to convert the position where I want to be clicked to the sendevent XY position.
If I send using ADB:
sendevent /dev/input/event5 3 53 2000 &&
sendevent /dev/input/event5 3 54 2000 &&
sendevent /dev/input/event5 0 2 0 &&
sendevent /dev/input/event5 0 0 0 &&
sendevent /dev/input/event5 0 2 0 &&
sendevent /dev/input/event5 0 0 0
It clicks somewhere around x75 y75, how this calc is done? i mean screen xy -> sendevent xy?
How to replicate:
First enable BlueStacks 5 adb in the window: Settings -> Advanced -> Android debug bridge
Open a cmd window and run cd C:\Program Files\BlueStacks_nxt assuming BlueStacks where installed in the default path.
Execute the commands:
hd-adb.exe connect 127.0.0.1:X where X is the port shown in the window where you enabled the ADB.
hd-adb.exe -s 127.0.0.1:X shell
Now we are on the shell, execute a new command: getevent -p
and search for:
... /dev/input/event5
name: "BlueStacks Virtual Touch"
On my emulator the input event for touch is event5 on yours it can be different, replace it according.
Now you can simulate a click with the code below changing XY to the position where you want to be clicked:
sendevent /dev/input/event5 3 53 X &&
sendevent /dev/input/event5 3 54 Y &&
sendevent /dev/input/event5 0 2 0 &&
sendevent /dev/input/event5 0 0 0 &&
sendevent /dev/input/event5 0 2 0 &&
sendevent /dev/input/event5 0 0 0
I'm trying to figure out how to convert the emulator screen position to the sendevent position.
For example, if you want to perform a click at x200 y200, using sendevent what the value needed?
How to calculate it?
thanks for the very precise instructions to reproduce:
I enabled
Settings -> Advanced -> Input debugging -> Show visual feedback for taps
and
Settings -> Advanced -> Input debugging -> Show pointer location for current touch data
when I hold down click, I can see: X: Y:
I collected these x coordinate points, my max X: is 1600.0 so my width is 1600.0
(8000, 390.6)
(16000, 781.2)
(32000, 1562.5)
then Excel: X Y (scatter) chart, add trendline, click trendline and click big + sign -> Chart Elements -> Trendline : (tick that) and ▶, More Options... -> Trendline Options -> Display Equation on chart
, click on the formula, then Label Options -> Category: Number, Decimal Places: 10
y = 0.0488294643x - 0.0500000000
1600 = 0.0488294643x - 0.0500000000
32768.1252075501 = X
I round to 32768 because 32768 is a magic number, close to Int16's 32767
edit: after Nathan's comment, it's 32767 (32768 doesn't even move the cursor)
so the formula is : (W: width, H: height)
32767*X/W
32767*Y/H
for your (X=200, Y=200, W=1980, H=1080)
32767*200/1920
32767*200/1080
3413.22916666667
6067.96296296296
I used this code to test: it doesn't do a tap, it holds down without releasing
sendevent /dev/input/event5 3 57 0
sendevent /dev/input/event5 3 53 3413.22916666667
sendevent /dev/input/event5 3 54 6067.96296296296
sendevent /dev/input/event5 3 48 5
sendevent /dev/input/event5 3 58 50
sendevent /dev/input/event5 0 2 0
sendevent /dev/input/event5 0 0 0
https://ktnr74.blogspot.com/2013/06/emulating-touchscreen-interaction-with.html#:~:text=ABS_MT_TRACKING_ID%20(57)%20%2D%20ID,end%20of%20report

How to perform a swipe with 'duration' using sendevent and adb

I'm using the code above to simulate a 'swipe' using sendevent:
sendevent /dev/input/event0 3 53 300 ;First position X
sendevent /dev/input/event0 3 54 600 ;First position Y
sendevent /dev/input/event0 3 48 5
sendevent /dev/input/event0 3 58 50
sendevent /dev/input/event0 0 2 0
sendevent /dev/input/event0 0 0 0
sendevent /dev/input/event0 3 53 300 ;Second position X
sendevent /dev/input/event0 3 54 400 ;Second position Y
sendevent /dev/input/event0 0 2 0
sendevent /dev/input/event0 0 0 0
sendevent /dev/input/event0 0 2 0
sendevent /dev/input/event0 0 0 0
However, it does swipe instantly without any delay.
I'm trying to figure how to specify the duration of the swipe, like you can do using adb shell input:
input [touchscreen|touchpad|touchnavigation] swipe <x1> <y1> <x2> <y2> [duration(ms)]
shell input swipe 300 400 300 200 2000
This produces a swipe with a duration of 2 seconds.
I have tried to add a
sleep 2 before the ;Second position but it does result in a pause before the swipe instead of a swipe with 2 seconds of duration.
With duration I mean, the time slowly swapping from position 1 to position 2.
The problem with this is that sending events through sendevent takes some time. I made a python script (You can take whatever you need from there) that interpolates points between the given ones. It also waits some time between points.
This is the lineal interpolation code:
def lerp(p1:tuple, p2:tuple, points:int) -> list:
output = []
header = [_p2 - _p1 for _p1, _p2 in zip(p1, p2)]
for p in range(points + 1):
percent = p / points
output.append((p1[0] + percent * header[0], p1[1] + percent * header[1]))
return output
The time problem appears when using multiples points. Using a path with 10 interpolated points with no time between them already takes 1.29 seconds and a 100 points one, 11.45.
If you compare the sendevent and input commands' source code you can clearly understand their goals; the former covers basic command line's input events whereas the latter covers more flexible and complex input scenarios.
To get an insight on how the swipe duration has been implemented (on input command) you can focus directly on the sendSwipe method: it sends multiple basic input events, leveraging the InputManager, in a timespan defined by the duration parameter
final long endTime = down + duration;
The function injectMotionEvent used by sendSwipe doesn't have any concept of "duration".
That said, I think the command you're looking for, as of today, doesn't exist and I believe you can still rely on console prompt like
input swipe 300 400 300 200 2000
that can be invoked after using
adb shell
One cannot set the duration on the low level, but one can record analog input and then play it back. This permits for more flexible and complex scenarios ...because the events are countless.
Run adb shell to open a shell.
Where ...
getevent --help shows all available options.
getevent -p shows all recordable devices.
getevent -lp /dev/input/event1 shows BTN_TOUCH event data format.
getevent /dev/input/event1 logs input events for device focaltech_ts.
getevent -l /dev/input/event1 is human-readable (useless for automation).
To record:
cd sdcard/Download
getevent /dev/input/event1 >> ./swipe.log
download swipe.log with the Android device explorer.
Where 0003 means coordinate, and 0x35 is the X-axis and 0x36 is the Y-axis:
0003 0035 000001a8
0003 0036 000005cb
This log can the be played back by a shell script loop, with sendevent.
sendevent --help shows the expected parameters: DEVICE TYPE CODE VALUE.
cat ./swipe.log | while read line
do
adb shell sendevent /dev/input/event1 $line
done
When delaying the execution with sleep, the lines with 0000 0000 00000000 might suit best.
Alike this one can also automate GPIO buttons, which maybe be quite specific on certain devices. UiObject2.swipe() might also just generate linear-interpolation coordinates and play them back. It generally does not matter, if they're generated or recorded - the only difference is that the one movement is perfectly straight and the other one obviously isn't.

Simulating combination of key presses from ADB terminal

I want to send "CTRL + W" to the Chrome for Android to close active tab. I tried lots of things but there is no success to achieve it from terminal. (If i connect a USB Keyboard with OTG, i can close the tab with CTRL+W)
Firstly i do not want to write a application for this, i only want a shell command to use it from Tasker.
I read somewhere that to achieve this (CTRL+W keypress), i have to simulate key presses like this:
Down CTRL
Down W
Up W
Up CTRL
And to achieve this from terminal, it seems i have to use "sendevent".
I can simulate all hardware keypress with "sendevent" but can not simulate the normal keys with it.
For example, to down and up to the POWER key:
sendevent /dev/input/event1 1 116 1
sendevent /dev/input/event1 0 0 0
sendevent /dev/input/event1 1 116 0
sendevent /dev/input/event1 0 0 0
i use this commands, but i can not use this commands to send normal keys. (for example a,b,c etc)
The event1 is the gpio-keys, so i'm using it. And all the other input events are sensors and one is the charging driver. (max77693-muic)
The output of the "getevent -p" says that:
add device 1: /dev/input/event9
name: "compass_sensor"
events:
REL (0002): 0000 0001 0002 0003 0004 0005 0006 0007
0008 0009
input props:
<none>
add device 2: /dev/input/event6
name: "barometer_sensor"
events:
REL (0002): 0000 0001 0002
input props:
<none>
add device 3: /dev/input/event5
name: "light_sensor"
events:
REL (0002): 0000 0001 0002 0009
input props:
<none>
add device 4: /dev/input/event4
name: "proximity_sensor"
events:
ABS (0003): 0019 : value 1, min 0, max 1, fuzz 0, flat 0, resolution 0
input props:
<none>
add device 5: /dev/input/event3
name: "gyro_sensor"
events:
REL (0002): 0003 0004 0005
input props:
<none>
could not get driver version for /dev/input/mice, Not a typewriter
add device 6: /dev/input/event7
name: "Midas_WM1811 Midas Jack"
events:
KEY (0001): 0072 0073 00e2
SW (0005): 0002 0004
input props:
<none>
add device 7: /dev/input/event1
name: "gpio-keys"
events:
KEY (0001): 0072 0073 0074 00ac
input props:
<none>
add device 8: /dev/input/event0
name: "max77693-muic"
events:
KEY (0001): 0072 0073 00a3 00a4 00a5
input props:
<none>
add device 9: /dev/input/event8
name: "sec_touchkey"
events:
KEY (0001): 008b 009e
LED (0011): 0008
input props:
<none>
add device 10: /dev/input/event2
name: "sec_touchscreen"
events:
ABS (0003): 002f : value 0, min 0, max 9, fuzz 0, flat 0, resolution 0
0030 : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
0031 : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
0032 : value 0, min 0, max 30, fuzz 0, flat 0, resolution 0
0035 : value 0, min 0, max 719, fuzz 0, flat 0, resolution 0
0036 : value 0, min 0, max 1279, fuzz 0, flat 0, resolution 0
0039 : value 0, min 0, max 65535, fuzz 0, flat 0, resolution 0
003c : value 0, min -90, max 90, fuzz 0, flat 0, resolution 0
003d : value 0, min 0, max 1, fuzz 0, flat 0, resolution 0
input props:
INPUT_PROP_DIRECT
Also my gpio-keys layout file "/system/usr/keylayout/gpio-keys.kl" like this:
key 115 VOLUME_UP WAKE
key 114 VOLUME_DOWN WAKE
key 116 POWER WAKE
key 172 HOME WAKE
I can send all normal keyevents with:
"input keyevent KEYCODE_X"
and to send more than one:
"input keyevent KEYCODE_X KEYCODE_Y"
You should think it can works like this:
"input keyevent KEYCODE_CTRL_LEFT KEYCODE W"
but keyevent down and up immediatly and i can not use it to send CTRL+W combination.
I know, the answer should be with "sendevent". But i can not find.
I also tried to adding some fake keys into the key layout file like this:
key 115 VOLUME_UP WAKE
key 114 VOLUME_DOWN WAKE
key 116 POWER WAKE
key 172 HOME WAKE
key 19 Q
i restarted the phone, then tried:
sendevent /dev/input/event1 1 19 1
sendevent /dev/input/event1 0 0 0
sendevent /dev/input/event1 1 19 0
sendevent /dev/input/event1 0 0 0
But it never writes "Q" into the any textbox.
Please help, thanks for your helps.
Oh YES!! I dont know why but whenever I feel stuck I come to stackoverflow and as soon as I start writing the question somehow I find the answer... xD
Anyways, I was able to do it by following procedure:
Go to /system/usr/keylayout/
In my case there was no gpio-keys, anyways open Generic.kl
It has all the keycodes you would need to simulate anything... such as for CTRL_RIGHT keycode is 97 and for W keycode is 17
Thats all you need, now open tasker --> New task --> Add wait 5 sec --> Run shell:
input keyevent 97
input keyevent 17
Now run the command and quickly open chrome, voila! in 5 secs you will see your tab disappearing!
Hope that helps all the future tasker pros ;)
Kudos...
The events section in getevent -p output lists all accepted key codes:
add device 7: /dev/input/event1
name: "gpio-keys"
events:
KEY (0001): 0072 0073 0074 00ac
i.e. VOLUME_UP(0x73), VOLUME_DOWN(0x72), POWER(0x74) and HOME(0xAC) in case of /dev/input/event1. Everything else gets filtered out by the linux kernel input driver long before it reaches the Android framework (where the layout files you tried to modify are used)

how to get media player state using adb command

Can you please let me know if there are any adb commands to get the state of MediaPlayer like, Play/Pause etc.
This is what i tried like below.
c:\>adb shell dumpsys media.player
Client
pid(3764), connId(94), status(0), looping(false)
AwesomePlayer
fd(40), flags(0x00000010), bitrate(48000 bps)
Track 1
MIME(audio/mpeg), decoder(OMX.google.mp3.decoder)
AudioOutput
stream type(3), left - right volume(1.000000, 1.000000)
msec per frame(0.000000), latency (-1)
aux effect id(0), send level (0.000000)
Client
pid(3764), connId(93), status(0), looping(false)
AwesomePlayer
fd(35), flags(0x00084014), bitrate(48000 bps)
Track 1
MIME(audio/mpeg), decoder(OMX.google.mp3.decoder)
AudioOutput
stream type(3), left - right volume(1.000000, 1.000000)
msec per frame(0.022676), latency (261)
aux effect id(0), send level (0.000000)
AudioTrack::dump
stream type(3), left - right volume(1.000000, 1.000000)
format(1), channel count(2), frame count(7680)
sample rate(44100), status(0)
state(2), latency (261)
No media recorder client
Files opened and/or mapped:
/proc/749/fd/35 -> /storage/sdcard1/Music/xxx/aaaa.mp3
/proc/749/fd/40 -> /storage/sdcard1/Music/xxx/bbbb.mp3
If you are just looking if Audio is Paused or Played.
You can try using
$ adb shell dumpsys audio
Remote Control stack entries (last is top of stack):
/*....
* Some Output Here...
*/
pi: PendingIntent{42feb5a8: PendingIntentRecord{42b6b748 com.google.android.music broadcastIntent}} -- pack: com.google.android.music -- ercvr: ComponentInfo{com.google.android.music/com.google.android.music.playback.MediaButtonIntentReceiver} -- client: android.media.IRemoteControlClient$Stub$Proxy#42e544d8 -- uid: 10059 -- type: 0 state: PLAYSTATE_PAUSED, 208457ms, 1.0X
Remote Control Client stack entries (last is top of stack):
uid: -1 -- id: 1 -- type: 0 -- state: PLAYSTATE_STOPPED, PLAYBACK_POSITION_INVALID, 1.0X -- vol handling: 1 -- vol: 15 -- volMax: 15 -- volObs: null
uid: -1 -- id: 8 -- type: 0 -- state: PLAYSTATE_STOPPED, PLAYBACK_POSITION_INVALID, 1.0X -- vol handling: 1 -- vol: 15 -- volMax: 15 -- volObs: null
uid: 10059 -- id: 9 -- type: 0 -- state: PLAYSTATE_PAUSED, 208457ms, 1.0X -- vol handling: 1 -- vol: 15 -- volMax: 15 -- volObs: null
In both, it shows if state is PLAYSTATE_PAUSED, PLAYSTATE_PLAYING or PLAYSTATE_STOPPED.
I even tried it on different device,
$ adb shell dumpsys audio
Remote Control stack entries:
pi: PendingIntent{41b84660: PendingIntentRecord{42239310 com.sonyericsson.music broadcastIntent}} -- ercvr: ComponentInfo{com.sonyericsson.music/com.sonyericsson.music.proxyservice.MediaButtonReceiver} -- client: android.media.IRemoteControlClient$Stub$Proxy#428b5528 -- uid: 10049 -- type: 0 state: 2
Remote Control Client stack entries:
uid: -1 -- id: 1 -- type: 0 -- state: 1 -- vol handling: 1 -- vol: 15 -- volMax: 15 -- volObs: null
uid: -1 -- id: 2 -- type: 0 -- state: 1 -- vol handling: 1 -- vol: 15 -- volMax: 15 -- volObs: null
uid: 10049 -- id: 5 -- type: 0 -- state: 2 -- vol handling: 1 -- vol: 15 -- volMax: 15 -- volObs: null
Here it shows the state:1 or state:2,
It basically the value for that.
PLAYSTATE_PLAYING
PLAYSTATE_PAUSED
PLAYSTATE_STOPPED
You could parse the output of the above to get these values.
Hopefully this is what you looking for.
Another way to tell will be from the state present in the AudioTrack::dump.
For instance, in your case:
AudioTrack::dump
stream type(3), left - right volume(1.000000, 1.000000)
format(1), channel count(2), frame count(7680)
sample rate(44100), status(0)
state(2), latency (261)
state(2) tells us that the media is paused/stopped. state(0) would mean that the media is playing and state(1) would mean that the playing media was interrupted by some pop-up.

Swapping X and Y on my touchscreen

I successfuly installed (after 1 week of work) Android on BeagleBoard C4. As display I use Lilliput 669 with an eGalax Usb TouchController. Everything seems ok with exception of touchscreen which have X and Y axes reverse.
I: Bus=0003 Vendor=0eef Product=0001
Version=0210 N: Name="eGalax Inc. USB
TouchController" P:
Phys=usb-ehci-omap.0-2.2/input0 S:
Sysfs=/devices/platform/ehci-omap.0/usb1/1-2/1-2.2/1-2.2:1.0/input/input1
U: Uniq= H: Handlers=event1 B: EV=9
B: ABS=600000 3
I: Bus=0003 Vendor=0eef Product=0001
Version=0210 N: Name="eGalax Inc. USB
TouchController" P:
Phys=usb-ehci-omap.0-2.2/input0 S:
Sysfs=/devices/platform/ehci-omap.0/usb1/1-2/1-2.2/1-2.2:1.0/input/input2
U: Uniq= H: Handlers=mouse0 event2 B:
EV=1b B: KEY=400 0 0 0 0 0 0 0 0 0 0
B: ABS=600000 3 B: MSC=10
Do you know how to reverse X and Y axis for my touchscreen ?
I know that this post is old, but this was a problem I encountered recently while I swapped the broken touchscreen from my Android tablet. The replacement was a poorly manufactured p.o.c.s... Anyway, after I plugged it in, the xy was swapped first, then I turned the connector over and it was just an x-axis problem. I knew that if I flipped the glass over, it would fix it, but that would make the connector too far away from the port on the motherboard. So I just plugged it in, and went to the settings of the tablet, and calibrated the touchscreen from the settings menu. Done.
That's it.
SOLUTION:
Just go to the settings option in the menu and find the "Touchscreen Calibration" option and calibrate it again. This should fix it :) Or just flip connector around and try again :)
The reason I posted this is to help others who might have this problem :)

Categories

Resources