Commit 16362ae8 authored by Matthijs Tijink's avatar Matthijs Tijink

Send a stop pointer message so we don't need to wait for timeout

parent 377d2ddc
......@@ -85,13 +85,12 @@ public class PresenterActivity extends AppCompatActivity implements SensorEventL
findViewById(R.id.pointer_button).setVisibility(View.VISIBLE);
findViewById(R.id.pointer_button).setOnTouchListener((v, event) -> {
if(event.getAction() == MotionEvent.ACTION_DOWN){
yPos = 0;
xPos = 0;
sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE), SensorManager.SENSOR_DELAY_GAME);
v.performClick(); // The linter complains if this is not called
}
else if (event.getAction() == MotionEvent.ACTION_UP) {
sensorManager.unregisterListener(this);
plugin.stopPointer();
}
return true;
});
......
......@@ -24,6 +24,7 @@ package org.kde.kdeconnect.Plugins.PresenterPlugin;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Network;
import android.os.Handler;
import android.os.Message;
import android.view.KeyEvent;
......@@ -129,4 +130,10 @@ public class PresenterPlugin extends Plugin {
device.sendPacket(np, NetworkPacket.PACKET_REPLACEID_PRESENTERPOINTER);
}
public void stopPointer() {
device.getAndRemoveUnsentPacket(NetworkPacket.PACKET_REPLACEID_PRESENTERPOINTER);
NetworkPacket np = new NetworkPacket(PACKET_TYPE_PRESENTER);
np.set("stop", true);
device.sendPacket(np);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment