summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
AgeCommit message (Collapse)Author
2021-12-05InputCommon: fix default input config default device not being loaded/foundFiloppi
Fixes bug: https://bugs.dolphin-emu.org/issues/12744 Before https://github.com/dolphin-emu/dolphin/commit/e1e3db13baabefa89991388d37db0bb260c4f535 the ControllerInterface m_devices_mutex was "wrongfully" locked for the whole Initialize() call, which included the first device population refresh, this has the unwanted (accidental) consequence of often preventing the different pads (GC Pad, Wii Contollers, ...) input configs from loading until that mutex was released (the input config defaults loading was blocked in EmulatedController::LoadDefaults()), which meant that the devices population would often have the time to finish adding its first device, which would then be selected as default device (by design, the first device added to the CI is the default default device, usually the "Keyboard and Mouse" device). After the commit mentioned above removed the unnecessary m_devices_mutex calls, the default default device would fail to load (be found) causing the default input mappings, which are specifically written for the default default device on every platform, to not be bound to any physical device input, breaking input on new dolphin installations (until a user tried to customize the default device manually). Default devices are now always added synchronously to avoid the problem, and so they should in the future (I added comments and warnings to help with that)
2021-11-20ControllerInterface: fix UpdateReferences() deadlockFiloppi
Removed useless locks to DeviceContainer::m_devices_mutex, as they were all already protected by m_devices_population_mutex. We have no interest in blocking other threads that were potentially reading devices at the same time so this seems fine. This simplifies the code, and I've adjusted a few comments which mentioned possible deadlock that should now be totally gone. The deadlock could have happen if a thread directly called EmulatedController::UpdateReferences(), while another another thread also reached EmulatedController::UpdateReferences() within a call to ControllerInterface::UpdateDevices(), as the mentioned function locked both the DeviceContainer::m_devices_mutex and s_get_state_mutex at the same time. The deadlock was frequent on game emulation startup on Android, due to the UpdateReferences() call in InputConfig::LoadConfig() and the UI thread triggering calls to ControllerInterface::UpdateDevices(). It could also have happened on Desktop if a user pressed "Refresh Devices" manually in the UI while the input config was loading. Also brought some UpdateReferences() comments and thread safety fixes from https://github.com/dolphin-emu/dolphin/pull/9489
2021-07-05treewide: convert GPLv2+ license info to SPDX tagsPierre Bourdon
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-06-07ControllerInterface: Implement ChangeWindow on DInput without recreating the ↵Filoppi
devices Also polished DInput code in general to try and mitigate issue 11702. Added a lot of logging and comments.
2021-06-07ControllerInterface: devices population is now async so implement devices ↵Filoppi
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-07ControllerInterface: make real Wiimote use PlatformPopulateDevices()Filoppi
2021-06-07ControllerInterface: Remove OSX window handleFiloppi
also make it more thread safe (avoid rare deadlock) and fix it trying to add devices before the CI has init
2021-06-07ControllerInterface: RefactorFiloppi
-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-07ControllerInterface: mixed commentsFiloppi
2021-06-07ControllerInterface: fix rare deadlockFiloppi
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-05-05InputCommon: replace SerialInterface log with ControllerInterfaceFiloppi
where appropriate. SerialInterface was a leftover from the past, and makes no sense to be used on actual/real controllers.
2021-03-17InputCommon / DolphinQt / Core: Add a "RelativeMouse" input which provides ↵iwubcode
the raw delta mouse input Co-authored-by: Jordan Woyak <jordan.woyak@gmail.com>
2020-12-13InputCommon: Fix callback dispatch deadlockseth
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-10-23InputCommon: Migrate logging over to fmtLioncash
Continues the migration of the logging calls over to the fmt capable ones.
2020-05-09Apply fixes to all platformsThomas May
2020-05-06Update ControllerInterface.cppThomas May
2020-03-11Common: Add a render_window field to WindowSystemInfoStenzek
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-02-17InputCommon: Add real Wii Remote support to ControllerInterface. Add option ↵Jordan Woyak
to connect additional Wii Remotes.
2020-02-17InputCommon/ControllerInterface: Make devices mutex recursive so ↵Jordan Woyak
RemoveDevice can be used within UpdateInput.
2020-01-24InputCommon: Make "Cursor" inputs aware of the rendered aspect ratio.Jordan Woyak
2019-10-27Rename all instances of "CemuhookUDPServer"/"UDPServer" to ↵rlnilsen
"DualShockUDPClient"/"DSUClient".
2019-10-26Add support for motion controllers via the CemuHook controller input protocol.rlnilsen
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-03-29ControllerInterface/Win32: Prevent devcies from losing their "id" on a ↵Jordan Woyak
hotplug event.
2019-03-29Add hotplug support to DInput and XInput controller backendsMichael M
2019-03-29Add ControllerInterface::Win32 to wrap XInput and DInputMichael M
2019-01-10ControllerInterface: Allow hotplug callbacks to be unregistered and don't ↵Jordan Woyak
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-02ControllerInterface: Shutdown order and race condition fix.Jordan Woyak
2018-10-29Core: Switch controller interface to render widget on bootingStenzek
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-29ControllerInterface: Don't crash on non-X11 QPAStenzek
2018-06-04Add hotplug support to SDL2 controller backendMichael M
2017-11-10ControllerInterface: don't call InvokeDevicesChangedCallbacks more than once ↵Michael M
when refreshing
2017-11-10ControllerInterface: add mutex around callbacks vectorMichael M
2017-11-10ControllerInterface: HotplugCallbacks -> DevicesChangedCallbacksMichael M
2017-11-10ControllerInterface: invoke callbacks in AddDevice/RemoveDeviceMichael M
Some backends already cause this to happen, so make it consistent across systems.
2017-02-07InputCommon: Extract ControlReference from ControllerInterfaceMichael Maltese
Better separation of concerns. Relegates `ControllerInterface` to enumerating input controls, and the new `ControlReference` deals with combining inputs and configuration expression parsing.
2016-11-30ControllerInterface: replace Reinitialize with RefreshDevicesMichael Maltese
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-30ControllerInterface: clear devices before shutting down backendsMichael Maltese
The SDL backend faults if it tries to close a joystick after SDL_Quit has been called.
2016-10-03Merge pull request #4102 from ligfx/quartz_inputshuffle2
Add Quartz/CoreGraphics controller interface for default k&m events
2016-09-04InputCommon: Remove the Xlib backendJasper St. Pierre
The XInput2 backend is more performant, so let's default to it and remove the old, core-only backend.
2016-08-08Add Quartz/CoreGraphics controller interface for default k&m eventsMichael Maltese
2016-07-29evdev: Add hotplugging supportLéo Lam
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-29ControllerInterface: Don't block on UpdateInput()Léo Lam
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-29ControllerInterface: Add RemoveDevice()Léo Lam
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-29ControllerInterface: Add a way to register callbacksLéo Lam
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-14ControllerInterface: Make the ID assigning code commonLéo Lam
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-06-25ControllerInterface: Switch to std::shared_ptrLéo Lam
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-25ControllerInterface: Add synchronisationLéo Lam
Since we may have to add/access devices from different threads, this adds synchronisation to anything that touches m_devices.
2016-06-25ControllerInterface: Don't pass m_devices to the backendsLéo Lam
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-24Reformat all the things. Have fun with merge conflicts.Pierre Bourdon
2016-01-10Comment change to reflect what code doesbooto