mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-22 18:07:55 +00:00
Send a stop pointer message so we don't need to wait for timeout
This commit is contained in:
parent
377d2ddcd1
commit
16362ae8f6
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user