Rearrange files again, and fix more bugs

This commit is contained in:
Samuel Sloniker 2021-06-17 14:52:23 -07:00
parent b0329fd8ce
commit d57905c731
4 changed files with 14 additions and 5 deletions

View File

@ -70,16 +70,18 @@ function touch(e) {
click_timeout = setTimeout(function() { click_timeout = setTimeout(function() {
is_short = false is_short = false
}, 1000) }, 1000)
is_short = true
} }
function release(e) { function release(e) {
clearTimeout(click_timeout)
x = e.layerX x = e.layerX
y = e.layerY y = e.layerY
w = displayWidth w = displayWidth
length = is_short?0:1 length = is_short?false:true
ws.send('touch ' + localStorage.getItem('password') + ' ' + x + ' ' + y + ' ' + w + ' ' + length) ws.send('touch ' + localStorage.getItem('password') + ' ' + x + ' ' + y + ' ' + w + ' ' + length)
clearTimeout(click_timeout)
is_short = true
} }

View File

@ -1,6 +1,5 @@
import os import os
import base64 import base64
import hcapi
import threading import threading
import logging import logging
import random import random
@ -10,11 +9,19 @@ import tempfile
import queue import queue
from websocket_server import WebsocketServer from websocket_server import WebsocketServer
# Select backend - backends.port8080 uses HamClock's port 8080 service;
# backends.x11 uses an X11 server (typically Xvfb) (make sure DISPLAY is set
# correctly!)
#import backends.port8080 as hcapi
import backends.x11 as hcapi
def cycle(): def cycle():
try: try:
changed = hcapi.get_img() changed = hcapi.get_img()
except Exception as e: except Exception as e:
#server.send_message_to_all('err%noconn%Server failed to capture screenshot')
for client in clients.values(): for client in clients.values():
client.send('err%noconn%Server failed to capture screenshot', 'ERR') client.send('err%noconn%Server failed to capture screenshot', 'ERR')
time.sleep(3) time.sleep(3)
@ -109,7 +116,7 @@ def do_touch(client, server, message):
else: else:
_, password, x, y, w, is_long = message.split(' ') _, password, x, y, w, is_long = message.split(' ')
if password == 'password': if password == 'password':
x, y, w, is_long = int(x), int(y), int(w), bool(is_long) x, y, w, is_long = int(x), int(y), int(w), is_long == 'true'
hcapi.touch(x, y, w, is_long) hcapi.touch(x, y, w, is_long)
else: else:
clients[client['id']].send(f'badpass', 'BADPASS') clients[client['id']].send(f'badpass', 'BADPASS')