Commit Graph

26516 Commits

Author SHA1 Message Date
Lioncash 27346fee8a ControllerInterface/Device: Take vector by const reference in DetectInput()
The vector is only ever queryied and it's contents aren't modified, so
there's no reason to take the vector by value. We can take a constant
reference to it to avoid unnecessary allocating.
2019-05-29 19:12:21 -04:00
Lioncash 246e2a77ce ControllerInterface/Device: std::move strings in constructor where applicable
Allows callers to move std::string values into the constructor,
potentially avoiding copies.
2019-05-29 18:46:49 -04:00
Lioncash 1355b43fd2 ControllerInterface/Device: Use std::string_view where applicable
In these cases, the given string is only ever compared against other
string, so std::string can be turned into a std::string_view to allow
non-allocating inputs.
2019-05-29 18:42:24 -04:00
Vincent Duvert 2c3c8bbb90 GCAdapter: Update Android-specific source
Fix the Android version of GCAdapter.cpp so it matches the new definitions in GCAdapter.h.
2019-05-29 18:28:24 +02: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 80d8173d29
Merge pull request #8132 from lioncash/string
Common/FileUtil: Use std::string_view with WriteStringToFile
2019-05-29 15:32:18 +02:00
Léo aca46b11f8
Merge pull request #8070 from leoetlino/usb-fixes
Update and patch libusb to fix USB issues
2019-05-29 14:07:19 +02:00
Léo Lam 918d707f3f
Merge pull request #8131 from lioncash/move
UICommon/ResourcePack/Manager: Resolve use-after-move in Add()
2019-05-29 13:24:08 +02:00
Léo Lam 0cfdcf436d
Merge pull request #8136 from lioncash/arglist
VideoCommon/{NetPlayChatUI/NetPlayGolfUI}: Minor changes
2019-05-29 13:18:03 +02:00
Lioncash 7346679986 Common/FileUtil: Use std::string::data within ReadFileToString
With C++17, .data() for std::string now has a non-const overload, so we
can make use of that instead of taking the address of the first element.
2019-05-29 07:06:56 -04:00
Lioncash c0f499b7f7 Common/FileUtil: Use std::string_view with WriteStringToFile
Allows writing out other forms of strings (e.g. C strings) without the
need to allocate a std::string and discard it after use.
2019-05-29 07:06:56 -04:00
Lioncash eb475025b8 Common/FileUtil: Make WriteStringToFile consistent with ReadFileToString
Makes the parameter ordering consistent and less error-prone.
2019-05-29 07:06:53 -04:00
Lioncash 1a0f8e7804 VideoCommon/VertexLoaderX64: Add missing header guard 2019-05-29 06:35:22 -04:00
Lioncash 778623c48c VideoCommon/NetPlayGolfUI: Remove unused header
This header doesn't actually make use of any std::string facilities.
2019-05-29 06:20:57 -04:00
Lioncash cf0f2bbf1d VideoCommon/NetPlayGolfUI: Default the destructor in the cpp file
Ensures the destruction logic is kept local to the translation unit. It
also doesn't really do much to have it specified in the header.
2019-05-29 06:20:05 -04:00
Lioncash 0fabab0760 VideoCommon/NetPlayGolfUI: Initialize netplay_client in the constructor initializer list 2019-05-29 06:20:05 -04:00
Lioncash c958fc1278 VideoCommon/NetPlayChatUI: Default destructor in the cpp file
Ensures that the destruction logic is kept local to the translation unit
(making it nicer when it comes to forward declaring non-trivial types).
It also doesn't really do much to define it in the header.
2019-05-29 06:20:05 -04:00
Lioncash 53b115b81e VideoCommon/NetPlayChatUI: Use nullptr where applicable
We gotsa type dedicated to this concept already :P
2019-05-29 06:14:43 -04:00
Lioncash 50a15b7484 VideoCommon/NetPlayChatUI: Take std::string by value in AppendChat()
Given we're simply storing the std::string into a deque. We can emplace
it and move it. Completely avoiding copies with the current usage of the
function.
2019-05-29 06:12:29 -04:00
Lioncash 08223bad9f VideoCommon/NetPlayChatUI: Set member variable within the constructor initializer list
Member variables should be initialized within the constructor
initializer list if possible.
2019-05-29 06:09:49 -04:00
Lioncash 4d2e0c7b48 UICommon/ResourcePack/Manager: Resolve use-after-move in Add()
The pack is already has its validity checked at the beginning of the
function, so we don't need to check this again after inserting it.

