public override bool OnGenericMotionEvent(MotionEvent e) { InputDevice device = e.Device; if (device != null && device.Id == current_device_id) { if (IsGamepad(device)) { var lx = GetCenteredAxis(e, device, AxesMapping.OrdinalValueAxis(Preferences.lxAxis)); //axes[0]; var ly = -GetCenteredAxis(e, device, AxesMapping.OrdinalValueAxis(Preferences.lyAxis)); //-axes[1]; var rx = GetCenteredAxis(e, device, AxesMapping.OrdinalValueAxis(Preferences.rxAxis)); // axes[2]; var ry = -GetCenteredAxis(e, device, AxesMapping.OrdinalValueAxis(Preferences.ryAxis)); //-axes[3]; Tello.controllerState.setAxis(lx, ly, rx, ry); Tello.sendControllerUpdate(); updateOnScreenJoyVisibility(); hatAxisX = GetCenteredAxis(e, device, AxesMapping.AXIS_HAT_X); hatAxisY = GetCenteredAxis(e, device, AxesMapping.AXIS_HAT_Y); //do flips only in speed mode. if (Tello.controllerState.speed > 0) { if (hatAxisY > 0.9f && (DateTime.Now - lastFlip).TotalMilliseconds > 600) { lastFlip = DateTime.Now; Tello.doFlip(2); } if (hatAxisY < -0.9f && (DateTime.Now - lastFlip).TotalMilliseconds > 600) { lastFlip = DateTime.Now; Tello.doFlip(0); } if (hatAxisX > 0.9f && (DateTime.Now - lastFlip).TotalMilliseconds > 600) { lastFlip = DateTime.Now; Tello.doFlip(3); } if (hatAxisX < -0.9f && (DateTime.Now - lastFlip).TotalMilliseconds > 600) { lastFlip = DateTime.Now; Tello.doFlip(1); } } RunOnUiThread(() => { TextView joystat = FindViewById <TextView>(Resource.Id.joystick_state); //var dataStr = string.Join(" ", buttons); joystat.Text = string.Format("JOY 0:{0: 0.00;-0.00} 1:{1: 0.00;-0.00} 2:{2: 0.00;-0.00} 3:{3: 0.00;-0.00} 4:{4: 0.00;-0.00} ",// BTN: " + dataStr, GetCenteredAxis(e, device, AxesMapping.OrdinalValueAxis(0)), GetCenteredAxis(e, device, AxesMapping.OrdinalValueAxis(1)), GetCenteredAxis(e, device, AxesMapping.OrdinalValueAxis(2)), GetCenteredAxis(e, device, AxesMapping.OrdinalValueAxis(3)), GetCenteredAxis(e, device, AxesMapping.OrdinalValueAxis(4)) ); }); //controller_view.Invalidate(); return(true); } } return(base.OnGenericMotionEvent(e)); }