Mouse template
This commit is contained in:
parent
478cb9c202
commit
6c1bd1235d
@ -12,18 +12,12 @@
|
|||||||
HID mouse service, POST data to /mouse <br/>
|
HID mouse service, POST data to /mouse <br/>
|
||||||
<div>
|
<div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<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" />
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
var btn=0;
|
var btn=0;
|
||||||
var posX=0;
|
var posX=0;
|
||||||
var posY=0;
|
var posY=0;
|
||||||
|
var wheel=0;
|
||||||
|
|
||||||
var socket = io();
|
var socket = io();
|
||||||
|
|
||||||
@ -37,18 +31,18 @@ $(document).ready(function(){
|
|||||||
btn=event.buttons;
|
btn=event.buttons;
|
||||||
handleMouse();
|
handleMouse();
|
||||||
});
|
});
|
||||||
|
$("canvas").mousemove(function(event){
|
||||||
|
posX=event.offsetX;
|
||||||
|
posY=event.offsetY;
|
||||||
|
handleMouse();
|
||||||
|
});
|
||||||
|
|
||||||
$("canvas").mousemove(function(event){
|
|
||||||
posX=event.offsetX;
|
|
||||||
posY=event.offsetY;
|
|
||||||
handleMouse();
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function handleMouse() {
|
function handleMouse() {
|
||||||
$("span").text(btn +", "+ posX + ", " + posY);
|
$("span").text(btn +", "+ posX + ", " + posY);
|
||||||
sendMouse(btn, posX, posY);
|
sendMouse(btn, posX, posY, wheel);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendMouse(btn, x, y) {
|
function sendMouse(btn, x, y) {
|
||||||
@ -56,7 +50,7 @@ function sendMouse(btn, x, y) {
|
|||||||
x: x,
|
x: x,
|
||||||
y: y,
|
y: y,
|
||||||
btn: btn,
|
btn: btn,
|
||||||
wheel: 0,
|
wheel: wheel,
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('mouseEvent', JSON.stringify(obj));
|
socket.emit('mouseEvent', JSON.stringify(obj));
|
||||||
@ -64,7 +58,7 @@ function sendMouse(btn, x, y) {
|
|||||||
|
|
||||||
</script>
|
</script>
|
||||||
<span></span><br/><br/>
|
<span></span><br/><br/>
|
||||||
<canvas width=1920 height=1080 style="border: 1px solid black" oncontextmenu="return false"></canvas>
|
<canvas width=1920 height=1080 style="border: 1px solid black" oncontextmenu="return false" onwheel='wheel=event.deltaY*-1; handleMouse(); wheel=0; return false;' ></canvas>
|
||||||
<!--<img src="placeholder.png" width=1920 height=1080 onmousemove='console.log("aaa");' />-->
|
<!--<img src="placeholder.png" width=1920 height=1080 onmousemove='console.log("aaa");' />-->
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user