Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #13 from rainforestapp/feature/paste-delay
Browse files Browse the repository at this point in the history
Feature/paste delay
  • Loading branch information
ukd1 committed Sep 23, 2015
2 parents 1d05ca8 + b482055 commit d762346
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
3 changes: 3 additions & 0 deletions Flashlight-VNC/src/Flashlight.mxml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
[Bindable] private var settings:VNCSettings = new VNCSettings();
[Bindable] private var hideControls:Boolean;
[Bindable] private var password:String;
[Bindable] private var pastePauseDelay:uint = 50;
[Bindable] private var fullscreenMode:Boolean = false;
[Bindable] private var updateRectangle:Rectangle;
Expand Down Expand Up @@ -95,6 +96,7 @@
if (parameters.host) settings.host = parameters.host;
if (parameters.port) settings.port = int(parameters.port);
if (parameters.password) password = parameters.password;
if (parameters.pastePauseDelay) pastePauseDelay = parameters.pastePauseDelay;
if (parameters.securityPort) {
settings.securityPort = int(parameters.securityPort);
settings.useSecurity = true;
Expand Down Expand Up @@ -317,6 +319,7 @@
port="{settings.port}"
securityPort="{settings.securityPort}"
password="{password}"
pastePauseDelay="{pastePauseDelay}"
viewOnly="{settings.viewOnly}"
shareConnection="{settings.shared}"
encoding="{settings.encoding}"
Expand Down
29 changes: 9 additions & 20 deletions Flashlight-VNC/src/com/flashlight/vnc/VNCClient.as
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ package com.flashlight.vnc
import flash.utils.ByteArray;
import flash.utils.Timer;
import flash.utils.getTimer;
import flash.utils.setTimeout;

import mx.binding.utils.ChangeWatcher;
import mx.controls.Alert;
Expand Down Expand Up @@ -102,6 +103,7 @@ package com.flashlight.vnc
[Bindable] public var securityPort:int = 0;
[Bindable] public var shareConnection:Boolean = true;
[Bindable] public var password:String;
[Bindable] public var pastePauseDelay:int = 50;

[Bindable] public var serverName:String;
[Bindable] public var screen:VNCScreen;
Expand Down Expand Up @@ -595,22 +597,13 @@ package com.flashlight.vnc
}
}

private function sleep(ms:int):void {
var init:int = getTimer();
while(true) {
if(getTimer() - init >= ms) {
break;
}
}
}

private function onTextInput(event:TextEvent):void {
if (status != VNCConst.STATUS_CONNECTED) return;

if (captureKeyEvents) {

logger.info(">> onTextInput()");
logger.info("Shfit Key Down? " + shiftKeyDown);
logger.info("Shift Key Down? " + shiftKeyDown);

expectKeyInput = false;

Expand All @@ -629,24 +622,20 @@ package com.flashlight.vnc
needsShift.push(chars.charCodeAt(i));
}

var waitTime:int = 0;
for (i=0; i<input.length ;i++) {
cc=input.charCodeAt(i);
useShift = !shiftKeyDown && needsShift.indexOf(cc) >= 0;
if(useShift){
logger.info("Using shift for char " + cc);
rfbWriter.writeKeyEvent(true,0xFFE1, true);
sleep(50);
setTimeout(rfbWriter.writeKeyEvent, waitTime += 50, true, 0xFFE1, true);
}
rfbWriter.writeKeyEvent(true,cc,false);
rfbWriter.writeKeyEvent(false,cc,true);
setTimeout(rfbWriter.writeKeyEvent, waitTime += 20, true, cc, false);
setTimeout(rfbWriter.writeKeyEvent, waitTime += 20, false, cc, true);
if(useShift){
rfbWriter.writeKeyEvent(false,0xFFE1, true);
sleep(50);
setTimeout(rfbWriter.writeKeyEvent, waitTime += 50, false, 0xFFE1, true);
}
// HACK: Massive ugly hack. It seems like some server don't support
// rapid key entry very well. So we just sleep a little between
// each key.
sleep(useShift ? 20 : 1);
waitTime += pastePauseDelay;
}

screen.textInput.text ='';
Expand Down

0 comments on commit d762346

Please sign in to comment.