2011-03-29 15:44:03 -05:00
|
|
|
<!DOCTYPE html>
|
2010-05-25 11:05:55 -05:00
|
|
|
<html>
|
|
|
|
|
<head><title>Input Test</title></head>
|
|
|
|
|
<body>
|
|
|
|
|
<br><br>
|
|
|
|
|
|
2011-07-23 21:24:59 -05:00
|
|
|
Canvas:
|
|
|
|
|
<span id="button-selection" style="display: none;">
|
|
|
|
|
<input id="button1" type="button" value="L"><input id="button2" type="button" value="M"><input id="button4" type="button" value="R">
|
|
|
|
|
</span>
|
|
|
|
|
<br>
|
2010-05-25 11:05:55 -05:00
|
|
|
<canvas id="canvas" width="640" height="20"
|
|
|
|
|
style="border-style: dotted; border-width: 1px;">
|
|
|
|
|
Canvas not supported.
|
|
|
|
|
</canvas>
|
|
|
|
|
|
|
|
|
|
<br>
|
|
|
|
|
Results:<br>
|
|
|
|
|
<textarea id="messages" style="font-size: 9;" cols=80 rows=25></textarea>
|
|
|
|
|
</body>
|
|
|
|
|
|
|
|
|
|
<!--
|
2016-08-26 15:47:03 -03:00
|
|
|
<script type='text/javascript'
|
2010-05-25 11:05:55 -05:00
|
|
|
src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
|
|
|
|
|
-->
|
2016-09-14 13:52:53 -04:00
|
|
|
<script src="../core/util.js"></script>
|
|
|
|
|
<script src="../app/webutil.js"></script>
|
|
|
|
|
<script src="../core/base64.js"></script>
|
2016-09-14 13:45:08 -04:00
|
|
|
<script src="../core/input/keysym.js"></script>
|
2017-05-13 01:45:23 +02:00
|
|
|
<script src="../core/input/keysymdef.js"></script>
|
2016-09-14 13:45:08 -04:00
|
|
|
<script src="../core/input/xtscancodes.js"></script>
|
2017-01-24 15:16:10 +01:00
|
|
|
<script src="../core/input/vkeys.js"></script>
|
2016-09-14 13:45:08 -04:00
|
|
|
<script src="../core/input/util.js"></script>
|
2017-09-12 11:03:39 +02:00
|
|
|
<script src="../core/input/keyboard.js"></script>
|
|
|
|
|
<script src="../core/input/mouse.js"></script>
|
2016-09-14 13:52:53 -04:00
|
|
|
<script src="../core/display.js"></script>
|
2010-05-25 11:05:55 -05:00
|
|
|
<script>
|
2011-07-23 21:24:59 -05:00
|
|
|
var msg_cnt = 0, iterations,
|
|
|
|
|
width = 400, height = 200,
|
|
|
|
|
canvas, keyboard, mouse;
|
2010-05-25 11:05:55 -05:00
|
|
|
|
2011-04-05 14:26:54 -05:00
|
|
|
var newline = "\n";
|
|
|
|
|
|
2010-05-25 11:05:55 -05:00
|
|
|
function message(str) {
|
|
|
|
|
console.log(str);
|
2016-09-03 13:39:12 -04:00
|
|
|
cell = document.getElementById('messages');
|
2017-01-12 11:43:35 -05:00
|
|
|
cell.textContent += msg_cnt + ": " + str + newline;
|
2010-05-25 11:05:55 -05:00
|
|
|
cell.scrollTop = cell.scrollHeight;
|
2011-04-05 14:26:54 -05:00
|
|
|
msg_cnt++;
|
2010-05-25 11:05:55 -05:00
|
|
|
}
|
|
|
|
|
|
2010-06-15 11:10:18 -05:00
|
|
|
function mouseButton(x, y, down, bmask) {
|
|
|
|
|
msg = 'mouse x,y: ' + x + ',' + y + ' down: ' + down;
|
|
|
|
|
msg += ' bmask: ' + bmask;
|
2010-05-25 11:05:55 -05:00
|
|
|
message(msg);
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-15 11:10:18 -05:00
|
|
|
function mouseMove(x, y) {
|
|
|
|
|
msg = 'mouse x,y: ' + x + ',' + y;
|
|
|
|
|
//console.log(msg);
|
2010-05-25 11:05:55 -05:00
|
|
|
}
|
|
|
|
|
|
2017-01-26 18:09:40 +01:00
|
|
|
function rfbKeyEvent(keysym, code, down) {
|
2011-04-05 14:26:54 -05:00
|
|
|
var d = down ? "down" : " up ";
|
2017-01-26 18:09:40 +01:00
|
|
|
var msg = "RFB key event " + d + " keysym: " + keysym + " code: " + code;
|
2013-11-27 15:17:32 +01:00
|
|
|
message(msg);
|
|
|
|
|
}
|
|
|
|
|
function rawKey(e) {
|
|
|
|
|
msg = "raw key event " + e.type +
|
2011-04-05 14:26:54 -05:00
|
|
|
" (key: " + e.keyCode + ", char: " + e.charCode +
|
|
|
|
|
", which: " + e.which +")";
|
2010-05-25 11:05:55 -05:00
|
|
|
message(msg);
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-23 21:24:59 -05:00
|
|
|
function selectButton(num) {
|
|
|
|
|
var b, blist = [1,2,4];
|
|
|
|
|
|
|
|
|
|
if (typeof num === 'undefined') {
|
|
|
|
|
// Show the default
|
|
|
|
|
num = mouse.get_touchButton();
|
|
|
|
|
} else if (num === mouse.get_touchButton()) {
|
|
|
|
|
// Set all buttons off (no clicks)
|
|
|
|
|
mouse.set_touchButton(0);
|
|
|
|
|
num = 0;
|
|
|
|
|
} else {
|
|
|
|
|
// Turn on one button
|
|
|
|
|
mouse.set_touchButton(num);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (b = 0; b < blist.length; b++) {
|
|
|
|
|
if (blist[b] === num) {
|
2016-09-03 13:39:12 -04:00
|
|
|
document.getElementById('button' + blist[b]).style.backgroundColor = "black";
|
|
|
|
|
document.getElementById('button' + blist[b]).style.color = "lightgray";
|
2011-07-23 21:24:59 -05:00
|
|
|
} else {
|
2016-09-03 13:39:12 -04:00
|
|
|
document.getElementById('button' + blist[b]).style.backgroundColor = "";
|
|
|
|
|
document.getElementById('button' + blist[b]).style.color = "";
|
2011-07-23 21:24:59 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-25 11:05:55 -05:00
|
|
|
window.onload = function() {
|
2016-09-03 13:39:12 -04:00
|
|
|
canvas = new Display({'target' : document.getElementById('canvas')});
|
2011-04-03 17:30:45 -05:00
|
|
|
keyboard = new Keyboard({'target': document,
|
2017-01-26 18:09:40 +01:00
|
|
|
'onKeyEvent': rfbKeyEvent});
|
2016-09-03 14:06:42 -04:00
|
|
|
document.addEventListener('keypress', rawKey);
|
|
|
|
|
document.addEventListener('keydown', rawKey);
|
|
|
|
|
document.addEventListener('keyup', rawKey);
|
2016-09-03 13:39:12 -04:00
|
|
|
mouse = new Mouse({'target': document.getElementById('canvas'),
|
2011-07-23 21:24:59 -05:00
|
|
|
'onMouseButton': mouseButton,
|
|
|
|
|
'onMouseMove': mouseMove});
|
|
|
|
|
|
2010-08-02 17:07:27 -05:00
|
|
|
canvas.resize(width, height, true);
|
2011-04-03 17:30:45 -05:00
|
|
|
keyboard.grab();
|
|
|
|
|
mouse.grab();
|
2011-07-23 21:24:59 -05:00
|
|
|
message("Display initialized");
|
|
|
|
|
|
2016-08-25 14:21:32 +02:00
|
|
|
if (Util.isTouchDevice) {
|
2011-07-23 21:24:59 -05:00
|
|
|
message("Touch device detected");
|
2016-09-03 13:39:12 -04:00
|
|
|
document.getElementById('button-selection').style.display = "inline";
|
|
|
|
|
document.getElementById('button1').onclick = function(){ selectButton(1) };
|
|
|
|
|
document.getElementById('button2').onclick = function(){ selectButton(2) };
|
|
|
|
|
document.getElementById('button4').onclick = function(){ selectButton(4) };
|
2011-07-23 21:24:59 -05:00
|
|
|
selectButton();
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-25 11:05:55 -05:00
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
</html>
|