Commit Graph

195 Commits

Author SHA1 Message Date
JosJuice 6ca2da53e8 Partially revert "Revert "Audit uses of IsRunning and GetState""
This reverts the revert commit bc67fc97c3,
except for the changes in BaseConfigLoader.cpp, which caused the bug
that made us revert 72cf2bdb87. PR 12917
contains an improved change to BaseConfigLoader.cpp, which can be merged
(or rejected) independently.

A few changes have also been made based on review comments.
2024-10-04 18:35:41 +02:00
mitaclaw 4f0954dd44 MainAndroid: Thread Correctness In WriteJitBlockLogDump
In a race condition, the core could shut down between the `JitInterface::GetCore` nullptr check and the `JitInterface::JitBlockLogDump` call which constructs a `CPUThreadGuard`. In this scenario, nothing horrible happens—`JitBlockLogDump` also checks for a nullptr—but it would be a failure to display the correct feedback to the user.
2024-07-28 16:10:59 -07:00
mitaclaw 7cafd78ffc MainAndroid: Use JNI_FALSE instead of static_cast<jboolean>(false) 2024-07-27 20:22:25 -07:00
JosJuice bc67fc97c3 Revert "Audit uses of IsRunning and GetState"
This reverts commit 72cf2bdb87.

SYSCONF settings are getting cleared when they shouldn't be. Let's
revert the change until I get proper time to figure out why it's broken.
2024-06-26 20:36:46 +02:00
Admiral H. Curtiss 9b33b777cf
Merge pull request #12828 from JosJuice/unify-state-variables-2
Clean up Core::GetState
2024-06-22 20:20:54 +02:00
JosJuice 72cf2bdb87 Audit uses of IsRunning and GetState
Some pieces of code are calling IsRunning because there's some
particular action that only makes sense when emulation is running, for
instance showing the state of the emulated CPU. IsRunning is appropriate
to use for this. Then there are pieces of code that are calling
IsRunning because there's some particular thing they must avoid doing
e.g. when the CPU thread is running or IOS is running. IsRunning isn't
quite appropriate for this. Such code should also be checking for the
states Starting and Stopping. Keep in mind that:

* When the state is Starting, the state can asynchronously change to
  Running at any time.
* When we try to stop the core, the state gets set to Stopping before we
  take any action to actually stop things.

This commit adds a new method Core::IsUninitialized, and changes all
callers of IsRunning and GetState that look to me like they should be
changed.
2024-06-21 20:52:55 +02:00
JosJuice 962230f91e Core: Store current state in less places
Core::GetState reads from four different pieces of state: s_is_stopping,
s_hardware_initialized, s_is_booting, and CPUManager::IsStepping.
I'm keeping that last one as is for now because there's code in Dolphin
that sets it directly, but we can unify the other three to make things
easier to reason about.

This commit also gets rid of s_is_started. This was previously used in
Core::IsRunningAndStarted to ensure true wouldn't be returned until the
CPU thread was started, but it wasn't used in Core::GetState, so
Core::GetState would happily return State::Running after we had
initialized the hardware but before we had initialized the CPU thread.
As far as I know, there are no callers that have any real need to know
whether the boot process is currently initializing the hardware or the
CPU thread. Perhaps once upon a time there was a desire to make the
apploader debuggable, but a long time has passed without anyone stepping
up to implement it, and the way CBoot::RunApploader is implemented makes
it rather difficult. So this commit makes all the functions in Core.cpp
consider the core to still be starting until the CPU thread is started.
2024-06-21 20:46:44 +02:00
Dentomologist c3bdd05d2a TAS Input: Enable hotkeys and controller input when Input has focus
Enable emulator hotkeys and controller input (when that option is
enabled) when a TAS Input window has focus, as if it was the render
window instead.  This allows TASers to use frame advance and the like
without having to switch the focused window or disabling Hotkeys Require
Window Focus which also picks up keypresses while other apps are active.

