diff --git a/src/org/kde/kdeconnect/Plugins/PresenterPlugin/PresenterActivity.java b/src/org/kde/kdeconnect/Plugins/PresenterPlugin/PresenterActivity.java index f36aca49..c7999361 100644 --- a/src/org/kde/kdeconnect/Plugins/PresenterPlugin/PresenterActivity.java +++ b/src/org/kde/kdeconnect/Plugins/PresenterPlugin/PresenterActivity.java @@ -56,16 +56,12 @@ public class PresenterActivity extends AppCompatActivity implements SensorEventL private PresenterPlugin plugin; private SensorManager sensorManager; - private float xPos, yPos; static final float SENSITIVITY = 0.05f; //TODO: Make configurable? public void gyroscopeEvent(SensorEvent event) { - xPos += -event.values[2] * SENSITIVITY; - yPos += -event.values[0] * SENSITIVITY; - - xPos = clamp(xPos, -1.f, 1.f); - yPos = clamp(yPos, -1.f, 1.f); + float xPos = -event.values[2] * SENSITIVITY; + float yPos = -event.values[0] * SENSITIVITY; plugin.sendPointer(xPos, yPos); } diff --git a/src/org/kde/kdeconnect/Plugins/PresenterPlugin/PresenterPlugin.java b/src/org/kde/kdeconnect/Plugins/PresenterPlugin/PresenterPlugin.java index ff7b0af5..9bec7a08 100644 --- a/src/org/kde/kdeconnect/Plugins/PresenterPlugin/PresenterPlugin.java +++ b/src/org/kde/kdeconnect/Plugins/PresenterPlugin/PresenterPlugin.java @@ -116,10 +116,16 @@ public class PresenterPlugin extends Plugin { device.sendPacket(np); } - public void sendPointer(float percentX, float percentY) { - NetworkPacket np = new NetworkPacket(PACKET_TYPE_PRESENTER); - np.set("px", percentX); - np.set("py", percentY); + public void sendPointer(float xDelta, float yDelta) { + NetworkPacket np = device.getAndRemoveUnsentPacket(NetworkPacket.PACKET_REPLACEID_PRESENTERPOINTER); + if (np == null) { + np = new NetworkPacket(PACKET_TYPE_PRESENTER); + } else { + xDelta += np.getInt("px"); + yDelta += np.getInt("px"); + } + np.set("px", xDelta); + np.set("py", yDelta); device.sendPacket(np, NetworkPacket.PACKET_REPLACEID_PRESENTERPOINTER); }