From da47b43ad3617d68ed354533a083ace9b619a2de Mon Sep 17 00:00:00 2001 From: Diego Waxemberg Date: Sun, 8 Dec 2013 16:25:41 -0500 Subject: [PATCH] added support for all 3 mouse buttons --- .../src/com/limelight/nvstream/NvConnection.java | 8 ++++---- .../nvstream/input/MouseButtonPacket.java | 16 +++++++++++++--- .../limelight/nvstream/input/NvController.java | 8 ++++---- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/moonlight-common/src/com/limelight/nvstream/NvConnection.java b/moonlight-common/src/com/limelight/nvstream/NvConnection.java index 13c05ae7..739f3d03 100644 --- a/moonlight-common/src/com/limelight/nvstream/NvConnection.java +++ b/moonlight-common/src/com/limelight/nvstream/NvConnection.java @@ -263,7 +263,7 @@ public class NvConnection { }); } - public void sendMouseButtonDown() + public void sendMouseButtonDown(final byte mouseButton) { if (inputStream == null) return; @@ -272,7 +272,7 @@ public class NvConnection { @Override public void run() { try { - inputStream.sendMouseButtonDown(); + inputStream.sendMouseButtonDown(mouseButton); } catch (IOException e) { listener.connectionTerminated(e); } @@ -280,7 +280,7 @@ public class NvConnection { }); } - public void sendMouseButtonUp() + public void sendMouseButtonUp(final byte mouseButton) { if (inputStream == null) return; @@ -289,7 +289,7 @@ public class NvConnection { @Override public void run() { try { - inputStream.sendMouseButtonUp(); + inputStream.sendMouseButtonUp(mouseButton); } catch (IOException e) { listener.connectionTerminated(e); } diff --git a/moonlight-common/src/com/limelight/nvstream/input/MouseButtonPacket.java b/moonlight-common/src/com/limelight/nvstream/input/MouseButtonPacket.java index 70cea01c..64f38805 100644 --- a/moonlight-common/src/com/limelight/nvstream/input/MouseButtonPacket.java +++ b/moonlight-common/src/com/limelight/nvstream/input/MouseButtonPacket.java @@ -6,6 +6,7 @@ import java.nio.ByteOrder; public class MouseButtonPacket extends InputPacket { private byte buttonEventType; + private byte mouseButton; public static final int PACKET_TYPE = 0x5; public static final int PAYLOAD_LENGTH = 5; @@ -15,11 +16,20 @@ public class MouseButtonPacket extends InputPacket { public static final byte PRESS_EVENT = 0x07; public static final byte RELEASE_EVENT = 0x08; - public MouseButtonPacket(boolean leftButtonDown) + // left + public static final byte BUTTON_1 = 0x01; + // middle + public static final byte BUTTON_2 = 0x02; + // right + public static final byte BUTTON_3 = 0x03; + + public MouseButtonPacket(boolean buttonDown, byte mouseButton) { super(PACKET_TYPE); - buttonEventType = leftButtonDown ? + this.mouseButton = mouseButton; + + buttonEventType = buttonDown ? PRESS_EVENT : RELEASE_EVENT; } @@ -29,7 +39,7 @@ public class MouseButtonPacket extends InputPacket { bb.put(toWireHeader()); bb.put(buttonEventType); - bb.putInt(1); // FIXME: button index? + bb.putInt(mouseButton); return bb.array(); } diff --git a/moonlight-common/src/com/limelight/nvstream/input/NvController.java b/moonlight-common/src/com/limelight/nvstream/input/NvController.java index e0f03eaf..28655a6e 100644 --- a/moonlight-common/src/com/limelight/nvstream/input/NvController.java +++ b/moonlight-common/src/com/limelight/nvstream/input/NvController.java @@ -45,15 +45,15 @@ public class NvController { out.flush(); } - public void sendMouseButtonDown() throws IOException + public void sendMouseButtonDown(byte mouseButton) throws IOException { - out.write(new MouseButtonPacket(true).toWire()); + out.write(new MouseButtonPacket(true, mouseButton).toWire()); out.flush(); } - public void sendMouseButtonUp() throws IOException + public void sendMouseButtonUp(byte mouseButton) throws IOException { - out.write(new MouseButtonPacket(false).toWire()); + out.write(new MouseButtonPacket(false, mouseButton).toWire()); out.flush(); }