chrippa / ds4drv

A Sony DualShock 4 userspace driver for Linux
MIT License
1.05k stars 213 forks source link

Profile switching exception: 'NoneType' object has no attribute 'close' #41

Open ghost opened 10 years ago

ghost commented 10 years ago

I've been attempting to configure ds4drv, but have hit a snag regarding hidraw/USB connectivity and the 'NoneType' object has no attribute '...' Python exception. The exception occurs when attempting to switch away from either of the mame or snes profiles. I've tried updating to the current development version of ds4drv, as well as performing a bit of debugging myself: trying emulate-xpad = false in the two profiles on the supposition it may have been carried over from the xpad profile, and going so far as to modify actions/input.py in an attempt to bypass the thrown exception - to no avail. Please see the relevant details below.

[ds4drv]
#daemon = true
hidraw = true

[bindings]
PS+Up = exec-background xdotool key XF86AudioRaiseVolume
PS+Down = exec-background xdotool key XF86AudioLowerVolume
PS+Left = prev-profile
PS+Right = next-profile

[controller:1]
battery-flash = true
led = ffffff
profiles=xpad,mame,snes

[profile:xpad]
led = 071f07
emulate-xpad = true

[profile:mame]
led = 1f1f07
mapping = mame

[profile:snes]
led = 1f071f
mapping = snes

[mapping:mame]
KEY_UP = dpad_up
KEY_DOWN = dpad_down
KEY_LEFT = dpad_left
KEY_RIGHT = dpad_right
KEY_LEFTCTRL = button_cross
KEY_LEFTALT = button_circle
KEY_SPACE = button_square
KEY_LEFTSHIFT = button_triangle
KEY_1 = button_options
KEY_5 = button_share

[mapping:snes]
KEY_UP = dpad_up
KEY_DOWN = dpad_down
KEY_LEFT = dpad_left
KEY_RIGHT = dpad_right
KEY_Z = button_cross
KEY_X = button_circle
KEY_A = button_square
KEY_S = button_triangle
KEY_D = button_l1
KEY_C = button_r1
KEY_APOSTROPHE = button_share
KEY_ENTER = button_options
[info][controller 1] Created devices /dev/input/js2 (joystick) /dev/input/event15 (evdev) 
[info][controller 1] Connected to USB Controller (1C:66:6D:0D:09:81 hidraw0)
[info][hidraw] Scanning for devices
[info][controller 1] Battery: Fully charged
[info][controller 1] Switching to profile: xpad
[info][controller 1] Switching to profile: mame
[info][controller 1] Switching to profile: snes
[error][controller 1] Failed to execute action: 'NoneType' object has no attribute 'close'
Traceback (most recent call last):
  File "/usr/local/bin/ds4drv", line 9, in <module>
    load_entry_point('ds4drv==0.5.0', 'console_scripts', 'ds4drv')()
  File "/usr/local/lib/python2.7/dist-packages/ds4drv-0.5.0-py2.7.egg/ds4drv/__main__.py", line 154, in main
    for device in backend.devices:
  File "/usr/local/lib/python2.7/dist-packages/ds4drv-0.5.0-py2.7.egg/ds4drv/backends/hidraw.py", line 148, in devices
    for hidraw_device in itertools.chain(existing_devices, future_devices):
  File "/usr/local/lib/python2.7/dist-packages/ds4drv-0.5.0-py2.7.egg/ds4drv/backends/hidraw.py", line 127, in _get_future_devices
    for device in iter(monitor.poll, None):
  File "/usr/local/lib/python2.7/dist-packages/pyudev/monitor.py", line 340, in poll
    rlist, _, _ = select.select([self], [], [], timeout)
KeyboardInterrupt
--- ds4drv/actions/input.py 2014-06-22 00:39:46.841204526 -0400
+++ /usr/local/lib/python2.7/dist-packages/ds4drv-0.5.0-py2.7.egg/ds4drv/actions/input.py   2014-06-22 00:26:13.545201662 -0400
@@ -72,7 +72,8 @@
                 self.mouse = None

             if self.joystick and self.joystick_layout != joystick_layout:
-                self.joystick.device.close()
+                if self.joystick.device is not None:
+                    self.joystick.device.close()
                 joystick = create_uinput_device(joystick_layout)
                 self.joystick = joystick
             elif not self.joystick:
Ape commented 8 years ago

Does this still occur?