Having a lot of problems finding the documentation (e.g. about sendevent)

Showing 1-15 of 15 messages
Having a lot of problems finding the documentation (e.g. about sendevent) a druid 4/17/09 8:53 AM
Hi,

Is it just me or is it really difficult to get information
about certain Android features?


Currently I wanted to understand, what exactly can be done with the
adb shell command 'sendevent'

I even fail performing a very simple test, which is to press a key in
the emulator.

For debugging and ome other purposes I would like to press keys and
perform touch screen events from the developing system and send them
to either the emulator or a device connected via the adb.

Somehow I am very unfortunate locating the adequate documentation.

Thanks in advance for a good place to start

Re: [android-beginners] Having a lot of problems finding the documentation (e.g. about sendevent) yesk13 4/17/09 10:08 AM
Perhaps this link will get your started, http://developer.android.com/guide/developing/tools/adb.html look for monkey.

This link as well http://developer.android.com/guide/developing/tools/monkey.html
Re: Having a lot of problems finding the documentation (e.g. about sendevent) a druid 4/20/09 4:33 AM
Hi Kent,

Thanks for your answer.
I already saw the documentation for monkey.
However this presses keys randomly.

What I wanted to do is to programatically (via adb shell, or via a
service like vnc server for PCs) pressing non random keys.

The simple first example, that I'd like to try is:
press (and release) the up button once.

I did not find any pointers explaining how to do this:

There seems to be a adb-shell command named 'sendevent', but I found
no documentation at all about the
event types / event numbers etc, that I should provide.


On Apr 17, 7:08 pm, Kent Yip <yes...@gmail.com> wrote:
> Perhaps this link will get your started,http://developer.android.com/guide/developing/tools/adb.htmllook for
> monkey.
>
> This link as wellhttp://developer.android.com/guide/developing/tools/monkey.html
>
> On Fri, Apr 17, 2009 at 8:53 AM, a druid <klausf...@gmail.com> wrote:
>
> > Hi,
>
> > Is it just me or is it really difficult to get information
> > about certain Android features?
>
> > Currently I wanted to understand, what exactly can be done with the
> > adb shell command 'sendevent'
>
> > I even fail performing a very simple test, which is to press a key in
> > the emulator.
>
> > For debugging and ome other purposes I would like to press keys and
> > perform touch screen events from the developing system and send them
> > to either the emulator or a device connected via the adb.
>
> > Somehow I am very unfortunate locating the adequate documentation.
>
> > Thanks in advance for a good place to start
>
>

On Apr 17, 7:08 pm, Kent Yip <yes...@gmail.com> wrote:
> Perhaps this link will get your started,http://developer.android.com/guide/developing/tools/adb.htmllook for
> monkey.
>
> This link as wellhttp://developer.android.com/guide/developing/tools/monkey.html
Re: Having a lot of problems finding the documentation (e.g. about sendevent) swarup 4/21/09 1:49 AM
1) study the output of 'adb shell getevent', get high level idea of
different parameters of keyevent.
2) look at source code of getevent, sendevent command.
3) also another command might interest you: input

P.S.: if you do not know the source code locations, then follow the
below gitweb path:

[platform/system/core.git] /toolbox/sendevent.c
[platform/system/core.git] /toolbox/getevent.c
[platform/frameworks/base.git] /cmds/input/src/com/android/commands/
input/Input.java
Re: [android-beginners] Re: Having a lot of problems finding the documentation (e.g. about sendevent) yesk13 4/21/09 1:02 PM
thank swarup for the insight

i was able to look at the events from emulator, the keycode i different than defined in frameworks/base/core/java/android/view/KeyEvent.java

all i can say is keycode for emulator and real device maybe different.

and i am using SDK version: android-sdk-windows-1.1_r1

here is how to use: sendevent

command format: sendevent device type code value

[command]     [device]             [type]    [code]   [value]
sendevent    /dev/input/event0    1          229      1

/dev/input/event0 is the device to send it to

[type] 1 is unknow for me ( maybe code for physical button on device )

[code] 229 is the MENU button of the emulator

[value] 1 is keydown or press down ( for keyup or up use 0 )

i wrote a batch file for sending the event to the device like below:

adb -s emulator-5554 shell sendevent /dev/input/event0 1 229 1
adb -s emulator-5554 shell sendevent /dev/input/event0 1 229 0