Also resolves a use-after-move case.
2019-05-28 17:40:28 -04:00
Lioncash b4470ad4c2 UICommon/GameFile: Make COVER_URL a plain C string
Same behavior but doesn't take up 8 bytes in the executable to store a
pointer. While we're at it, move it into an anonymous namespace within
the UICommon namespace.
2019-05-28 07:27:41 -04:00
Lioncash 8229ada922 UICommon/GameFile: Remove unused includes
Nothing within the source file makes use of anything in those includes,
so they can be removed.
2019-05-28 07:27:41 -04:00
Lioncash 80786cd295 UICommon/GameFile: Remove unnecessary value() calls in DownloadDefaultCover()
We already check ahead of time if the optional contains a value within
it before accessing it, so we don't need to use the throwing value()
accessor. We can just directly use operator->
2019-05-28 07:27:41 -04:00
Lioncash ab0892e5a5 UICommon/GameFile: Deduplicate string paths where applicable
Rather than construct strings twice, we can just construct it once and
reuse it. While we're at it, we can move variables closer to where
they're actually used within DownloadDefaultCover()
2019-05-28 07:27:35 -04:00
Lioncash 27ecb93b32 UICommon/GameFile: Remove unnecessary initializers
All of the standardized types have constructors that will automatically
initialize them, so the explicit initializers are redundant.
2019-05-28 07:00:15 -04:00
Lioncash 56faf750be UICommon/GameFile: std::move std::string argument in constructor
Allows for calling code to move the argument into the constructor,
avoiding a copy.
2019-05-28 06:57:48 -04:00
Lioncash 8e65869484 UICommon/GameFile: Default no-arg constructor and destructor within the cpp file
A GameFile instance contains quite a lot of non-trivial types, so
default construction and destruction in the same translation unit.
2019-05-28 05:53:40 -04:00
Lioncash 49ca31467d UICommon/GameFile: Use in-class initializers where applicable
Allows deduplicating code within the constructor initializer list.
2019-05-28 05:51:51 -04:00
Léo Lam 800d875faa
Merge pull request #8127 from lioncash/resource
UICommon/ResourcePack: Minor cleanup
2019-05-27 23:05:10 +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
Lioncash f07cf9ebab UICommon/ResourcePack: Allow ReadCurrentFileUnlimited() to read into any contiguous container
This allows the same code to be used to read into a std::string, which
allows for eliminating the vector->string transfer when reading the
manifest file.

