35 from bluetooth 
import *
    48     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    49     sock.bind((
"127.0.0.1",0))
    51     return sock,sock.getsockname()[1]
    56         threading.Thread.__init__(self)
    64         print "driversim exiting"    67         self.cm.shutdown = 
True    71         threading.Thread.__init__(self)
    72         print "Starting joystick simulator on ports", intr, 
"and", ctrl
    73         self.
intr = socket.socket()
    74         self.intr.connect((
"127.0.0.1", intr))
    76             raise "Error creating interrput socket."    77         self.
ctrl = socket.socket()
    78         self.ctrl.connect((
"127.0.0.1", ctrl))
    80             raise "Error creating control socket."    87             (rd, wr, err) = select.select([self.
ctrl], [], [], 1)
    89                 cmd = self.ctrl.recv(128)
    90                 if cmd == 
"\x53\xf4\x42\x03\x00\x00":
    92                     print "Got activate command"    94                     print "Got unknown command (len=%i)"%len(cmd),
    99         print "joyactivate exiting"   103             ranges = [255] * 17 + [8191] * 20
   104             axval = [ int((v + 1) * s / 2) 
for (v,s) 
in zip(ax, ranges)]
   109                     newval = (newval << 1)
   112                 buttout.append(newval)
   113             joy_coding = 
"!1B2x3B1x4B4x12B15x4H"   115             self.intr.send(struct.pack(joy_coding, 161, *(buttout + [0] + axval)))
   117             print "Tried to publish while inactive"   119 if __name__ == 
"__main__":
   126     signal.signal(signal.SIGINT, stop_all_threads)
   139     buttons1 = [
True] * 16
   140     axes1 = [1, 0, -1, .5] * 5
   141     buttons2 = [
False] * 16
   143     buttons3 = [
False] * 16
   146     while not js.active 
and not shutdown:
   153         js.publishstate(axes1, buttons2)
   156         js.publishstate(axes2, buttons2)
 
def stop_all_threads(a, b)
def __init__(self, intr, ctrl)
def __init__(self, intr, ctrl)
def publishstate(self, ax, butt)