From 3395c63fea67980288bceb72acd29e4696fc6bae Mon Sep 17 00:00:00 2001 From: elupus Date: Thu, 27 Oct 2011 22:48:11 +0200 Subject: ps3d: made commandline sixpair usable --- tools/EventClients/lib/python/ps3/sixpair.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'tools/EventClients/lib') diff --git a/tools/EventClients/lib/python/ps3/sixpair.py b/tools/EventClients/lib/python/ps3/sixpair.py index c9b2bbb8c4..bb022c4278 100755 --- a/tools/EventClients/lib/python/ps3/sixpair.py +++ b/tools/EventClients/lib/python/ps3/sixpair.py @@ -12,9 +12,7 @@ passed_value = 0x03f5 def find_sixaxes(): res = [] for bus in usb.busses(): - print bus.dirname for dev in bus.devices: - print "-" + dev.filename if dev.idVendor == vendor and dev.idProduct == product: res.append(dev) return res @@ -92,10 +90,24 @@ def update_pair(dev, mac): if __name__=="__main__": devs = find_sixaxes() + + mac = None + if len(sys.argv) > 1: + try: + mac = sys.argv[1].split(':') + mac = tuple([int(x, 16) for x in mac]) + if len(mac) != 6: + print "Invalid length of HCI address, should be 6 parts" + mac = None + except: + print "Failed to parse HCI address" + mac = None for dev in devs: - msg = get_pair(dev) - print "Found sixaxis paired to: %02x:%02x:%02x:%02x:%02x:%02x" % (msg[0], msg[1], msg[2], msg[3], msg[4], msg[5]); msg + if mac: + update_pair(dev, mac) + else: + print "Found sixaxis paired to: " + mac_to_string(get_pair(dev)) -- cgit v1.2.3