have to use the follow command to simulate a pressing of button ( aka pressing down then let go )

Key Name                 CODE
MENU                       229
HOME                       102
BACK (back button)    158
CALL (call button)       231
END (end call button)  107

now keyboard shown on the emulator

Key Name                 CODE
1                               2
2                               3
3                               4
4                               5
5                               6
6                               7
7                               8
8                               9
9                               10
0                               11
q                               16
w                               17
e                               18
r                                19
t                                20
y                               21
u                               22
i                                23
o                               24
p                               25
a                               30
s                               31
d                               32
f                                33
g                               34
h                               35
j                                36
k                               37
l                                38
DEL (delete key)        14
SHIFT (shift key)        42
z                               44
x                               45
c                               46
v                               47
b                               48
n                               49
m                              50
. (period)                    52
return (enter key)        28
Lt Alt (Left ALT key)    56
SYM                         127
@                             215
Spc (Space key)        57
/                               53
, (comma)                 51
Rt Alt (Right ALT key) 100
Pwr ( Power on/off )     116
Re: Having a lot of problems finding the documentation (e.g. about sendevent) a druid 4/22/09 5:21 AM
Just a tiny comment.

getevent outputs the event values in hexadecimal.
sendevent on the other hand seems to expect decimal values.

In my first tests this was, where I stumbled.
Re: Having a lot of problems finding the documentation (e.g. about sendevent) raj.10788 5/10/09 11:34 PM
Hi Kent Yip,

I found that your post is really useful to the beginners. But here we
can see only mini no of key codes. when you look at the keyevent.java
file you can see a lot of keycodes in that. why those key codes are
not available in this. Can you please tell me where can I find these
key code mappings and list in the Android Source code.

thanks
raj
On Apr 22, 5:21 pm, a druid <klausf...@gmail.com> wrote:
> Just a tiny comment.
>
> getevent outputs the event values in hexadecimal.
> sendevent on the other hand seems to expect decimal values.
>
> In my first tests this was, where I stumbled.
>
> On Apr 21, 10:02 pm, Kent Yip <yes...@gmail.com> wrote:
>
>
>
> > thank swarup for the insight
>
> > i was able to look at theeventsfrom emulator, the keycode i different than
> > defined in frameworks/base/core/java/android/view/KeyEvent.java
>
> > all i can say is keycode for emulator and real device maybe different.
>
> > and i am using SDK version:android-sdk-windows-1.1_r1
>
> > here is how to use: sendevent
>
> > command format: sendevent device type code value
>
> > [command]     [device]             [type]    [code]   [value]
> > sendevent    /dev/input/event0    1          229      1
>
> > /dev/input/event0 is the device to send it to
>
> > [type] 1 is unknow for me ( maybe code for physical button on device )
>
> > [code] 229 is the MENU button of the emulator
>
> > [value] 1 is keydown or press down ( for keyup or up use 0 )
>
> > i wrote a batch file forsendingthe event to the device like below:
> > > > > > performtouchscreeneventsfrom the developing system and send them
> > > > > > to either the emulator or a device connected via the adb.
>
> > > > > > Somehow I am very unfortunate locating the adequate documentation.
>
> > > > > > Thanks in advance for a good place to start
>
> > > > On Apr 17, 7:08 pm, Kent Yip <yes...@gmail.com> wrote:
>
> > > > > Perhaps this link will get your started,
> > >http://developer.android.com/guide/developing/tools/adb.htmllookfor
> > > > > monkey.
>
> > > > > This link as wellhttp://
> > > developer.android.com/guide/developing/tools/monkey.html
>
> > > > > On Fri, Apr 17, 2009 at 8:53 AM, a druid <klausf...@gmail.com> wrote:
>
> > > > > > Hi,
>
> > > > > > Is it just me or is it really difficult to get information
> > > > > > about certainAndroidfeatures?
>
> > > > > > Currently I wanted to understand, what exactly can be done with the
> > > > > > adb shell command 'sendevent'
>
> > > > > > I even fail performing a very simple test, which is to press a key in
> > > > > > the emulator.
>
> > > > > > For debugging and ome other purposes I would like to press keys and
> > > > > > performtouchscreeneventsfrom the developing system and send them
> > > > > > to either the emulator or a device connected via the adb.
>
> > > > > > Somehow I am very unfortunate locating the adequate documentation.
>
> > > > > > Thanks in advance for a good place to start- Hide quoted text -
>
> - Show quoted text -
Re: [android-beginners] Re: Having a lot of problems finding the documentation (e.g. about sendevent) yesk13 5/11/09 12:01 AM
this is the file i was talking about, it is in the android source of cupcake

