Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
96376a4d7d | |||
a808748f6c | |||
![]() |
751a0383cb | ||
![]() |
91f1ee82af | ||
5682dc722d | |||
5f0d133580 |
@ -5,6 +5,7 @@ Public Class main
|
|||||||
Dim weblistener As HttpListener
|
Dim weblistener As HttpListener
|
||||||
Dim lastpos As New Point(0, 0)
|
Dim lastpos As New Point(0, 0)
|
||||||
Dim startpos As New Point(0, 0)
|
Dim startpos As New Point(0, 0)
|
||||||
|
Dim lastmouseseq As Integer = 0
|
||||||
Dim nexttoggleclick As UInteger = MouseEventFlags.MOUSEEVENTF_LEFTDOWN Or MouseEventFlags.MOUSEEVENTF_RIGHTDOWN Or MouseEventFlags.MOUSEEVENTF_MIDDLEDOWN Or MouseEventFlags.MOUSEEVENTF_XDOWN
|
Dim nexttoggleclick As UInteger = MouseEventFlags.MOUSEEVENTF_LEFTDOWN Or MouseEventFlags.MOUSEEVENTF_RIGHTDOWN Or MouseEventFlags.MOUSEEVENTF_MIDDLEDOWN Or MouseEventFlags.MOUSEEVENTF_XDOWN
|
||||||
|
|
||||||
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles StartButton.Click
|
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles StartButton.Click
|
||||||
@ -39,8 +40,6 @@ Public Class main
|
|||||||
Dim context As HttpListenerContext = Nothing
|
Dim context As HttpListenerContext = Nothing
|
||||||
Dim resp As HttpListenerResponse
|
Dim resp As HttpListenerResponse
|
||||||
Dim respstr As String = String.Empty
|
Dim respstr As String = String.Empty
|
||||||
Dim lastpacket As Long = -1
|
|
||||||
Dim lastpack As Long
|
|
||||||
Dim leftclicking As Boolean = False
|
Dim leftclicking As Boolean = False
|
||||||
While weblistener.IsListening
|
While weblistener.IsListening
|
||||||
Try
|
Try
|
||||||
@ -57,13 +56,8 @@ Public Class main
|
|||||||
|
|
||||||
If path = "/" Then
|
If path = "/" Then
|
||||||
respstr = FileIO.FileSystem.ReadAllText("res/page.html")
|
respstr = FileIO.FileSystem.ReadAllText("res/page.html")
|
||||||
lastpacket = 0
|
|
||||||
Else
|
Else
|
||||||
Dim pack As Long = context.Request.QueryString("seq")
|
respstr = handleinput(context.Request)
|
||||||
If pack > lastpack Then
|
|
||||||
respstr = handleinput(context.Request)
|
|
||||||
lastpack = pack
|
|
||||||
End If
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If String.IsNullOrEmpty(respstr) Then
|
If String.IsNullOrEmpty(respstr) Then
|
||||||
@ -117,11 +111,16 @@ Public Class main
|
|||||||
lastpos.Y = req.QueryString("y")
|
lastpos.Y = req.QueryString("y")
|
||||||
startpos.X = req.QueryString("x")
|
startpos.X = req.QueryString("x")
|
||||||
startpos.Y = req.QueryString("y")
|
startpos.Y = req.QueryString("y")
|
||||||
|
lastmouseseq = 0
|
||||||
|
|
||||||
Case "move" 'trackpad touch move
|
Case "move" 'trackpad touch move
|
||||||
mouse_event(MouseEventFlags.MOUSEEVENTF_MOVE, req.QueryString("x") - lastpos.X, req.QueryString("y") - lastpos.Y, 0, 0)
|
Dim seq As Integer = req.QueryString("seq")
|
||||||
lastpos.X = req.QueryString("x")
|
If seq > lastmouseseq Then
|
||||||
lastpos.Y = req.QueryString("y")
|
mouse_event(MouseEventFlags.MOUSEEVENTF_MOVE, req.QueryString("x") - lastpos.X, req.QueryString("y") - lastpos.Y, 0, 0)
|
||||||
|
lastpos.X = req.QueryString("x")
|
||||||
|
lastpos.Y = req.QueryString("y")
|
||||||
|
lastmouseseq = seq
|
||||||
|
End If
|
||||||
|
|
||||||
Case "end"
|
Case "end"
|
||||||
Dim tol As Integer = TapInput.Value
|
Dim tol As Integer = TapInput.Value
|
||||||
@ -191,10 +190,9 @@ Public Class main
|
|||||||
End Try
|
End Try
|
||||||
|
|
||||||
Case "text"
|
Case "text"
|
||||||
Dim encodedtext As String = req.QueryString("text")
|
Dim text As String = req.QueryString("text")
|
||||||
Dim decodedtext As String = Uri.UnescapeDataString(encodedtext)
|
|
||||||
Try
|
Try
|
||||||
SendKeysEscaped(decodedtext)
|
SendKeysEscaped(text)
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
log(ex.ToString)
|
log(ex.ToString)
|
||||||
End Try
|
End Try
|
||||||
|
@ -36,7 +36,6 @@ button:active {
|
|||||||
#canvas {
|
#canvas {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background-color: #111;
|
background-color: #111;
|
||||||
outline: gray solid 1px;
|
|
||||||
}
|
}
|
||||||
div{
|
div{
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -44,7 +43,7 @@ div{
|
|||||||
input{
|
input{
|
||||||
background-color: #111;
|
background-color: #111;
|
||||||
color: gray;
|
color: gray;
|
||||||
outline: gray solid 1px;
|
border: 1px solid gray;
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,41 +51,40 @@ input{
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div style="flex:2">
|
<div style="flex:2">
|
||||||
<button style="flex:1">menu</button>
|
<button onclick="fetch('/key?code=46')" style="flex:1">del</button>
|
||||||
<button onclick="sendmessage('key', 'code=46')" style="flex:1">del</button>
|
<button onclick="fetch('/key?code=8')" style="flex:1">bksp</button>
|
||||||
<button onclick="sendmessage('key', 'code=8')" style="flex:1">bksp</button>
|
<button onclick="fetch('/key?code=13')" style="flex:1">enter</button>
|
||||||
<button onclick="sendmessage('key', 'code=13')" style="flex:1">enter</button>
|
|
||||||
<input id="typebox" placeholder="type here" size=8 style="flex:2">
|
<input id="typebox" placeholder="type here" size=8 style="flex:2">
|
||||||
</div>
|
</div>
|
||||||
<div style="flex:1">
|
<div style="flex:1">
|
||||||
<button onclick="sendmessage('sendkeys', 'keys=j')" style="flex:1">j</button>
|
<button onclick="fetch('/sendkeys?keys=j')" style="flex:1">j</button>
|
||||||
<button onclick="sendmessage('sendkeys', 'keys={LEFT}')" style="flex:1">←</button>
|
<button onclick="fetch('/sendkeys?keys={LEFT}')" style="flex:1">←</button>
|
||||||
<button onclick="sendmessage('sendkeys', 'keys=k')" style="flex:1">k</button>
|
<button onclick="fetch('/sendkeys?keys=k')" style="flex:1">k</button>
|
||||||
<button onclick="sendmessage('sendkeys', 'keys={RIGHT}')" style="flex:1">→</button>
|
<button onclick="fetch('/sendkeys?keys={RIGHT}')" style="flex:1">→</button>
|
||||||
<button onclick="sendmessage('sendkeys', 'keys=l')" style="flex:1">l</button>
|
<button onclick="fetch('/sendkeys?keys=l')" style="flex:1">l</button>
|
||||||
</div>
|
</div>
|
||||||
<div style="flex:12">
|
<div style="flex:12">
|
||||||
<span id="canvas"></span>
|
<span id="canvas"></span>
|
||||||
</div>
|
</div>
|
||||||
<div style="flex:2">
|
<div style="flex:2">
|
||||||
<button onclick="sendmessage('toggle', 'button=left')" style="flex:2">left (toggle)</button>
|
<button onclick="fetch('/toggle?button=left')" style="flex:2">left (toggle)</button>
|
||||||
<button onclick="sendmessage('wheel', 'axis=vert&delta=120')" style="flex:1">up</button>
|
<button onclick="fetch('/wheel?axis=vert&delta=120')" style="flex:1">up</button>
|
||||||
<button onclick="sendmessage('click', 'button=middle')" style="flex:1">mid</button>
|
<button onclick="fetch('/click?button=middle')" style="flex:1">mid</button>
|
||||||
<button onclick="sendmessage('wheel', 'axis=vert&delta=-120')" style="flex:1">dn</button>
|
<button onclick="fetch('/wheel?axis=vert&delta=-120')" style="flex:1">dn</button>
|
||||||
<button onclick="sendmessage('click', 'button=right')" style="flex:2">right</button>
|
<button onclick="fetch('/click?button=right')" style="flex:2">right</button>
|
||||||
</div>
|
</div>
|
||||||
<div style="flex:2">
|
<div style="flex:2">
|
||||||
<button onclick="sendmessage('key', 'code=174')" style="flex:2">vol -</button>
|
<button onclick="fetch('/key?code=174')" style="flex:2">vol -</button>
|
||||||
<button onclick="sendmessage('key', 'code=173')" style="flex:1">mute</button>
|
<button onclick="fetch('/key?code=173')" style="flex:1">mute</button>
|
||||||
<button onclick="sendmessage('key', 'code=175')" style="flex:2">vol +</button>
|
<button onclick="fetch('/key?code=175')" style="flex:2">vol +</button>
|
||||||
</div>
|
</div>
|
||||||
<div style="flex:2">
|
<div style="flex:2">
|
||||||
<button onclick="sendmessage('key', 'code=178')" style="flex:1">stop</button>
|
<button onclick="fetch('/key?code=178')" style="flex:1">stop</button>
|
||||||
<button onclick="sendmessage('key', 'code=177')" style="flex:1">prev</button>
|
<button onclick="fetch('/key?code=177')" style="flex:1">prev</button>
|
||||||
<button onclick="sendmessage('key', 'code=179')" style="flex:1">play/pause</button>
|
<button onclick="fetch('/key?code=179')" style="flex:1">play/pause</button>
|
||||||
<button onclick="sendmessage('key', 'code=176')" style="flex:1">next</button>
|
<button onclick="fetch('/key?code=176')" style="flex:1">next</button>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script type="text/javascript">
|
||||||
function startup() {
|
function startup() {
|
||||||
var el = document.getElementById("canvas");
|
var el = document.getElementById("canvas");
|
||||||
el.addEventListener("touchstart", handleStart, false);
|
el.addEventListener("touchstart", handleStart, false);
|
||||||
@ -107,8 +105,9 @@ var packetnum = 0;
|
|||||||
|
|
||||||
function handleStart(evt) {
|
function handleStart(evt) {
|
||||||
if (currenttouch == null) {
|
if (currenttouch == null) {
|
||||||
currenttouch = evt.changedTouches[0];
|
currenttouch = evt.changedTouches[0];
|
||||||
sendmessage("start", "x=" + currenttouch.pageX + "&y=" + currenttouch.pageY)
|
packetnum = 0;
|
||||||
|
fetch("/start?x=" + currenttouch.pageX + "&y=" + currenttouch.pageY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,8 +118,9 @@ function handleMove(evt) {
|
|||||||
}
|
}
|
||||||
for (var i = 0; i < touches.length; i++) {
|
for (var i = 0; i < touches.length; i++) {
|
||||||
if (touches[i].identifier == currenttouch.identifier) {
|
if (touches[i].identifier == currenttouch.identifier) {
|
||||||
currenttouch = evt.changedTouches[0];
|
currenttouch = evt.changedTouches[0];
|
||||||
sendmessage("move", "x=" + currenttouch.pageX + "&y=" + currenttouch.pageY)
|
packetnum++;
|
||||||
|
fetch("/move?x=" + currenttouch.pageX + "&y=" + currenttouch.pageY + "&seq=" + packetnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,7 +130,7 @@ function handleEnd(evt) {
|
|||||||
for (var i = 0; i < touches.length; i++) {
|
for (var i = 0; i < touches.length; i++) {
|
||||||
if (touches[i].identifier == currenttouch.identifier) {
|
if (touches[i].identifier == currenttouch.identifier) {
|
||||||
currenttouch = evt.changedTouches[0];
|
currenttouch = evt.changedTouches[0];
|
||||||
sendmessage("end", "x=" + currenttouch.pageX + "&y=" + currenttouch.pageY)
|
fetch("/end?x=" + currenttouch.pageX + "&y=" + currenttouch.pageY)
|
||||||
currenttouch = null;
|
currenttouch = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ function handleCancel(evt) {
|
|||||||
for (var i = 0; i < touches.length; i++) {
|
for (var i = 0; i < touches.length; i++) {
|
||||||
if (touches[i].identifier == currenttouch.identifier) {
|
if (touches[i].identifier == currenttouch.identifier) {
|
||||||
currenttouch = evt.changedTouches[0];
|
currenttouch = evt.changedTouches[0];
|
||||||
sendmessage("end", "x=" + currenttouch.pageX + "&y=" + currenttouch.pageY)
|
fetch("/end?x=" + currenttouch.pageX + "&y=" + currenttouch.pageY)
|
||||||
currenttouch = null;
|
currenttouch = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -149,17 +149,10 @@ function handleCancel(evt) {
|
|||||||
|
|
||||||
function handlekeypress(evt) {
|
function handlekeypress(evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
sendmessage("text", "text=" + encodeURIComponent(evt.target.value));
|
fetch("/text?text=" + encodeURIComponent(evt.target.value));
|
||||||
evt.target.value = "";
|
evt.target.value = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendmessage(opt, q) {
|
|
||||||
fetch("/" + opt + "/?" + q + "&seq=" + packetnum);
|
|
||||||
packetnum++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
@ -8,6 +8,7 @@ Mouse messages are:
|
|||||||
move - continue a trackpad movement
|
move - continue a trackpad movement
|
||||||
end - end a trackpad movement
|
end - end a trackpad movement
|
||||||
All of the above take 2 arguments: x and y.
|
All of the above take 2 arguments: x and y.
|
||||||
|
Each touch has a "seq" argument that starts at 0 and increments with each move, to avoid out-of-order movements.
|
||||||
Mouse movement is relative so don't worry about the absolute values.
|
Mouse movement is relative so don't worry about the absolute values.
|
||||||
X is positive left, and Y is positive down.
|
X is positive left, and Y is positive down.
|
||||||
|
|
||||||
|
@ -153,7 +153,9 @@
|
|||||||
<Content Include="res\page.html">
|
<Content Include="res\page.html">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="res\readme.txt" />
|
<Content Include="res\readme.txt">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user