Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

Is there any documentation on the format of the getevent and sendevent shell commands? specifically the ones for touchevents. or is this device-dependent?

it is a bit hard to guess what those ids are doing.

share|improve this question

2 Answers 2

There is some documentation on the AOSP site:

Plus several Howtos like e.g.

However, the answer to your question on Google Groups states:

No, this is fairly device-dependent. getevent prints a summary of all the devices so you know what those are. The data generated for a device are generally the Linux kernel's event protocol, so you can look there for further help, but there is no guarantee that a particular device will be following those conventions.

share|improve this answer
    
Not all of them work... for security reasons, you cannot inject touch events/keyboard events into an activity.. unless the app is system-signed :) –  t0mm13b Aug 14 '12 at 14:34
    
Well -- the question was about "any documentation" -- not whether something works :) But I'd say your commend shall be added to "any documentation", as it's a useful hint! –  Izzy Aug 14 '12 at 14:38

That will depend on the factors for the kernel in question:

  • If it has uinput enabled then that's good...
  • Touchscreen drivers, some initialize themselves to reside anywhere within /dev/input/eventX
  • How the kernel handles the input, for the hardware buttons

If this passes the three criteria above, then by reading certain events from /dev/input/eventX where X is a number - this will be determined at boot-time, depending on the ordering of loading the appropriate drivers. This will vary but you can try it out and see:

  • adb shell cat /dev/input/eventX (where X is a number, you will need to know before hand!)
  • depending on which event it is then you can see funny things happening on the screen based on the appropriate /dev/input/eventX being outputted.

The values are in encoded form, based on the kernel's input structure - struct input_event which can be found in most kernel sources under include/linux/input.h.

Be careful! Depending on the touchscreen driver used, some, do not actually return the proper coordinates - that's left as an exercise :)

On the Samsung GT-i5500 running Eclair, /dev/input/event2 is the touchscreen and the values are in encoded form, this is not to be taken for granted as that will depend on what touchscreen driver is used. On the Sony ST15i, running ICS, its, surprisingly, the same! But on the Zte Blade, its /dev/input/event1.

Incidentally, I did some work about a year ago, on creating a touchscreen for ClockWorkMod Recovery which can be found over on Modaco.

The real painful part was trying to determine which event was the touchscreen and act on it accordingly which was ported over to Zte Skate, Zte Racer and Samsung GT-i5500.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.