Commit Graph

442 Commits

Author SHA1 Message Date
Shawn Hoffman 6bc8ab7001 WGInput: use c++/winrt 2022-08-26 23:20:34 -07:00
Shawn Hoffman 76d2e47444 ciface/win32: use CM_Register_Notification instead of wnd msgs 2022-08-26 21:59:56 -07:00
TellowKrinkle 588c4bd635 InputCommon:QuarzKB&M: Use view position instead of window position 2022-08-18 16:29:43 -05:00
TellowKrinkle 798b241832 InputCommon:QuarzKB&M: Use KVO to watch window position
CGWindowListCreateDescriptionFromArray would block for up to ~1ms, which isn't a great thing to do on the main emulation thread
2022-08-18 16:29:43 -05:00
TellowKrinkle b96bc4267e InputCommon: Enable ARC for obj-c++ 2022-08-12 02:09:53 -05:00
Admiral H. Curtiss 9d15a1c5a1
Merge pull request #10858 from AdmiralCurtiss/mouse-center-hotkey
Add hotkey for centering mouse in render window.
2022-07-26 12:52:33 +02:00
Shawn Hoffman f92541fbd9 StripSpaces: only strip spaces
StripWhitespace maintains old behavior
2022-07-25 18:40:12 -07:00
Admiral H. Curtiss d14bd10cd7
Quartz: Handle mouse centering hotkey.
Co-authored-by: Dentomologist <dentomologist@gmail.com>
2022-07-25 01:26:57 +02:00
Admiral H. Curtiss e0870166ef
XInput2: Handle mouse centering hotkey. 2022-07-25 01:26:56 +02:00
Admiral H. Curtiss d57d04bb04
DInput: Handle mouse centering hotkey. 2022-07-25 01:26:56 +02:00
Admiral H. Curtiss 4d27022d0e
Add hotkey for centering mouse in render window. 2022-07-25 00:59:47 +02:00
Admiral H. Curtiss 89067e66f9
InputCommon: Get rid of static strings. 2022-07-15 19:53:10 +02:00
Admiral H. Curtiss e79c7d4985
InputCommon: Don't force-link against SDL2.lib on Windows. 2022-07-13 01:37:05 +02:00
Shawn Hoffman 54b4ad8f55 ci/sdl: pump messages for SDL_hidapi so device detection works 2022-07-10 15:39:06 -07:00
Shawn Hoffman ddf83462ac sdl: enable SDL_HINT_JOYSTICK_THREAD
fixes window message pumping
2022-07-10 15:39:06 -07:00
Shawn Hoffman 655fb94e61 ci/win32: give the wndclass a unique name
other things (like SDL) may try to use "Message"
2022-07-10 15:39:06 -07:00
Shawn Hoffman dd20c7cf78 ci/sdl: re-add the x360 controller block 2022-07-10 15:39:06 -07:00
Shawn Hoffman 3f7a2c6d4d ci/sdl: minor cleanup 2022-07-10 15:39:06 -07:00
Jun Bo Bi ceed42a0ee Add SDL as a submodule 2022-07-10 15:38:59 -07:00
Jun Bo Bi 6cb936d0cf Add SDL motion input and rumble support 2022-07-10 14:49:49 -07:00
TellowKrinkle 994210e369 InputCommon: SDL 2.0.22 init crash workaround
See https://github.com/libsdl-org/SDL/pull/5598
2022-06-14 21:02:45 -05:00
Pokechu22 a86fb9b475 Core/WGInput: Use fmt logging and include HRESULT in messages 2022-05-19 12:12:19 -07:00
Admiral H. Curtiss 5fda8ee8ec
Core/WGInput: Dynamically load winrt function addresses. 2022-04-08 03:26:09 +02:00
Jordan Woyak 566dfc1cf4 ControllerInterface: Update sort priorities. 2022-04-03 19:03:44 -05:00
Jordan Woyak 076a262b9e InputCommon: Add Windows.Gaming.Input to ControllerInterface. 2022-04-03 19:03:35 -05:00
Jordan Woyak b589d720bf MappingCommon: Fix detection of hotkey and conjunction expressions. 2022-03-16 22:25:04 -05:00
JosJuice 1bc057614e Move parts of MappingCommon out of DolphinQt
Some of the functions in MappingCommon would be useful to use on
mobile in the future.
2022-03-06 14:30:49 +01:00
Pokechu22 6e5f4125e3 Use Common::ToLower and Common::ToUpper 2022-01-16 17:00:12 -08:00
Pokechu22 ca9bf3174f Use HRWrap in remaining locations
Note that D3DCommon can't use DX11HRWrap or DX12HRWrap since it's shared between them.
2022-01-09 12:44:55 -08:00
Pokechu22 558de04cfc Common/Assert: Actually use the ASSERT_MSG's log type parameter
Since it was unused, nonexistent values were used in a few places.  I've replaced them.
2022-01-09 12:44:14 -08:00
Pokechu22 0c19f895d3 Replace remaining uses of zlib crc32 with Common/Hash.h 2022-01-01 10:36:38 -08:00
Pokechu22 2025763420 Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
Filoppi 125971d9f2 InputCommon: fix default input config default device not being loaded/found
Fixes bug: https://bugs.dolphin-emu.org/issues/12744

Before e1e3db13ba
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-12-05 23:35:47 +02:00
Filoppi 1badceb455 ControllerInterface: fix UpdateReferences() deadlock
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-11-20 16:54:36 +02:00
Pokechu22 78bfd25964 Fix all uninitialized variable warnings (C26495) 2021-10-13 12:32:16 -07:00
OatmealDome 1bb72f00b5 QuartzKeyboardAndMouse: Ensure windowNumber is fetched on the main thread 2021-07-06 04:46:27 -04:00
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 a77e3b4a9b InputCommon: Make Wiimote rumble variable thread safe 2021-06-07 11:48:30 +03:00
Filoppi 08f8c27927 ControllerInterface: fix DSU thread safety and use PlatformPopulateDevices() 2021-06-07 11:48:29 +03:00
Filoppi 8b53af9cbc ControllerInterface: polish DInput Keyboard and Mouse (add comments and logs)
Also fix the cursor axis not being updated when the mouse device had failed aquiring,
despite them being completely unrelated
2021-06-07 11:07:06 +03:00
Filoppi 038b57fecc ControllerInterface: DInput Joystick fix non thread safe static variable
also fix devices being added to its own custom list of devices even when rejected by the CI
2021-06-07 11:07:06 +03: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 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