Rate This Document
Findability
Accuracy
Completeness
Readability

Data Injection

Different from data output, the InjectData API needs to be invoked for data input. You can specify data using the SEND_TOUCH_EVENT and SEND_KEY_EVENT command words in the VmiCmdTouch enumeration and inject data to the server through the InjectData API. The following is an example:

VmiDataType module = TOUCH;
VmiCmd cmd = SEND_TOUCH_EVENT;
VmiTouchInputData touchData;
uint8_t* data = &touchData;
InjectData(module, cmd, data, sizeof(VmiTouchInputData));

VmiDataType module = TOUCH;
VmiCmd cmd = SEND_KEY_EVENT;
VmiKeyInputData keyData;
uint8_t* data = &keyData;
InjectData(module, cmd, data, sizeof(VmiKeyInputData));
  • The server performs limited verification on touch data, for example, determining whether a touch point in the touch data is within an effective area. However, the server cannot distinguish abnormal data caused by an abnormal behavior. For example, a finger is lifted from the client screen but the client sends a Down event (which should be an UP event). Therefore, pay attention to this issue when writing client code.
  • On some mobile phone models (vivo phones detected), if three or more fingers press the screen at the same time or in sequence at a short interval, the client sends an EVENT_CANCEL event. As a result, the server resets the status of all touch points, causing a touch control failure. This issue does not occur if the interval between finger pressing is longer.