diff options
author | Joakim Plate <elupus@xbmc.org> | 2012-01-08 14:27:27 +0100 |
---|---|---|
committer | elupus <elupus@xbmc.org> | 2012-01-08 21:36:26 +0100 |
commit | d4516c54d6f6dfcc8c984c90c1f5cd142d1d1925 (patch) | |
tree | a76883eb166bba01b47ad0d78d0ae344e43be5c1 /tools | |
parent | 516f1b0e3798989c71357b959f06743c23a1857d (diff) |
changed: avoid crashing just cause we fail to set MTU
It is usually not needed. Also added a readme file
for ubuntu about what packages are needed
Diffstat (limited to 'tools')
-rw-r--r-- | tools/EventClients/Clients/PS3 Sixaxis Controller/README.ubuntu | 1 | ||||
-rw-r--r-- | tools/EventClients/lib/python/ps3/sixaxis.py | 18 |
2 files changed, 17 insertions, 2 deletions
diff --git a/tools/EventClients/Clients/PS3 Sixaxis Controller/README.ubuntu b/tools/EventClients/Clients/PS3 Sixaxis Controller/README.ubuntu new file mode 100644 index 0000000000..bf4a5a43a8 --- /dev/null +++ b/tools/EventClients/Clients/PS3 Sixaxis Controller/README.ubuntu @@ -0,0 +1 @@ +sudo apt-get install python-usb python-pyudev python-bluez diff --git a/tools/EventClients/lib/python/ps3/sixaxis.py b/tools/EventClients/lib/python/ps3/sixaxis.py index c8f2d4f48d..9ba60cc1e9 100644 --- a/tools/EventClients/lib/python/ps3/sixaxis.py +++ b/tools/EventClients/lib/python/ps3/sixaxis.py @@ -154,7 +154,21 @@ def smooth(arr, val): arr.pop(cnt) return average(arr) +def set_l2cap_mtu2(sock, mtu): + SOL_L2CAP = 6 + L2CAP_OPTIONS = 1 + + s = sock.getsockopt (SOL_L2CAP, L2CAP_OPTIONS, 12) + o = list( struct.unpack ("HHHBBBH", s) ) + o[0] = o[1] = mtu + s = struct.pack ("HHHBBBH", *o) + try: + sock.setsockopt (SOL_L2CAP, L2CAP_OPTIONS, s) + except: + print "Warning: Unable to set mtu" + class sixaxis(): + def __init__(self, xbmc, control_sock, interrupt_sock): self.xbmc = xbmc @@ -172,8 +186,8 @@ class sixaxis(): self.psdown = 0 self.mouse_enabled = 0 - set_l2cap_mtu(control_sock, 64) - set_l2cap_mtu(interrupt_sock, 64) + set_l2cap_mtu2(control_sock, 64) + set_l2cap_mtu2(interrupt_sock, 64) time.sleep(0.25) # If we ask to quickly here, it sometimes doesn't start # sixaxis needs this to enable it |