Commit Graph

84 Commits

Author SHA1 Message Date
mitaclaw eb92d6f0a8 Core::GetState: Avoid Global System Accessor 2024-04-08 16:23:23 -07:00
Jordan Woyak 719d76ab2e GCAdapter: Adjust libusb transfer timeout to 100ms. 2024-03-20 18:02:06 -05:00
Admiral H. Curtiss 07c035e659
Core/SystemTimers: Refactor to class, move to System. 2024-01-04 23:35:19 +01:00
JosJuice 7197e3abd0 Use structs for config callback IDs
This way you can't mix up regular config callback IDs and CPU thread
config callback IDs. (It would be rather bad if you did!)
2023-08-17 19:19:26 +02:00
Dentomologist 274b11e4e9 GCAdapter: Fix Android unused constant warning
CONTROLLER_OUTPUT_INIT_PAYLOAD_SIZE is only used by the libusb
implementation.
2023-08-12 20:20:42 -07:00
Dentomologist 77d33d61de GCAdapter: Fix spelling of constants 2023-08-12 20:20:41 -07:00
nyanpasu64 5d0f1bd10b Switch libusb_config_descriptor to RAII type 2023-07-05 20:38:22 -07:00
nyanpasu64 c893ccca58 Workaround GC adapter detection breaking when reset fails 2023-07-05 20:38:22 -07:00
nyanpasu64 559a16da49 Reset GC adapter upon IO error after sleep-wake
Fixes GC adapter breaking on sleep-wake on Linux and burning a full CPU
core. This is cleaner than alternative approaches.
2023-07-05 20:38:22 -07:00
nyanpasu64 afb5eff426 Don't burn a CPU core and spam logs when GC Adapter fails 2023-07-05 20:38:22 -07:00
nyanpasu64 54850e936c Fix memory leak in libusb code 2023-07-05 20:38:22 -07:00
Pokechu22 49a84cbc4c Resolve various "no previous declaration" warnings 2023-02-09 16:23:01 -08:00
Admiral H. Curtiss c9558ecb4c
CoreTiming: Refactor to class. 2022-11-27 03:47:12 +01:00
Jordan Woyak 5ed0543430 GCAdapter: Process pad state in read thread and other general cleanups. 2022-10-22 00:38:59 -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
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
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
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
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
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
Sepalani ce8004c9c1 Lint: End of namespace 2021-06-07 12:55:52 +04: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
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
Filip Gawin 0ede5d1537 Use range loop (if possible) 2020-07-18 18:29:16 -05:00
Jordan Woyak b350d3cca3 InputCommon/GCAdapter: Unbreak Mayflash GCAdapters by allowing libusb_control_transfer call to fail. 2020-07-09 17:17:44 -05:00
Jordan Woyak f2fd5c7f90 InputCommon/GCAdapter: Fix offbrand "GCAdapters" with a libusb_control_transfer call. 2020-07-07 14:45:19 -05:00
Pierre Bourdon daf1c30a94
GCAdapter: add libusb error logging on reads/writes 2020-05-10 09:26:49 +02:00
Léo Lam cf60a9a7f7 Use separate libusb contexts to avoid thread safety issues
Unfortunately, it appears that using libusb's synchronous transfer API
from several threads causes nasty race conditions in event handling and
can lead to deadlocks, despite the fact that libusb's synchronous API
is documented to be perfectly fine to use from several threads (only
the manual polling functionality is supposed to require special
precautions).

Since usbdk was the only real reason for using a single libusb context
and since usbdk (currently) has so many issues with Dolphin, I think
dropping support for it in order to fix other backends is acceptable.
2019-06-26 17:55:51 +02:00
Lioncash c0c0e412e0 Core/ConfigManager: Use forward declarations where applicable
Avoids dragging in IniFile, EXI device and SI device headers in this header which is
quite widely used throughout the codebase.

This also uncovered a few cases where indirect inclusions were being
relied upon, which this also fixes.
2019-06-07 19:54:39 -04:00
Vincent Duvert 9e7d4d2abb GCAdapter: Handle dynamic status updates for non-hotplug libusb
Detect when the setup function found no adapter, or found one but could
not connect to it, and report the new status in that case.
2019-05-29 18:28:24 +02:00