for more information on how to download the cupcake source goto http://source.android.com/download

code in the attachment ( after u got the source go to: "frameworks/base/core/java/android/view" directory
Re: Having a lot of problems finding the documentation (e.g. about sendevent) raj.10788 5/11/09 12:21 AM
Hi Kent Yip,


I got that. It's working fine. But I found that I can do only key
events. not motion events. Do you have any Idea how to send the touch
events to the device from the PC.

Is ther any possibility in the sendevent to do the same.

thanks
raj

On May 11, 12:01 pm, Kent Yip <yes...@gmail.com> wrote:
> this is the file i was talking about, it is in the android source of cupcake
>
>  KeyEvent.java
> 46KViewDownload
>
> for more information on how to download the cupcake source gotohttp://source.android.com/download
>
> code in the attachment ( after u got the source go to:
> "frameworks/base/core/java/android/view" directory
>
>
>
> > > - Show quoted text -- Hide quoted text -
Re: [android-beginners] Re: Having a lot of problems finding the documentation (e.g. about sendevent) yesk13 5/11/09 1:51 AM
ok, i have taken another look at keyevent on the action performed on the screen

i pressed on one spot on the screen ( pressed then let go )

--------------------------------->x
|
|
|
|
|
|
v
y


what was generated were:

/dev/input/event0: 0003 0000 00000005
/dev/input/event0: 0003 0001 0000001d
/dev/input/event0: 0001 014a 00000001
/dev/input/event0: 0000 0000 00000000
/dev/input/event0: 0001 014a 00000000
/dev/input/event0: 0000 0000 00000000

i am not 100% sure, here is what i think

0003 0000 00000005

is the screen location in the x-position

the type 0003 is the screen type

0000 is the x-coordinate code

00000005 is the pixel (maybe) value
-----------------------------------------------------------------------------

0003 0001 0000001d

is the y-coordinate on the screen

0003 is the screen type

0001 is the y-coordinate code

0000001d is the pixel value

------------------------------------------------------------------------------

so 

/dev/input/event0: 0003 0000 00000005
/dev/input/event0: 0003 0001 0000001d

will be at screen location in pixel x=5, y=21
that just the screen location i have touched, it doesn't have the touch/untouch that would indicate a press on the screen
------------------------------------------------------------------------------

/dev/input/event0: 0001 014a 00000001
/dev/input/event0: 0000 0000 00000000

this would indicate a touch/press down on the screen (i think)
it always show up in pair

0001 is unbeknownst to me

014a is the code for screen i think

00000001 would indicate a touch/press down

-------------------------------------------------------------------------------

/dev/input/event0: 0001 014a 00000000
/dev/input/event0: 0000 0000 00000000

this would indicate a untouch/up on the screen

as 00000000 would indicate untouch/up

-------------------------------------------------------------------------------

all these are from the emulator screen

i'll stop explaining for now, more about dragging across the screen later.
Re: Having a lot of problems finding the documentation (e.g. about sendevent) raj.10788 5/13/09 10:21 PM
Hi Kent,

I tried this one with the sendevent but it's not working. I can't see
any action in the emulator. I have few clarification on the about
solution.

1. From where you got this logs(I mean the logs you got like the oo3
0001 0001d)

2. I used the following code in batch file, but it's not giving any o/
p

    adb shell sendevent /dev/input/event0 0003 0000 00000005
    adb shell sendevent /dev/input/event0 0003 0001 0000001d
    adb shell sendevent /dev/input/event0 0003 014a 00000001
    adb shell sendevent /dev/input/event0 0003 0000 00000000



thanks
raj


On May 11, 1:51 pm, Kent Yip <yes...@gmail.com> wrote:
> ok, i have taken another look at keyevent on the action performed on the
> screen...
>
> read more »
>
> i pressed on one spot on the screen ( pressed then let go )
>
> --------------------------------->x
> |
> |
> |
> |
> |
> |
> v
> y
>
> what was generated were:
>
> /dev/input/event0: 0003 0000 00000005
> /dev/input/event0: 0003 0001 0000001d
> /dev/input/event0: 0001 014a 00000001
> /dev/input/event0: 0000 0000 00000000
> /dev/input/event0: 0001 014a 00000000
> /dev/input/event0: 0000 0000 00000000
>
> i am not 100% sure, here is what i think
>
> 0003 0000 00000005
>
> is the screen location in the x-position
>
> the type 0003 is the screen type
>
> 0000 is the x-coordinate code
>
> 00000005 is the pixel (maybe) value
> ---------------------------------------------------------------------------­--
>
> 0003 0001 0000001d
>
> is the y-coordinate on the screen
>
> 0003 is the screen type
>
> 0001 is the y-coordinate code
>
> 0000001d is the pixel value
>
> ---------------------------------------------------------------------------­---
>
> so
>
> /dev/input/event0: 0003 0000 00000005
> /dev/input/event0: 0003 0001 0000001d
>
> will be at screen location in pixel x=5, y=21
> that just the screen location i have touched, it doesn't have the
> touch/untouch that would indicate a press on the screen
> ---------------------------------------------------------------------------­---
>
> /dev/input/event0: 0001 014a 00000001
> /dev/input/event0: 0000 0000 00000000
>
> this would indicate a touch/press down on the screen (i think)
> it always show up in pair
>
> 0001 is unbeknownst to me
>
> 014a is the code for screen i think
>
> 00000001 would indicate a touch/press down
>
> ---------------------------------------------------------------------------­----
>
> /dev/input/event0: 0001 014a 00000000
> /dev/input/event0: 0000 0000 00000000
>
> this would indicate a untouch/up on the screen
>
> as 00000000 would indicate untouch/up
>
> ---------------------------------------------------------------------------­----
>
> all these are from the emulator screen
>
> i'll stop explaining for now, more about dragging across the screen later.
>
>
>
> On Mon, May 11, 2009 at 12:21 AM, rk <raj.10...@gmail.com> wrote:
>
> > Hi Kent Yip,
>
> > > > > > > > > > the emulator.- Hide quoted text -
Re: [android-beginners] Re: Having a lot of problems finding the documentation (e.g. about sendevent) yesk13 5/13/09 11:37 PM
Hi rk,



>1. From where you got this logs(I mean the logs you got like the oo3
>0001 0001d)

you can get those events by doing a adb -s emulator-5554 shell getevent
in the command prompt


>2. I used the following code in batch file, but it's not giving any o/
>p
>
>  adb shell sendevent /dev/input/event0 0003 0000 00000005
>  adb shell sendevent /dev/input/event0 0003 0001 0000001d
>  adb shell sendevent /dev/input/event0 0003 014a 00000001
>  adb shell sendevent /dev/input/event0 0003 0000 00000000

sorry i wasn't clear on the sendevent command
sendevent expects integer values not hex value you have entered

your first two commands should look like this

adb shell sendevent /dev/input/event0 3 0 5
adb shell sendevent /dev/input/event0 3 1 29

as for the last two commands you did something wrong with it

as you touch the screen on the device it has to know the location and what happen there
as android wants to know what did you do on that location

your 0003 014a 00000001 was incorrect

after the location u sent you need to indicate what's happening

0001 014a 00000001
0000 0000 00000000

the above would indicate a touch at the location
however to do something useful you will want to untouch which indicate a tap gesture on the screen

the untouch part looks like this:

0001 014a 00000000
0000 0000 00000000

so to tap at 5 pixel from the left and 29 pixel from top top of the screen you would use this

adb shell sendevent /dev/input/event0 3 0 5
adb shell sendevent /dev/input/event0 3 1 29
adb shell sendevent /dev/input/event0 1 330 1
adb shell sendevent /dev/input/event0 0 0 0
adb shell sendevent /dev/input/event0 1 330 0
adb shell sendevent /dev/input/event0 0 0 0

remeber sendevent expects integer values
if it happens that a program icon in at that location the above code will indicate a tap on the program which android will launch it


here is my commands for lauching a Messaging program on the emulator. the messaging program is located at x=39, y=262 on my emulator. after executing the code the Messaging program launched!

adb shell sendevent /dev/input/event0 3 0 39
adb shell sendevent /dev/input/event0 3 1 262
adb shell sendevent /dev/input/event0 1 330 1
adb shell sendevent /dev/input/event0 0 0 0
adb shell sendevent /dev/input/event0 1 330 0
adb shell sendevent /dev/input/event0 0 0 0

if you want to know more about what's happening on the screen or when you press something get used to looking at getevent command

dragging ( flick on the screen ) on the screen is a little more difficult, but not too different from the above commands
for example flicking/dragging left or right on the android desktop/home screen will slide the desktop to the direction you flicked/dragged

hope this time i explained more clearly.

sorry for being long winded
Re: Having a lot of problems finding the documentation (e.g. about sendevent) raj.10788 5/14/09 1:28 AM
Hi Kent,

It's really great tutorial. It's working fine. But in the following
code what the 330 means. and also that we are here giving the dvice

> adb shell sendevent /dev/input/event0 3 0 39
> adb shell sendevent /dev/input/event0 3 1 262
> adb shell sendevent /dev/input/event0 1 330 1

what the 330 means in the above code(will it do touch on the current
location[39,262]...!!!) and also what the below code will do with all
0 values (will it do the untouch..!!!)?


> adb shell sendevent /dev/input/event0 0 0 0
> adb shell sendevent /dev/input/event0 1 330 0
> adb shell sendevent /dev/input/event0 0 0 0
>


thanks
raj

Re: [android-beginners] Re: Having a lot of problems finding the documentation (e.g. about sendevent) yesk13 5/14/09 10:12 AM
think of 330 as a finger is touching on the screen.


> adb shell sendevent /dev/input/event0 1 330 0
> adb shell sendevent /dev/input/event0 0 0 0

the commands goes in pairs

a tap on the screen will have 4 event actions

1 330 1, follow by 0 0 0 always they go in pair
then 1 330 0, follow by 0 0 0 always

1 330 1
0 0 0
1 330 0
0 0 0

here is one way to think of the touch and untouch part, think button, there's a press down part and there is a up part, which goes together to indicate a press on the button.

1 330 1<
0 0 0

the 1 at the end would indicate a touch ( think button; press down )

and

1 330 0<
0 0 0

the 0 at the end would indicate a untouch ( think button; letting go of the button )
Re: Having a lot of problems finding the documentation (e.g. about sendevent) raj.10788 5/14/09 10:21 PM
yeah.. I understood that part. but the problem here for me is this.
But when we give this 330 as input where this 330 wil be proscess. for
example if we give key_code there it will compare it some where with
the keyboard maping and will give you the results. like that where
this 330 will be compared.

But at the same time one more question is, Are you testing this one on
the Emulator or G1 Device. Is it working in the device,


thanks
raj

On May 14, 10:12 pm, Kent Yip <yes...@gmail.com> wrote:
> think of 330 as a finger is touching on the screen.
>
> > adb shell sendevent /dev/input/event0 1 330 0
> > adb shell sendevent /dev/input/event0 0 0 0
>
> the commands goes in pairs
>
> a tap on the screen will have 4 event actions
>
> 1 330 1, follow by 0 0 0 always they go in pair
> then 1 330 0, follow by 0 0 0 always
>
> 1 330 1
> 0 0 0
> 1 330 0
> 0 0 0
>
> here is one way to think of the touch and untouch part, think button,
> there's a press down part and there is a up part, which goes together to
> indicate a press on the button.
>
> 1 330 1<
> 0 0 0
>
> the 1 at the end would indicate a touch ( think button; press down )
>
> and
>
> 1 330 0<
> 0 0 0
>
> the 0 at the end would indicate a untouch ( think button; letting go of the
> button )
>
>
>
> On Thu, May 14, 2009 at 1:28 AM, rk <raj.10...@gmail.com> wrote:
>
> > Hi Kent,
>
> > It's really great tutorial. It's working fine. But in the following
> > code what the 330 means. and also that we are here giving the dvice
>
> > > adb shell sendevent /dev/input/event0 3 0 39
> > > adb shell sendevent /dev/input/event0 3 1 262
> > > adb shell sendevent /dev/input/event0 1 330 1
>
> > what the 330 means in the above code(will it do touch on the current
> > location[39,262]...!!!) and also what the below code will do with all
> > 0 values (will it do the untouch..!!!)?
>
> > > adb shell sendevent /dev/input/event0 0 0 0
> > > adb shell sendevent /dev/input/event0 1 330 0
> > > adb shell sendevent /dev/input/event0 0 0 0
>
> > thanks
> > raj- Hide quoted text -