Add support for vertical mouse scrolling

This commit is contained in:
Cameron Gutman 2014-09-03 22:52:48 -07:00
parent 1bb9a13c17
commit 50f8f78b8d
3 changed files with 48 additions and 0 deletions

View File

@ -335,4 +335,11 @@ public class NvConnection {
inputStream.sendKeyboardInput(keyMap, keyDirection, modifier);
}
public void sendMouseScroll(final byte scrollClicks) {
if (inputStream == null)
return;
inputStream.sendMouseScroll(scrollClicks);
}
}

View File

@ -282,4 +282,9 @@ public class ControllerStream {
{
queuePacket(new KeyboardPacket(keyMap, keyDirection, modifier));
}
public void sendMouseScroll(byte scrollClicks)
{
queuePacket(new MouseScrollPacket(scrollClicks));
}
}

View File

@ -0,0 +1,36 @@
package com.limelight.nvstream.input;
import java.nio.ByteBuffer;
public class MouseScrollPacket extends InputPacket {
public static final int PACKET_TYPE = 0xa;
public static final int PAYLOAD_LENGTH = 10;
public static final int PACKET_LENGTH = PAYLOAD_LENGTH +
InputPacket.HEADER_LENGTH;
short scroll;
public MouseScrollPacket(byte scrollClicks)
{
super(PACKET_TYPE);
this.scroll = (short)(scrollClicks * 120);
}
@Override
public byte[] toWire() {
ByteBuffer bb = ByteBuffer.allocate(PACKET_LENGTH);
bb.put(toWireHeader());
bb.put((byte) 0x09);
bb.put((byte) 0);
bb.put((byte) 0);
bb.put((byte) 0);
bb.putShort(scroll);
bb.putShort(scroll);
bb.putShort((short) 0);
return bb.array();
}
}