HID Templates: first merge kbd and mouse
This commit is contained in:
parent
1fa5e4be16
commit
11119bb1cb
@ -6,15 +6,7 @@
|
|||||||
<style>
|
<style>
|
||||||
</style>
|
</style>
|
||||||
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
|
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
|
||||||
</head>
|
<script src="//cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js" integrity="sha256-yr4fRk/GU1ehYJPAs8P4JlTgu0Hdsp4ZKrx8bDEDC3I=" crossorigin="anonymous"></script>
|
||||||
<body>
|
|
||||||
HID input service, POST data to /keyboard or /mouse <br/>
|
|
||||||
<div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<br/>
|
|
||||||
Server response: <span></span>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function zapis(t) {
|
function zapis(t) {
|
||||||
$("div").text(t);
|
$("div").text(t);
|
||||||
@ -51,10 +43,7 @@ $(window).bind('keydown', function(event) {
|
|||||||
dataType: "json"
|
dataType: "json"
|
||||||
});
|
});
|
||||||
|
|
||||||
$("span").text(ret.responseText);
|
|
||||||
console.log(ret);
|
console.log(ret);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var text = "";
|
var text = "";
|
||||||
@ -74,8 +63,53 @@ $(window).bind('keydown', function(event) {
|
|||||||
previous = event.keyCode;
|
previous = event.keyCode;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
var btn=0;
|
||||||
|
var posX=0;
|
||||||
|
var posY=0;
|
||||||
|
var wheel=0;
|
||||||
|
|
||||||
|
var socket = io();
|
||||||
|
|
||||||
|
$(document).ready(function(){
|
||||||
|
|
||||||
|
$("canvas").mousedown(function(event){
|
||||||
|
btn=event.buttons;
|
||||||
|
handleMouse();
|
||||||
|
});
|
||||||
|
$("canvas").mouseup(function(event){
|
||||||
|
btn=event.buttons;
|
||||||
|
handleMouse();
|
||||||
|
});
|
||||||
|
$("canvas").mousemove(function(event){
|
||||||
|
posX=event.offsetX;
|
||||||
|
posY=event.offsetY;
|
||||||
|
handleMouse();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function handleMouse() {
|
||||||
|
$("span").text(btn +", "+ posX + ", " + posY);
|
||||||
|
sendMouse(btn, posX, posY, wheel);
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendMouse(btn, x, y) {
|
||||||
|
var obj = {
|
||||||
|
x: x,
|
||||||
|
y: y,
|
||||||
|
btn: btn,
|
||||||
|
wheel: wheel,
|
||||||
|
}
|
||||||
|
|
||||||
|
socket.emit('mouseEvent', JSON.stringify(obj));
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
HID Remote Keyboard and mouse<br/>
|
||||||
|
|
||||||
|
<div></div>
|
||||||
|
|
||||||
|
<span></span><br/><br/>
|
||||||
|
<canvas width=1920 height=1080 style="border: 1px solid black" oncontextmenu="return false" onwheel='wheel=event.deltaY*-1; handleMouse(); wheel=0; return false;' ></canvas>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
|
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
HID input service, POST data to /keyboard or /mouse <br/>
|
HID input keyboard, POST data to /keyboard<br/>
|
||||||
<div>
|
<div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -36,8 +36,6 @@ $(document).ready(function(){
|
|||||||
posY=event.offsetY;
|
posY=event.offsetY;
|
||||||
handleMouse();
|
handleMouse();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function handleMouse() {
|
function handleMouse() {
|
||||||
|
Loading…
Reference in New Issue
Block a user