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/devices.js"></script>
35 <script src=
"../core/display.js"></script>
37 var msg_cnt =
0, iterations,
38 width =
400, height =
200,
39 canvas, keyboard, mouse;
42 if (Util.Engine.trident) {
43 var newline =
"<br>\n";
46 function message(str) {
48 cell = document.getElementById('messages');
49 cell.textContent += msg_cnt +
": " + str + newline;
50 cell.scrollTop = cell.scrollHeight;
54 function mouseButton(x, y, down, bmask) {
55 msg = 'mouse x,y: ' + x + ',' + y + ' down: ' + down;
56 msg += ' bmask: ' + bmask;
60 function mouseMove(x, y) {
61 msg = 'mouse x,y: ' + x + ',' + y;
65 function rfbKeyEvent(keysym, code, down) {
66 var d = down ?
"down" :
" up ";
67 var msg =
"RFB key event " + d +
" keysym: " + keysym +
" code: " + code;
71 msg =
"raw key event " + e.type +
72 " (key: " + e.keyCode +
", char: " + e.charCode +
73 ", which: " + e.which +
")";
77 function selectButton(num) {
78 var b, blist = [
1,
2,
4];
80 if (typeof num === 'undefined') {
82 num = mouse.get_touchButton();
83 } else if (num === mouse.get_touchButton()) {
84 // Set all buttons off (no clicks)
85 mouse.set_touchButton(
0);
89 mouse.set_touchButton(num);
92 for (b =
0; b < blist.length; b++) {
93 if (blist[b] === num) {
94 document.getElementById('button' + blist[b]).style.backgroundColor =
"black";
95 document.getElementById('button' + blist[b]).style.color =
"lightgray";
97 document.getElementById('button' + blist[b]).style.backgroundColor =
"";
98 document.getElementById('button' + blist[b]).style.color =
"";
103 window.onload = function() {
104 canvas = new Display({'target' : document.getElementById('canvas')});
105 keyboard = new Keyboard({'target': document,
106 'onKeyEvent': rfbKeyEvent});
107 document.addEventListener('keypress', rawKey);
108 document.addEventListener('keydown', rawKey);
109 document.addEventListener('keyup', rawKey);
110 mouse = new Mouse({'target': document.getElementById('canvas'),
111 'onMouseButton': mouseButton,
112 'onMouseMove': mouseMove});
114 canvas.resize(width, height, true);
117 message(
"Display initialized");
119 if (Util.isTouchDevice) {
120 message(
"Touch device detected");
121 document.getElementById('button-selection').style.display =
"inline";
122 document.getElementById('button1').onclick = function(){ selectButton(
1) };
123 document.getElementById('button2').onclick = function(){ selectButton(
2) };
124 document.getElementById('button4').onclick = function(){ selectButton(
4) };