Commit Graph

22 Commits

Author SHA1 Message Date
Tillmann Karras 57a005ff3e evdev: reduce startup time
GetName() creates a new evdev device which calls tons of ioctls. But the
main culprit is close() which for input devices appears to be a slow
path in the kernel.

This commit reduces PopulateDevices() by 50% on my laptop, but ~730 ms
is still ridiculously slow for something that isn't needed right away.
2016-12-26 01:24:35 +01:00
Tillmann Karras f575902cf3 evdev: set flag in a thread-safe way 2016-12-05 00:47:26 +00:00
Tillmann Karras 3c090a37d4 evdev: fix shutdown hang
Note: This probably means our approach of populating from udev isn't
safe to be called multiple times.
2016-12-05 00:47:26 +00:00
Michael Maltese 3e69d066f5 ControllerInterface: replace Reinitialize with RefreshDevices
The SDL backend crashes when you close a joystick after SDL_Quit has
been called. Some backends don't need to be shutdown and
re-initialized everytime, we can just ask to enumerate devices again.
2016-11-30 16:07:55 -08:00
Léo Lam 68156a02ed Fix -Wunused-result warnings 2016-10-23 00:43:08 +02:00
Léo Lam 135641404a evdev: Add hotplugging support
This adds hotplugging support to the evdev input backend. We use
libudev to monitor changes to input devices in a separate thread.
Removed devices are removed from the devices list, and new devices
are added to the list.

The effect is that controllers are usable immediately after plugging
them without having to manually refresh devices (if they were
configured to be used, of course).
2016-07-29 17:18:40 +02:00
Léo Lam 788e19f54d ControllerInterface: Make the ID assigning code common
This makes the device ID assigning code common to all backends, by
moving it to AddDevice() instead of copy-pasting or replicating
the logic in the backends.

Also, to prepare for hotplugging, instead of relying on a name usage
count, the new ID assigning system always starts from ID 0 and tries
to assign the first ID that is not used.
2016-07-14 10:50:53 +02:00
Scott Mansell e0839a9478 Strip whitespace from Evdev and OSX controller names. 2016-07-12 14:19:07 +12:00
Léo Lam 6cc4591226 evdev: Clamp axis values to the 0.0-1.0 range
The values are expected to be in the 0.0-1.0 range (as indicated by the
comment), and other parts of Dolphin also expect it to be in that range
since the "full" axis has a -1.0 to 1.0 range.  However, this is not
always the case and fvalue can end up being outside of the range. This
clamps fvalue to always be in the 0.0 and 1.0 range.
2016-07-11 14:00:09 +02:00
Léo Lam 8678133e87 ControllerInterface: Switch to std::shared_ptr
Small cleanup by using std::shared_ptr and getting rid of
ciface.Devices() which just returned the m_devices (which defeats the
point of making m_devices protected).

Incidentally, this should make the code safer when we have
different threads accessing devices in the future (for hotplug?).

A lot of code use Device references directly so there is
no easy way to remove FindDevice() and make those unique_ptrs.
2016-06-25 21:46:39 +02:00
Léo Lam fd29e5c4cc ControllerInterface: Don't pass m_devices to the backends
Previously, the devices vector would be passed to all backends. They
would then manually push_back to it to add new devices. This was fine
but caused issues when trying to add synchronisation.

Instead, backends now call AddDevice() to fill m_devices so that it is
not accessible from the outside.
2016-06-25 13:46:53 +02:00
Pierre Bourdon 3570c7f03a Reformat all the things. Have fun with merge conflicts. 2016-06-24 10:43:46 +02:00
Lioncash 19ac565e0d Common: Move asserts to their own header 2015-09-26 18:51:27 -04:00
Tillmann Karras b3ff66dc7a evdev: don't pass null path to the kernel 2015-08-15 12:51:34 +02:00
Rohit Nirmal ac54bbe02d Fix building with PCH disabled. 2015-08-04 12:59:34 -05:00
Tillmann Karras 5a05187b3b Fix some warnings
reorder, sign-compare, pessimizing-move
2015-08-04 10:58:24 +02:00
Gabriel Corona 2722f3f337 Stable device identifier for evdev 2015-08-02 01:51:06 +02:00
Scott Mansell dc25277a2f Merge branch 'stable' into 'master' 2015-07-13 12:40:38 +12:00
Rohit Nirmal c38ae5236e Fix building with PCH disabled. 2015-07-08 13:52:43 -05:00
Scott Mansell 6e969133f5 evdev: Delete rumble effects on the correct file descriptor.
Was using m_id insted of m_fd.
Also re-arrange the code so rumble effects always get deleted instead of
just on stop commands.
2015-07-07 16:59:10 +12:00
Scott Mansell 77183899e0 evdev: Support axis with ranges which extend below zero. 2015-07-01 10:13:05 +12:00
Scott Mansell 2721fdf8a9 Linux: Add an evdev based controller backend, to replace SDL. 2015-07-01 10:13:05 +12:00