Cursor updates are disabled when the TAS Input window has focus, as
otherwise the Wii IR widget (and anything else controlled by the mouse)
becomes unusable. The cursor continues to work normally when the render
window has focus.
2024-05-31 15:14:44 -07:00
mitaclaw 0b04975c26 Core::SetState: Avoid Global System Accessor 2024-05-03 21:04:44 -07:00
mitaclaw 0df401b164 Core::IsRunning: Avoid Global System Accessor 2024-05-01 08:54:17 -07:00
Admiral H. Curtiss 0c1a76398b
Merge pull request #12691 from mitaclaw/jit-profiling-restoration
JitCache: Software Profiling Restoration
2024-04-13 01:35:25 +02:00
mitaclaw ee8bcf2ccc JitCache: Software Profiling Restoration
Rekindle software JIT profiling with a std::chrono conversion and a config connection.
2024-04-09 13:43:31 -07:00
mitaclaw eb92d6f0a8 Core::GetState: Avoid Global System Accessor 2024-04-08 16:23:23 -07:00
Admiral H. Curtiss a2074a8583
Merge pull request #12645 from mitaclaw/ppc-symbols-signal
DolphinQt: A Ubiquitous Signal For When Symbols Change
2024-03-31 06:36:09 +02:00
mitaclaw b52a08d533 DolphinQt: A Ubiquitous Signal For When Symbols Change
There were three distinct mechanisms for signaling symbol changes in DolphinQt: `Host::NotifyMapLoaded`, `MenuBar::NotifySymbolsUpdated`, and `CodeViewWidget::SymbolsChanged`. The behavior of these signals has been consolidated into the new `Host::PPCSymbolsUpdated` signal, which can be emitted from anywhere in DolphinQt to properly update symbols everywhere in DolphinQt.
2024-03-28 09:57:22 -07:00
mitaclaw 73f9904f2a Core: Remove RunAsCPUThread
It's a fine function, but CPUThreadGuard is more vogue. Also, its potential for being confused with RunOnCPUThread will not be missed.
2024-03-23 03:33:26 -07:00
Admiral H. Curtiss 3948ac9513
Merge pull request #12606 from mitaclaw/state-global-system
State: Avoid Global System Accessor
2024-03-22 04:27:12 +01:00
Admiral H. Curtiss f814dc58b5
Merge pull request #12620 from mitaclaw/jit-interface-cpu-thread-guard
JitInterface::ClearCache: Modernize With CPUThreadGuard
2024-03-22 04:17:33 +01:00
mitaclaw f09b71582e Core: Avoid (Some) Global System Accessor 2024-03-18 01:35:42 -07:00
Admiral H. Curtiss c964d552c9
Merge pull request #12616 from mitaclaw/dvd-interface-cpu-thread-guard
DVDInterface: Modernize With CPUThreadGuard
2024-03-17 16:14:56 +01:00
mitaclaw fe61efcd7a DVDInterface: Modernize With CPUThreadGuard 2024-03-08 15:17:41 -08:00
mitaclaw 4568446398 JitInterface::ClearCache: Modernize With CPUThreadGuard
It is recommended to view this diff with whitespace changes hidden.
2024-03-04 19:45:34 -08:00
mitaclaw 16c609dcd4 BootManager: Avoid Global System Accessor 2024-03-01 23:39:04 -08:00
mitaclaw 0d4cb5ddc7 State: Avoid Global System Accessor 2024-03-01 10:52:50 -08:00
Admiral H. Curtiss 9a3e770c23
Migrate SConfig::bWii to System. 2024-01-31 12:54:07 +01:00
JosJuice 5bda811a00 Android: Remove HostThreadLocks that are no longer needed
71ce8bb6f0 got rid of the need to be the
host or CPU thread when writing to the config.
2023-11-25 14:06:29 +01:00
JosJuice 1f130bf8a3 Android: Declare host thread when generating analytics ID
Another instance of the host thread check failing.
2023-06-21 18:16:46 +02:00
JosJuice 27db8d4123
Merge pull request #11935 from nitanmarcel/patch-1
Use getCacheDir if getExternalCacheDir returns null.
2023-06-19 20:47:27 +02:00
Marcel Alexandru Nitan cff7a4bfd2 Use getCacheDir if getExternalCacheDir returns null. 2023-06-13 18:44:27 +00:00
JosJuice 03f2f57edf Android: Add HostThreadLock where necessary 2023-06-12 23:39:42 +02:00
JosJuice 3519a7070d Android: And Lock and Unlock wrappers to HostThreadLock
This way we can ensure DeclareAsHostThread and UndeclareAsHostThread
are called when locking and unlocking.
2023-06-12 23:39:42 +02:00
JosJuice 5524042922 Android: Move host thread lock to a separate file 2023-06-12 23:39:42 +02:00
Robin Kertels 23bebc5270
VideoBackends:Vulkan: Allow loading custom drivers on Android
... using libadrenotools
2023-06-11 13:52:34 +02:00
Admiral H. Curtiss b3c9f49cbe
Core: Assert that only the Host thread may call PauseAndLock(). 2023-06-02 18:51:43 +02:00
Admiral H. Curtiss 9217a9eba4
JitInterface: Refactor to class, move to System. 2023-03-26 14:38:07 +02:00
JosJuice 62ff2f1030
Merge pull request #11385 from JosJuice/android-input-overhaul
Android input overhaul
2023-03-11 12:37:44 +01:00
Admiral H. Curtiss eb25c46a91
HW/DVDInterface: Refactor to class. 2023-03-10 18:12:59 +01: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 93657cce54 Android: Stop extracting pre-defined controller INIs 2023-03-03 22:28:24 +01:00
JosJuice 9e7a2ee0fb Android: Remove old motion input implementation 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 86c1f6e1e7 Jit: Don't use a second stack
This second stack leads to JNI problems on Android, because ART fetches
the address and size of the original stack using pthread functions
(see GetThreadStack in art/runtime/thread.cc), and (presumably) treats
stack addresses outside of the original stack as invalid. (What I don't
understand is why some JNI operations on the CPU thread work fine
despite this but others don't.)

Instead of creating a second stack, let's borrow the approach ART uses:
Use pthread functions to find out the stack's address and size, then
install guard pages at an appropriate location. This lets us get rid
of a workaround we had in the MsgAlert function.

Because we're no longer choosing the stack size ourselves, I've made some
tweaks to where the put the guard pages. Previously we had a stack of
2 MiB and a safe zone of 512 KiB. We now accept stacks as small as 512 KiB
(used on macOS) and use a safe zone of 256 KiB. I feel like this should
be fine, but haven't done much testing beyond "it seems to work".

By the way, on Windows it was already the case that we didn't create
a second stack... But there was a bug in the implementation!
The code for protecting the stack has to run on the CPU thread, since
it's the CPU thread's stack we want to protect, but it was actually
running on EmuThread. This commit fixes that, since now this bug
matters on other operating systems too.
2023-02-28 20:29:46 +01:00
Scott Mansell abfc75f362 Cleanup headers 2023-01-31 19:41:24 +13:00
Scott Mansell 0d4537d60f Move Presenting, Dumping and ImGui out of Renderer 2023-01-31 18:45:21 +13:00
JosJuice 0b9351c194 Android: Make more meticulous use of DeleteLocalRef
If we're in a function that isn't just going to immediately return to
Java, leaking local references can lead to problems eventually.
2022-12-27 22:03:44 +01: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
InvoxiPlayGames f9e39cf200 Add Discord presence ioctlv to /dev/dolphin 2022-08-06 07:32:29 +01:00
JosJuice 01e4ce54c8 Android: Call WiimoteReal::InitAdapterClass before controller init
Should fix https://bugs.dolphin-emu.org/issues/12980.
2022-07-19 23:00:21 +02:00
JosJuice dabad82219 Require frontend to initialize controllers
We currently have two different code paths for initializing controllers:
Either the frontend (DolphinQt) can do it, or if the frontend doesn't do
it, the core will do it automatically when booting. Having these two
paths has caused problems in the past due to only one frontend being
tested (see de7ef47548). I would like to get rid of the latter path to
avoid further problems like this.
2022-07-17 14:03:04 +02: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