Lib.Mouse: Fix sceMouseOpen checks (#4605)

* Fix checks for param flag

* Refactor merge check

Makes the check it's own variable to improve readability.

* Explicitly set default to normal

Addresses other review comment.
This commit is contained in:
Stephen Miller 2026-06-22 15:18:38 -04:00 committed by GitHub
parent 1155575ca4
commit 7bb1f9df7b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View File

@ -81,15 +81,17 @@ int PS4_SYSV_ABI sceMouseOpen(Libraries::UserService::OrbisUserServiceUserId use
s32 index, OrbisMouseOpenParam* pParam) {
LOG_WARNING(Lib_Mouse, "(DUMMY) called, uid: {}, type: {}, index: {}", userId, type, index);
auto u = UserManagement.GetUserByID(userId);
if (!u || !pParam || (u8)pParam->flag > 1 || index < 0 || index > 1) {
if (!u || type != 0 || index < 0 || index > 1) {
LOG_ERROR(Lib_Mouse, "invalid argument");
return ORBIS_MOUSE_ERROR_INVALID_ARG;
}
if (pParam->flag == MouseOpenBehaviour::Merged && index != 0) {
MouseOpenBehaviour mouse_mode = pParam ? pParam->flag : MouseOpenBehaviour::Normal;
bool merged_mode = True(mouse_mode & MouseOpenBehaviour::Merged);
if (merged_mode && index != 0) {
LOG_ERROR(Lib_Mouse, "Only one mouse can be opened in merged mode!");
return ORBIS_MOUSE_ERROR_ALREADY_OPENED;
}
g_is_merged_mode = pParam->flag == MouseOpenBehaviour::Merged;
g_is_merged_mode = merged_mode;
if (mouse_handles[index] != -1) {
LOG_ERROR(Lib_Mouse, "already opened");
return ORBIS_MOUSE_ERROR_ALREADY_OPENED;

View File

@ -3,6 +3,7 @@
#pragma once
#include "common/enum.h"
#include "common/ring_buffer_queue.h"
#include "core/libraries/system/userservice.h"
@ -27,6 +28,7 @@ enum class MouseOpenBehaviour : u8 {
Normal = 0,
Merged = 1,
};
DECLARE_ENUM_FLAG_OPERATORS(MouseOpenBehaviour);
struct OrbisMouseOpenParam {
MouseOpenBehaviour flag;