Skip to content

Commit 2d79c6b

Browse files
committed
keyboard layout support + log level
1 parent 8605f44 commit 2d79c6b

File tree

13 files changed

+539
-340
lines changed

13 files changed

+539
-340
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## 0.2.0 - 20150707
2+
* Add this changelog
3+
* Add support for qwerty keyboard on Unicode format (chrome)
4+
* Fix bitmap decompression bugs
5+
* Adapt log level from command line

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44

55
**Mstsc.js** is pure javascript Microsoft RDP (Remote Desktop Client) client using nodejs, [**node-rdpjs**](https://github.com/citronneur/node-rdpjs) and socket.io. It allows you to connect to any terminal server compatible application, through web browser (optimized for firefox, compatible with chrome and internet explorer 11).
66

7-
![](./img/mstsc.js.login.png)
8-
9-
![](./img/mstsc.js.connect.png)
10-
11-
![](./img/mstsc.js.explorer.png)
7+
<img src='./img/mstsc.js.login.png' width=100/>
8+
<img src='./img/mstsc.js.connect.png' width=100/>
9+
<img src='./img/mstsc.js.explorer.png' width=100/>
1210

1311
## Cozy-Cloud
1412

client/js/canvas.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,32 @@
4747
var inputHeap = new Uint8Array(Module.HEAPU8.buffer, inputPtr, input.length);
4848
inputHeap.set(input);
4949

50-
var ouputSize = bitmap.width * bitmap.height * 4;
50+
var output_width = bitmap.destRight - bitmap.destLeft + 1;
51+
var output_height = bitmap.destBottom - bitmap.destTop + 1;
52+
var ouputSize = output_width * output_height * 4;
5153
var outputPtr = Module._malloc(ouputSize);
5254

5355
var outputHeap = new Uint8Array(Module.HEAPU8.buffer, outputPtr, ouputSize);
5456

5557
var res = Module.ccall(fName,
5658
'number',
57-
['number', 'number', 'number', 'number', 'number', 'number'],
58-
[outputHeap.byteOffset, bitmap.width, bitmap.height, inputHeap.byteOffset, input.length]
59+
['number', 'number', 'number', 'number', 'number', 'number', 'number', 'number'],
60+
[outputHeap.byteOffset, output_width, output_height, bitmap.width, bitmap.height, inputHeap.byteOffset, input.length]
5961
);
6062

6163
var output = new Uint8ClampedArray(outputHeap.buffer, outputHeap.byteOffset, ouputSize);
6264

6365
Module._free(inputPtr);
6466
Module._free(outputPtr);
6567

66-
return output;
68+
return { width : output_width, height : output_height, data : output };
69+
}
70+
71+
/**
72+
* Un compress bitmap are reverse in y axis
73+
*/
74+
function reverse (bitmap) {
75+
return { width : bitmap.width, height : bitmap.height, data : new Uint8ClampedArray(bitmap.data) };
6776
}
6877

6978
/**
@@ -81,14 +90,17 @@
8190
* @param bitmap {object}
8291
*/
8392
update : function (bitmap) {
84-
var output = new Uint8ClampedArray(bitmap.data);
93+
var output = null;
8594
if (bitmap.isCompress) {
8695
output = decompress(bitmap);
8796
}
97+
else {
98+
output = reverse(bitmap);
99+
}
88100

89101
// use image data to use asm.js
90-
var imageData = this.ctx.createImageData(bitmap.width, bitmap.height);
91-
imageData.data.set(output);
102+
var imageData = this.ctx.createImageData(output.width, output.height);
103+
imageData.data.set(output.data);
92104
this.ctx.putImageData(imageData, bitmap.destLeft, bitmap.destTop);
93105
}
94106
}

client/js/client.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,18 @@
160160
});
161161

162162
// emit infos event
163-
this.socket.emit('infos', {ip : ip, port : 3389, screen : { width : this.canvas.width, height : this.canvas.height }, domain : domain, username : username, password : password});
163+
this.socket.emit('infos', {
164+
ip : ip,
165+
port : 3389,
166+
screen : {
167+
width : this.canvas.width,
168+
height : this.canvas.height
169+
},
170+
domain : domain,
171+
username : username,
172+
password : password,
173+
locale : Mstsc.locale()
174+
});
164175
}
165176
}
166177

client/js/keyboard.js

Lines changed: 112 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
"MediaSelect" : 0xE06D
171171
};
172172

