Commit Graph

1371 Commits

Author SHA1 Message Date
Jeffrey Bosboom a902480cb0 XInput2: Make button state a u32
Because we care how many bits it has, not its arithmetic range.  No
functional change on all supported platforms.
2023-05-19 14:20:09 -07:00
Admiral H. Curtiss 50fe493990
Merge pull request #11739 from OatmealDome/iokit-be-gone
InputCommon: Remove OSX (IOKit) input backend
2023-05-19 19:31:40 +02:00
Admiral H. Curtiss 279fcafdc3
Merge pull request #11758 from jbosboom/xinput2-client-pointer
XInput2: Accept input from keyboards other than the first master
2023-05-19 19:29:24 +02:00
Lioncash a9f1edeb61 StringUtil: Move IsAlpha() into Common namespace 2023-05-16 14:11:02 -04:00
R c5d2ad99d2 Support Steam Deck controls directly through hidraw
This reads Steam Deck controls bypassing Steam Input. This allows for access to
motion controls as well as independent access to thumb sticks, trackpads, and
back grip buttons.
2023-05-10 13:28:32 +01:00
JosJuice 82f70cdf94 ControllerInterface/Android: Add some missing DeleteLocalRef calls 2023-05-07 18:44:43 +02:00
JosJuice 24a697514e ControllerInterface/Android: Use InputEvent.getDeviceId
Instead of InputEvent.getDevice followed by InputDevice.getId.
Should hopefully fix https://bugs.dolphin-emu.org/issues/13237,
while also being simpler.
2023-05-07 18:40:28 +02:00
Admiral H. Curtiss e9dbb93cb5
Merge pull request #11756 from lioncash/ini
Common/IniFile: Move interface into Common namespace
2023-04-14 20:52:30 +02:00
Jeffrey Bosboom c6f9e61d38 XInput2: Accept input from keyboards other than the first master
XInput2 was created to support multiple pointer/keyboard pairs (often
called MPX for multi-pointer X).  Dolphin's XInput2 implementation has
always supported MPX by creating a KeyboardMouse object per master
pointer.  Since commit bbb12a7, Dolphin's keyboard state is filtered by
the output of XQueryKeymap.  As a core X function, XQueryKeymap queries
"the" keyboard, which by default is the first master keyboard.  As a
result, Dolphin will ignore keys pressed on other master keyboards
unless the first master is simultaneously pressing the same keys.

XInput2 doesn't provide a function to query the keyboard state.  There
is no XIQueryKeymap and the current state is not a member of the
XIKeyClassInfo returned by XIQueryDevice.  Instead, XInput2 allows a
master pointer to be nominated as "the" pointer on a per-client basis,
with "the" keyboard automatically becoming the associated master
keyboard.  The "documentation" [1] says passing None for the window is
only for debugging purposes, but it is documented in the
XISetClientPointer man page and seems to be the only way to query
keyboards beyond the first.

With this commit, Dolphin correctly reads keys from keyboards other than
the first master keyboard.  To test, use the xinput command-line utility
to create a master pointer and reattach a keyboard to the associated
master keyboard.

