Commit graph

63 commits

Author SHA1 Message Date
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
Vincent Duvert
2ac1ca133f GCPadWiiUConfigDialog: Update the adapter state dynamically
Update the GC adapter config GUI if the adapter is plugged or unplugged.
2019-05-29 18:28:24 +02:00
Vincent Duvert
b08e2ec959 GCAdapter: Report libusb open errors to the user
If opening the adapter fails, report the libusb error message in the GUI
instead of “No Adapter Detected”.

The error condition is removed when the adapter is unplugged.
2019-05-29 18:28:24 +02:00
Vincent Duvert
0165e5e703 GCAdapter: Close libusb handle if an open error occurs
The handle was previously kept open, which was causing future adapter
plug/unplug events to be ignored.
2019-05-29 18:28:24 +02:00
Léo Lam
256c9375c9 Move libusb utilities to LibusbUtils
* Simplifies libusb context usage and allows us to set options for
all contexts easily. Notably, this lets us enable usbdk support
in libusb, which is now opt-in in the latest version.

* Moves the libusb config descriptor wrapper class to LibusbUtils too
since that could easily be reused.

* Moves device listing to LibusbUtils too and add a lock around it
as some libusb backends are not thread safe.

* Consequences: only a single context and a single event handling
thread is used now, which is more efficient.
2019-05-27 20:09:55 +02:00
Jordan Woyak
a015851b02 HW/SI: GCAdapter calibration fix. 2019-03-29 06:15:58 -05:00
Emmanuel Gil Peyrot
fb6fae2b2b Flatten GCAdapter function
Make CheckDeviceAccess() more flat by inverting checks, reducing
indentation and removing dead code.
2019-01-16 14:20:00 +01:00
spycrab
40bb9974f2 Reformat all the things! 2018-04-12 21:28:39 +02:00
Michael M
22a9a08b24 Add Core::State::Starting 2017-09-13 17:30:18 -07:00
Hannes Mann
56239d1ae1 Send rumble data to the adapter on a separate thread 2017-08-02 00:44:46 +02:00
Shawn Hoffman
9357cee2ef do not assign in conditional statements 2017-06-07 20:09:44 -07:00
Lioncash
0c1d56c16f Core: Hide determinism global
This is only ever queried and not set outside of the Core.cpp, so this
should just be hidden internally and just have a function exposed that
allows querying it.
2017-04-03 14:56:12 -04:00
Léo Lam
32a1b5068a Revert "Use a single libusb context"
This reverts commit c8a6dc6c23.

libusb on Windows isn't really safe to use from different threads
with a single context.
2017-03-26 15:58:30 +02:00
Lioncash
f0eeb3c63a SI: Namespace device classes
Places all of the SI code under the SerialInterface namespace instead of
only the main source file. This keeps all SI code under a common name,
as well as out of the global namespace
2017-03-16 04:41:39 -04:00
Lioncash
a728d858b3 SI: Move MAX_SI_CHANNELS into the SerialInterface namespace
Given this constant is related to the serial interface, it shouldn't be
outside of the namespace.
2017-03-16 01:57:57 -04:00
Léo Lam
6a0bf24e0b Move libusb context initialization to on first use
This prevents libusb warnings from showing up even when the user is
not using Bluetooth or USB passthrough, or the Wii U GC adapter.
2017-02-07 00:47:21 +01:00
Matthew Parlane
d244597b42 Merge pull request #4408 from leoetlino/usb
IOS: USB support (OH0, USB_VEN, USB_HID)
2017-02-07 09:17:05 +13:00
Lioncash
e07383a783 Core: Convert State enum into an enum class 2017-02-05 08:32:23 -05:00
Léo Lam
c8a6dc6c23 Use a single libusb context
libusb on Windows is limited to only a single context. Trying to open
more than one can cause device enumerations to fail randomly.

libusb is thread-safe and we don't use the manual polling support (with
`poll()`) so this should be safe.
2017-02-05 11:36:48 +01:00
Lioncash
794d0a9d7c Core: Move SI source files to their own directory 2017-01-20 19:33:24 -05:00
Jeffrey Pfau
c5b3b52d55 InputCommon: Fix FreeBSD 11 libusb incompatibilities 2017-01-17 00:30:08 -08:00
aldelaro5
f0aa9b3751 Reorganise a ton of logs level
Most of this commits changes performance decreasing logs from info to debug and also cleans up innacurate levels.
2016-10-01 15:50:28 -04:00