The ControllerConfigDiag design was getting confusing, so more
significant changes needed to be done.
Firstly, the GC controller and the Wiimote section layouts have been
aligned for consistency.
The Balance Board source chooser is a checkbox.
The "general settings" that affect the SYSCONF have been moved to the
Wii pane in the Config dialog. It makes more sense because those
affect the Wii's settings in the NAND, unlike the other options.
Another reason for moving it is that the Controller Config Dialog was
getting pretty crowded, and the whole section is disabled when
emulation is running, which is wasted space.
The Wiimotes section is now organised by two radio buttons. One is for
the Passthrough Mode, with sync/reset buttons under it; the other is
the emulated Bluetooth mode, which still has the regular Wiimote source
choosers, the Continuous Scanning controls and the Enable Speaker Data
option (which only applies to the emulated BT mode).
Hopefully this should make things a bit clearer and look cleaner.
(This is a monolithic commit because separating UI changes is hard)
Apparently, Nintendo's Bluetooth stack expects the ACL packet buffer
size to be limited to 10.
Reporting anything higher than that could cause memory corruption,
which can result in warning messages in the logs ("event mismatch"),
and more annoyingly, random disconnects.
Thanks to shuffle2 for the fix!
This adds the ability to passthrough a whole Bluetooth adapter and skip
the majority of the Bluetooth emulation code. We use libusb to send HCI
commands, receive HCI events and transfer ACL data directly to the
first adapter that is found or to a specific adapter (if configured to)
This is possible because the Wii's Bluetooth module is actually just
a pretty standard Bluetooth adapter…
…except for two vendor-specific commands, for which replies are faked,
and also for the sync button. This adds a hotkey that works in the
exact same way as the sync button would on a Wii: it triggers an HCI
event, which emulated software interpret as a command to perform
a BT inquiry.
This commit also changes the UI code to expose passthrough mode
and WII_IPC_HLE to be a bit more thread safe (for the device map).
This moves the unordered_map used to store connected Wiimotes IDs to
WiimoteReal, and makes the ID insert/erase logic common so we don't
have to duplicate this code in scanner backends.
The Balance board detection logic is already implemented in a simpler
way in Wiimote::IsBalanceBoard() (since hidapi also needs it).
Therefore, IOWin now only needs to check if a device is a Wiimote.
This is intended to make reconnecting Wiimotes easier with a DolphinBar.
Unfortunately, this change isn't enough as it doesn't always catch
disconnections for Wiimotes connected with a DolphinBar.
But it's better than nothing and eventually a disconnection will be
detected when something tries to write to the Wiimote, instead of never.
There is no other solution as the DolphinBar always exposes 4 HIDs even
when the associated Wiimotes are not connected.
We could try to detect this using the fake input reports sent by the
DolphinBar, but this only works for the first HID (probably because of
a bug in the firmware?), so this method is not an option.
If FindWiimotes() took more time than the UI shutting down, the scanner
would try connecting a Wiimote and sending an event to the UI code
long after it has shut down, which causes a segfault.
This fixes the race by ignoring any found Wiimotes during shutdown.
Normally this would have never happened, but it is possible with hidapi
since Wiimotes can be connected before Dolphin starts.
wxWidgets causes a segfault if Host_ConnectWiimote is called and we try
to create an event from the Wiimote scanner thread while the GUI is
still initialising.
Based on ca0c2efe7a. Credits go to flacs.
However, unlike the original commit, hidapi does not completely replace
the current implementations, so we can still connect Wiimotes with 1+2
(without pairing).
Also, it is only used on Linux and OS X for now. This removes the
advantage of having only one implementation but there is no other
choice: using hidapi on Windows is currently impossible because
hid_write() is implemented in a way that won't work with Wiimotes.
Additionally:
* We now check for the device name in addition to the PID/VID so we can
support the Balance Board and maybe third-party Wiimotes too. This
doesn't achieve anything with the DolphinBar but it does with hidraw.
* Added a check to not connect to the same device more than once.
Should fix a possible reference to deleted framebuffers, as well as fixing
the issues with the render area being correct if the game's source area
changes, or auto-scaling is enabled.
Same thing but allows both GeckoCode and Code to be utilized directly
without predicates for equality/inequality in stardard algorithms
The size check for std::vectors is unnecessary, as this is built into std::vector's operator==
Because of the way this works, randomly overwriting the handler
when loading a savestate will break things because of the
self-modifying nature of the handler.
GeckoCodes require address hooks which don't correspond to any
symbol in the symbol table. The hooks get deleted when repatching
the game because they did not persist across calls to
HLE::PatchFunctions.
Dolphin emulates GeckoCodes by fiddling with the CPU state when a
VI Interrupt occurs. The problem with this is that we don't know
where the PC is so it's non-deterministic and not necessarily
suitable for use with the codehandler.
There are two options: Patch the game like Gecko OS either directly
or using HLE::Patch, or use a trampoline so we can branch from any
PC even if it would otherwise not be valid. The problem with Gecko OS
patches is there are 10 of them and they have to be configured
manually (i.e. Game INIs to would need to have a [Core]GeckoHookType
property).
HLE_Misc::GeckoReturnTrampoline enables the Code Handler to be
entered from anywhere, the trampoline restores all the registers that
had to be secretly saved to the stack.
If the installation fails because codehandler.bin is missing or
unusable then Dolphin will try again every single frame even though
it's highly unlikely a disk file will have changed. Better to just
fail once then only try again when the active code set is changed.
Suppresses generating 60 log messages per second.
Turns out one of the magic numbers was very magic. The gameid is
an ad-hoc comm protocol with HLE_Misc to control the number of times
the ICache is reset.
The code table builder cuts off the end of codes that won't fit
after already writing part of it. That seems quite unlikely to
work the way anyone would find useful since the codes can contain
actual PPC instructions.
The active codes vector cannot safely be used outside the mutex,
move the lock out into RunCodeHandler. s_code_handler_installed was
also racing against SetActiveCodes since it's being written both
inside and outside the lock.
General cleanup. Add s_ prefixes, use constexpr, remove C casts.
Executing PPC code inside an external events callback is a bad idea.
CoreTiming::Advance does not support recursion properly which will
cause timing glitches. The interpreter has a slice length hack that
counters this but without it this would cause a 20000 cycles time
skip. It isn't clear what this was supposed to accomplish that just
changing the current PC would not. Changing the PC works fine.
Deleting instead of overwriting makes the INI cleaner.
Also, in case we change defaults in the future, users will
get the new default when using a new version even if
they have pressed the Reset button in an older version.
Makes the buffering code a bit more explicit (circular buffer, but
blocks until individual buffers get unqueued by OpenAL), and fixes a
bug in the startup of Super Mario Sunshine:
https://bugs.dolphin-emu.org/issues/9811
When standby mode is enabled, this causes games to ES_Launch the system
menu instead of directly asking IOS (the STM more precisely) to shut
down, which prevents graceful shutdown from working
(it'll appear to hang).
Dolphin never supported WC24 standby mode anyway, so this shouldn't
cause any issues. (This should be reverted if and when WC24 standby is
implemented…)
This adds support for triggering the power event (in the STM), so that
stopping emulation first triggers a shutdown event, which notably gives
emulated software time to save game data (issue 8979) and clean up
SYSCONF (to disconnect Wiimotes and update their state in the SYSCONF).
On the first press, the stop button/hotkey/whatever will trigger a STM
power event. On a second try, we will forcefully stop emulation, just
like how it was working before.
There was as far as I know no reason to put everything in the header.
Separating the declaration from the implementation reduces build
times in case the implementation is updated without changing
any declaration.
This is needed because for some reason the WSI for NV Vulkan drivers
doesn't return VK_ERROR_OUT_OF_DATE_KHR, so there is no other way to know
that a resize has occured apart from polling, which is a poor solution for
X11 (since it is blocking).
Considering there's a public method in the class using it, leaving the
definition in the cpp file can cause a linker error if any method outside
that cpp file calls it for one reason or another.
Single step: Fix an oddity when a breakpoint is hit at the beginning of a block, then after, a single step is performed and finally, hitting play, the breakpoint will be skipped even in the case when it would be hit again. This was done by using the interpreter version of single step. Also, remove some redundant update request.
Step over: fix some GUI lags.
Step out: Add consideration for conditional branching by checking the condition as the interpreter does. Now, every bclr instructions except those that changes the LR (because it would not be the end of the function) will cause the end of the step out and not just blr instructions. Also now stops if a bp is detected and finally, remove redundant GUI updates calls.
This also removes a superfluous draw call on the GUI as the codeView was refreshing twice per event to do so.