3 <head><title>Input Test
</title></head>
8 <span id=
"button-selection" style=
"display: none;">
9 <input id=
"button1" type=
"button" value=
"L"><input id=
"button2" type=
"button" value=
"M"><input id=
"button4" type=
"button" value=
"R">
12 <canvas id=
"canvas" width=
"640" height=
"20"
13 style=
"border-style: dotted; border-width: 1px;">
19 <textarea id=
"messages" style=
"font-size: 9;" cols=
80 rows=
25></textarea>
23 <script type='text/javascript'
24 src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
26 <script src=
"../core/util.js"></script>
27 <script src=
"../app/webutil.js"></script>
28 <script src=
"../core/base64.js"></script>
29 <script src=
"../core/input/keysym.js"></script>
30 <script src=
"../core/input/keysymdef.js"></script>
31 <script src=
"../core/input/xtscancodes.js"></script>
32 <script src=
"../core/input/vkeys.js"></script>
33 <script src=
"../core/input/util.js"></script>
34 <script src=
"../core/input/keyboard.js"></script>
35 <script src=
"../core/input/mouse.js"></script>
36 <script src=
"../core/display.js"></script>
38 var msg_cnt =
0, iterations,
39 width =
400, height =
200,
40 canvas, keyboard, mouse;
44 function message(str) {
46 cell = document.getElementById('messages');
47 cell.textContent += msg_cnt +
": " + str + newline;
48 cell.scrollTop = cell.scrollHeight;
52 function mouseButton(x, y, down, bmask) {
53 msg = 'mouse x,y: ' + x + ',' + y + ' down: ' + down;
54 msg += ' bmask: ' + bmask;
58 function mouseMove(x, y) {
59 msg = 'mouse x,y: ' + x + ',' + y;
63 function rfbKeyEvent(keysym, code, down) {
64 var d = down ?
"down" :
" up ";
65 var msg =
"RFB key event " + d +
" keysym: " + keysym +
" code: " + code;
69 msg =
"raw key event " + e.type +
70 " (key: " + e.keyCode +
", char: " + e.charCode +
71 ", which: " + e.which +
")";
75 function selectButton(num) {
76 var b, blist = [
1,
2,
4];
78 if (typeof num === 'undefined') {
80 num = mouse.get_touchButton();
81 } else if (num === mouse.get_touchButton()) {
82 // Set all buttons off (no clicks)
83 mouse.set_touchButton(
0);
87 mouse.set_touchButton(num);
90 for (b =
0; b < blist.length; b++) {
91 if (blist[b] === num) {
92 document.getElementById('button' + blist[b]).style.backgroundColor =
"black";
93 document.getElementById('button' + blist[b]).style.color =
"lightgray";
95 document.getElementById('button' + blist[b]).style.backgroundColor =
"";
96 document.getElementById('button' + blist[b]).style.color =
"";
101 window.onload = function() {
102 canvas = new Display({'target' : document.getElementById('canvas')});
103 keyboard = new Keyboard({'target': document,
104 'onKeyEvent': rfbKeyEvent});
105 document.addEventListener('keypress', rawKey);
106 document.addEventListener('keydown', rawKey);
107 document.addEventListener('keyup', rawKey);
108 mouse = new Mouse({'target': document.getElementById('canvas'),
109 'onMouseButton': mouseButton,
110 'onMouseMove': mouseMove});
112 canvas.resize(width, height, true);
115 message(
"Display initialized");
117 if (Util.isTouchDevice) {
118 message(
"Touch device detected");
119 document.getElementById('button-selection').style.display =
"inline";
120 document.getElementById('button1').onclick = function(){ selectButton(
1) };
121 document.getElementById('button2').onclick = function(){ selectButton(
2) };
122 document.getElementById('button4').onclick = function(){ selectButton(
4) };