mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-07-10 02:04:42 -06:00
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:
parent
1155575ca4
commit
7bb1f9df7b
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user