A ContiguousContainer is a concept that includes std::array,
std::string, and std::vector.
2019-05-27 13:29:40 -04:00
Lioncash 5c4d3f55da UICommon/Manager: Remove unused std::string variable in Remove() 2019-05-27 13:09:21 -04:00
Léo Lam 42de5b9a10
Merge pull request #8126 from lioncash/todo
Core/GCMemcard: Remove obsolete TODO
2019-05-27 19:04:06 +02:00
Léo Lam 525c65dd19
Merge pull request #8125 from lioncash/verify
DiscIO/VolumeVerifier: Make use of unused variable (+ minor other changes)
2019-05-27 19:03:13 +02:00
Lioncash 41cda6fe6d UICommon/ResourcePack: Use ScopeGuards to manage closing files
Makes it way harder to introduce resource leaks, and plugs the existing
resource leaks in the constructor and Install() where the file wouldn't
be closed in some error cases.
2019-05-27 13:02:04 -04:00
Lioncash 157a305507 UICommon/ResourcePack: Deduplicate string construction
A few cases duplicate the string patch creation, which is kind of
wasteful. We can just construct the string once.
2019-05-27 12:45:23 -04:00
Lioncash a22cc615a9 UICommon/ResourcePack: Remove unnecessary resizes
We can simply construct the containers with the desired size in these
cases.
2019-05-27 12:37:46 -04:00
Lioncash 57701cd988 UICommon/ResourcePack: Make TEXTURE_PATH a regular array
Same behavior, only it doesn't unnecessarily store a pointer in the
executable. While we're at it, make it constexpr and move it into the
namespace.
2019-05-27 12:33:50 -04:00
Lioncash b2b5b01eda Core/GCMemcard: Remove obsolete TODO
Now that we assume C++17, the in-file definition of the std::array can
be removed. This is all that's necessary, as constexpr used on a static
member variable implies inline (and so, automatically has C++17's static
inline behavior).
2019-05-27 11:48:38 -04:00
Lioncash d220e33862 DiscIO/VolumeVerifier: Make no-argument overload of GetBiggestUsedOffset() const
The overload taking a partition is already a const member function, so
this one can be turned into one as well.
2019-05-27 10:40:41 -04:00
Lioncash bf6948c1d4 DiscIO/VolumeVerifier: Use structured bindings where applicable
Allows providing better names than "first" or "second".
2019-05-27 10:40:38 -04:00
Lioncash fa57396e97 DiscIO/VolumeVerifier: In-class initialize members where applicable
Removes redundant initializers from the constructor and provides
initializers for all members that don't already have one for consistency
(and deterministic initial state).
2019-05-27 10:40:17 -04:00
Lioncash 52eb2d0d82 DiscIO/VolumeVerifier: Default destructor within the cpp file
Given the volume verifier has quite a few non-trivial object within it,
it's best to default the destructor within the cpp file to prevent
inlining complex destruction logic elsewhere, while also making it nicer
if a forward-declared type is ever used in a member variable.
2019-05-27 10:19:51 -04:00
Lioncash 0ccaa2b5d6 DiscIO/VolumeVerifier: Take std::string by value in AddProblem()
This allows both std::moving into the function and moving the parameter
from within the function, potentially avoiding an unnecessary copy.
2019-05-27 10:17:11 -04:00
Lioncash a1f77fd14b DiscIO/VolumeVerifier: Make use of unused variable in CheckMisc()
This variable wasn't being utilized when comments indicate that it
probably should be.
2019-05-27 10:09:55 -04:00
Lioncash ab2adfb0a7 Common/HttpRequest: Simplify cURL initialization
std::call_once is guaranteed to execute the given callable object
exactly once. This guarantee holds even if the function is called
concurrently from several threads.

Given that, we can replace the mutex and boolean flag with
std::call_once and a std::once_flag to perform the same behavior.
2019-05-27 09:46:57 -04:00
Lioncash b15f595130 Common/HttpRequest: Avoid unnecessary copies in loop in Fetch()
Previously, every entry pair within the map would be copied. The reason
for this is subtle.

A std::map's internal entry type is defined as:

std::pair<const Key, Value>

but the loop was declaring it as:

std::pair<Key, Value>

These two types aren't synonymous with one another and so the compiler
is required to always perform a copy.

