Example #1
0
  private boolean handleOnTouch(View v, MotionEvent event) {
    int action = event.getAction() & MotionEvent.ACTION_MASK;
    int x1 = 0;
    int y1 = 0;
    int x2 = 0;
    int y2 = 0;
    switch (action) {
        // define the region the touch event is beginning in
      case MotionEvent.ACTION_DOWN:
        {
          motorHandler.calcMotorSpeeds(x1, y1, x2, y2);
          break;
        }
        // touch has left screen - take note of this
      case MotionEvent.ACTION_UP:
        {
          motorHandler.calcMotorSpeeds(x1, y1, x2, y2);
          break;
        }

        // define the region the touch event is beginning in
      case MotionEvent.ACTION_POINTER_DOWN:
        {
          motorHandler.calcMotorSpeeds(x1, y1, x2, y2);
          break;
        }

        // touch has left screen - take note of this
      case MotionEvent.ACTION_POINTER_UP:
        {
          motorHandler.calcMotorSpeeds(x1, y1, x2, y2);
          break;
        }

      case MotionEvent.ACTION_MOVE:
        {
          x1 = (int) FloatMath.floor(event.getX(0));
          y1 = (int) FloatMath.floor(event.getY(0));
          if (event.getPointerCount() > 1) {
            x2 = (int) FloatMath.floor(event.getX(1));
            y2 = (int) FloatMath.floor(event.getY(1));
          }
          motorHandler.calcMotorSpeeds(x1, y1, x2, y2);
          break;
        }
    }
    return true;
  }
Example #2
0
 public void Connect() {
   socketHandler =
       new SocketHandler(ctx, motorHandler.getMotorFirst(), motorHandler.getMotorSecond());
   socketHandler.execute("");
 }