mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-28 20:57:42 +00:00
parent
3043ca5d05
commit
b54e2ea36e
@ -10,6 +10,9 @@ import org.kde.kdeconnect.Device;
|
|||||||
import org.kde.kdeconnect_tp.R;
|
import org.kde.kdeconnect_tp.R;
|
||||||
|
|
||||||
public class MousePadActivity extends Activity implements GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {
|
public class MousePadActivity extends Activity implements GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {
|
||||||
|
|
||||||
|
private final static float MinDistanceToSendScroll = 2.5f;
|
||||||
|
|
||||||
private float mPrevX;
|
private float mPrevX;
|
||||||
private float mPrevY;
|
private float mPrevY;
|
||||||
private float mCurrentX;
|
private float mCurrentX;
|
||||||
@ -17,6 +20,8 @@ public class MousePadActivity extends Activity implements GestureDetector.OnGest
|
|||||||
|
|
||||||
boolean isScrolling = false;
|
boolean isScrolling = false;
|
||||||
|
|
||||||
|
float accumulatedDistanceY = 0;
|
||||||
|
|
||||||
private String deviceId;
|
private String deviceId;
|
||||||
|
|
||||||
private GestureDetector mDetector;
|
private GestureDetector mDetector;
|
||||||
@ -91,16 +96,27 @@ public class MousePadActivity extends Activity implements GestureDetector.OnGest
|
|||||||
if (e2.getPointerCount() <= 1) {
|
if (e2.getPointerCount() <= 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
isScrolling = true;
|
isScrolling = true;
|
||||||
BackgroundService.RunCommand(this, new BackgroundService.InstanceCallback() {
|
|
||||||
@Override
|
accumulatedDistanceY += distanceY;
|
||||||
public void onServiceStart(BackgroundService service) {
|
if (accumulatedDistanceY > MinDistanceToSendScroll || accumulatedDistanceY < -MinDistanceToSendScroll)
|
||||||
Device device = service.getDevice(deviceId);
|
{
|
||||||
MousePadPlugin mousePadPlugin = (MousePadPlugin)device.getPlugin("plugin_mousepad");
|
final float scrollToSendY = accumulatedDistanceY;
|
||||||
if (mousePadPlugin == null) return;
|
|
||||||
mousePadPlugin.sendScroll(distanceX, distanceY);
|
BackgroundService.RunCommand(this, new BackgroundService.InstanceCallback() {
|
||||||
}
|
@Override
|
||||||
});
|
public void onServiceStart(BackgroundService service) {
|
||||||
|
Device device = service.getDevice(deviceId);
|
||||||
|
MousePadPlugin mousePadPlugin = (MousePadPlugin)device.getPlugin("plugin_mousepad");
|
||||||
|
if (mousePadPlugin == null) return;
|
||||||
|
mousePadPlugin.sendScroll(0, scrollToSendY);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
accumulatedDistanceY = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user