Using structured bindings avoids this (as would plain auto or correcting
the explicit type), while also allowing the use of more appropriate
names compared to first and second.
2019-05-27 09:36:31 -04:00
Lioncash 8dc8cf8019 Common/HttpRequest: std::move callback in constructor
std::function is allowed to heap allocate in order to hold any necessary
bound data in order to execute properly (e.g. lambdas with captures), so
this avoids unnecessary reallocating.
2019-05-27 09:26:28 -04:00
Pokechu22 69d9d9f87a Also free when initialization fails, and move to end 2019-05-26 19:59:29 -07:00
Pokechu22 19fb3bb4fe DX11: Fix access violation on closing dolphin 2019-05-26 15:01:05 -07:00
Léo Lam f92c17e76f
Merge pull request #7799 from Tilka/mapping
DolphinQt/Mapping: red = error, don't flash
2019-05-26 18:10:06 +02:00
Tillmann Karras 2195ef30f3 DolphinQt/Mapping: red = error, don't flash 2019-05-26 17:59:30 +02:00
Roland Munsil 4ce7079098 CheatsManager: Improve performance of searching & add input validation
The previous implementation of cheat search would reconvert the input
string for every single memory value. Now we do it once and construct
a comparison lambda which we pass to the search code.

In addition, I also added input validation. So, for example, if you've
selected Decimal input and you try to compare against "FF",
it won't search and will instead let the user know they've entered an
invalid value. Similar logic for if you enter "1.2" in a search for
bytes. Before, it would just use 0 if it failed to convert the value.
2019-05-26 17:32:48 +02:00
Admiral H. Curtiss 15abb1c92d GCMemcardDirectory: Improve logic for which files are loaded into the virtual memory card.
- Files for the current game are now guaranteed to be loaded, space and validity permitting.
- Avoid showing PanicAlerts for every problem encountered, most of them aren't really important enough and will probably just annoy the user.
- And for the only error the user will definitely care about, when the save of the game they're trying to play fails to load, show an imgui message instead.
2019-05-25 21:51:36 +02:00
Admiral H. Curtiss 5af05f6714 GCMemcard/GCIFile: Implement LoadHeader(). 2019-05-25 21:49:09 +02:00
Admiral H. Curtiss 884af05589 GCMemcardDirectory: Move GCIFile class to its own file. 2019-05-25 21:49:09 +02:00
8times9 00855552e9 Qt/MenuBar: Reorder Tools menu 2019-05-25 20:22:52 +02:00
Léo Lam edf988b465
Merge pull request #8019 from AdmiralCurtiss/gcmemcard-header-cleanup
GCMemcard: A little cleanup.
2019-05-25 19:20:43 +02:00
Admiral H. Curtiss e390fd0f4e GCMemcard: Remove unused ability of ImportGci() to write a GCI file to disk. 2019-05-25 17:58:05 +02:00
Admiral H. Curtiss 018572018e GCMemcard: Dismantle the global return value enum into a few function specific enum classes. 2019-05-25 17:58:05 +02:00
Admiral H. Curtiss d09303683c GCMemcard: Convert a few enums into constexprs. 2019-05-25 17:58:05 +02:00
Admiral H. Curtiss cbc5acb8cd GCMemcard: Get rid of stray signed length in ImportGciInternal(). 2019-05-25 17:58:05 +02:00
Admiral H. Curtiss 2d38364410 GCMemcard: Remove memsets that don't do anything in GCMemcard::Format(). 2019-05-25 17:58:05 +02:00
Admiral H. Curtiss 88a0773309 GCMemcard: Rewrite checksum calculation without undefined behavior. 2019-05-25 17:58:05 +02:00
Admiral H. Curtiss fcd75841ca GCMemcard: Rewrite Header::CalculateSerial() without undefined behavior. 2019-05-25 17:58:05 +02:00
Léo Lam 5fb56505b2
Merge pull request #8109 from leoetlino/ios-usb-fixes
IOS: USB fixes
2019-05-24 22:03:46 +02:00
Léo Lam 6dd0fe21f2 IOS/USB: Claim all interfaces ahead-of-time
To avoid having to claim/release interfaces all the time, and having to
trigger interface changes from several places, all interfaces are now
claimed ahead of time.

