Commit Graph

399 Commits

Author SHA1 Message Date
Filoppi 0718cfd7d7 ControllerInterface: make evdev use PlatformPopulateDevices
Also fix evdev non thread safe acces to static variables
2021-06-07 11:07:06 +03:00
Filoppi 2aa941081e ControllerInterface: make SDL use PlatformPopulateDevices()
and avoid waiting on SDL async population being finished for no reason
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 98b00a28e4 ControllerInterface: make DSU inputs start from resting pose instead of 0. Add battery level 2021-05-31 02:24:41 +03:00
Filoppi 16e4dede72 ControllerInterface: DSU polish: avoid hanging host thread, add disconnection detection, ...
-Reworked thread waits to never hang the Host thread for more than a really small time
(e.g. when disabling DSU its thread now closes almost immediately)
-Improve robustness when a large amount of devices are connected
-Add devices disconnection detection (they'd stay there forever until manually refreshed)
2021-05-31 02:21:17 +03:00
Filoppi 83806462ec ControllerInterface: fix DSU using the same client uid between server and controllers queries
that's not the way it's supposed to work
2021-05-31 02:17:25 +03:00
Filoppi a261e61e9e InputCommon: add a ton of missing consts
fix some related grammar errors
only the ButtonManager required code changes
2021-05-10 23:48:10 +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
Léo Lam 9a3e752021
Merge pull request #9558 from iwubcode/dsu-multi-server-avoid-blocking
InputCommon: block on DSU servers collectively instead of individually
2021-03-16 10:12:32 +01:00
Dentomologist 486a25dd2b Touchscreen: Add override specifiers
Fix -Winconsistent-missing-override warnings on Android
2021-03-07 10:10:02 -08:00
Dentomologist 1fd332d3b7 ControllerInterface: Fix unused-result warning
Add ! before unused variables to 'use' them.

Ubuntu-x64 emits warnings for unused variables because gcc decides
it should ignore the void cast around them. See thread for discussion:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425
2021-03-07 10:10:02 -08:00
iwubcode dbb0b72cc5 InputCommon: instead of blocking on individual DSU server sockets, block on a selector built up from all server sockets 2021-03-05 12:05:38 -06:00
Léo Lam 858f00b641
Merge pull request #9492 from nolange/fix_norandr_build
Cleanup X11 and XRANDR Macros
2021-03-01 11:36:39 +01:00
Filoppi e020b2e8ea Common: don't call OnConfigChanged() unless it has actually changed
DualShock UDP Client is the only place in the code that assumed OnConfigChanged()
is called at least once on startup or it won't load up the setting, so I took care of that
2021-02-26 01:14:00 +02:00
Norbert Lange 29eaf09be4 Cleanup X11 and XRANDR Macros
This fixes build with X11 enabled and XRANDR disabled.
2021-02-22 14:30:43 +01:00
Shawn Hoffman 7e1df34735 rename InputCommon/ControllerInterface/Device to CoreDevice 2021-01-27 14:29:48 -08:00
Shawn Hoffman 0be1491ef0 rename ciface::Wiimote to ciface::WiimoteController 2021-01-27 14:29:48 -08:00
Léo Lam ee25f03ff9
Merge pull request #9418 from Filoppi/patch-10
Fix DualShockUDP not adding/removing devices correctly
2021-01-05 15:15:53 +01:00
Filippo Tarpini 1e4a1bee43 Fix DualShockUDP not adding/removing devices correctly
-If adding 2 devices with the same name, they their unique id wouldn't be increased, causing a conflict.
-Removing a device wouldn't actually remove it from the internal devices list because the list of devices had already been updated when going through it.
-It was possible to remove devices belonging to other sources by adding a device with the same name and then removing it.
2021-01-03 21:06:06 +02:00
Filippo Tarpini 8813ba69f5 Fix Quartz cursor going to +infinite if the window size was 0 2021-01-02 19:55:19 +02:00
Filippo Tarpini 5a5c815ff0
Fix DInput cursor going to +infinite if the window size was 0 2021-01-02 18:33:13 +02:00
Filippo Tarpini 75f35393c3
Fix XInput2 cursor going to +infinite if the window size was 0 2021-01-02 18:30:14 +02: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
LC de96fe0860
Merge pull request #9162 from jordan-woyak/quaternion
Replace stateful rotational matrices with quaternions.
2020-10-21 17:34:11 -04:00
Jordan Woyak 09431635f3 InputCommon/WiimoteEmu: Replace stateful rotational matrices with quaternions. 2020-10-19 16:33:55 -05:00
Jordan Woyak bbb12a7560 Linux/XInput2: Fix keys being stuck pressed on focus loss. 2020-10-19 11:46:01 -05:00
Jordan Woyak f9280d0f66 ControllerInterface/Wiimote: Add "IR Distance" input providing a calculated distance from sensor bar in meters. 2020-09-28 18:09:34 -05:00
Jordan Woyak 48b76ff90f InputCommon: Improve input detection to produce buton combinations. 2020-09-25 22:51:32 -05:00
Jordan Woyak d8ad8c3861 InputCommon: Make hotkeys and input detection aware of Ctrl -> L_Ctrl / R_Ctrl hierarchy. 2020-09-25 20:29:18 -05:00
Jordan Woyak f015c99a51 ControllerInterface: Add platform consistent names for modifier keys. 2020-09-25 20:29:18 -05:00
Jordan Woyak b3acc7403f InputCommon: Support detecting combinations of inputs. (Hotkeys) 2020-09-25 20:29:18 -05:00
Jordan Woyak 50b5224d06
Merge pull request #8840 from Techjar/evdev-combining-phys
ControllerInterface: Combine evdev devices with the same physical location in addition to unique ID
2020-09-20 09:28:09 -05:00
JMC47 4f1f849c9d
Merge pull request #8985 from jordan-woyak/btemu-cleanup
BTEmu/Wiimote: Fixes and Cleanups.
2020-09-14 02:09:27 -04:00
Techjar 8423f848d0 ControllerInterface: Combine evdev devices with the same physical location in addition to unique ID 2020-09-08 18:52:15 -04:00
Shawn Hoffman 6ef9d70701 name some threads 2020-08-22 17:22:07 -07:00
Jordan Woyak 13ee6bd7bb BTEmu/Wiimote: Cleanups/Fixes. 2020-08-16 11:38:13 -05:00
Tilka f17b5dd41b
Merge pull request #8804 from iwubcode/dsu-improvements
DolphinQt / InputCommon - Support multiple DSU servers
2020-08-08 20:45:57 +01:00
LC 487cd7abd9
Merge pull request #8905 from JosJuice/jni-encoding
Android: Use correct encoding when converting strings
2020-07-18 22:13:14 -04:00
iwubcode 97c9cf3e21 DolphinQt / InputCommon - add DSU string validator to avoid crashes, limited backwards compatibility support 2020-07-17 14:53:39 -05:00
iwubcode 58aa0150e1 DolphinQt / InputCommon: Support multiple DSU servers 2020-07-17 14:53:39 -05:00
Jordan Woyak 5299e902aa ControllerInterface/Wiimote: Provide fallback values for extensions with bad calibration data. 2020-07-11 19:55:14 -05:00
JosJuice 15d9fab0bb Common: Rename UTF16ToUTF8
This function does *not* always convert from UTF-16. It converts
from UTF-16 on Windows and UTF-32 on other operating systems.

Also renaming UTF8ToUTF16 for consistency, even though it
technically doesn't have the same problem since it only was
implemented on Windows.
2020-07-08 14:51:35 +02:00
LC 87287181dd
Merge pull request #8907 from JosJuice/android-overlay-stick-gate
Android: Use octagonal stick gate in overlay
2020-07-08 08:50:47 -04:00
Jordan Woyak d382c6bab9 WiimoteCommon: Tweak battery level math. 2020-06-28 19:40:26 -05:00
JosJuice db75509ec5 Android: Enfore correct stick gate in overlay
Currently, the touch controller overlay uses a square gate for
sticks. This commit changes that so that it instead uses the
stick gate configured in the INI, which ensures that the values
sent to the core are appropriately scaled regardless of what
is configured in the INI and makes the overlay look nicer
if the INI is set to a stick gate that matches the graphics.
2020-06-29 01:20:02 +02: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
Léo Lam 19da101164 Remove redundant Config prefix from ConfigInfo/ConfigLocation
Both structs are already in the Config namespace.
2020-05-02 14:40:14 +02:00
Léo Lam 9d44af4c31
Merge pull request #8696 from howard0su/cleanup_shadow
Cleanup warnings of -Wmissing-declarations
2020-04-27 15:33:01 +02:00
Jun Su b6ff15c130 Cleanup warnings of -Wmissing-declarations
Add static to the functions which is not intentionally
export to big scope.
2020-03-24 20:16:10 +08:00
Jun Su 997cfa49fc InputCommon: cleanup warnings of -Wclass-memaccess
Initialize m_state with the default constructor.
2020-03-23 14:26:36 +08: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 7accd9825f InputCommon: Remove racy UpdateInput call in DetectInput. 2020-02-24 16:25:06 -06:00
Jordan Woyak da12f3eebc InputCommon: Constify Device::Input::IsDetectable function. 2020-02-22 10:27:43 -06:00
Jordan Woyak 70ac9ad2e6 InputCommon: Remove Wii Remote real-time calibration of M+ in favor of functionality provided by ControllerEmu. 2020-02-17 16:14:03 -06: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
JMC47 5ab846ad12 Merge pull request #8614 from jordan-woyak/xinput-battery
InputCommon/XInput: Expose battery as input and cleanups.
2020-02-09 09:29:00 -05:00
Jordan Woyak 4f47cccd9f Cleanup: Use std::abs instead of abs. 2020-02-08 18:21:14 -06:00
Jordan Woyak e7400cafd2 InputCommon: XInput cleanups. 2020-02-08 15:51:02 -06:00
Jordan Woyak 86e8745169 InputCommon: Expose XInput battery level as an input. 2020-02-08 15:03:56 -06:00
Léo Lam 0491831483
Merge pull request #8592 from phcoder/devid
ButtonManager: Fix handling of empty device id.
2020-02-02 16:52:12 +01:00
Connor McLaughlin 69ee15e5ef
Merge pull request #8478 from jordan-woyak/dsu-client-cleanup
ControllerInterface/DSUClient: Minor cleanup.
2020-02-01 11:29:29 +10:00
Vladimir Serbinenko 02c5d292fa ButtonManager: Fix handling of empty device id.
Device id is "" on ChromeOS when using gamepad
2020-01-29 02:47:18 +01:00
Jordan Woyak b92f6480a0 InputCommon: Make "Cursor" inputs aware of the rendered aspect ratio. 2020-01-24 09:20:41 -06:00
Jordan Woyak 6106f780a7 ControllerInterface/DSUClient: Eliminate m_accl/m_gyro state by accessing the pad data directly like every other input. 2020-01-13 17:35:33 -06:00
JMC47 eacbff76dd
Merge pull request #8474 from jordan-woyak/dsu-battery
ControllerInterface: Exposse DSU client battery level as an input.
2020-01-13 18:30:53 -05:00
Jordan Woyak e2d5c92c76 ControllerInterface: Remove and re-add device when combining nodes. 2020-01-13 16:50:58 -06:00
Jordan Woyak aabe8d2ccd ControllerInterface: Don't consider the empty string a valid unique ID. 2020-01-13 16:50:58 -06:00
Jordan Woyak ac907ef977 ControllerInterface: Combine evdev devices with the same unique ID.
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.
2020-01-13 16:50:56 -06:00
Jordan Woyak 2b9fa0597a ControllerInterface: Minor DSU client device cleanups. 2020-01-13 16:32:02 -06:00
Jordan Woyak f0534cabc6 ControllerInterface: Exposse DSU client battery level as an input. 2020-01-13 16:29:24 -06:00
Scott Mansell a8c33f4ef6
Fix trailing whitespace 2020-01-07 12:52:05 +13:00
Scott Mansell 21528c3e72
Document the evdev "interesting" heuristic
Was checking over this old code, and saw a comment calling me out for a lack of documentation.

It might be half a decade late, but better late then never.
2020-01-07 12:46:24 +13:00
Pierre Bourdon 5c996dec89
DualShockUDPClient: downgrade spurious NOTICE_LOGs 2019-12-23 18:36:18 +01:00
OatmealDome ef32a10d69 InputCommon: Decouple ButtonManager and Touchscreen from Android
Changes were also made for codestyle compliance.
2019-11-28 15:20:51 -05:00
Anthony 155016531f
Merge pull request #8439 from JosJuice/android-native-motion-controls
Android: Native motion controls
2019-11-27 15:40:43 -08:00
Léo Lam ec895f544c
Merge pull request #8486 from lioncash/dualshock
InputCommon/DualShockUDPClient: Minor cleanup
2019-11-24 00:46:19 +01:00
Lioncash 334e2768f5 InputCommon/DualShockUDPClient: Use an alias for the clock type
Makes code slightly less verbose without exposing the whole chrono
header to the current source file.
2019-11-22 17:06:10 -05:00
Lioncash db9e592765 InputCommon/DualShockUDPClient: Use deduction guides for lock_guard
With C++17, we can use template deduction guides provided by the
standard library. This allows the omission of the mutex type itself.
2019-11-22 17:06:10 -05:00
Lioncash 278d03f737 InputCommon/DualShockUDPClient: Make use of std::array where applicable
Provides the same semantics of a C array, but is much nicer to work
with.

Notably, it makes all cases of performing comparisons with said arrays
significantly less reading-involved.
2019-11-22 17:06:07 -05:00
Lioncash 67097b4574 InputCommon/DualShockUDPClient: Relocate settings to top of source file
This is a small namespace, so we can move it to the top of the file to
get it out of the way of everything else.
2019-11-22 15:56:29 -05:00
Lioncash 4488719a76 InputCommon/DualShockUDPClient: In-class initialize members where applicable
Deduplicates members within the constructor's initializer list.
2019-11-22 15:56:29 -05:00
Lioncash 544d6cbe52 InputCommon/DualShockUDPClient: Add missing header guard
Prevents potential inclusion issues from occurring.
2019-11-22 15:56:26 -05:00
Lioncash e8edc49bbe InputCommon: Make use of fmt where applicable
Continues the migration over to fmt
2019-11-22 14:38:26 -05:00
JosJuice c8b8a60033 Android: Let WiimoteEmu know whether we have accelerometer/gyroscope 2019-11-20 20:13:36 +01:00
JosJuice b143df91be Android: Native motion controls 2019-11-20 18:22:20 +01:00
Jordan Woyak 0c57887839 evdev: fix bad integer division. 2019-11-10 10:10:37 -06:00
Jordan Woyak 1180c231a6 InputCommon: Detect when evdev exposes acceleration/gyroscope data. 2019-11-09 13:34:29 -06:00
rlnilsen da1f153b47 Rename all instances of "CemuhookUDPServer"/"UDPServer" to "DualShockUDPClient"/"DSUClient". 2019-10-27 16:05:22 +01:00
rlnilsen 5ff79499a5 UDPServer: Add configuration UI.
Accessed through button "Alternate Input Sources" in the "Controller Settings" dialog.
2019-10-26 02:20:18 +02: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
Connor McLaughlin 48ca2c6f2e
Merge pull request #8233 from JosJuice/stringutil-string-view
StringUtil: Use std::string_view more
2019-08-09 23:39:01 +10:00
Lioncash 37d643c7d3 InputCommon/DInputJoystick: Correct force-feedback flag testing
Introduced in a995e2f5ba

We need to be performing a bitwise AND on the flags and not a logical
AND, otherwise we could end up counting device objects that don't
support forced feedback.
2019-08-02 10:26:44 -04:00