173-
UnicodeToCodeFirefox_FR = {
173+
var UnicodeToCodeFirefox_FR = {
174174
27 : "Escape",
175175
112 : "F1",
176176
113 : "F2",
@@ -275,7 +275,7 @@
275275
17 : "ControlLeft"
276276
};
277277

278-
UnicodeToCodeChrome_FR = {
278+
var UnicodeToCodeChrome_FR = {
279279
27 : "Escape",
280280
112 : "F1",
281281
113 : "F2",
@@ -380,13 +380,117 @@
380380
17 : "ControlLeft"
381381
};
382382

383-
UnicodeToCode = {
383+
var UnicodeToCode_EN = {
384+
27 : "Escape",
385+
112 : "F1",
386+
113 : "F2",
387+
114 : "F3",
388+
115 : "F4",
389+
116 : "F5",
390+
117 : "F6",
391+
118 : "F7",
392+
119 : "F8",
393+
120 : "F9",
394+
121 : "F10",
395+
122 : "F11",
396+
123 : "F12",
397+
192 : "Backquote",
398+
49 : "Digit1",
399+
50 : "Digit2",
400+
51 : "Digit3",
401+
52 : "Digit4",
402+
53 : "Digit5",
403+
54 : "Digit6",
404+
55 : "Digit7",
405+
56 : "Digit8",
406+
57 : "Digit9",
407+
48 : "Digit0",
408+
173 : "Minus",
409+
61 : "Equal",
410+
8 : "Backspace",
411+
9 : "Tab",
412+
81 : "KeyQ",
413+
87 : "KeyW",
414+
69 : "KeyE",
415+
82 : "KeyR",
416+
84 : "KeyT",
417+
89 : "KeyY",
418+
85 : "KeyU",
419+
73 : "KeyI",
420+
79 : "KeyO",
421+
80 : "KeyP",
422+
219 : "BracketLeft",
423+
221 : "BracketRight",
424+
13 : "Enter",
425+
20 : "CapsLock",
426+
65 : "KeyA",
427+
83 : "KeyS",
428+
68 : "KeyD",
429+
70 : "KeyF",
430+
71 : "KeyG",
431+
72 : "KeyH",
432+
74 : "KeyJ",
433+
75 : "KeyK",
434+
76 : "KeyL",
435+
59 : "Semicolon",
436+
222 : "Quote",
437+
220 : "Backslash",
438+
16 : "ShiftLeft",
439+
220 : "IntlBackslash",
440+
90 : "KeyZ",
441+
88 : "KeyX",
442+
67 : "KeyC",
443+
86 : "KeyV",
444+
66 : "KeyB",
445+
78 : "KeyN",
446+
77 : "KeyM",
447+
188 : "Comma",
448+
190 : "Period",
449+
191 : "Slash",
450+
16 : "ShiftRight",
451+
17 : "ControlLeft",
452+
18 : "AltLeft",
453+
91 : "OSLeft",
454+
32 : "Space",
455+
18 : "AltRight",
456+
91 : "OSRight",
457+
93 : "ContextMenu",
458+
17 : "ControlRight",
459+
37 : "ArrowLeft",
460+
38 : "ArrowUp",
461+
40 : "ArrowDown",
462+
39 : "ArrowRight",
463+
144 : "NumLock",
464+
144 : "NumLock",
465+
111 : "NumpadDivide",
466+
106 : "NumpadMultiply",
467+
109 : "NumpadSubtract",
468+
103 : "Numpad7",
469+
104 : "Numpad8",
470+
105 : "Numpad9",
471+
107 : "NumpadAdd",
472+
100 : "Numpad4",
473+
101 : "Numpad5",
474+
102 : "Numpad6",
475+
97 : "Numpad1",
476+
98 : "Numpad2",
477+
99 : "Numpad3",
478+
13 : "NumpadEnter",
479+
96 : "Numpad0",
480+
110 : "NumpadDecimal",
481+
17 : "ControlLeft"
482+
};
483+
484+
485+
var UnicodeToCode = {
384486
'firefox' : {
385-
'fr' : UnicodeToCodeFirefox_FR
487+
'fr' : UnicodeToCodeFirefox_FR,
488+
'en' : UnicodeToCode_EN
386489
},
387490

388491
'chrome' : {
389-
'fr' : UnicodeToCodeChrome_FR
492+
'fr' : UnicodeToCodeChrome_FR,
493+
'en' : UnicodeToCode_EN
390494
}
391495
}
392496

@@ -396,7 +500,9 @@
396500
* @return {integer} scancode
397501
*/
398502
function scancode (e) {
399-
return KeyMap[e.code || UnicodeToCode[Mstsc.browser() || 'firefox']['fr'][e.keyCode]];
503+
var locale = Mstsc.locale();
504+
locale = (['fr', 'en'].indexOf(locale) > 0 && locale) || 'en';
505+
return KeyMap[e.code || UnicodeToCode[Mstsc.browser() || 'firefox'][locale][e.keyCode]];
400506
}
401507

402508
Mstsc.scancode = scancode;

client/js/mstsc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@
6565
}
6666

6767
return null;
68+
},
69+
70+
/**
71+
* Try to detect language
72+
* @returns
73+
*/
74+
locale : function () {
75+
return window.navigator.userLanguage || window.navigator.language;
6876
}
6977
}
7078

0 commit comments

Comments
 (0)