This commit also makes us avoid changing the active interface when it's
not necessary.

Changing the active interface has side effects such as resetting the
active alternate setting -- which is extremely undesirable because it
would require the emulated software to change the alternate setting
again, which isn't supposed to be necessary at all.

This fixes Your Shape, which submits isochronous transfers on an
endpoint that only exists in alt setting 6 right after submitting
control transfers (which would have reset to alt setting 0 prior to
this fix).
2019-05-24 20:47:46 +02:00
Léo Lam e07b514b62
Merge pull request #8115 from booto/powerpc_pvr
PowerPC: Add Broadway's PVR (retail Wii)
2019-05-24 14:51:06 +02:00
Léo Lam 9373bc3aa9
Merge pull request #8102 from dreamsyntax/debug-mousefix
Qt/Debugger CodeWidget navigation unification
2019-05-24 14:49:05 +02:00
dreamsyntax e06a62d9d1 Qt: Fix CodeWidget navigation
Changed itemSelectionChanged and itemClicked signal to itemPressed in CodeWidget.
Holding mouse down and moving will only travel up/down the stack one time.
This fixes the common occurrence of unintentionally traveling deeper down the stack or higher up the callstack than intended.
2019-05-24 14:39:15 +02:00
Léo Lam 6eb7c525b2
Merge pull request #7801 from GerbilSoft/feature/Discord-PPCTitleChanged
Update Discord rich presence when the PPC title changes
2019-05-24 14:30:52 +02:00
David Korth 8417c78b7a Update Discord rich presence when the title changes
This allows us to update the rich presence description if a channel
is launched from the Wii Menu. It also handles other PPC title
launches, e.g. Smash Bros. Masterpieces.

Host.h: Added Host_TitleChanged().

DolphinNoGUI/MainNoGUI.cpp: Implemented Host_TitleChanged().
DolphinQt/Host.cpp: Implemented Host_TitleChanged().

Android/jni/MainAndroid.cpp: Stubbed Host_TitleChanged().
DSPTool/StubHost.cpp: Stubbed Host_TitleChanged().
UnitTests/StubHost.cpp: Stubbed Host_TitleChanged().
2019-05-24 14:12:48 +02:00
booto 27cb407ecf PowerPC: Add Broadway's PVR (retail Wii) 2019-05-23 19:56:41 -04:00
Léo Lam 702344ba9c
Merge pull request #8105 from 8times9/render-window
Qt/InterfacePane: Rename "In-Game" to "Render Window"
2019-05-23 13:06:36 +02:00
Léo Lam 617747e905
Merge pull request #8113 from lioncash/ini-key
Common/IniFile: Simplify Set()
2019-05-23 12:15:30 +02:00
Léo Lam 67c2aa0701
Merge pull request #8114 from lioncash/ini-line
IniFile: Prevent potential out-of-bounds access in ParseLine()
2019-05-23 12:12:41 +02:00
booto c5a9a77684 clang-format: revert 'AfterCaseLabel' setting 2019-05-23 00:42:42 -04:00
Lioncash 2ae370fc37 IniFile: Prevent potential out-of-bounds access in ParseLine()
While current usages of ParseLine aren't problematic, this is still a
public function that can be used for other purposes. Essentially makes
the function handle potential external inputs a little nicer.
2019-05-22 21:09:11 -04:00
Lioncash 869acb96c6 Common/IniFile: Simplify Set()
We can just utilize map's insert_or_assign() function and check the
return value to determine whether or not we need to insert the key into
the keys_order vector.
2019-05-22 20:58:49 -04:00
Techjar 2e602344ea Add BraceWrapping/AfterCaseLabel to .clang-format 2019-05-22 01:51:11 -04:00
Connor McLaughlin 68877c52d1
Merge pull request #8027 from MerryMage/MOVAPS
Jit64: Prefer MOVAPS where possible
2019-05-22 15:05:17 +10:00
Léo Lam 2b44e1b851 IOS/USB: Fix initial device scan
Even though libusb is supposed to be thread-safe, in practice
it's not (at least on Windows); getting a list of devices from two
different threads can result in libusb crashes. This is easily
fixed by waiting for the scan thread to complete scanning instead
of running the scan on the CPU thread.

