PythonからXXXHapticsの数値を取得する

pip install websocket-client

import sys import json import websocket # def on_open( ws ): print( "open" ) # def on_close( ws ): print( "close" ) # def on_error( ws, error ): print( error ) # def on_message( ws, msg ): cmd = json.loads( msg ) # print( cmd ) if "cmd" in cmd: if cmd[ "cmd" ] == "volume": # haptics values!! print( cmd[ "volumes" ] ) # def main(): url = "localhost:49152" # websocket.enableTrace( True ) ws = websocket.WebSocketApp( "ws://" + url + "/ws/", on_message = on_message, on_close = on_close, on_error = on_error ) ws.on_open = on_open # ws.run_forever() return 0 if __name__ == "__main__": sys.exit( main() )