44 lines
1.0 KiB
Python
44 lines
1.0 KiB
Python
from flask import Flask, render_template
|
|
from flask_socketio import SocketIO
|
|
import pyautogui
|
|
|
|
pyautogui.FAILSAFE = False
|
|
app = Flask(__name__)
|
|
socketio = SocketIO(app)
|
|
|
|
@app.route('/')
|
|
def index():
|
|
return render_template('index.html')
|
|
|
|
@socketio.on('text')
|
|
def handle_typewrite(text):
|
|
pyautogui.typewrite(text)
|
|
|
|
@socketio.on('touchstart')
|
|
def handle_mouseDown():
|
|
pyautogui.mouseDown()
|
|
|
|
@socketio.on('touchend')
|
|
def handle_mouseUp():
|
|
pyautogui.mouseUp()
|
|
|
|
@socketio.on('left')
|
|
def handle_leftClick():
|
|
pyautogui.click(button='right')
|
|
|
|
@socketio.on('orientation_data')
|
|
def handle_orientation_data(data):
|
|
|
|
alpha = data.get('alpha', 0)
|
|
beta = data.get('beta', 0)
|
|
gamma = data.get('gamma', 0)
|
|
|
|
sensitivity = 0.4
|
|
move_x = int(gamma * sensitivity)
|
|
move_y = -int(beta * sensitivity)
|
|
|
|
|
|
pyautogui.move(move_x, move_y)
|
|
|
|
if __name__ == '__main__':
|
|
socketio.run(app, host='0.0.0.0', port=5000, ssl_context=('ssl/cert.pem', 'ssl/key.pem')) |