Commit Graph

75 Commits

Author SHA1 Message Date
Pierre Bourdon e149ad4f0a
treewide: convert GPLv2+ license info to SPDX tags
SPDX standardizes how source code conveys its copyright and licensing
information. See https://spdx.github.io/spdx-spec/1-rationale/ . SPDX
tags are adopted in many large projects, including things like the Linux
kernel.
2021-07-05 04:35:56 +02:00
Filoppi a0ecca1a84 ControllerInterface: Implement ChangeWindow on DInput without recreating the devices
Also polished DInput code in general to try and mitigate issue 11702.
Added a lot of logging and comments.
2021-06-07 11:07:06 +03:00
Filoppi dcc345400e ControllerInterface: devices population is now async so implement devices sorting priority
This helps us keeping the most important devices (e.g. Mouse and Keyboard) on the top
of the list of devices (they still are on all OSes supported by dolphin
and to make hotplug devices like DSU appear at the bottom.
2021-06-07 11:07:06 +03:00
Filoppi 1d816f8f26 ControllerInterface: make real Wiimote use PlatformPopulateDevices() 2021-06-07 11:07:06 +03:00
Filoppi c238e49119 ControllerInterface: Remove OSX window handle
also make it more thread safe (avoid rare deadlock)
and fix it trying to add devices before the CI has init
2021-06-07 11:07:05 +03:00
Filoppi 2376aec135 ControllerInterface: Refactor
-Fix Add/Remove/Refresh device safety, devices could be added and removed at the same time, causing missing or duplicated devices (rare but possible)
-Fix other devices population race conditions in ControllerInterface
-Avoid re-creating all devices when dolphin is being shut down
-Avoid re-creating devices when the render window handle has changed (just the relevantr ones now)
-Avoid sending Devices Changed events if devices haven't actually changed
-Made most devices populations will be made async, to increase performance and avoid hanging the host or CPU thread on manual devices refresh
2021-06-07 11:07:05 +03:00
Filoppi f90d851e25 ControllerInterface: mixed comments 2021-06-07 11:07:05 +03:00
Filoppi c285ae57fb ControllerInterface: fix rare deadlock
A "devices changed" callback could have ended up waiting on another thread that was also populating devices
and waiting on the previous thread to release the callbacks mutex.
2021-06-07 11:07:05 +03:00
Filoppi 81092cf7e4 InputCommon: replace SerialInterface log with ControllerInterface
where appropriate. SerialInterface was a leftover from the past,
and makes no sense to be used on actual/real controllers.
2021-05-05 00:16:08 +03:00
iwubcode db4b4e40cb InputCommon / DolphinQt / Core: Add a "RelativeMouse" input which provides the raw delta mouse input
Co-authored-by: Jordan Woyak <jordan.woyak@gmail.com>
2021-03-17 20:58:33 -05:00
seth 00ec25d520 InputCommon: Fix callback dispatch deadlock
Make sure m_is_populating_devices is true when a WM_INPUT_DEVICE_CHANGE
event is received directly on the ciface thread, so that callbacks do
not occur while removing devices. This breaks a hold-and-wait deadlock
between the ciface thread and the CPU thread when using emulated
Wiimotes.

Co-authored-by: brainleq <brainleq@users.noreply.github.com>
Co-authored-by: oldmud0 <oldmud0@users.noreply.github.com>
2020-12-13 00:30:27 +00:00
Lioncash a5e1415e74 InputCommon: Migrate logging over to fmt
Continues the migration of the logging calls over to the fmt capable
ones.
2020-10-23 13:16:18 -04:00
Thomas May 76ae1d4070 Apply fixes to all platforms 2020-05-09 22:35:20 +01:00
Thomas May 78e8ccea6d Update ControllerInterface.cpp 2020-05-06 01:30:49 +01:00
Stenzek 86db015c23 Common: Add a render_window field to WindowSystemInfo
We need this because we need to pass the layer to MoltenVK, not
the view handle. But the input subsystem still needs the window.
2020-03-11 23:09:30 +10:00
Jordan Woyak 58448d74c5 InputCommon: Add real Wii Remote support to ControllerInterface. Add option to connect additional Wii Remotes. 2020-02-17 16:14:01 -06:00
Jordan Woyak 4176cc77e1 InputCommon/ControllerInterface: Make devices mutex recursive so RemoveDevice can be used within UpdateInput. 2020-02-17 15:58:06 -06:00
Jordan Woyak b92f6480a0 InputCommon: Make "Cursor" inputs aware of the rendered aspect ratio. 2020-01-24 09:20:41 -06:00
rlnilsen da1f153b47 Rename all instances of "CemuhookUDPServer"/"UDPServer" to "DualShockUDPClient"/"DSUClient". 2019-10-27 16:05:22 +01:00
rlnilsen 4cb3baba5c Add support for motion controllers via the CemuHook controller input protocol.
This is done by:
1) Implementing said protocol in a new controller input class CemuHookUDPServer.
2) Adding functionality in the WiimoteEmu class for pushing that motion input to the emulated Wiimote and MotionPlus.
3) Suitably modifying the UI for configuring an Emulated Wii Remote.
2019-10-26 02:19:53 +02:00
Jordan Woyak eadbdd6bc3 ControllerInterface/Win32: Prevent devcies from losing their "id" on a hotplug event. 2019-03-29 09:04:16 -05:00
Michael M d26c1ce24d Add hotplug support to DInput and XInput controller backends 2019-03-29 08:01:40 -05:00
Michael M 92ca6e124e Add ControllerInterface::Win32 to wrap XInput and DInput 2019-03-29 08:01:39 -05:00
Jordan Woyak b425f86121 ControllerInterface: Allow hotplug callbacks to be unregistered and don't reload the entire config from the ini file on hotplug, just update the control references. This should fix a crash on shutdown on Android. 2019-01-10 18:32:16 -06:00
Jordan Woyak 25d43ffd98 ControllerInterface: Shutdown order and race condition fix. 2019-01-02 08:19:42 -06:00
Stenzek 52828901ef Core: Switch controller interface to render widget on booting
Previously, the Qt frontend would initialize the controller
interface on starting, resulting in the cursor position being
relative to the main window, instead of the render window.
2018-10-29 11:46:06 +10:00
Stenzek a7f334dc2a ControllerInterface: Don't crash on non-X11 QPA 2018-10-29 11:46:06 +10:00
Michael M 932ca644aa Add hotplug support to SDL2 controller backend 2018-06-04 17:50:08 +02:00
Michael M 8e6677be90 ControllerInterface: don't call InvokeDevicesChangedCallbacks more than once when refreshing 2017-11-10 13:37:42 -08:00
Michael M fd7cbd633e ControllerInterface: add mutex around callbacks vector 2017-11-10 13:37:42 -08:00
Michael M 1ed7532af8 ControllerInterface: HotplugCallbacks -> DevicesChangedCallbacks 2017-11-10 13:37:42 -08:00
Michael M 7355b5f70d ControllerInterface: invoke callbacks in AddDevice/RemoveDevice
Some backends already cause this to happen, so make it consistent across
systems.
2017-11-10 13:37:41 -08:00
Michael Maltese a509f56116 InputCommon: Extract ControlReference from ControllerInterface
Better separation of concerns. Relegates `ControllerInterface` to
enumerating input controls, and the new `ControlReference` deals with
combining inputs and configuration expression parsing.
2017-02-07 22:59:10 -08: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
Michael Maltese cebb4d84f2 ControllerInterface: clear devices before shutting down backends
The SDL backend faults if it tries to close a joystick after SDL_Quit
has been called.
2016-11-30 16:07:54 -08:00
shuffle2 2747fd3a0d Merge pull request #4102 from ligfx/quartz_input
Add Quartz/CoreGraphics controller interface for default k&m events
2016-10-03 03:13:58 -07:00
Jasper St. Pierre 928d05ec47 InputCommon: Remove the Xlib backend
The XInput2 backend is more performant, so let's default to it and
remove the old, core-only backend.
2016-09-04 10:44:22 -07:00
Michael Maltese 3dc8136e14 Add Quartz/CoreGraphics controller interface for default k&m events 2016-08-08 09:38:22 -07: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 3926db624d ControllerInterface: Don't block on UpdateInput()
Changes UpdateInput() to skip if we can't lock the mutex, instead of
potentially blocking the CPU thread and causing a short but noticeable
frame drop.
2016-07-29 17:18:40 +02:00
Léo Lam 93f5df4195 ControllerInterface: Add RemoveDevice()
This adds RemoveDevice() to ControllerInterface, fixes ExpressionParser
and some other code to support device removals without crashing,
and adds an IsValid() method to Device, to prepare for hotplugging.
2016-07-29 17:18:37 +02:00
Léo Lam 0d783f0869 ControllerInterface: Add a way to register callbacks
This adds RegisterHotplugCallback() to register a callback which will
be invoked by the input backends' hotplug threads when there is a new
device, so that Core (GCKeyboard, GCPad, Wiimote, Hotkey) can reload
the configuration without adding a dependency to Core from InputCommon.
2016-07-29 17:16:22 +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
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 d3e2ae35ff ControllerInterface: Add synchronisation
Since we may have to add/access devices from different threads, this
adds synchronisation to anything that touches m_devices.
2016-06-25 13:46:53 +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
booto b89c79b9f2 Comment change to reflect what code does 2016-01-10 02:42:56 +08:00
spxtr d9d6cf8eda GC controller input using named pipes
Currently only works on unix, but can be extended to other systems. Can
also be extended to do wiimotes.

Searches the Pipes folder for readable named pipes and creates a dolphin
input device out of them. Send controller inputs to the game by writing
to the file. Commands are described in Pipes.h.
2015-10-24 20:20:03 -07:00
Scott Mansell 2721fdf8a9 Linux: Add an evdev based controller backend, to replace SDL. 2015-07-01 10:13:05 +12:00