Skip to content

Commit

Permalink
add wheel support
Browse files Browse the repository at this point in the history
  • Loading branch information
citronneur committed Jul 2, 2015
1 parent f44d585 commit 020c377
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions lib/protocol/rdp.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ RdpClient.prototype.close = function () {
RdpClient.prototype.sendPointerEvent = function (x, y, button, isPressed) {
if (!this.connected)
return;

var event = pdu.data.pointerEvent();
if (isPressed) {
event.obj.pointerFlags.value |= pdu.data.PointerFlag.PTRFLAGS_DOWN;
Expand Down Expand Up @@ -255,6 +256,9 @@ RdpClient.prototype.sendKeyEventScancode = function (code, isPressed, extended)
* @param isPressed {boolean}
*/
RdpClient.prototype.sendKeyEventUnicode = function (code, isPressed) {
if (!this.connected)
return;

var event = pdu.data.unicodeKeyEvent();
event.obj.unicode.value = code;

Expand All @@ -264,6 +268,39 @@ RdpClient.prototype.sendKeyEventUnicode = function (code, isPressed) {
this.global.sendInputEvents([event]);
}

/**
* Wheel mouse event
* @param x {integer} mouse x position
* @param y {integer} mouse y position
* @param step {integer} wheel step
* @param isNegative {boolean}
* @param isHorizontal {boolean}
*/
RdpClient.prototype.sendWheelEvent = function (x, y, step, isNegative, isHorizontal) {
if (!this.connected)
return;

var event = pdu.data.pointerEvent();
if (isHorizontal) {
event.obj.pointerFlags.value |= pdu.data.PointerFlag.PTRFLAGS_HWHEEL;
}
else {
event.obj.pointerFlags.value |= pdu.data.PointerFlag.PTRFLAGS_WHEEL;
}


if (isNegative) {
event.obj.pointerFlags.value |= pdu.data.PointerFlag.PTRFLAGS_WHEEL_NEGATIVE;
}

event.obj.pointerFlags.value |= (step & pdu.data.PointerFlag.WheelRotationMask)

event.obj.xPos.value = x;
event.obj.yPos.value = y;

this.global.sendInputEvents([event]);
}

function createClient(config) {
return new RdpClient(config);
};
Expand Down

0 comments on commit 020c377

Please sign in to comment.