Commit Graph

15561 Commits

Author SHA1 Message Date
shuffle2 46b6a32b46 Merge pull request #4281 from shuffle2/Tilka-jit_bitwise
Jit64: use domain-appropriate instructions
2016-10-03 15:05:33 -07:00
Léo Lam 6fba48cd15 MemoryView: Don't segfault if Core isn't running
There was a bug that caused MemoryView to indirectly cause a segfault;
the simplest way to reproduce it is 1) start a game; 2) stop the game;
3) click on the Refresh button and watch Dolphin segfault.

This commit fixes it by only calling PowerPC::HostIsRAMAddress when
emulation is running.
2016-10-03 23:45:02 +02:00
Léo Lam 6ff06ed41d WII_IPC_HLE: Clean up variable naming
It doesn't make much sense to prefix g_ to static variables and for
some to be completely unprefixed.

Also renames a lot of other variables for the new conventions
2016-10-03 23:13:10 +02:00
Léo Lam 8912bb3ff4 Back up part of SYSCONF when switching to emulated BT
This fixes an issue where the Bluetooth info section could be fully
filled up by syncing 5 Wiimotes in passthrough mode then switching to
emulated Bluetooth; emulated Wiimotes were then unable to be used.

The "real" SYSCONF section is now backed up before being replaced with
a blank section that the emulated BT adapter can always fill with 5
Wiimotes without issues.

This backup is restored by the passthrough code, instead of during
the Bluetooth mode switch because this should be done regardless of the
user interface, and even without UI (if the config file is edited
manually).
2016-10-03 23:13:09 +02:00
Léo Lam b91095a9fc IPC_HLE/57e_305: Fake vendor-specific command replies
Homebrew programs seem to rely on getting a reply to the vendor
specific commands, without which Bluetooth initialisation will never
complete.

This vendor-specific command is typically used to patch the Wii's
Bluetooth module, so the replies are only faked when the passed through
adapter is not a Wii Bluetooth module.
2016-10-03 23:13:09 +02:00
Léo Lam 5b50b1e1aa WII_IPC_HLE/57e_305: Store link keys
This stores the address of paired devices and associated link keys.
It is needed because some adapters forget all stored link keys when
they are reset, which breaks pairings because the Wii relies on the
Bluetooth module to remember them.

It doesn't fix adapters that can't remember any link key
at all and always return 0 for the number of stored/written link keys.
For those adapters, there is no fix.