[1]: https://who-t.blogspot.com/2009/07/xi2-recipes-part-6.html
     (the XInput2 developer's blog)
2023-04-13 20:10:00 -07:00
Lioncash e4caace6bb Common/IniFile: Move interface into Common namespace
Gets this out of the global namespace and into the Common namespace
2023-04-13 10:19:28 -04:00
Minty-Meeo f29019180f Pragma diagnostic ignore [-Wregister] is no longer needed 2023-04-12 03:59:57 -05:00
OatmealDome 72d08f6c80 InputCommon: Remove OSX (IOKit) input backend 2023-04-07 15:40:14 -04:00
Pierre Bourdon 3783bedc25
Merge pull request #11635 from Dentomologist/wiimote_fix_disconnection_deadlock
ControllerInterface: Fix deadlock when Wii Remote disconnects
2023-03-14 02:41:36 +01:00
Dentomologist d6a8e6caaf ControllerInterface: Fix deadlock when Wii Remote disconnects
In UpdateInput, lock m_devices_population_mutex before m_devices_mutex
to be consistent with other ControllerInterface functions. Normally the
former lock isn't needed in UpdateInput, but when a Wii Remote
disconnects it calls RemoveDevice which results in the mutexes being
locked in the wrong order.
2023-03-08 17:22:27 -08:00
JosJuice 1b55d7c594 Android: Change how the overlay controller setting works
Up until now, there have been two settings on Android that stored the
selected Wii Remote extension: the normal one that's also used on PC,
and a SharedPreferences one that's used by the overlay controls to
determine what controls to show. It is possible for these two to end up
out of sync, and my input changes have made that more likely to happen.

To fix this, let's rework how the overlay controller setting works.
We don't want it to encode the currently selected Wii Remote extension.
However, we can't simply get rid of the setting, because for some Wii
games we need the ability to switch between a GameCube controller and a
Wii Remote. What this commit does is give the user the option to select
any of the 4 GameCube controllers and any of the 4 Wii Remotes. (Before,
controllers 2-4 weren't available in the overlay.) Could be useful for
things like the Psycho Mantis fight in Metal Gear Solid. I'm also
switching from SharedPreferences to Dolphin.ini while I'm at it.
2023-03-07 17:39:34 +01:00
JosJuice 4c326f2030 Android: Remove the in-emulation IR sensitivity options
This too can be set in the normal controller settings now.
2023-03-07 17:39:34 +01:00
JosJuice c2779aef06 Android: Add the advanced input mapping dialog
It's missing a lot of features from the PC version for now, like
buttons for inserting functions and the ability to see what the
expression evaluates to. I mostly just wanted to get something in
place so you can set up rumble.

Co-authored-by: Charles Lombardo <clombardo169@gmail.com>
2023-03-07 17:39:30 +01:00
JosJuice 2b1dd52750 Android: Add input device selection 2023-03-03 22:28:24 +01:00
JosJuice 8e33458f48 ControllerInterface/Android: Implement rumble 2023-03-03 22:28:23 +01:00
JosJuice 065481d989 ControllerInterface/Android: Automatically suspend sensors
This is a battery-saving measure. Whether a sensor should be suspended
is determined in the same way as whether key events and motion events
should be handled by the OS rather than consumed by Dolphin.
2023-03-03 22:28:23 +01:00
JosJuice 36acb17700 ControllerInterface/Android: Implement sensor input for InputDevices
This functionality was added in Android 12 to let apps get motion data
for gamepads.
2023-03-03 22:28:23 +01:00
JosJuice 5e51b56d72 ControllerInterface/Android: Implement sensor input 2023-03-03 22:28:23 +01:00
JosJuice 104ea09892 ControllerInterface/Android: Implement hotplug 2023-03-03 22:28:23 +01:00
JosJuice d6af294a23 ControllerInterface/Android: Return whether input was handled
When Android presents an input event to an app, it wants the app to
return true or false depending on whether the app handled the event or
not. If the event wasn't handled by the app, it will be passed on to
the system, which may decide to take an action depending on what kind
of input event it is. For instance, if a B button press is passed on to
the system, it will be turned into a Back press. But if an R1 press is
passed on to the system, nothing in particular happens.

It's important that we get this return value right in Dolphin. For
instance, the user generally wouldn't want a B button press to open
the EmulationActivity menu, so B button presses usually shouldn't be
passed on to the system - but volume button presses usually should be
passed on to the system, since it would be hard to adjust the volume
otherwise. What ButtonManager did was to pass on input events that are
for a button which the user has not mapped, which I think makes sense.
But exactly how to implement that is more complicated in the new input
backend than in ButtonManager, because now we have a separation between
the input backend and the code that keeps track of the user's mappings.

What I'm going with in this commit is to treat an input as mapped if
it has been polled recently. In part I chose this because it seemed
like a simple way of implementing it that wouldn't cause too many
layering violations, but it also has two useful side effects:

1. If a controller is not being polled (e.g. GameCube controllers in
   Wii games that don't use them), its mappings will not be considered.
2. Once sensor input is implemented in the Android input backend,
   we will be able to use this "polled recently" tracking to power down
   the sensors at times when the game is using a Wii Remote reporting
   mode that doesn't include motion data. (Assuming that the sensor
   inputs only are mapped to Wii Remote motion controls, that is.)
2023-03-03 22:28:23 +01:00
JosJuice ca508e4503 ControllerInterface/Android: Handle input events
Android doesn't let us poll inputs whenever we want. Instead, we
listen to input events (activities will have to forward them to the
input backend), and store the received values in atomic variables
in the Input classes. This is similar in concept to how ButtonManager
worked, but without its homegrown second input mapping system.
2023-03-03 22:28:23 +01:00
JosJuice 792cb62195 ControllerInterface/Android: Implement device population 2023-03-03 22:28:23 +01:00
JosJuice 0150f521f7 ControllerInterface/Android: Rip out ButtonManager
ButtonManager is very different from how a normal input backend works,
and is making it hard for us to improve controller support on Android.
The following commits will add a new input backend in its place.
2023-03-03 22:28:23 +01:00
JosJuice 9b3816c993 InputCommon: Fix ControlGroup::SaveConfig with DefaultValue::Disabled
I also changed LoadConfig, but that change doesn't affect correctness,
it's only so it looks neat by matching SaveConfig.

This bug was added in 18a4afb053, the
commit that introduced DefaultValue::Disabled. The bug can't actually be
triggered in master, but it can be triggered in the Android input
overhaul PR.
2023-02-26 17:45:09 +01:00
Pokechu22 f1f3fd5d9d InputCommon: Fix memory leak in ExpressionParser
We allocate in MakeSuppressor via `return unique_ptr(std::make_unique<...>(...).release(), InvokingDeleter{}`, so it wasn't properly getting freed.
2023-02-17 18:29:36 -08:00
Pokechu22 74a14c7d1f ControllerInterface: Fix uninitialized variables in DualShockUDPClient
Strangely, this case did not trigger a C26495 warning in Visual Studio's analyzer; instead, I spotted this when using Valgrind.
2023-02-15 19:23:47 -08:00
Pokechu22 7fafb00561 InputCommon/XInput2: Fix shadowing warning 2023-02-09 16:23:02 -08:00
Pokechu22 49a84cbc4c Resolve various "no previous declaration" warnings 2023-02-09 16:23:01 -08:00
Markus Wick 17d7b75a9b
Merge pull request #11544 from jmallach/spng
Allow building against system libspng
2023-02-09 14:47:58 +01:00
Jordi Mallach 4d164fcb77 Allow building against system libspng 2023-02-06 13:30:46 +01:00
Scott Mansell 0da69055d9 Split out everying remaining from Swap 2023-01-31 19:41:24 +13:00
Lioncash e5b91f00b0 Common: Replace StringBeginsWith/StringEndsWith with std equivalents
Obsoletes these functions in favor of the standard member functions
added in C++20.
2023-01-24 14:58:20 -05:00
Admiral H. Curtiss d949aa60bb
Merge pull request #11397 from TellowKrinkle/QuartzMousePos
InputCommon:QuartzKB&M: Fix mouse y coordinates
2023-01-02 23:04:12 +01:00
TellowKrinkle 8659de4d71 InputCommon:QuartzKB&M: Fix mouse y coordinates
Cocoa uses a different coordinate system from Carbon (Carbon's origin is the top left while Cocoa's is the bottom left)
2022-12-31 23:42:11 -06:00
TheConfuZzledDude 288fa635f9 InputCommon/XInput2: Changed axis value reading to be more correct 2022-12-26 17:27:48 +00:00
TheConfuZzledDude 27d596b89c InputCommon/Xinput: Cleaned up a bit 2022-12-23 22:35:09 +00:00
TheConfuZzledDude c3018fdc3b InputCommon/XInput2: Added an axis output for the scroll wheel 2022-12-23 22:10:28 +00:00
Admiral H. Curtiss c9558ecb4c
CoreTiming: Refactor to class. 2022-11-27 03:47:12 +01:00
TellowKrinkle 72eadc6520 InputCommon:SDL: Add SDL 2.26 left and right motion inputs 2022-11-24 15:12:07 -06:00
Jordan Woyak 168a49c87f ControllerInterface: DSU InputBackend implementation. 2022-11-01 21:59:09 -05:00
Jordan Woyak 2e5cd5d519 ControllerInterface: evdev InputBackend implementation. 2022-11-01 21:59:08 -05:00
Jordan Woyak 44a4573303 ControllerInterface: Add InputBackend interface and SDL implementation. 2022-11-01 21:59:08 -05:00
JMC47 bc4d08047d
Merge pull request #10979 from tellowkrinkle/QuartzWindowSpeed
InputCommon:QuartzKB&M: Use KVO to watch window position
2022-10-22 04:55:12 -04:00
Jordan Woyak 5ed0543430 GCAdapter: Process pad state in read thread and other general cleanups. 2022-10-22 00:38:59 -05:00
Jordan Woyak f5b9049421 Input: Add "abs" input expression function. 2022-10-11 19:28:21 -05:00
JosJuice 51ee05cb35 Android: Use input override system for touch controls
This is the first step of getting rid of the controller indirection
on Android. (Needing a way for touch controls to provide input
to the emulator core is the reason why the controller indirection
exists to begin with as far as I understand it.)
2022-10-03 22:04:09 +02:00
JosJuice b296248b49 DolphinQt: Use input override system for TAS input windows
This lets the TAS input code use a higher-level interface for
overriding inputs instead of having to fiddle with raw bits.
WiiTASInputWindow in particular was messy with how much
controller code it had to re-implement.
2022-10-03 22:04:09 +02:00
JosJuice cb16d20f2d ControllerEmu: Add new "input override" system 2022-10-03 22:00:21 +02:00
Admiral H. Curtiss 26fd4ea361
WiimoteEmu: Update IR camera status from DesiredWiimoteState. 2022-10-02 23:14:35 +02:00
Admiral H. Curtiss 02a967f786
InputCommon: Add equality operators to RawValue. 2022-09-24 01:44:21 +02:00
Admiral H. Curtiss 24a1fe32f1
InputCommon: Make RawValue constructors constexpr. 2022-09-24 01:38:09 +02:00
Minty-Meeo 73dfcc15a5 Use std::llround in MapFloat
I don't see why not.
2022-09-22 11:30:32 -05:00
Admiral H. Curtiss 710210365a
Merge pull request #11038 from AdmiralCurtiss/steam-overlay-crash-fix-wgi
WGInput: Work around crash with Steam overlay.
2022-09-08 19:03:31 +02:00
Admiral H. Curtiss b8ca1b2907
InputCommon: Fix deadlock in EmulatedController::UpdateReferences(). 2022-09-07 22:37:24 +02:00
Admiral H. Curtiss 67c97a0bf2
WGInput: Work around crash with Steam overlay. 2022-09-07 21:06:26 +02:00
Shawn Hoffman cd407abe34 WGInput: implement error handling 2022-08-27 02:11:27 -07:00
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 a9edf129e3
Merge pull request #10889 from shuffle2/spng
replace libpng with libspng
2022-07-26 12:53:04 +02: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
Shawn Hoffman acb10f0006 replace libpng with libspng 2022-07-25 18:32:16 -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
Admiral H. Curtiss eccf527bf6
Merge pull request #9147 from jordan-woyak/imu-accel-weight-setting
WiimoteEmu: Expose IMU pointing accelerometer weight setting.
2022-07-07 23:17:47 +02:00
Admiral H. Curtiss 24498ca315
Merge pull request #10712 from tellowkrinkle/ControllerLocks
InputCommon/ControllerEmu: Use more locks
2022-07-05 11:39:48 +02:00
Jordan Woyak 4c409411ed DolphinQt: Don't show the advanced input settings on the main dialog. 2022-06-26 22:48:13 -05:00
Jordan Woyak 80d9e79cf1 ControllerEmu: Allow settings to be categorized as "advanced". Make "Virtual Notches" and "Gate Size" categorized as such. 2022-06-26 22:42:16 -05:00
Jordan Woyak 643f82539c ControllerEmu: Expose gate size setting for octagon analog sticks. 2022-06-26 22:33:44 -05:00
Admiral H. Curtiss 23ed611077
Merge pull request #10729 from Pokechu22/libusb-error-wrap
Improve libusb error logging
2022-06-17 16:01:46 +02:00
JosJuice 107a928452
Merge pull request #10748 from tellowkrinkle/SDL22Fun
InputCommon: SDL 2.0.22 init crash workaround
2022-06-15 18:02:59 +02: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
Jordan Woyak 1fc86cacd7 WiimoteEmu: Expose IMU pointing accelerometer weight setting. 2022-06-13 00:07:00 -05:00
Pokechu22 27772e01d9 GCAdapter: Compare with LIBUSB_SUCCESS instead of 0 2022-06-08 15:30:22 -07:00
Pokechu22 15cbb5c8f9 Log warnings when LibusbUtils::GetDeviceList fails 2022-06-08 15:29:11 -07:00
Pokechu22 6823b4d7a0 GCAdapter: Use LibusbUtils::ErrorWrap in log messages 2022-06-02 19:39:36 -07:00
Pokechu22 0d8772ccbe GCAdapter: Make local variables const where possible 2022-06-02 19:39:36 -07:00
Pokechu22 cd9edeacda GCAdapter: Merge Read logic 2022-06-02 19:39:36 -07:00
Pokechu22 9ec65baf46 GCAdapter: Have the read thread control the write thread
This was done for Android in 6cc40b1235.
2022-06-02 19:39:36 -07:00
Pokechu22 0fa92694d1 GCAdapter: Exit early if the adapter fails to open on Android
This is only so that indentation is consistent with the non-android code.
2022-06-02 19:39:36 -07:00
Pokechu22 749a4ad1ef GCAdapter: Remove check on write size on android
It was removed for non-android in 56239d1ae1, and android already uses a separate thread, so presumably this isn't needed anymore.
2022-06-02 19:39:36 -07:00
Pokechu22 27947046af GCAdapter: Harmonize read/write thread variable names 2022-06-02 19:39:36 -07:00
Pokechu22 279888da8c GCAdapter: Remove unused includes 2022-06-02 19:39:36 -07:00
Pokechu22 3ae775e574 GCAdapter: Use determinism hack on Android
This hack was added in 8f0cbefbe5, and the part of it in SI_DeviceGCAdapter is present on Android already, so I don't see any reason why this part doesn't apply to Android.
2022-06-02 19:39:36 -07:00
Pokechu22 55922e6d17 GCAdapter: Convert ControllerType to an enum class 2022-06-02 19:39:36 -07:00
Pokechu22 682d86f4da GCAdapter: Fix rumble enabled config on Android
I believe the setting already existed in the UI; it just wasn't implemented in GCAdapter_Android.cpp.
2022-06-02 19:39:36 -07:00
Pokechu22 36d4ee0939 GCAdapter: Use std::array for controller read and write payloads 2022-06-02 19:39:36 -07:00
Pokechu22 dd6592698e GCAdapter: Merge GCAdapter.cpp and GCAdapter_Android.cpp
This is mostly a brainless merge, #ifdef-ing anything that doesn't match between the two while preserving common logic.  I didn't rename any variables (although similar ones do exist), but I did change one log that was ERROR on android and NOTICE elsewhere to just always be NOTICE.  Further merging will follow.
2022-06-02 19:39:36 -07:00
TellowKrinkle f9c6eb7b98 InputCommon/ControllerEmu: Use more locks
Loading configs while another thread is messing with stuff just doesn't feel like a good idea
Hopefully fixes Wiimote Scanning Thread crashes on startup
2022-05-31 20:17:37 -05:00
Admiral H. Curtiss 580c721c82
cmake: Don't use PCH with Qt6. 2022-05-22 01:19:44 +02:00
Pokechu22 a86fb9b475 Core/WGInput: Use fmt logging and include HRESULT in messages 2022-05-19 12:12:19 -07:00
JosJuice e0afcb3b94
Merge pull request #10540 from nyanpasu64/fix-gcadapter-atomics
Remove atomic usage and fix mutex locking in GCAdapter code
2022-04-23 22:04:10 +02:00
Shawn Hoffman 12cd81bdb3 GCAdapter: don't call libusb_detach_kernel_driver on apple 2022-04-22 09:56:47 -07:00
Shawn Hoffman 5cd3cf9072 GCAdapter: fix retval check of libusb_detach_kernel_driver 2022-04-22 09:56:47 -07:00
Shawn Hoffman 978c90845b GCAdapter: move libusb context teardown last 2022-04-22 09:56:47 -07:00
Shawn Hoffman 1c9dfb7bb6 GCAdapter: some macro cleanup 2022-04-22 09:56:47 -07:00
Shawn Hoffman f52d94832e GCAdapter: set read/write thread names 2022-04-22 07:12:09 -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
nyanpasu64 b5a7ae52b5 Fix locking the wrong mutex in GCAdapter_Android.cpp ResetRumble()
I am not confident there are no race conditions between s_write_mutex,
s_controller_write_payload_size, and s_controller_write_payload. But
this code should be safer than before.
2022-03-27 22:39:26 -07:00
nyanpasu64 7616027684 Remove unnecessary atomic usage in GCAdapter_Android.cpp
s_controller_write_payload_size needs to remain an atomic because Read()
loads and stores without holding a mutex, Output() stores while holding
s_write_mutex, and ResetRumble() stores while holding s_read_mutex! I'm
pretty sure this code is wrong, specifically ResetRumble().
2022-03-27 22:39:26 -07:00
nyanpasu64 871b01a5d9 Remove unnecessary atomic usage in GCAdapter.cpp
You can safely read or write non-atomic integers on multiple threads,
as long as every thread reading or writing it holds the same mutex
while doing so (here, s_mutex).

Removing the atomic accesses makes the code faster, but the actual
performance difference is probably negligible.
2022-03-27 22:27:57 -07:00
Jordan Woyak b589d720bf MappingCommon: Fix detection of hotkey and conjunction expressions. 2022-03-16 22:25:04 -05:00
Léo Lam e10967e918
Merge pull request #10502 from Pokechu22/defer-gcadapter
GCAdapter: Defer initialization until MainWindow::InitControllers
2022-03-15 16:00:28 +01:00
Pokechu22 37806472e1 GCAdapter: Defer initialization until MainWindow::InitControllers
If libusb fails to initialize, an assertion fails, but if that happens before the main window is created, then Dolphin just dies.  Now, the panic alert is properly shown and the user can ignore it.
2022-03-10 10:35:45 -08: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
Mai M 1cea399e9c
Merge pull request #10345 from jordan-woyak/modifier-range
InputCommon: Re-enable "Modifier" "Range" settings.
2022-01-13 08:32:15 -05: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
Admiral H. Curtiss 5c325eef38
Config: Port SI device settings to new config system. 2022-01-08 20:08:21 +01:00
Admiral H. Curtiss 0bfffe4095
Config: Port GC Adapter settings to new config system. 2022-01-05 03:25:19 +01:00
Jordan Woyak 78a9bdf04a InputCommon: Use value of "Modifier" button "Range" setting rather than always applying 50%.
Make "Clear" button reset "Modifier" "Range" settings to 50%.
2022-01-04 14:09:50 -06:00
Pokechu22 0c19f895d3 Replace remaining uses of zlib crc32 with Common/Hash.h 2022-01-01 10:36:38 -08:00
Pokechu22 de7c78ef3d ControllerEmu: Hide the cursor if the input gate is disabled 2021-12-23 15:22:35 -08:00
Pokechu22 2025763420 Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
JosJuice 2f4ecde5cc
Merge pull request #10253 from Filoppi/fix_input_config_loading
Fix InputConfig::LoadConfig() not always replacing emu controllers values
2021-12-09 22:21:02 +01:00
Filoppi 689545a795 InputCommon: fix InputConfig::LoadConfig() not always replacing emu controllers values
If InputConfig::LoadConfig() was called once with a non empty/customized config,
then called again after manually deleting the config (dolphin calls LoadConfig() every time it opens the mapping widget),
the second load would fail to clear the values on any non first EmulatedController and would instead keep the
previous config values despite it being deleted (while it would instead correctly default the first EmulatedController).

This is not a big bug though the code is better now.
2021-12-05 23:37:58 +02: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
Léo Lam aa5cb35c86
Merge pull request #10143 from Pokechu22/png-compression-level
Add option for setting the PNG zlib compression level
2021-11-23 16:40:34 +01: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 94ccf765af Add option for setting the PNG zlib compression level 2021-11-18 13:10:22 -08:00
Pokechu22 78bfd25964 Fix all uninitialized variable warnings (C26495) 2021-10-13 12:32:16 -07:00
Bonta 8ee21acf34 Pad: GBA config 2021-07-13 16:42:35 +02: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 702f86ccc0 InputCommon: fix 2nd+ controller not defaulting to the default device 2021-06-07 19:31:38 +03:00
Léo Lam 5e371bb4be
Merge pull request #9792 from sepalani/lint
Lint: End of namespace
2021-06-07 12:16:08 +02:00
Sepalani ce8004c9c1 Lint: End of namespace 2021-06-07 12:55:52 +04: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