This also fixes an issue that I had overlooked in the initial
implementation: IOS interfaces such as OH0 are sometimes opened
every frame, in which case we were doing a full device scan every
single frame on the CPU thread!
2019-05-21 19:07:30 +02:00
Léo Lam b274a054a9 IOS/VEN: Read cancel endpoint correctly
Fixes an embarrassing bug that made the implementation utterly useless.

This fixes Your Shape hanging on shutdown. The game was waiting for an
interrupt transfer to be cancelled, and Dolphin wasn't cancelling
transfers on the correct endpoint.
2019-05-21 19:07:30 +02:00
Léo Lam d7e23d71f8 IOS/VEN: Return -4 when no transfer was cancelled
Simple accuracy fix.
2019-05-21 19:07:30 +02:00
Léo Lam 4c6ef81291 IOS/USB: Verify that isochronous req buffer size is consistent
To catch possible bugs.
2019-05-21 19:07:30 +02:00
Léo Lam a6da38d75d IOS/USB: Fix TransferCommand length type
The total buffer size for isochronous transfers should be a u32,
not a u16. It is easy to hit the bug with devices such as cameras,
which require larger buffers.

This fixes Your Shape.

This also fixes the length type for bulk and interrupt transfers,
which should be u32 as that's what IOS supports. I'm not sure why
I made them u16... probably because OH0 uses u16 for most lengths...
2019-05-21 19:07:30 +02:00
Léo Lam 5226d6103a IOS/USB: Add debug logging for all transfers
This makes debugging USB issues easier.
2019-05-21 19:07:29 +02:00
Léo Lam 57fbf1cd6e
Merge pull request #8107 from lioncash/string
DolphinQt/AboutDialog: Remove unnecessary QStringLiteral
2019-05-21 18:44:37 +02:00
Lioncash 1d22e50899 Core/Boot/Boot: Amend use-after-move cases in GenerateFromFile()
In terms of order of operations, the move would occur first before the
construction of the relevant reader would occur. However, given the
local variable 'path' was declared const, this bug actually wouldn't
occur, as std::move on a const variable does nothing (in a non-mutable
context), resulting in a copy instead, masking this issue.

Given this is a bug waiting to happen, we correct the code.
2019-05-21 08:44:29 -04:00
Lioncash ae329b7b1b DolphinQt/AboutDialog: Remove unnecessary QStringLiteral
QStrings automatically initialize to an empty string by default, making
this unnecessary.
2019-05-21 07:13:14 -04:00
Léo Lam e2c769a9c5
Merge pull request #7992 from artemist/centering
ControllerEmu: Add support for setting the center of a ReshapableInput
2019-05-20 18:29:31 +02:00
Léo Lam d2c7a6f239
Merge pull request #8094 from leoetlino/log-type-names
Qt/LogConfigWidget: Show log type short names
2019-05-20 18:27:57 +02:00
Artemis Tosini 4bbbd02de7
ControllerEmu: Do not change center when closing window 2019-05-19 16:55:29 +00:00
8times9 ba3b59fd18 Qt/InterfacePane: Rename In-Game to Render Window 2019-05-18 16:01:38 -05:00
Artemis Tosini e5683988c0
ControllerEmu: Zero the center of a ReshapableInput when calibrating 2019-05-18 19:32:48 +00:00
Artemis Tosini 99cf9a57fc
Draw center when calibrating and remove constant
This adds the center to the calibration menu when it is nonzero.
It also refactors CENTER_COLOR to be a function, similar to other colors
after an earlier commit.
2019-05-18 18:36:28 +00:00