diff --git a/tools/joystick/web.py b/tools/joystick/web.py new file mode 100755 index 0000000000..63dcbbae99 --- /dev/null +++ b/tools/joystick/web.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +from flask import Flask +import cereal.messaging as messaging + +app = Flask(__name__) +pm = messaging.PubMaster(['testJoystick']) + +index = """ + + + + + +
+ +""" + +@app.route("/") +def hello_world(): + return index + +@app.route("/control//") +def control(x, y): + x,y = float(x), float(y) + x = max(-1, min(1, x)) + y = max(-1, min(1, y)) + dat = messaging.new_message('testJoystick') + dat.testJoystick.axes = [y,x] + dat.testJoystick.buttons = [False] + pm.send('testJoystick', dat) + return "" + +if __name__ == '__main__': + app.run(host="0.0.0.0") +