/* Get the touch screen X and Y positions values.  */
int32_t SX8651_GetState(SX8651_Object_t *pObj, SX8651_State_t *State)
/* Get the touch screen X and Y positions values.  */
int32_t SX8651_GetState(SX8651_Object_t *pObj, SX8651_State_t *State)
{
  int32_t ret = SX8651_OK;
  uint8_t data[4];
  State->TouchDetected = 0;
  State->TouchX = 0;
  State->TouchY = 0;
  if (SX8651_DetectTouch(pObj) == 1)
  {
    State->TouchDetected = 1;
    if (sx8651_read_data(&pObj->Ctx, data, (uint16_t)sizeof(data)) != SX8651_OK)
    {
      ret = SX8651_ERROR;
    }
    else
    {
      State->TouchX = ((data[0] & 0xF) << 8) | data[1];
      State->TouchY = ((data[2] & 0xF) << 8) | data[3];
    }
  }
  return ret;
}