Implement horizontal scrolling with Sunshine

This commit is contained in:
Cameron Gutman 2023-02-20 19:56:01 -06:00
parent 91dd7b7049
commit f4df0714b5
7 changed files with 42 additions and 14 deletions

View File

@ -1521,6 +1521,7 @@ public class Game extends Activity implements SurfaceHolder.Callback,
if (event.getActionMasked() == MotionEvent.ACTION_SCROLL) { if (event.getActionMasked() == MotionEvent.ACTION_SCROLL) {
// Send the vertical scroll packet // Send the vertical scroll packet
conn.sendMouseHighResScroll((short)(event.getAxisValue(MotionEvent.AXIS_VSCROLL) * 120)); conn.sendMouseHighResScroll((short)(event.getAxisValue(MotionEvent.AXIS_VSCROLL) * 120));
conn.sendMouseHighResHScroll((short)(event.getAxisValue(MotionEvent.AXIS_HSCROLL) * 120));
} }
if ((changedButtons & MotionEvent.BUTTON_PRIMARY) != 0) { if ((changedButtons & MotionEvent.BUTTON_PRIMARY) != 0) {
@ -2187,10 +2188,15 @@ public class Game extends Activity implements SurfaceHolder.Callback,
} }
@Override @Override
public void mouseScroll(byte amount) { public void mouseVScroll(byte amount) {
conn.sendMouseScroll(amount); conn.sendMouseScroll(amount);
} }
@Override
public void mouseHScroll(byte amount) {
conn.sendMouseHScroll(amount);
}
@Override @Override
public void keyboardEvent(boolean buttonDown, short keyCode) { public void keyboardEvent(boolean buttonDown, short keyCode) {
short keyMap = keyboardTranslator.translate(keyCode, -1); short keyMap = keyboardTranslator.translate(keyCode, -1);

View File

@ -9,6 +9,7 @@ public interface EvdevListener {
void mouseMove(int deltaX, int deltaY); void mouseMove(int deltaX, int deltaY);
void mouseButtonEvent(int buttonId, boolean down); void mouseButtonEvent(int buttonId, boolean down);
void mouseScroll(byte amount); void mouseVScroll(byte amount);
void mouseHScroll(byte amount);
void keyboardEvent(boolean buttonDown, short keyCode); void keyboardEvent(boolean buttonDown, short keyCode);
} }

View File

@ -513,7 +513,13 @@ public class NvConnection {
public void sendMouseScroll(final byte scrollClicks) { public void sendMouseScroll(final byte scrollClicks) {
if (!isMonkey) { if (!isMonkey) {
MoonBridge.sendMouseScroll(scrollClicks); MoonBridge.sendMouseHighResScroll((short)(scrollClicks * 120)); // WHEEL_DELTA
}
}
public void sendMouseHScroll(final byte scrollClicks) {
if (!isMonkey) {
MoonBridge.sendMouseHighResHScroll((short)(scrollClicks * 120)); // WHEEL_DELTA
} }
} }
@ -523,6 +529,12 @@ public class NvConnection {
} }
} }
public void sendMouseHighResHScroll(final short scrollAmount) {
if (!isMonkey) {
MoonBridge.sendMouseHighResHScroll(scrollAmount);
}
}
public void sendUtf8Text(final String text) { public void sendUtf8Text(final String text) {
if (!isMonkey) { if (!isMonkey) {
MoonBridge.sendUtf8Text(text); MoonBridge.sendUtf8Text(text);

View File

@ -307,12 +307,12 @@ public class MoonBridge {
short leftStickX, short leftStickY, short leftStickX, short leftStickY,
short rightStickX, short rightStickY); short rightStickX, short rightStickY);
public static native void sendMouseScroll(byte scrollClicks);
public static native void sendKeyboardInput(short keyMap, byte keyDirection, byte modifier, byte flags); public static native void sendKeyboardInput(short keyMap, byte keyDirection, byte modifier, byte flags);
public static native void sendMouseHighResScroll(short scrollAmount); public static native void sendMouseHighResScroll(short scrollAmount);
public static native void sendMouseHighResHScroll(short scrollAmount);
public static native void sendUtf8Text(String text); public static native void sendUtf8Text(String text);
public static native String getStageName(int stage); public static native String getStageName(int stage);

View File

@ -52,13 +52,13 @@ Java_com_limelight_nvstream_jni_MoonBridge_sendKeyboardInput(JNIEnv *env, jclass
} }
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_com_limelight_nvstream_jni_MoonBridge_sendMouseScroll(JNIEnv *env, jclass clazz, jbyte scrollClicks) { Java_com_limelight_nvstream_jni_MoonBridge_sendMouseHighResScroll(JNIEnv *env, jclass clazz, jshort scrollAmount) {
LiSendScrollEvent(scrollClicks); LiSendHighResScrollEvent(scrollAmount);
} }
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_com_limelight_nvstream_jni_MoonBridge_sendMouseHighResScroll(JNIEnv *env, jclass clazz, jshort scrollAmount) { Java_com_limelight_nvstream_jni_MoonBridge_sendMouseHighResHScroll(JNIEnv *env, jclass clazz, jshort scrollAmount) {
LiSendHighResScrollEvent(scrollAmount); LiSendHighResHScrollEvent(scrollAmount);
} }
JNIEXPORT void JNICALL JNIEXPORT void JNICALL

View File

@ -38,7 +38,8 @@ public class EvdevCaptureProvider extends InputCaptureProvider {
public void run() { public void run() {
int deltaX = 0; int deltaX = 0;
int deltaY = 0; int deltaY = 0;
byte deltaScroll = 0; byte deltaVScroll = 0;
byte deltaHScroll = 0;
// Bind a local listening socket for evdevreader to connect to // Bind a local listening socket for evdevreader to connect to
try { try {
@ -115,9 +116,13 @@ public class EvdevCaptureProvider extends InputCaptureProvider {
listener.mouseMove(deltaX, deltaY); listener.mouseMove(deltaX, deltaY);
deltaX = deltaY = 0; deltaX = deltaY = 0;
} }
if (deltaScroll != 0) { if (deltaVScroll != 0) {
listener.mouseScroll(deltaScroll); listener.mouseVScroll(deltaVScroll);
deltaScroll = 0; deltaVScroll = 0;
}
if (deltaHScroll != 0) {
listener.mouseHScroll(deltaHScroll);
deltaHScroll = 0;
} }
break; break;
@ -129,8 +134,11 @@ public class EvdevCaptureProvider extends InputCaptureProvider {
case EvdevEvent.REL_Y: case EvdevEvent.REL_Y:
deltaY = event.value; deltaY = event.value;
break; break;
case EvdevEvent.REL_HWHEEL:
deltaHScroll = (byte) event.value;
break;
case EvdevEvent.REL_WHEEL: case EvdevEvent.REL_WHEEL:
deltaScroll = (byte) event.value; deltaVScroll = (byte) event.value;
break; break;
} }
break; break;

View File

@ -13,6 +13,7 @@ public class EvdevEvent {
/* Relative axes */ /* Relative axes */
public static final short REL_X = 0x00; public static final short REL_X = 0x00;
public static final short REL_Y = 0x01; public static final short REL_Y = 0x01;
public static final short REL_HWHEEL = 0x06;
public static final short REL_WHEEL = 0x08; public static final short REL_WHEEL = 0x08;
/* Buttons */ /* Buttons */