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

ControllerInterface: Combine evdev devices with the same unique ID. #8473

Open
wants to merge 3 commits into
base: master
from

Conversation

@jordan-woyak
Copy link
Member

jordan-woyak commented Nov 17, 2019

Unfortunately newer Linux drivers for DS4 (Playstation 4) controllers split the device into three separate event nodes.

On my system I get:
"Sony Interactive Entertainment Wireless Controller"
"Sony Interactive Entertainment Wireless Controller Touchpad"
"Sony Interactive Entertainment Wireless Controller Motion Sensors"

Apparently this is due to some evdev policy: "A device must not mix regular directional axes and accelerometer axes on the same event node."

Our input system does allow use of multiple devices via "All Devices" or so-called "absolute path" control expressions, but this is less than desirable especially when making use of multiple DS4s.

This PR combines evdev devices that return the same non-null unique ID (via libevdev_get_uniq).

Mapping of DS4 acceleration, gyroscope, and touchpad inputs is now less horrible.

To prevent collisions of input names in combined devices I've made a few changes:

  • If the INPUT_PROP_BUTTONPAD property is set then only X/Y axes are added with "Cursor X/Y" names. (Our default mouse mappings now work with the DS4 touchpad)
  • Axes beyond ABS_MISC are no longer enumerated as they relate to multi-touch and require tracking and special processing of events for useful data.
  • Buttons now take on their libevdev_event_code_get_name names in more situations rather than numbered "Button 0" names. (Existing normal button configurations will still work by overriding IsMatchingName. Touchpad inputs will need to be remapped but this is unavoidable as the names clashed.)
g_controller_interface.RemoveDevice([&name](const auto& device) {
return device->GetSource() == "evdev" && device->GetName() == name && !device->IsValid();
});
const auto it = s_devnode_objects.find(devnode);

This comment has been minimized.

Copy link
@CookiePLMonster

CookiePLMonster Nov 17, 2019

Contributor

devnode is a const char*, while s_devnode_objects's key is std::string. This will construct a temporary std::string , unless you make s_devnode_objects use a transparent comparator (std::less<>).

This comment has been minimized.

Copy link
@jordan-woyak

jordan-woyak Nov 17, 2019

Author Member

This was also done before I touched the code. There's nothing too wrong with a temporary std::string.

@jordan-woyak jordan-woyak force-pushed the jordan-woyak:evdev-combine branch from c25bb96 to d0177bd Nov 17, 2019
@jordan-woyak jordan-woyak changed the title ControllerInterface: Combine evdev devices with the same unique ID. WIP - ControllerInterface: Combine evdev devices with the same unique ID. Nov 17, 2019
@jordan-woyak jordan-woyak changed the title WIP - ControllerInterface: Combine evdev devices with the same unique ID. ControllerInterface: Combine evdev devices with the same unique ID. Nov 17, 2019
@lioncash

This comment has been minimized.

Copy link
Member

lioncash commented Nov 17, 2019

The first commit should probably include most of the description put in the main PR comments, so that context is actually stored in the repository history.

This works around Linux drivers for DS4 (Playstation 4) controllers splitting the device into three separate event nodes which makes configuration difficult.
To prevent collisions of input names in combined devices more descriptive names are now used when possible.
@jordan-woyak jordan-woyak force-pushed the jordan-woyak:evdev-combine branch from 35dd194 to f3b81fc Nov 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants
You can’t perform that action at this time.