I'm building Android 5.1 with kernel version 3.10.52. Everything goes fine before I attached a hdmi touch screen (http://www.waveshare.net/wiki/7inch_HDMI_LCD_(B)). HDMI output was fine and it's landscape, and touch function was working. But the direction of touch function is different from HDMI output. Touch screen is functioned via USB port by hid-usb driver.
In Linux dist, we usually use Xorg and the libinput config to calibrate. But now it's on Android, and I really don't know how to rotate touch screen.
Could anyone help?
I am having a problem with running Android 7.1 on a virtual machine inside OpenNebula (QEMU/KVM) - more specifically, a problem with mouse integration.
When creating a machine, I tried setting the input two ways:
1. Mouse/USB
2. Tablet/USB
In case 1. the mouse cursor is not in the location it should be (more to the left/right/up/down, depending on speed of mouse movement).
In case2. I have to hold left-click to move the cursor - this makes it move but also works as holding down the finger on touch screen.
My question is: is there a way to set the correct input type, so I can use the mouse normally when working with the system?
Info: It was not a problem in Android 4.4, where the Table/USB option worked correctly.
I've an android TV box (jellybean) to which I have connected a 17'' eGalaxy touchscreen. It moves the pointer but only with in a small are. I've created the necessary idc file but don't know the right configuration to put in it.
You probably just need to run a touch screen calibration app.
Regards
Rasmus
There is an API to detect if Android 4.x (ICS or JB) is in touchscreen or mouse mode. Android can actually go from one mode to the other: if you are in mouse mode (a cursor is displayed) and you do a touchscreen press, the mouse will disappear. In an apk application, I would like to query the state of mouse vs. touchscreen. This feature is only for > 4.0. Does anyone know this API?
As suggested by nandeesh in the comment section, "isintouchmode" is the answer to this question.
I've started creating a MonkeyRunner script. This is going ok, but whenever I add a MonkeyDevice::touch command, I have to determine the input coordinates by trial-and-error. Basically I guess at the coordinates I want to touch and see if those coordinates result in the button touch I'm trying to test. That works, but it's a slow process. Is there anyway to determine the coordinates of UI controls, perhaps from the layout XML files?
I found how to do it. Use the Pixel Perfect view within Eclipse to determine the x & y coordinates of the UI element. Here's a quick overview:
1) Eclipse must be running
2) Your Android device must be connected (either the real device via ADB, or the emulator)
3) Run the hierarchy viewer (in /tools)
4) Select "Inspect screenshot"
The Pixel Perfect view will launch automatically. Just place the cross-hairs on the UI element. The x and y coordinates, along with the RGB values, are displayed below.
Here's the URL that got me started: http://developer.android.com/guide/developing/debugging/debugging-ui.html#pixelperfect
This post (monkeyrunner: interacting with views), may give you and idea of how to obtain the View's coordinates using AndroidViewClient.
Most of the Android versions you can enable pointer location in Settings->Developer Options. Once you enable it, it is easy to find out the (x,y) coordinates.
you can also use the HierarchyViewer tool in your AndroidSDK>tools folder to take screenshots of the current screen and examine that image pixel by pixel to get exact coordinates.
For devices older than Android 4.0, see the paragraph following this one. Android 4.0 and later include Settings->Developer options->Pointer location toggle which toggles a transparent ribbon across the top of the device screen with coordinates, velocities and touch-pressure readings including swipe tracks and x/y crosshairs for the current touch location. This is a lot easier than using alternatives such as Monkey Recorder and other means. In Android 4.2 and later, Developer options is hidden from the Settings menu and must be enabled by going to Settings->About tablet and tapping on Build number seven times. One can only presume that Android hid Developer options because of the increasingly user-experience-affecting options it contains and the number of consumer calls/complaints to device makers from people who played with it or whose children played with it.
In older versions which may not include a Pointer location toggle, there is an app on the Play Store (aka Android Market), Developers Tools. See link here: https://play.google.com/store/apps/details?id=com.ggb.development
It will show up with a gear icon and the caption Dev Tools on a device and provide similar functionality which Dev Tools in an AVD (Android Virtual Device) has. That includes Dev Tools ->Development settings>No Pointer Location/Pointer Location radio button toggle. Setting that toggle to Pointer Location provides the exact same functionality built-in with Android 4.0 and later. The same application also has a more limited pointer setting at Dev Tools->Pointer Location which limits pointer location to only a blank screen.
Enjoy!
Create a xyz.py file with below code and connect the device and run it in terminal like monkeyrunner xyz.py, then you will get your device in pc, then u click on any button in the recorder it will give you the coordinates, after that explore it to any file and you can use the coordinates.
from com.android.monkeyrunner import MonkeyRunner as mr
from com.android.monkeyrunner.recorder import MonkeyRecorder as recorder
device = mr.waitForConnection()
recorder.start(device)
I found an adb approach. Use adb shell getevent -l to get a list of events, grep for ABS_MT_POSITION (gets the line with touch events in hex) and finally use awk to get the relevant hex values, strip them of zeros and convert hex to decimal that monkey runner uses. This is all done with the following:
adb shell getevent -l | grep ABS_MT_POSITION --line-buffered | awk '{a = substr($0,54,8); sub(/^0+/, "", a); b = sprintf("0x%s",a); printf("%d\n",strtonum(b))}'
This continuously prints the x and y coordinates in the terminal only when you press on the device.