2020-05-25 01:55:31 +02:00
|
|
|
<!doctype html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
2020-05-25 02:35:10 +02:00
|
|
|
<title>Mouse remote</title>
|
2020-05-25 01:55:31 +02:00
|
|
|
<style>
|
|
|
|
</style>
|
|
|
|
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
HID mouse service, POST data to /mouse <br/>
|
|
|
|
<div>
|
|
|
|
</div>
|
|
|
|
|
2020-05-25 02:35:10 +02:00
|
|
|
<input type="button" onclick="sendMouse(0, 0, -10);" value="^" />
|
|
|
|
<input type="button" onclick="sendMouse(0, -10, 0);" value="<" />
|
|
|
|
<input type="button" onclick="sendMouse(0, 10, 0);" value=">" />
|
|
|
|
<input type="button" onclick="sendMouse(0, 0, 10);" value="v" /><br />
|
|
|
|
<input type="button" onclick="sendMouse(1, 0, 0);" value="LEFT" />
|
|
|
|
<input type="button" onclick="sendMouse(2, 0, 0);" value="RIGHT" />
|
2020-05-25 01:55:31 +02:00
|
|
|
<script>
|
|
|
|
|
2020-06-05 15:04:27 +02:00
|
|
|
var btn=0;
|
|
|
|
var posX=0;
|
|
|
|
var posY=0;
|
|
|
|
|
|
|
|
$(document).ready(function(){
|
|
|
|
|
|
|
|
$("canvas").mousedown(function(event){
|
|
|
|
btn=event.buttons;
|
|
|
|
handleMouse();
|
|
|
|
});
|
|
|
|
$("canvas").mouseup(function(event){
|
|
|
|
btn=event.buttons;
|
|
|
|
handleMouse();
|
|
|
|
});
|
|
|
|
|
|
|
|
$("canvas").mousemove(function(event){
|
|
|
|
// sendMouse(0, event.originalEvent.movementX, event.originalEvent.movementY);
|
|
|
|
posX=event.offsetX;
|
|
|
|
posY=event.offsetY;
|
|
|
|
handleMouse();
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
function handleMouse() {
|
|
|
|
$("span").text(btn +", "+ posX + ", " + posY);
|
|
|
|
sendMouse(btn, posX, posY);
|
|
|
|
}
|
|
|
|
|
2020-05-25 02:35:10 +02:00
|
|
|
function sendMouse(btn, x, y) {
|
2020-05-25 01:55:31 +02:00
|
|
|
var obj = {
|
2020-05-25 02:35:10 +02:00
|
|
|
x: x,
|
|
|
|
y: y,
|
|
|
|
btn: btn,
|
2020-05-25 01:55:31 +02:00
|
|
|
wheel: 0,
|
|
|
|
}
|
|
|
|
|
|
|
|
var ret = $.ajax({
|
|
|
|
type: "POST",
|
2020-06-05 15:04:27 +02:00
|
|
|
url: "hid/mouseabs",
|
2020-05-25 01:55:31 +02:00
|
|
|
data: JSON.stringify(obj),
|
|
|
|
contentType: "application/json; charset=utf-8",
|
|
|
|
dataType: "json"
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
</script>
|
2020-06-05 15:04:27 +02:00
|
|
|
<span></span><br/><br/>
|
|
|
|
<canvas width=500 height=500 style="border: 1px solid black" oncontextmenu="return false"></canvas>
|
|
|
|
<!--<img src="placeholder.png" width=1920 height=1080 onmousemove='console.log("aaa");' />-->
|
2020-05-25 01:55:31 +02:00
|
|
|
</body>
|
2020-05-25 02:35:10 +02:00
|
|
|
</html>
|