This also improves the usability of passthrough mode for adapters that
already work, since pairings will now keep working even if the link
keys get cleared by something else (for example by the host Bluetooth
stack).
2016-10-03 23:13:09 +02:00
Léo Lam e63b07f73b ControllerConfigDiag: Improve the UI
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)
2016-10-03 23:13:09 +02:00
Léo Lam 419a9c55e4 WII_IPC_HLE/57e_305: Fake CommandReadBufferSize replies
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!
2016-10-03 23:06:23 +02:00
Léo Lam 4b47997cf8 Add ability to passthrough a Bluetooth adapter
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).
2016-10-03 23:06:23 +02:00
Léo Lam 59a17db6c4 Add a __LIBUSB__ define
This allows us to only check if __LIBUSB__ is defined, which is cleaner
than checking for __LIBUSB__ and _WIN32.
2016-10-03 21:07:12 +02:00
shuffle2 2c66f5bdc0 Merge pull request #4283 from leoetlino/misc-warning-fixes
Fix a few warnings
2016-10-03 12:03:52 -07:00
shuffle2 f63b767f78 Merge pull request #4280 from shuffle2/lioncash-misc
VideoCommon: Minor changes
2016-10-03 12:03:00 -07:00
Léo Lam 04c1757b49 Fix a few warnings 2016-10-03 19:29:35 +02:00
Léo Lam fad17246db InputCommon: Fix formatting issues in Quartz
This wasn't caught by the lint script because it was broken (by me) at
some point :(

If it had been rebased, it wouldn't have passed lint
2016-10-03 18:59:52 +02:00
Shawn Hoffman f000bb7590 Jit64: use domain-appropriate instructions
Original commit:
commit 62d3423ccf
Author: Tillmann Karras <tilkax@gmail.com>
Date:   Wed Nov 18 20:32:20 2015 +0100
2016-10-03 07:15:26 -07:00
Shawn Hoffman 86112c7258 VideoCommon: Minor changes
Make Renderer::GetMaxTextureSize return u32 instead of int.
2016-10-03 06:51:46 -07:00
shuffle2 cc66f0336f Merge pull request #3963 from JosJuice/banner-loaded-failure
VolumeGC: Set m_banner_loaded when banner loading fails
2016-10-03 06:33:52 -07:00
shuffle2 f121fa07c2 Merge pull request #2868 from sepalani/dolphin_ssl
Dolphin new Dump SSL features
2016-10-03 06:16:49 -07:00
shuffle2 e38ddfd787 Merge pull request #4111 from EmptyChaos/startup-perf-langs
InputCommon: Fix slow startup on some Windows systems with language packs (Issue 9744)
2016-10-03 04:02:54 -07:00
Shawn Hoffman b7dbc58c27 quick fix to prevent heap corruption by overwriting 4bytes of 1byte sysconf element 2016-10-03 03:43:01 -07:00
shuffle2 2db2e88620 Merge pull request #4010 from leoetlino/relative-input
Add relative input for the Wiimote IR
2016-10-03 03:26:04 -07:00
shuffle2 4b62d41728 Merge pull request #4090 from leoetlino/hidapi
WiimoteReal: Add a hidapi IO implementation
2016-10-03 03:20:17 -07:00
shuffle2 2747fd3a0d Merge pull request #4102 from ligfx/quartz_input
Add Quartz/CoreGraphics controller interface for default k&m events
2016-10-03 03:13:58 -07:00
Léo Lam 2511bfdb8a WiimoteReal: Make the connected Wiimote check common
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.
2016-10-03 11:43:05 +02:00
Léo Lam 222f7e6fc3 WiimoteReal: IOWin: Remove duplicate code
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.
2016-10-03 11:41:23 +02:00
Léo Lam 132ca8d02c WiimoteReal: hidapi: Add support for the Balance Board
A name change isn't enough for the DolphinBar; we have to actually
query the Wiimote to know if the Wiimote is a Balance Board.
2016-10-03 11:41:23 +02:00
Léo Lam d9a9e34994 WiimoteReal: Disconnect the Wiimote if IOWrite fails
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.
2016-10-03 11:41:23 +02:00
Léo Lam 53d553d2b0 WiimoteReal: Fix race between shutdown and FindWiimotes
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.
2016-10-03 11:41:23 +02:00
Léo Lam 1ff94c5f2d DolphinWX: Prevent crash with Wiimote connected on start
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.
2016-10-03 11:41:23 +02:00
Léo Lam 843b030eda WiimoteReal: Add a hidapi IO implementation
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.
2016-10-03 11:41:23 +02:00
shuffle2 5045fc869c Merge pull request #4188 from degasus/dynamic-bat
Dynamic bat: Merge failure and small cleanup
2016-10-03 02:37:33 -07:00
degasus f7e07f8f3b MMU: Don't generate virtual memory area on 32bit builds.
There is no JIT, so no need for fastmem. This memory won't be used at all.
2016-10-03 10:26:23 +02:00
degasus 0de1c6c99c MMU: Sort physical access by common access pattern. 2016-10-03 10:26:23 +02:00
degasus d1488d0dc4 MMU: Drop force inline usage.
This is not needed, the compiler will do it on it's own if required.
2016-10-03 10:26:19 +02:00
degasus 4b3e388bd7 Jit64: Fix merge failure of dynamic_bat. 2016-10-03 10:15:52 +02:00
degasus ebc47a4b36 Memmap: Drop redundant global bFakeVMEM flag. 2016-10-03 10:15:52 +02:00
EmptyChaos 76558c4d87 HLE: Fix warnings 2016-10-03 18:49:08 +11:00
shuffle2 d139659ea2 Merge pull request #4276 from lioncash/code
GeckoCode: Provide operator== and operator!= overloads
2016-10-03 00:01:23 -07:00
Lioncash e8cd5a3979 GeckoCode: Provide operator== and operator!= overloads
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==
2016-10-03 02:32:43 -04:00
shuffle2 332c9b514b Merge pull request #4275 from lioncash/net
NetPlaySetupFrame: Use an anonymous namespace instead of static
2016-10-02 22:59:35 -07:00
shuffle2 09fd2fd8e2 Merge pull request #4015 from EmptyChaos/wx-misc-fixes
WX: Fix pop-under (win) / game list garbage (win) / language support (Linux)
2016-10-02 22:46:14 -07:00
shuffle2 fba6801851 Merge pull request #4216 from EmptyChaos/geckocodes-cleanup
GeckoCodes: Don't run PPC code in CoreTiming callbacks
2016-10-02 22:37:51 -07:00
EmptyChaos 09372a55da GeckoCode: Save installation state to savestates
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.
2016-10-03 16:27:42 +11:00
EmptyChaos b3547870ee PatchEngine/GeckoCode: Heuristic stack checks
Try to make sure the stack is sane before calling into the
codehandler. This is intended to reduce the possibility of random
memory corruption.
2016-10-03 16:27:42 +11:00
EmptyChaos 31cf8432bf HLE: Differentiate Address hooks from Symbol hooks
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.
2016-10-03 16:27:42 +11:00
EmptyChaos c3cef54910 PatchEngine: Handle MSR more cleanly
Instead of fiddling with the MSR value, just reschedule and try again
after the game fixes it itself.
2016-10-03 16:27:42 +11:00
EmptyChaos 83407263e5 HLE/GeckoCode: Add new HLE hook exit trampoline
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.
2016-10-03 16:27:42 +11:00
EmptyChaos 249d8a76e1 GeckoCode: Don't spam retry after the install fails
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.
2016-10-03 16:27:42 +11:00
EmptyChaos 541a42a7e3 GeckoCode: Use named constants in ICache flush hack
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.
2016-10-03 16:27:18 +11:00
EmptyChaos 4fef9d8d64 GeckoCode: Don't truncate codes that won't fit
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.
2016-10-03 16:27:18 +11:00