Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Original grabbed joystick device causing problems in hidraw mode #45

Open
hanetzer opened this issue Sep 24, 2014 · 11 comments
Open

Original grabbed joystick device causing problems in hidraw mode #45

hanetzer opened this issue Sep 24, 2014 · 11 comments

Comments

@hanetzer
Copy link

hanetzer commented Sep 24, 2014

When using the hidraw mode, ds4drv grabs the original joystick device (provided by the kernel drivers) and creates a new device. The original device is still present for the rest of the system, but it is disabled. Seems like the original device is causing problems. -@Ape

As above. Running either minecraft 1.7.10 with liteloader installed or FEZ from steam with this running causes a hang in both, and both remain hung until ds4drv is killed. Immediatly after running systemctl stop ds4drv.service both resume function, while the latter, even if I kill all steam and such processes continues to run in D state, and will not even respond to SIGKILL, but once I disable it it kills off properly.

@benmoran56
Copy link

Are you using the hidraw mode with ds4drv? If you are, then I think that is the problem. The extra joystick device that is created is there, but unresponsive. I think it causes trouble with the way some games initialize game controllers. Try testing it in raw mode (having to put the DS4 into sync mode each time). This should work, though it's not as easy.

@hanetzer
Copy link
Author

blarg. I'll try that, but I'll not be happy XD
still, very annoying issue, would hope that it could be fixed at some point :)

@hanetzer
Copy link
Author

hrm... well, how does this exactly work, then. I've held the PS+Share buttons, got the blink, but no results...
ah nevermind. powered it on normally and all is well. But its still rather strange that hidraw would kill the functionality of these games :/

@hanetzer
Copy link
Author

I would close this issue, but changing to non-hidraw mode is more of a workaround than an actual fix.

@benmoran56
Copy link

I don't think anyone has found a way to remove the other js devices (the ones that are not being used anymore when using hidraw mode). It must be possible, as xboxdrv removes them in a similar fashion I believe.

@Ryochan7
Copy link
Contributor

xboxdrv uses the EVIOCGRAB flag on the joystick device file handler in order to have exclusive access to a joystick device. That way, other programs will not use the joystick device so the controller is only seen once. Here is an example. https://github.com/Grumbel/xboxdrv/blob/master/src/controller/evdev_controller.cpp#L70

if (m_grab)
{ // grab the device, so it doesn't broadcast events into the wild
    int ret = ioctl(m_fd, EVIOCGRAB, 1);
    if ( ret == -1 )
    {
        close(m_fd);
        throw std::runtime_error(strerror(errno));
    }
}

@benmoran56
Copy link

I took a look at python-evdev, and it does have EVIOCGRAB support, simply called "grab". It also looks like ds4drv is already using it (you can see it in hidraw.py, in the HidrawDS4Device class).

This seems to make sense, since ds4drv DOES grab the device properly, it just leaves the non-responsive one behind. Maybe the bit of code that xboxdrv uses to "hide" the device is elsewhere, or maybe python-evdev doesn't implement those bits of EVIOCGRAB correctly...

@Ryochan7
Copy link
Contributor

One thing that might help with this problem is to try changing the permissions of the original joystick device file after grabbing it in the application. Based on some experimenting, removing read access for that joystick device will ensure that applications that are launched later will skip over those devices; it will not affect applications that have already opened the joystick device. That way, a game will only see 1 joystick device as opposed to 2.

@Ape Ape changed the title Strange bug, having ds4drv running prevents certain games from working. Original grabbed joystick device causing problems in hidraw mode Jul 16, 2016
@Snowman3456
Copy link

@Ryochan7 How do I figure out how to do that? Pretty sure I'm having this issue. DS4 works for Steam Big Picture but not in any game. Makes sense that maybe it's being mapped to a player 2 or some such.

@Ape
Copy link
Collaborator

Ape commented Aug 31, 2016

You can try to remove the original device (when ds4drv is already running). E.g. if the original device is /dev/input/js0 then just do this:

sudo rm /dev/input/js0

The original device should return when you reconnect the controller.

@Ryochan7
Copy link
Contributor

Ryochan7 commented Aug 31, 2016

That should work as well. For my SteamOS box, I have it set up where the steam user is the owner of all joystick devices. It is easier to perform chmod 000 <device> in that case as opposed to having to use sudo to remove the original device file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants