Skip to content

Commit

Permalink
feat: bring back system pointer (uinput virtual tablet)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xtr126 committed Nov 5, 2023
1 parent 5042a8f commit f7198b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/src/main/java/xtr/keymapper/server/Input.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class Input {
private long lastTouchDown;
private final SmoothScroll scrollHandler = new SmoothScroll();
private Handler mHandler;
public int pointerCount;

private void initPointers() {
for (int i = 0; i < PointersState.MAX_POINTERS; ++i) {
Expand Down Expand Up @@ -58,7 +59,7 @@ public void injectTouch(int action, int pointerId, float pressure, float x, floa
pointer.setPressure(pressure);
pointer.setUp(action == MotionEvent.ACTION_UP);

int pointerCount = pointersState.update(pointerProperties, pointerCoords);
pointerCount = pointersState.update(pointerProperties, pointerCoords);

if (pointerCount == 1) {
if (action == MotionEvent.ACTION_DOWN) {
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/xtr/keymapper/server/InputService.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class InputService implements IInputInterface {
private final IRemoteServiceCallback mCallback;
final int supportsUinput;
boolean stopEvents = false;
boolean pointerUp = false;
private final boolean isWaylandClient;

public InputService(KeymapProfile profile, KeymapConfig keymapConfig, IRemoteServiceCallback mCallback, int screenWidth, int screenHeight, boolean isWaylandClient){
Expand All @@ -40,9 +41,11 @@ public InputService(KeymapProfile profile, KeymapConfig keymapConfig, IRemoteSer
public void injectEvent(float x, float y, int action, int pointerId) {
switch (action) {
case UP:
pointerUp = true;
input.injectTouch(MotionEvent.ACTION_UP, pointerId, 0.0f, x, y);
break;
case DOWN:
pointerUp = false;
input.injectTouch(MotionEvent.ACTION_DOWN, pointerId, 1.0f, x, y);
break;
case MOVE:
Expand Down Expand Up @@ -89,13 +92,17 @@ public void moveCursorX(float x) {
mCallback.cursorSetX((int) x);
} catch (RemoteException ignored) {
}
if (input.pointerCount < 1) cursorSetX((int) x);
else if (input.pointerCount == 1 && pointerUp) cursorSetX((int) x);
}

public void moveCursorY(float y) {
try {
mCallback.cursorSetY((int) y);
} catch (RemoteException ignored) {
}
if (input.pointerCount < 1) cursorSetY((int) y);
else if (input.pointerCount == 1 && pointerUp) cursorSetY((int) y);
}

public void reloadKeymap() {
Expand Down

0 comments on commit f7198b0

Please sign in to comment.