#!/usr/bin/env python3

import sys
import socket
import time
from message import Message


JL_H = 0  # left joystick horizontal axis
JL_V = 1  # left joystick vertical axis
JR_H = 2  # right joystick horizontal axis
JR_V = 3  # right joystick vertical axis

controller = 0
type = 0

host = "192.168.0.1"
port = 9999

# process command line args
for i in range(1, len(sys.argv)):
    arg = sys.argv[i]

    if arg == "-h" or arg == "--host":
        host = sys.argv[i + 1]


def send_message(controller, type, index, value):
    m = Message()

    m.controller_index = controller
    m.input_type = type
    m.input_index = index
    m.input_value = value

    s.send(bytes(m))

    response = s.recv(1024)

    decoded_response = response.decode('ascii')

    if decoded_response != "OK":
        print(decoded_response)


s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
print("Connected to server")

# send 50% forward for 1 second
send_message(controller, type, JL_V, 0.5)
time.sleep(1)
send_message(controller, type, JL_V, 0.0)

s.close()

@@ -270,22 +270,33 @@
 = 0%0A
-type
+AXIS
  = 0%0A
-%0Ahost
+BUTTON = 1%0A%0AHOST
  = %22
@@ -308,20 +308,20 @@
 68.0.1%22%0A
-port
+PORT
  = 9999%0A
@@ -453,20 +453,20 @@
         
-host
+HOST
  = sys.a
@@ -660,16 +660,185 @@
  value%0A%0A
+    if type == AXIS:%0A        print(%22Setting axis %7B%7D to %7B%7D%22.format(index, value))%0A    elif type == BUTTON:%0A        print(%22Setting button %7B%7D to %7B%7D%22.format(index, value))%0A%0A
     s.se
@@ -879,17 +879,16 @@
 v(1024)%0A
-%0A
     deco
@@ -1064,18 +1064,18 @@
 ct((
-host, port
+HOST, PORT
 ))%0Ap
@@ -1152,36 +1152,36 @@
 age(controller, 
-type
+AXIS
 , JL_V, 0.5)%0Atim
@@ -1216,20 +1216,20 @@
 roller, 
-type
+AXIS
 , JL_V, 

Make output more verbose