Commit graph

438 commits

Author SHA1 Message Date
mageven
27179d0218
Improve multi-controller support in HID and Controller Applet (#1453)
* Initial commit

Enable proper LED patterns
Toggle Hotkeys only on focus
Ignore Handheld on Docked mode
Remove PrimaryController
Validate NpadIdType
Rewrite NpadDevices to process config in update loop
Cleanup

* Notify in log periodically when no matched controllers

* Remove duplicate StructArrayHelpers in favor of Common.Memory

Fix struct padding CS0169 warns in Touchscreen

* Remove GTK markup from Controller Applet

Use IList instead of List
Explicit list capacity in 1ms loop
Fix formatting

* Restrict ControllerWindow to show valid controller types

Add selected player name to ControllerWindow title

* ControllerWindow: Fix controller type initial value

NpadDevices: Simplify default battery charge

* Address AcK's comments

Use explicit types and fix formatting

* Remove HashSet for SupportedPlayers

Fixes potential exceptions due to race

* Fix ControllerSupportArg struct packing

Also comes with two revisions of struct for 4/8 players max.
2020-08-23 22:54:11 +02:00
Ac_K
5eb0ee3cca
account: Implement IManagerForApplication calls and IAsyncContext (#1466)
* account: Implement IManagerForApplication calls and IAsyncContext

This implement:
- IManagerForApplication::EnsureIdTokenCacheAsync (accordingly to RE) but the Async task is stubbed.
- IAsyncContext interface (accordingly to RE).
- IManagerForApplication::LoadIdTokenCache (checked with RE, and stubbed).

I've tried some games but now they needs some `sfdnsres` calls, some other boots and crashes with other issues.
Maybe we should disable the connection somewhere to lets the game think we are offline. I have done many attempts, without success, but since the code is here now, it's better than nothing.

(I've cleaned up `using` of IGeneralService too)

Closes #629 and closes #630

* change AccountId

* Fix gdkchan's comments

* use CompletedTask
2020-08-18 21:24:54 +02:00
Mary
5b26e4ef94
Misc audio fixes (#1348)
Changes:

    Implement software surround downmixing (fix #796).
    Fix a crash when no audio renderer were created when stopping emulation.

NOTE: This PR also disable support of 5.1 surround on the OpenAL backend as we cannot detect if the hardware directly support it. (the downmixing applied by OpenAL on Windows is terribly slow)
2020-08-18 21:03:55 +02:00
Mary
a389dd59bd
Amadeus: Final Act (#1481)
* Amadeus: Final Act

This is my requiem, I present to you Amadeus, a complete reimplementation of the Audio Renderer!

This reimplementation is based on my reversing of every version of the audio system module that I carried for the past 10 months.
This supports every revision (at the time of writing REV1 to REV8 included) and all features proposed by the Audio Renderer on real hardware.

Because this component could be used outside an emulation context, and to avoid possible "inspirations" not crediting the project, I decided to license the Ryujinx.Audio.Renderer project under LGPLv3.

- FE3H voices in videos and chapter intro are not present.
- Games that use two audio renderer **at the same time** are probably going to have issues right now **until we rewrite the audio output interface** (Crash Team Racing is the only known game to use two renderer at the same time).

- Persona 5 Scrambler now goes ingame but audio is garbage. This is caused by the fact that the game engine is syncing audio and video in a really aggressive way. This will disappears the day this game run at full speed.

* Make timing more precise when sleeping on Windows

Improve precision to a 1ms resolution on Windows NT based OS.
This is used to avoid having totally erratic timings and unify all
Windows users to the same resolution.

NOTE: This is only active when emulation is running.
2020-08-17 22:49:37 -03:00
Ac_K
1ad9045c6b
bluetooth: Fix event handle in IBluetoothDriver (#1464)
This fix the InitializeBluetoothLe call who didn't return any event handle
2020-08-13 01:04:59 +02:00
LDj3SNuD
e36e97c64d
CPU: This PR fixes Fpscr, among other things. (#1433)
* CPU: This PR fixes Fpscr, among other things.

* Add Fpscr.Qc = 1 if sat. for Vqrshrn & Vqrshrun.

* Fix Vcmp & Vcmpe opcode table.

* Revert "Fix Vcmp & Vcmpe opcode table."

This reverts commit c117d9410d.

* Address PR feedbacks.
2020-08-08 17:18:51 +02:00
Alex Barney
8d59ad88b4
Forward OpenSaveDataInfoReaderOnlyCacheStorage to OpenSaveDataInfoReaderWithFilter (#1449) 2020-08-08 16:02:06 +02:00
mageven
a33dc2f491
Improved Logger (#1292)
* Logger class changes only

Now compile-time checking is possible with the help of Nullable Value
types.

* Misc formatting

* Manual optimizations

PrintGuestLog
PrintGuestStackTrace
Surfaceflinger DequeueBuffer

* Reduce SendVibrationXX log level to Debug

* Add Notice log level

This level is always enabled and used to print system info, etc...
Also, rewrite LogColor to switch expression as colors are static

* Unify unhandled exception event handlers

* Print enabled LogLevels during init

* Re-add App Exit disposes in proper order

nit: switch case spacing

* Revert PrintGuestStackTrace to Info logs due to #1407

PrintGuestStackTrace is now called in some critical error handlers
so revert to old behavior as KThread isn't part of Guest.

* Batch replace Logger statements
2020-08-04 01:32:53 +02:00
mageven
c11855565e
Implement Software Keyboard GTK frontend (#1434)
* Implement SwKbd GUI

* Relocate UI handler to Emu Context from Config

Also create a common interface for UI handlers in the context and specialize for Gtk

Add basic input length validation in InputDialog

* Add Transfer Memory support to AppletCreator

Read Initial Text for SwKbd using Transfer Memory

* Improve InputDialog widget

Improve length validation
Has extra label to show validition info
Handle potential errors and log them

* Misc improvements

* Improve string validation
* Improve error handling
* Remove tuple in struct
* Address formatting nits

* Add proper Cancel functionality

Also handle GUI errors in UI handler

* Address jD's comments

* Fix _uiHandler init

* Address AcK's comments
2020-08-03 03:30:58 +02:00
Ac_K
1457ab5456
friend: Implement GetPlayHistoryRegistrationKey (#1424)
* friend: Implement GetPlayHistoryRegistrationKey

This implement IServiceCreator::GetPlayHistoryRegistrationKey call accordingly to RE.

Close #1110

* Fix comments

* Fix guid and comment some codes

* Improve guid casting and remove unused vars
2020-08-02 02:20:44 +02:00
Mary
3c099454ca
fs: stub ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute (#1443)
This is required by AC:NH for the new online save features of 1.4.0
2020-07-31 12:25:33 +02:00
gdkchan
57bb0abda3
Print guest stack trace on invalid memory access (#1407)
* Print guest stack trace on invalid memory access

* Improve XML docs
2020-07-30 23:16:41 +10:00
Ac_K
ca0d1f8205
ns/nim: Stub eShop related calls (#1420)
* ns/nim: Stub eShop related calls

As we aren't able to process purchase on the eShop throught the emulator, I have:
- Stub IPurchaseEventManager::SetDefaultDeliveryTarget (with RE check).
- Implement IPurchaseEventManager::GetPurchasedEventReadableHandle (with RE check).

As we can't do any eShop async call throught the emulator, I have:
- Stub IShopServiceAccessServerInterface::CreateServerInterface
- Stub IShopServiceAccessServer::CreateAccessorInterface
- Stub IShopServiceAccessor::IShopServiceAsync

Close #1084 and #1322

* fix handle copy

* Fix align

* Fix readonly event
2020-07-27 01:04:08 +02:00
Ac_K
d8515b603b
audin: Implement IAudioInManager ListAudioIns (#1419)
* audin: Implement IAudioInManager ListAudioIns

This implement some calls of IAudioInManager:
- ListAudioIns
- ListAudioInsAuto
- ListAudioInsAutoFiltered

Accordingly to RE.

Close #1056

* Fix count

* Comment condition

* Fix comment
2020-07-27 00:25:04 +02:00
gdkchan
8dbcae1ff8
Implement BGRA texture support (#1418)
* Implement BGRA texture support

* Missing AppendLine

* Remove empty lines

* Address PR feedback
2020-07-26 00:03:40 -03:00
Alex Barney
41ac824273
Update to LibHac 0.11.3 (#1414)
Removes the timeout when deleting files from the local file system
2020-07-24 06:12:19 +02:00
gdkchan
5a7df48975
New GPFifo and fast guest constant buffer updates (#1400)
* Add new structures from official docs, start migrating GPFifo

* Finish migration to new GPFifo processor

* Implement fast constant buffer data upload

* Migrate to new GPFifo class

* XML docs
2020-07-23 23:53:25 -03:00
Ac_K
9e141bc3da
vi: Implement GetIndirectLayerImageRequiredMemoryInfo (#1415)
This implement GetIndirectLayerImageRequiredMemoryInfo call from vi service, accordingly to RE.

Thanks to Thog and gdkchan for helping me to understand some GPU things.

Close #942
2020-07-23 20:25:41 +10:00
Ac_K
c6e12949e5
Add multiple calls to am service (#1411)
* Add multiple calls to am service

This implement/stub some am calls:

- SetAutoSleepDisabled
- IsAutoSleepDisabled
- SetAlbumImageTakenNotificationEnabled
- EnableApplicationCrashReport
- GetPreviousProgramIndex
- NeedsToExitProcess
- RequestForAppletToGetForeground
- GetIndirectLayerConsumerHandle

All checked by RE.
Additionnaly to that, there is some cleanup here and there.

Fix #1387, #1324, #1165, #1163, #1065

* Fix casting

* Thread safe assign
2020-07-22 14:56:00 +10:00
mageven
4aa47a66c6
Better TimeZone entry in System Settings (#1254)
* Better timezone labels in System TimeZone

Replace with GtkEntry with auto-complete

Also removed async task as now loading is fast

Address Thog's comments

self-nit: Remove string alias

Address AcK's comments

* Improve parsing
* Optimize and fix string matching

Address jD's comments

* Also, make abbreviations searchable
* Optimize EntryCompletion's MatchFunc

* nit: Result.IsFailure()

* Fix potential crash on opening Settings window w/o FW installed
2020-07-21 06:14:42 +02:00
gdkchan
1c84b683c2
Fix IDeliveryCacheProgressService GetEvent (#1409) 2020-07-21 10:54:50 +10:00
Mary
d5c34291a3
ipc hle: Fix disposing of session created with MakeObject (#1404)
This fix a missing part of #1397, making HLE ipc session being disposed
when needed.

THis is needed for upcoming wip changes.
2020-07-20 12:23:26 +10:00
gdkchan
e7f2a5ecb7
Fix session service disposal and improve transfer memory implementation (#1397)
* Fix session service disposal and improve transfer memory implementation

* Remove useless assignment
2020-07-19 15:24:18 -03:00
gdkchan
9d65de74fc
Do not print guest stack trace for svcBreak debug calls (#1398) 2020-07-18 12:54:41 +10:00
gdkchan
20774dab14
Improve kernel WaitSynchronization syscall implementation (#1362) 2020-07-17 14:22:13 +10:00
gdkchan
9f6b24edfd
Improve kernel IPC related syscalls (#1379)
* Implement session count decrement when the handle is closed

* Remove unused field

* Implement SendSyncRequestWithUserBuffer, SendAsyncRequestWithUserBuffer and ReplyAndReceiveWithUserBuffer syscalls

* Nits

* Fix swapped copy dst/src

* Add missing pointer buffer descriptor write on reply

* Fix IPC unaligned buffer copy and restoring client attributes on reply

* Oops

* Fix SetIpcMappingPermission

* Fix unaligned copy bugs

* Free memory used for temporary IPC buffers
2020-07-17 14:19:07 +10:00
gdkchan
46f8cef6a9
Fix resource limit reserve taking too long (#1391) 2020-07-17 14:18:31 +10:00
mageven
16dafe6316
mods: Fix crash when loading via LoadCart (#1388) 2020-07-15 09:40:17 +10:00
gdkchan
4d02a2d2c0
New NVDEC and VIC implementation (#1384)
* Initial NVDEC and VIC implementation

* Update FFmpeg.AutoGen to 4.3.0

* Add nvdec dependencies for Windows

* Unify some VP9 structures

* Rename VP9 structure fields

* Improvements to Video API

* XML docs for Common.Memory

* Remove now unused or redundant overloads from MemoryAccessor

* NVDEC UV surface read/write scalar paths

* Add FIXME comments about hacky things/stuff that will need to be fixed in the future

* Cleaned up VP9 memory allocation

* Remove some debug logs

* Rename some VP9 structs

* Remove unused struct

* No need to compile Ryujinx.Graphics.Host1x with unsafe anymore

* Name AsyncWorkQueue threads to make debugging easier

* Make Vp9PictureInfo a ref struct

* LayoutConverter no longer needs the depth argument (broken by rebase)

* Pooling of VP9 buffers, plus fix a memory leak on VP9

* Really wish VS could rename projects properly...

* Address feedback

* Remove using

* Catch OperationCanceledException

* Add licensing informations

* Add THIRDPARTY.md to release too

Co-authored-by: Thog <me@thog.eu>
2020-07-12 05:07:01 +02:00
mageven
189c0c9c72
Implement modding support (#1249)
* Implement Modding Support

* Executables: Rewrite to use contiguous mem and Spans

* Reorder ExeFs, Npdm, ControlData and SaveData calls

After discussion with gdkchan, it was decided it's best to call
LoadExeFs after all other loads are done as it starts the guest process.

* Build RomFs manually instead of Layering FS

Layered FS approach has considerable latency when building the final
romfs. So, we manually replace files in a single romfs instance.

* Add RomFs modding via storage file

* Fix and cleanup MemPatch

* Add dynamically loaded NRO patching

* Support exefs file replacement

* Rewrite ModLoader to use mods-search architecture

* Disable PPTC when exefs patches are detected

Disable PPTC on exefs replacements too

* Rewrite ModLoader, again

* Increased maintainability and matches Atmosphere closely
* Creates base mods structure if it doesn't exist
* Add Exefs partition replacement
* IPSwitch: Fix nsobid parsing

* Move mod logs to new LogClass

* Allow custom suffixes to title dirs again

* Address nits

* Add a per-App "Open Mods Directory" context menu item

Creates the path if not present.

* Normalize tooltips verbiage

* Use LocalStorage and remove unused namespaces
2020-07-09 14:31:15 +10:00
Mary
43b78ae157
prepo: Update implementation for 10.x changes (#1361)
* prepo: Update implementation for 10.x changes

On 10.x, Nintendo changed yet another time the prepo SaveReport &
SaveReportWithUser command ids.

This PR add support for command 10104 & 10105 and update naming of the
old variants to match switchbrew.

* Fix misalign and remove a ToString

* Address jD's comment
2020-07-05 10:58:11 +10:00
Mary
2c48750ff0
Fix compilation warnings and use new LibHac APIs for executable loading (#1350)
* Fix compilation warnings and use new LibHac APIs for executable loading

* Migrate NSO loader to the new reader and fix kip loader

* Fix CS0162 restore

* Remove extra return lines

* Address Moose's comment
2020-07-04 01:58:01 +02:00
mageven
5644780e6e
Stub nifm IRequest GetAppletInfo (#1326)
* Stub GetAppletInfo to be consistent with GetResult

* Fix formatting and enum

* Update and use ResultCode
2020-07-04 00:48:07 +02:00
Mary
c70056bc76
sockets: Make sure to write the receivedBuffer (#1346)
Fix #1341
2020-07-04 00:13:35 +02:00
Xpl0itR
4472196b48 Import DLC title key from ticket when loading into content manager (#1318) 2020-06-23 16:48:27 +02:00
Xpl0itR
2ed9db1fcd
Implement dlc management window (#1313)
* Implement dlc management window

* reduce repetition

* Implement per NCA toggling of DLC rather than per container
2020-06-23 10:32:07 +10:00
VolcaEM
a78a69a6e7
Update NRR structs (#1291)
* Update NRR structs

This was based on Switchbrew page: switchbrew.org/wiki/NRR

* Address review comments
2020-06-22 13:36:55 +02:00
mageven
1c2af7ce92
Implement aoc:u and support loading AddOnContent (#1221)
* Initial rebased AddOnContent support

* Fix bounds calculation
* Use existing GameCard in VFS per Xpl0itR's suggestion
+ Add dummy IPurchaseEventManager per AcK's suggestion

* Support multiple containers

* Add option to selectively disable addons

* Import tickets from AOC FS

* Load all nsps in base directory automatically

* Revert LoadNsp renaming

Removes conflicts with Mods PR. Not much is lost, old names were fine.

* Address AcK's comments

* Address Thog's comments

Dispose opened nsp files
Fix potential bug by clearing metadata on load
2020-06-20 19:38:14 +02:00
LDj3SNuD
5e724cf24e
Add Profiled Persistent Translation Cache. (#769)
* Delete DelegateTypes.cs

* Delete DelegateCache.cs

* Add files via upload

* Update Horizon.cs

* Update Program.cs

* Update MainWindow.cs

* Update Aot.cs

* Update RelocEntry.cs

* Update Translator.cs

* Update MemoryManager.cs

* Update InstEmitMemoryHelper.cs

* Update Delegates.cs

* Nit.

* Nit.

* Nit.

* 10 fewer MSIL bytes for us

* Add comment. Nits.

* Update Translator.cs

* Update Aot.cs

* Nits.

* Opt..

* Opt..

* Opt..

* Opt..

* Allow to change compression level.

* Update MemoryManager.cs

* Update Translator.cs

* Manage corner cases during the save phase. Nits.

* Update Aot.cs

* Translator response tweak for Aot disabled. Nit.

* Nit.

* Nits.

* Create DelegateHelpers.cs

* Update Delegates.cs

* Nit.

* Nit.

* Nits.

* Fix due to #784.

* Fixes due to #757 & #841.

* Fix due to #846.

* Fix due to #847.

* Use MethodInfo for managed method calls.

Use IR methods instead of managed methods about Max/Min (S/U).
Follow-ups & Nits.

* Add missing exception messages.

Reintroduce slow path for Fmov_Vi.
Implement slow path for Fmov_Si.

* Switch to the new folder structure.

Nits.

* Impl. index-based relocation information. Impl. cache file version field.

* Nit.

* Address gdkchan comments.

Mainly:
- fixed cache file corruption issue on exit; - exposed a way to disable AOT on the GUI.

* Address AcK77 comment.

* Address Thealexbarney, jduncanator & emmauss comments.

Header magic, CpuId (FI) & Aot -> Ptc.

* Adaptation to the new application reloading system.

Improvements to the call system of managed methods.
Follow-ups.
Nits.

* Get the same boot times as on master when PTC is disabled.

* Profiled Aot.

* A32 support (#897).

* #975 support (1 of 2).

* #975 support (2 of 2).

* Rebase fix & nits.

* Some fixes and nits (still one bug left).

* One fix & nits.

* Tests fix (by gdk) & nits.

* Support translations not only in high quality and rejit.

Nits.

* Added possibility to skip translations and continue execution, using `ESC` key.

* Update SettingsWindow.cs

* Update GLRenderer.cs

* Update Ptc.cs

* Disabled Profiled PTC by default as requested in the past by gdk.

* Fix rejit bug. Increased number of parallel translations. Add stack unwinding stuffs support (1 of 2).

Nits.

* Add stack unwinding stuffs support (2 of 2). Tuned number of parallel translations.

* Restored the ability to assemble jumps with 8-bit offset when Profiled PTC is disabled or during profiling.

Modifications due to rebase.
Nits.

* Limited profiling of the functions to be translated to the addresses belonging to the range of static objects only.

* Nits.

* Nits.

* Update Delegates.cs

* Nit.

* Update InstEmitSimdArithmetic.cs

* Address riperiperi comments.

* Fixed the issue of unjustifiably longer boot times at the second boot than at the first boot, measured at the same time or reference point and with the same number of translated functions.

* Implemented a simple redundant load/save mechanism.

Halved the value of Decoder.MaxInstsPerFunction more appropriate for the current performance of the Translator.
Replaced by Logger.PrintError to Logger.PrintDebug in TexturePool.cs about the supposed invalid texture format to avoid the spawn of the log.
Nits.

* Nit.

Improved Logger.PrintError in TexturePool.cs to avoid log spawn.
Added missing code for FZ handling (in output) for fp max/min instructions (slow paths).

* Add configuration migration for PTC

Co-authored-by: Thog <me@thog.eu>
2020-06-16 20:28:02 +02:00
Shrek5InTheatres2019
4ef689c67d
Stubbing ImportServerPki (#1281)
* Stubbed ImportServerPki

* thought it might be nice to name this variable properly

* i really need to name variables better

* Change Var

Co-authored-by: Thog <thog@protonmail.com>

* Change .ReadBytes(5) to IPC send buffer

Co-authored-by: Thog <thog@protonmail.com>

* Add description comment

Co-authored-by: Thog <thog@protonmail.com>

* fix build issue

* Resolve final suggestion

Co-authored-by: Thog <thog@protonmail.com>

* uhh

* it should work now shut up

* aligned variables just look so much nicer :)

* better variable alignment

* aligned

Co-authored-by: Thog <thog@protonmail.com>
2020-06-06 13:04:30 +02:00
Thog
bcb7761eac
SurfaceFlinger: fix some bugs (#1262)
* SurfaceFlinger: fix some bugs

This fixes some bugs in the current implementation and make it closer to
the real implementation.

* Fix align of some variables
2020-06-02 17:58:19 +02:00
mageven
b663cd22c8
Fix GetDesiredLanguage (#1275)
* Fix GetDesiredLanguage

* Correct tzcnt slip-up

* Address gdkchan's comments
2020-05-27 10:40:23 +02:00
mageven
6b55cedd73
Fix GetDisplayVersion (#1276) 2020-05-27 18:22:50 +10:00
Thog
cc8dbdd3fb
time: Make sure to initialize the network system clock with a valid system clock (#1259)
This should fix AC:NH events and probably other games.
2020-05-20 11:35:30 +02:00
Alex Barney
9544ed98b6
Update to LibHac 0.11.2 (#1240) 2020-05-16 12:12:13 +02:00
Thog
da3fd3f71b surfaceflinger: FreeBufferLocked doesn't reset the graphic buffer
That's the job of the user on Horizon (via SetPreallocatedBuffer).
2020-05-15 12:20:24 +02:00
mageven
ba4830293e
Refactor out Application details from Horizon (#1236)
* Initial Application refactor

* Misc typo and access modifier fixes

* Clean unused namespaces

* Address gdkchan's comments

* Move ticket reading to common method

* Change IParentalControlService to use ApplicationLoader.ControlData
2020-05-15 03:16:46 -03:00
Thog
0ff00bd6d3
am: Implement common web applets (#1188)
* am: Implemnet common web applets

This implement parsing of input and output of web applets while making
those close directly.

TODO for the future: Use and hook a web browser.

* Address Ac_K's comments
2020-05-15 03:56:14 +02:00
Thog
378259a40a
Surface Flinger: Implement GetBufferHistory (#1232)
* Surface Flinger: Implement GetBufferHistory

Also fix some bugs on the Surface Flinger implementation

* Address Ac_K's comment
2020-05-15 03:30:08 +02:00
Ac_K
b2e5855928
pctl: refactoring IParentalControlServiceFactory and IParentalControl… (#1219)
* pctl: refactoring IParentalControlServiceFactory and IParentalControlService call

Our previous implementation was totally guessed. Now it's implemented according to RE, even if it's stubbed because we will not support Parental Control for now.

* unknownFlag > permissionFlag
2020-05-15 03:14:38 +02:00