Commit Graph

1433 Commits

Author SHA1 Message Date
junminlee2004
6c282aa1da
kernel: fix recursive read-lock deadlock on PthreadRwlock (#4517) 2026-06-03 22:26:34 +03:00
Marcin Mikołajczyk
e777f56964
Prevent opening duplicate windows of a shader dump (#4512) 2026-06-02 15:55:42 -07:00
Stephen Miller
0b9eb3dd17
Core: Only initialize logging once (#4509)
* Only initialize logging once

* Swap LOG macros for std::cerr and std::cout use.

* Add quick exit when trying to log before logger init

* Revert "Swap LOG macros for std::cerr and std::cout use."

This reverts commit a14d46d383.

* Use fmt's functions instead of cerr

Makes the commits a tad cleaner.

* Revert macro change

If I remember right, the if check here was to make sure we didn't throw exceptions after terminating the logger, which can happen due to a race involving some debug libSceVideoOut logs.

* Oops
2026-06-02 08:03:18 +03:00
kalaposfos13
4ac417b74f
Implement trophy migration (#4501)
* Implement trophy migration

* Respect user choice from save migration

* yet another nested subfolder iterator

* refactoring and remove original hardcoded forced migration code
2026-06-01 15:13:56 +02:00
Stephen Miller
0e23d468ca
Clean up trophy extraction logic (#4498)
This code has been an absolute mess since the trophy rework. This eliminates several redundant loops through game trophy files, and separates the logic into it's own function.
2026-06-01 15:00:15 +02:00
kalaposfos13
2736ce8c2e
Implement save migration (#4496)
* Implement save migration

* Slightly cursed macro programming

* Line break

* add const

* Remove std::filesystem redefine

---------

Co-authored-by: Stephen Miller <56742918+StevenMiller123@users.noreply.github.com>
2026-05-31 16:16:43 -05:00
kalaposfos13
d1030d01db
Don't log asserts/unreachables twice on Windows (#4497) 2026-05-31 23:15:21 +03:00
Valdis Bogdāns
f1873bb1d8
Core: Enhance AvPlayer with improved error handling and stream duration calculations (#4483) 2026-05-27 14:37:21 +03:00
kalaposfos13
2b5aa0b1c3
Attempt to fix yet another input regression in some Unity games (#4480)
* Set dummy GameController's m_connected to false

* Remove this check and handle it differently

* Save one reverse lookup on a map
this is mostly irrelevant on performance

* i have no clue so let's just log stuff

* apparently this is the correct default

* swap this to debug logging

* the loathsome clang-formatter
2026-05-26 10:54:16 -05:00
squidbus
8a08bb46ee
cpu_patches: Log full instruction on JIT patch failure. (#4477) 2026-05-25 08:31:31 -07:00
Stephen Miller
86a64fb980
Lib.Kernel: Various (mostly signal-related) fixes (#4463)
* sigaddset, sigdelset, sigismember

* Some define fixups

Based on decomp, PS4 sigset is defined as a u32[4]. This doesn't change any behavior, but makes my decomp-based sigaddset and sigdelset implementations function appropriately.
Additionally, define handler and sigaction functions as PS4_SYSV_ABI.

* Fix returns

* Implement signal, export _sigintr

In libkernel, signal just uses sigaction. No harm in implementing it, since we've got our own implementations for everything except sigaction (and sigaction is implemented for Unix platforms).

* Fix and cleanup posix_select defines

Swaps use of defines for just having static functions, and fixes the pd_set_posix struct to match FreeBSD/Orbis properly (sizeof(long) == 4 on Windows, which does not match Orbis).

* Fix siginfo struct

Again, sizeof(long) differs on different platforms. Need to use our proper typedef to ensure accuracy.

* Clang, the bane of my existance.

* Oops
2026-05-25 10:27:55 +03:00
georgemoralis
9dada49956
np score initial (#4472)
* move np_score to /np_score folder

* added more logging to np functions

* using common np_error file

* moved web_api to dedicated folder

* implemented some context creations for np_score so logging would be more productive
2026-05-25 09:38:43 +03:00
Xupie
c0d35332af
Lib.Audio3d: implement sceAudio3dPortCreate and update sceAudio3dPortOpen (#4457)
* implement sceAudio3dPortCreate and closer implementation to sceAudio3dPortOpen

* clang format and forgot to remove some lines

* refactor port creation, small cleanups and openal

* rename parameter arguments

* idk might be correct

* floor size_this to closest multiple of 8
2026-05-24 20:07:04 +03:00
Stephen Miller
e5c406d809
Upstreaming valid changes from others (#4469)
* Fix nids for strcmp vs strncmp

Co-Authored-By: m33ts4k0z <3597723+m33ts4k0z@users.noreply.github.com>

* Fix sign_bit_set logic

Co-Authored-By: m33ts4k0z <3597723+m33ts4k0z@users.noreply.github.com>

* Fix IterateDirectory on mounts

IterateDirectory would just retrieve the base path when trying to iterate /app0, since GetHostPath for the other path types would still return the base path.

Co-Authored-By: m33ts4k0z <3597723+m33ts4k0z@users.noreply.github.com>

* Fix function resolves

If multiple modules export the same library and module, then we would only check the first one we find for the symbol. This can end up breaking the font library stack

Co-Authored-By: m33ts4k0z <3597723+m33ts4k0z@users.noreply.github.com>

* Update fs.cpp

Co-Authored-By: m33ts4k0z <3597723+m33ts4k0z@users.noreply.github.com>

* Oops

---------

Co-authored-by: m33ts4k0z <3597723+m33ts4k0z@users.noreply.github.com>
2026-05-24 09:42:31 +03:00
georgemoralis
00339cf010
http part6 (#4460)
* added http* epolls

* changed info to debug

* one more info to debug

* helper function
2026-05-21 20:57:55 +03:00
georgemoralis
82beca2bbf
http part5 (#4453)
* added async state sending support

* typo

* implemented blocking

* clang is not my friend

* fixed stephen's review

* code organize / nothing changed
2026-05-21 17:14:03 +03:00
Stephen Miller
03ebac577b
Lib.VideoOut: Properly remove events on close (#4456)
* Fix flip status on close

* Store equeues by handle instead of pointer

As is, a game could call sceKernelDeleteEqueue on the equeue registered for flip/vblank events, and terminate the equeue while our VideoOut driver retains a valid pointer to it.
Changing to storing the equeue handle means we can check if the equeue still exists and prevent this.

* Remove flip and vblank events on sceVideoOutClose

* Don't forget to clear vectors

* Oops

Intended to erase the memset on FlipStatus, not VblankStatus.
2026-05-20 14:31:37 -07:00
kalaposfos13
f95edd27e0
major skill issue (#4451) 2026-05-20 09:31:23 +03:00
georgemoralis
6b5adca8a5
added some libScePosix functions (#4452) 2026-05-19 13:08:31 -05:00
Stephen Miller
7572c51c0e
Lib.Audio3d: Implement sceAudio3dPortGetAttributesSupported based on currently handled attributes (#4450)
* Stub sceAudio3dPortGetAttributesSupported to return no supported attributes

* Report supported attributes

* Slight fix
2026-05-19 08:25:33 +03:00
georgemoralis
112a4561cf
Http part4 (#4449)
* fix validation sequence in sceHttpCreateRequestWithURL2 as well

* Added timeout settings functions

* added redirect functions settings

* connection should snapshot the template's settings at creation

* sceHttpSetInflateGZIPEnabled,sceHttpSetRequestContentLength

* Https- enable/disable options functions
2026-05-18 23:43:23 +03:00
georgemoralis
88e562f63d
http_part3 (#4443)
* verified sceHttpGetLastErrno with decompile

* sceHttpCreateRequest2 fixed validation order
2026-05-18 08:28:17 +03:00
Stephen Miller
caec23154c
Lib.SystemService: Add SDK checks for console language (#4444)
* Add proper SDK checks for language values

Fixes some crashes caused by otherwise valid languages in older titles.

* Rename firmware constants

Makes more sense this way, and works better in case we find an SDK check added in a more minor update.
Instead of 1.00 being 10, 1.50 being 15, and so on, this commit changes 1.00 to 100, 1.50 to 150, and so on.

* Claaaaang
2026-05-17 18:35:36 -07:00
georgemoralis
94786d70ca
Http part2 (#4441)
* more uri work based on decompile and tests

* fix includes

* fix loader stubs

* cleanups

* sceHttpParseStatusLine matches decompile and tests

* sceHttpParseResponseHeader implemenation and tests

* try fixing no-internet path in sendrequest

* minimal state machine to support proper erroring of no-internet available

* more improvements

* more implementation based on stephen's comments

* some more fixes based on decompile
2026-05-17 22:54:34 +03:00
Stephen Miller
c7686e33a8
Core: Fix file position after read-only file mmaps (#4442)
* Fix file position after file mmaps

* Oops
2026-05-17 22:29:13 +03:00
Connor Harrison
482d17c6e1
Load custom modules stored in custom_modules/<gameid> (#4440)
* Load custom modules stored in custom_modules/<gameid>

* Fix formatting
2026-05-17 21:11:21 +03:00
georgemoralis
7337364f4c
Http part1 (#4431)
* add parameters and logging

* added sceHttpUriBuild , fixes to sceHttpUriEscape ,sceHttpUriParse

* return an error to statuscode , this should be enough for no-connection
2026-05-15 23:35:31 +03:00
kalaposfos13
4fae53f791
Quadruple stub array capacity and rewrite generation logic to C++ templates (#4424)
* Quadruple stub array capacity and rewrite generation logic to C++ templates

* remove apple ifdef
2026-05-15 19:10:44 +03:00
Niram7777
b7a85c13b2
Flush log on terminate (#4429)
* Flush log on terminate

* Flush on unhandeld signal

* hexa code

Co-authored-by: kalaposfos13 <153381648+kalaposfos13@users.noreply.github.com>

---------

Co-authored-by: kalaposfos13 <153381648+kalaposfos13@users.noreply.github.com>
2026-05-15 18:36:27 +03:00
kalaposfos13
e36dff45f4
Add setting to toggle Enter button from cross to circle (#4427)
* Add setting to toggle Enter button from cross to circle

* clang is not my friend :(
2026-05-15 14:05:00 +03:00
squidbus
b89e356cfa
videoout: Implement sceVideoOutSubmitChangeBufferAttribute (#4408) 2026-05-15 13:11:38 +03:00
kalaposfos13
50d33b4dbf
Assert on attempting to login the same user for two different slots (#4421) 2026-05-15 12:50:28 +03:00
kalaposfos13
1e58af0cc2
Revert "Assert on attempting to login the same user more than once (#4416)" (#4420)
This reverts commit a5885435d6.
2026-05-15 06:58:12 +02:00
Kravickas
44692090d2
handle DingDong (#4418)
When the rptr and wptr are equal, the ring is idle
2026-05-15 07:29:34 +03:00
Stephen Miller
85b6f5f505
Proper check for double init (#4419) 2026-05-14 18:18:16 -07:00
kalaposfos13
a5885435d6
Assert on attempting to login the same user more than once (#4416) 2026-05-14 23:00:42 +03:00
Valdis Bogdāns
b39d529324
np-legacy-state-callback (#4410)
* Core: Add user state callback management and improve user login/logout handling

* Core: Implement handle key lookup and special handle checks in pad library

---------

Co-authored-by: w1naenator <valdis.bogdans@hotmail.com>
2026-05-14 22:22:43 +03:00
oltolm
9559468c2e
core: simplify sysv_abi wrappers for MinGW-w64 GCC (#4402)
Use template <auto f> for HostCallWrapperImpl and OrbisWrapperImpl instead of passing the function type and value separately.

This keeps the wrapper behavior the same while matching the form MinGW-w64 GCC accepts.
2026-05-13 21:10:37 -07:00
Stephen Miller
622cfffaf2
Lib.Kernel: Export empty environment (#4409)
* Export empty environment

Media Player tries to read from environ before doing some rather freaky stuff, without anything exported it will just crash from dereferencing an invalid pointer.

* Set program name

Wasn't sure what the best way would be to do this

* Just stub to eboot.bin

Accurate enough, hopefully.
2026-05-13 20:50:45 -07:00
Stephen Miller
65986d8a8a
Kernel.Pthread: Various fixes (#4406)
* Fix for SignalTo behavior

Should run FindThread to make sure thread input is valid.

* Missing mutex-related exports

* Oops

* All missing cond exports

We have these implemented, so we might as well export them.
I also organized them a bit.

* Implement pthread_attr_getscope, pthread_attr_setcreatesuspend_np, pthread_attr_setscope

Also export all of our pthread_attr functions.

* Oops

* Fix SchedPolicy::Fifo definition

Some tricks FreeBSD source performs breaks with this incorrectly set.
Specifically, stuff like setting priorities breaks because we do array accesses with priority - 1 like FreeBSD, but Fifo being 0 makes that an oob read.

* Fix error checks in pthread_attr_setschedparam

* Fix and run thread destructors

_sceKernelSetThreadDtors receives the function itself, not a pointer to the function.

* Oops

* Rewrite pthread_rename_np for accuracy

There's a couple details the initial implementation missed that decomp shows. We weren't locking, we weren't doing the reference add or delete ops, and we were erroneously skipping null names when real hardware actually seems to allow it (the only thing real hardware skips for null name is naming the thread stack).

* Avoid changing common code by using the converted thread name instead

Slightly cleaner code

* Oops

* Flip priority defines

This better matches with FreeBSD's defines, and fixes the returns of sched_get_priority_min and sched_get_priority_max

* Fix args and return for sched_get_priority_max and sched_get_priority_min

Behavior is based on my own kernel decomp (though what I'm seeing matches what red_prig's done for fpPS4 too).

* Better comment

why not

* Fix error behavior of scePthreadGetPrio

Can error from invalid thread input, which the function hardcodes as an ORBIS_KERNEL_ERROR_ESRCH.

* Fix pthread_setprio

This should use the RefAdd and RefDelete functions on non-curthread threads, not FindThread.

* Remove pthread_set_name_np

Decomp shows it's identical to pthread_rename_np.

* Bring back pthread_set_name_np

What I didn't realize was that it was a void method. Behavior is the same as pthread_rename_np though, so call it instead of doing the direct common setname call.

* Move pthread_set_name_np

Needs to be under pthread_rename_np so I can actually call it.

* Better implementation of pthread_getname_np

* rwlock types

Some Sony extension to rwlocks, paired with a proper SDK check specific to rwlock init. I've implemented both pthread_rwlockattr_gettype_np and pthread_rwlockattr_settype_np, and added the relevant SDK check for rwlockattr type.

* Missing thread unlock in SignalTo

SignalTo specifically runs FindThread, then unlocks before running pretty much the same code as Signal.

* Fix comment
2026-05-13 20:50:37 -07:00
kalaposfos13
0c78ea9bba
Swap Update and Defaults button order in settings migration popup (#4399) 2026-05-12 17:17:06 +03:00
Stephen Miller
f510f9aef2
Core: Various new stubs (#4398)
* sceKernelGetProcessType

* sceCoredumpRegisterCoredumpHandler stub

* Better stub for sceCoredumpRegisterCoredumpHandler, stub sceCoredumpUnregisterCoredumpHandler

* sceNpSetNpTitleId stub

* sceNpSetContentRestriction stub

* sceKernelMlock stub

* posix_sigfillset

* posix_sigprocmask stub

Just logs the how parameter

* posix_msync stub

Just logging for now

* libSceContentExport stubs

* Clang

* sceVideoRecordingSetInfo stub

* sceKernelTitleWorkaroundIsEnabled

* Provide title workaround bits

Just grabbed them from fpPS4 code, I have a feeling actually applying these is gonna be a bit of a pain though.

* fpPS4 has a 0x39 bit, I guess that was probably added after 12.52 though.

* Bump to error

It's not going to work without proper sceKernelGetAppInfo workaround data

* Clang

* Clang2
2026-05-11 20:14:57 -07:00
Sam Kenny
201aaf232b
MapViewOfFile3 fails on PAGE_NOACCESS (#4392) 2026-05-10 21:26:53 -07:00
kalaposfos13
1409b26e50
Fix scePadResetLightBar and scePadResetOrientation being called with the wrong handle (#4391) 2026-05-10 17:23:29 -07:00
Sam Kenny
b48d917e29
Fixes regressions and issues causing PSP emulated games to not run. (#4389)
* Fixes PSP emulation with the following changes:

1. Reserved Memory cannot be mapped, this seems to be incorrect and the
   PSP emulation relies on reserving then mapping memory at startup.
   From other logs, this may affect PS2 emulation as well.

2. Temp directory output may have garbase and the API is not null
   terminating the output, resulting in failures when the file
   path is not valid.

3. Fix misaligned images when viewport is sized for PSP.
   This fixes garbage in movies on the PSP emulator, making the
   movies viewable, scaled correctly for the screen.

4. Some PSP moves render incorrectly without sceVideodec2GetAvcPictureInfo

5. Fix dirty hash size calculation and RGB4444 mapping to fix textures

 These changes combined allow Jean d'Arc, LocoRoco and Patapon to run
 decently.

* fix formatting

* null terminate the temp path rather than using memset

* fix memory mapping in a more correct way

* revert RGB4444 changes as it breaks other games color mapping
2026-05-10 17:22:41 -07:00
kalaposfos13
6e675c32f2
Do not crash on encountering an unknown option in PosixSocket::SetSocketOptions (#4346)
* what's one more hacky bypass on this pile of already existing hacky bypasses amirite

* Stub only that one option vue needs
2026-05-10 14:18:39 +01:00
kalaposfos13
66112bc90a
Refactor pad handles (#4386)
* Set up [userid, type, index] -> pad_handle mapping and hook up currently existing GameControllers backend to it

* just use basic oop principles why are we even shoving callee responsibility in caller logic

* support special pads

* random edge case I thought of

* return error if handle is already opened, redirect scePadOpenExt to scePadOpen

* scePadClose

* error out if trying to close an unopened handle

* oof

* logging
2026-05-10 11:04:20 +03:00
Stephen Miller
d3597c7f18
Kernel.Vmm: Fix protection check for file mappings (#4388) 2026-05-09 16:09:51 -07:00
Valdis Bogdāns
05df651cd8
Add IME keyboard layout and panel metrics support (#3973)
* Add IME keyboard layout and panel metrics support

- Introduced new header and implementation files for IME keyboard layout handling.
- Added structures for viewport metrics, keyboard grid layout, and drawing parameters.
- Implemented functions to compute viewport and panel metrics for the IME dialog.
- Enhanced the IME dialog UI to utilize the new keyboard layout and metrics.
- Updated input handling to support new keyboard interactions and layout adjustments.
- Added caret management and text normalization features in the IME dialog state.
- Improved window positioning logic to accommodate different screen resolutions.

* fix for Maxos Linux builds

* Align IME behavior with real PS4 libSceIme/Dialog flow

Features:
- Add validation helpers for IME option/language/extended-option masks
- Implement `sceImeGetPanelSize` sizing logic
- Replace `sceImeSetTextGeometry` no-op path with real state/argument validation
- Align panel sizing/validation paths closer to PS4 IME behavior
- Improve panel text/caret handling reliability during UI updates
- Add IME panel movement via controller right stick
- Support mouse drag repositioning for the panel
- Respect `FIXED_POSITION` by disabling movement when locked

Updates:
- Tighten `sceImeOpen` checks (user/type/input method, handler, work alignment, reserved, overlap)
- Validate initial/runtime text rules (`\n`/`\r` and surrogate rejection) in open/set-text paths
- Enforce caret bounds and null-caret behavior in `sceImeSetCaret`
- Update `sceImeUpdate` to return `NOT_OPENED` in invalid states and respect handler matching
- Harden `ImeHandler` against null state/callback execution paths
- Optimize keyboard grid rendering by reusing per-frame buffers
- Reduce input callback allocations with fixed-size buffers
- Harden panel update paths for invalid handler/open-state cases
- Clamp panel position to visible screen bounds
- Apply stick deadzone/speed scaling for stable movement
- Keep panel coordinates consistent with IME coordinate mode

* 🤦‍♂️

* Enhance IME UI and Input Handling

- Introduced BrightenColor function to adjust color brightness for UI elements.
- Improved UTF-16 character handling with new functions to count UTF-16 units and reject input based on UTF-16 limits.
- Added functionality to clamp input buffer to UTF-16 limits, ensuring text input does not exceed specified limits.
- Refactored virtual pad input handling to encapsulate left stick directions and panel movement.
- Enhanced IME UI drawing logic to incorporate new input handling and navigation features.
- Updated keyboard layout handling to support dynamic configurations and improved navigation shortcuts.
- Integrated additional font ranges for better language support in the IME, including Chinese, Arabic, and Thai.
- Improved overall code structure and readability by utilizing modern C++ features such as std::vector and std::array.

* Remove non existing Roboto Medium font from IME initialization

* Enhance IME Dialog and UI with Improved Gamepad Navigation and Key Mapping

- Added support for disabling gamepad input through OrbisImeDisableDevice in ImeDialogState.
- Updated ImeKbLayout to modify key mappings for better character input, including changes to punctuation keys.
- Implemented enhanced left stick navigation with repeat functionality in ImeUi, allowing for smoother input handling.
- Introduced new constants for stick navigation delays and repeat intervals to improve responsiveness.
- Refactored input handling logic to accommodate both virtual and gamepad inputs, ensuring consistent behavior across devices.
- Added functionality to clear all text in the input field with a specific shortcut, aligning with expected user behavior.

* clang

* Enhance IME functionality with improved gamepad navigation and layout handling

* ime: fix specials/accent layout mapping and dynamic panel resize handling

- Expand specials/accent keyboard layouts to a 7-row model and move function keys to fixed bottom rows.
- Add variable row-height support to the keyboard grid (`fixed_bottom_rows`, `bottom_row_h`) and compute row offsets/span heights from layout config.
- Preserve function-row height in `ime_ui` and `ime_dialog_ui` while distributing remaining height across typing rows.
- Make mode-switch focus layout-driven by resolving `SymbolsMode`/`SpecialsMode` action keys in the active layout instead of relying on implicit row assumptions.
- Track panel layout anchor deltas in `ime_dialog_ui` and use press-offset dragging so cursor remains on the originally pressed point when panel dimensions/position change.

* Add IME UI enhancements and shared utilities

- Introduced new states for panel navigation and selector fade in `ime_ui.h`.
- Added a new header file `ime_ui_shared.h` containing utility functions and structures for virtual pad input handling, including deadzone application and stick navigation direction resolution.
- Updated `font_stack.cpp` to include additional Unicode ranges for general punctuation in the font atlas.

* Refactor IME settings: remove deprecated accessibility options and update references to use new settings structure

* Refactor IME UI Navigation and Activation Logic

- Introduced a new mechanism for handling virtual button repeat actions, improving responsiveness for gamepad navigation.
- Added support for stick navigation with adjustable repeat rates and initial delays, enhancing user experience during input.
- Removed the ImeSelectorFadeState structure and related logic to streamline the IME keyboard layout drawing process.
- Simplified the activation logic for menus, ensuring that menu activation is more intuitive and responsive to user input.
- Adjusted the navigation threshold for stick inputs to improve sensitivity and control.
- Cleaned up the code by removing unused variables and consolidating repeated logic into reusable functions.

* Refactor IME UI shared header: streamline code and improve structure

- Removed unused includes and redundant structures.
- Consolidated virtual pad snapshot handling and input state management.
- Introduced new structures for OSK pad input and navigation handling.
- Updated function signatures for clarity and consistency.
- Enhanced keyboard parameter application for OSK shortcuts.
- Improved overall readability and maintainability of the code.

* Refactor OskShortcutActionResult to simplify triangle button press handling

* Enhance IME Keyboard Layout and UI Functionality

- Added new key glyphs for Shift and Caps Lock in ime_kb_layout.h.
- Improved keyboard navigation logic to skip non-action keys.
- Introduced new constants for selector IDs in ime_ui.cpp for better readability.
- Refactored keyboard row and column clamping logic for clarity.
- Enhanced selector drawing logic with fade and pulse effects for better user feedback.
- Implemented functions for cycling keyboard case states and toggling keyboard family modes.
- Added functionality to focus on keyboard action keys based on their actions.
- Improved edit menu handling with new templated functions for better code reuse.
- Updated caret blinking logic to improve text input experience.
- Expanded symbol ranges in font_stack.cpp to include keyboard symbols.

---------

Co-authored-by: w1naenator <valdis.bogdans@hotmail.com>
2026-05-09 23:41:14 +03:00
Stephen Miller
8bcc19248e
Core: Fix argv[0] value (#4378)
* Fix executable path

* Remove args.empty() check

Emulator::Run adds the guest executable path, so arguments will never be empty.
2026-05-09 11:13:47 +03:00