From d42aaf9acfe751147d2c12fb6c6c8b52ebba91c5 Mon Sep 17 00:00:00 2001 From: lxsang Date: Fri, 21 Sep 2018 01:34:44 +0200 Subject: [PATCH] fix --- apps/Makefile | 10 ++++++++-- apps/assets/coffee/WVNC.coffee | 27 +++++++++++---------------- apps/assets/scripts/decoder.js | 2 +- apps/assets/scripts/main.js | 28 +++++++++++----------------- 4 files changed, 31 insertions(+), 36 deletions(-) diff --git a/apps/Makefile b/apps/Makefile index 9b947ca..ee7259e 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -7,6 +7,12 @@ coffees = assets/coffee/bootstrap.coffee \ assets/coffee/MarkOn.coffee \ assets/coffee/WVNC.coffee +SED=sed +UNAME_S := $(shell uname -s) +ifeq ($(UNAME_S),Darwin) + SED=gsed +endif + main: js - mkdir -p $(BUILDDIR)/assets cp -rf $(copyfiles) $(BUILDDIR) @@ -18,8 +24,8 @@ js: for f in $(coffees); do (cat "$${f}"; echo) >> assets/scripts/main.coffee; done coffee --compile assets/scripts/main.coffee coffee --compile assets/coffee/decoder.coffee - sed '2d' assets/coffee/decoder.js > assets/scripts/tmp.js - head -n -1 assets/scripts/tmp.js > assets/scripts/decoder.js + $(SED) '2d' assets/coffee/decoder.js > assets/scripts/tmp.js + $(SED) '$$ d' assets/scripts/tmp.js > assets/scripts/decoder.js -rm assets/coffee/decoder.js -rm assets/scripts/tmp.js -rm assets/scripts/main.coffee diff --git a/apps/assets/coffee/WVNC.coffee b/apps/assets/coffee/WVNC.coffee index a9fd59c..a74a976 100644 --- a/apps/assets/coffee/WVNC.coffee +++ b/apps/assets/coffee/WVNC.coffee @@ -40,7 +40,7 @@ class WVNC extends window.classes.BaseObject me.sendPointEvent p.x, p.y, me.mouseMask return unless me.canvas - ($ me.canvas).css "cursor", "none" + #($ me.canvas).css "cursor", "none" ($ me.canvas).contextmenu (e) -> e.preventDefault() return false @@ -61,16 +61,11 @@ class WVNC extends window.classes.BaseObject me.canvas.onkeydown = me.canvas.onkeyup = me.canvas.onkeypress = (e) -> # get the key code - if e.key is "Shift" - code = 16 - else if e.ctrlKey - code = 17 - else if e.altKey - code = 18 - else if e.metaKey - code = 91 - else - code = String.charCodeAt(e.key) + keycode = e.keyCode + if ((keycode > 47 and keycode < 58) or (keycode > 64 and keycode < 91) or (keycode > 95 and keycode < 112) or (keycode > 185 and keycode < 193) or (keycode > 218 && keycode < 223)) + code = e.key.charCodeAt(0) + else + code = keycode if e.type is "keydown" me.sendKeyEvent code, 1 else if e.type is "keyup" @@ -150,9 +145,9 @@ class WVNC extends window.classes.BaseObject console.log "socket closed" initConnection: () -> - vncserver = "localhost:5901" + vncserver = "192.168.1.20:5901" data = new Uint8Array vncserver.length + 5 - data[0] = 16 # bbp + data[0] = 32 # bbp ### flag: 0: raw data no compress @@ -160,7 +155,7 @@ class WVNC extends window.classes.BaseObject 2: raw data compressed by zlib 3: jpeg data compressed by zlib ### - data[1] = 2 + data[1] = 3 data[2] = 50 # jpeg quality ## rate in milisecond rate = 30 @@ -186,7 +181,7 @@ class WVNC extends window.classes.BaseObject data = new Uint8Array 2 data[0] = code data[1] = v - console.log String.fromCharCode(code), v + console.log code, v @socket.send( @buildCommand 0x06, data ) buildCommand: (hex, o) -> @@ -217,7 +212,7 @@ class WVNC extends window.classes.BaseObject console.log "Error", dec.decode(data) when 0x81 console.log "Request for password" - pass = "!x$@n9" + pass = "lxsan9"#"!x$@n9" @socket.send (@buildCommand 0x02, pass) when 0x82 console.log "Request for login" diff --git a/apps/assets/scripts/decoder.js b/apps/assets/scripts/decoder.js index 94248eb..47d55bd 100644 --- a/apps/assets/scripts/decoder.js +++ b/apps/assets/scripts/decoder.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.9.3 +// Generated by CoffeeScript 1.12.7 var decodeJPEG, decodeRaw, getImageData, onmessage, pixelValue, resolution, update; importScripts('pako.min.js'); diff --git a/apps/assets/scripts/main.js b/apps/assets/scripts/main.js index 76bee10..57025d6 100644 --- a/apps/assets/scripts/main.js +++ b/apps/assets/scripts/main.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.9.3 +// Generated by CoffeeScript 1.12.7 (function() { var APIManager, BaseObject, MarkOn, WVNC, require, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, @@ -228,7 +228,6 @@ if (!me.canvas) { return; } - ($(me.canvas)).css("cursor", "none"); ($(me.canvas)).contextmenu(function(e) { e.preventDefault(); return false; @@ -249,17 +248,12 @@ return sendMouseLocation(e); }); me.canvas.onkeydown = me.canvas.onkeyup = me.canvas.onkeypress = function(e) { - var code; - if (e.key === "Shift") { - code = 16; - } else if (e.ctrlKey) { - code = 17; - } else if (e.altKey) { - code = 18; - } else if (e.metaKey) { - code = 91; + var code, keycode; + keycode = e.keyCode; + if ((keycode > 47 && keycode < 58) || (keycode > 64 && keycode < 91) || (keycode > 95 && keycode < 112) || (keycode > 185 && keycode < 193) || (keycode > 218 && keycode < 223)) { + code = e.key.charCodeAt(0); } else { - code = String.charCodeAt(e.key); + code = keycode; } if (e.type === "keydown") { me.sendKeyEvent(code, 1); @@ -366,9 +360,9 @@ WVNC.prototype.initConnection = function() { var data, rate, vncserver; - vncserver = "localhost:5901"; + vncserver = "192.168.1.20:5901"; data = new Uint8Array(vncserver.length + 5); - data[0] = 16; + data[0] = 32; /* flag: @@ -377,7 +371,7 @@ 2: raw data compressed by zlib 3: jpeg data compressed by zlib */ - data[1] = 2; + data[1] = 3; data[2] = 50; rate = 30; data[3] = rate & 0xFF; @@ -408,7 +402,7 @@ data = new Uint8Array(2); data[0] = code; data[1] = v; - console.log(String.fromCharCode(code), v); + console.log(code, v); return this.socket.send(this.buildCommand(0x06, data)); }; @@ -444,7 +438,7 @@ return console.log("Error", dec.decode(data)); case 0x81: console.log("Request for password"); - pass = "!x$@n9"; + pass = "lxsan9"; return this.socket.send(this.buildCommand(0x02, pass)); case 0x82: console.log("Request for login");