remove old hle mouse

This commit is contained in:
Vinicius Rangel 2024-11-14 02:47:57 -03:00
parent 31b3b1976b
commit e40ef8e100
No known key found for this signature in database
GPG Key ID: A5B154D904B761D9
8 changed files with 14 additions and 294 deletions

View File

@ -309,8 +309,6 @@ set(SYSTEM_LIBS src/core/libraries/system/commondialog.cpp
src/core/libraries/remote_play/remoteplay.h
src/core/libraries/share_play/shareplay.cpp
src/core/libraries/share_play/shareplay.h
src/core/libraries/mouse/mouse.cpp
src/core/libraries/mouse/mouse.h
)
set(VIDEOOUT_LIB src/core/libraries/videoout/buffer.h

View File

@ -122,7 +122,6 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) {
SUB(Lib, Fiber) \
SUB(Lib, Vdec2) \
SUB(Lib, Videodec) \
SUB(Lib, Mouse) \
CLS(Frontend) \
CLS(Render) \
SUB(Render, Vulkan) \

View File

@ -89,7 +89,6 @@ enum class Class : u8 {
Lib_Fiber, ///< The LibSceFiber implementation.
Lib_Vdec2, ///< The LibSceVideodec2 implementation.
Lib_Videodec, ///< The LibSceVideodec implementation.
Lib_Mouse, ///< The LibSceMouse implementation
Frontend, ///< Emulator UI
Render, ///< Video Core
Render_Vulkan, ///< Vulkan backend

View File

@ -44,7 +44,6 @@
#include "core/libraries/videodec/videodec.h"
#include "core/libraries/videodec/videodec2.h"
#include "core/libraries/videoout/video_out.h"
#include "src/core/libraries/mouse/mouse.h"
namespace Libraries {
@ -90,7 +89,6 @@ void InitHLELibs(Core::Loader::SymbolsResolver* sym) {
Libraries::SharePlay::RegisterlibSceSharePlay(sym);
Libraries::Remoteplay::RegisterlibSceRemoteplay(sym);
Libraries::Videodec::RegisterlibSceVideodec(sym);
// Libraries::Mouse::RegisterlibSceMouse(sym);
}
} // namespace Libraries

View File

@ -1,226 +0,0 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "mouse.h"
#include <common/singleton.h>
#include <core/libraries/system/msgdialog_ui.h>
#include <input/mouse.h>
#include "common/elf_info.h"
#include "common/logging/log.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/libs.h"
#include <mutex>
using Common::ElfInfo;
namespace Libraries::Mouse {
static std::mutex g_mtx;
static bool g_initialized = false;
static bool g_mouse1_open = false;
static bool g_mouse2_open = false;
constexpr int32_t MOUSE1_HANDLE = 0x72617431; // rat1
constexpr int32_t MOUSE2_HANDLE = 0x72617432; // rat2
static_assert(MOUSE1_HANDLE > 0);
static_assert(MOUSE2_HANDLE > 0);
constexpr auto ORBIS_MOUSE_OPEN_PARAM_NORMAL = 0x00;
constexpr auto ORBIS_MOUSE_OPEN_PARAM_MERGED = 0x01;
int PS4_SYSV_ABI sceMouseClose(s32 handle) {
LOG_INFO(Lib_Mouse, "called");
if (!g_initialized) {
return ORBIS_MOUSE_ERROR_NOT_INITIALIZED;
}
std::lock_guard lck{g_mtx};
if (handle == MOUSE1_HANDLE && g_mouse1_open) {
g_mouse1_open = false;
return ORBIS_OK;
}
if (handle == MOUSE2_HANDLE && g_mouse2_open) {
g_mouse2_open = false;
return ORBIS_OK;
}
return ORBIS_MOUSE_ERROR_INVALID_HANDLE;
}
int PS4_SYSV_ABI sceMouseConnectPort() {
LOG_ERROR(Lib_Mouse, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceMouseDebugGetDeviceId() {
LOG_ERROR(Lib_Mouse, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceMouseDeviceOpen() {
LOG_ERROR(Lib_Mouse, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceMouseDisconnectDevice() {
LOG_ERROR(Lib_Mouse, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceMouseDisconnectPort() {
LOG_ERROR(Lib_Mouse, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceMouseGetDeviceInfo() {
LOG_ERROR(Lib_Mouse, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceMouseInit() {
LOG_INFO(Lib_Mouse, "called");
std::lock_guard lck{g_mtx};
g_initialized = true;
return ORBIS_OK;
}
int PS4_SYSV_ABI sceMouseMbusInit() {
LOG_ERROR(Lib_Mouse, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceMouseOpen(s32 userId, s32 type, s32 index, OrbisMouseOpenParam* pParam) {
LOG_INFO(Lib_Mouse, "called");
if (!g_initialized) {
return ORBIS_MOUSE_ERROR_NOT_INITIALIZED;
}
if (type != 0) {
return ORBIS_MOUSE_ERROR_INVALID_ARG;
}
std::lock_guard lck{g_mtx};
bool merge = ElfInfo::Instance().FirmwareVer() >= ElfInfo::FW_20 && pParam != nullptr &&
(pParam->behaviorFlag & ORBIS_MOUSE_OPEN_PARAM_MERGED) != 0;
if (merge || index == 0) {
if (g_mouse1_open) {
return ORBIS_PAD_ERROR_ALREADY_OPENED;
}
g_mouse1_open = true;
if (!Common::Singleton<Input::GameMouse>::Instance()->m_connected) {
MsgDialog::ShowMsgDialog(
MsgDialog::MsgDialogState(MsgDialog::MsgDialogState::UserState{
.type = MsgDialog::ButtonType::YESNO,
.msg = "Game wants to use your mouse.\nDo you want to allow it?",
}),
false, [](MsgDialog::DialogResult result) {
if (result.buttonId == MsgDialog::ButtonId::YES) {
auto* mouse = Common::Singleton<Input::GameMouse>::Instance();
mouse->m_connected = true;
}
});
}
return MOUSE1_HANDLE;
}
if (index == 1) {
if (g_mouse2_open) {
return ORBIS_PAD_ERROR_ALREADY_OPENED;
}
g_mouse2_open = true;
return MOUSE2_HANDLE;
}
return ORBIS_MOUSE_ERROR_INVALID_ARG;
}
int PS4_SYSV_ABI sceMouseRead(s32 handle, OrbisMouseData* pData, s32 num) {
LOG_TRACE(Lib_Mouse, "called");
if (!g_initialized) {
return ORBIS_MOUSE_ERROR_NOT_INITIALIZED;
}
if (num < 1 || num > 64 || pData == nullptr) {
return ORBIS_MOUSE_ERROR_INVALID_ARG;
}
std::lock_guard lck{g_mtx};
auto* mouse = Common::Singleton<Input::GameMouse>::Instance();
if (handle == MOUSE1_HANDLE) {
if (!g_mouse1_open) {
return ORBIS_MOUSE_ERROR_INVALID_HANDLE;
}
} else if (handle == MOUSE2_HANDLE) {
if (!g_mouse2_open) {
return ORBIS_MOUSE_ERROR_INVALID_HANDLE;
}
// Mouse 2 will never be connected
pData[0] = OrbisMouseData{
.connected = false,
};
return 1;
} else {
return ORBIS_MOUSE_ERROR_INVALID_HANDLE;
}
if (!mouse->m_connected) {
pData[0] = OrbisMouseData{
.connected = false,
};
return 1;
}
Input::MouseState states[64];
int ret_num = mouse->ReadStates(states, num);
for (int i = 0; i < ret_num; i++) {
const auto& s = states[i];
pData[i] = OrbisMouseData{
.timestamp = s.time,
.connected = true,
.buttons = s.button_state,
.xAxis = s.x_axis,
.yAxis = s.y_axis,
.wheel = s.wheel,
.tilt = s.tilt,
};
}
return ret_num;
}
int PS4_SYSV_ABI sceMouseSetHandType() {
LOG_ERROR(Lib_Mouse, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceMouseSetPointerSpeed() {
LOG_ERROR(Lib_Mouse, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceMouseSetProcessPrivilege() {
LOG_ERROR(Lib_Mouse, "(STUBBED) called");
return ORBIS_OK;
}
void RegisterlibSceMouse(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("cAnT0Rw-IwU", "libSceMouse", 1, "libSceMouse", 1, 1, sceMouseClose);
LIB_FUNCTION("Ymyy1HSSJLQ", "libSceMouse", 1, "libSceMouse", 1, 1, sceMouseConnectPort);
LIB_FUNCTION("BRXOoXQtb+k", "libSceMouse", 1, "libSceMouse", 1, 1, sceMouseDebugGetDeviceId);
LIB_FUNCTION("WiGKINCZWkc", "libSceMouse", 1, "libSceMouse", 1, 1, sceMouseDeviceOpen);
LIB_FUNCTION("eDQTFHbgeTU", "libSceMouse", 1, "libSceMouse", 1, 1, sceMouseDisconnectDevice);
LIB_FUNCTION("jJP1vYMEPd4", "libSceMouse", 1, "libSceMouse", 1, 1, sceMouseDisconnectPort);
LIB_FUNCTION("QA9Qupz3Zjw", "libSceMouse", 1, "libSceMouse", 1, 1, sceMouseGetDeviceInfo);
LIB_FUNCTION("Qs0wWulgl7U", "libSceMouse", 1, "libSceMouse", 1, 1, sceMouseInit);
LIB_FUNCTION("1FeceR5YhAo", "libSceMouse", 1, "libSceMouse", 1, 1, sceMouseMbusInit);
LIB_FUNCTION("RaqxZIf6DvE", "libSceMouse", 1, "libSceMouse", 1, 1, sceMouseOpen);
LIB_FUNCTION("x8qnXqh-tiM", "libSceMouse", 1, "libSceMouse", 1, 1, sceMouseRead);
LIB_FUNCTION("crkFfp-cmFo", "libSceMouse", 1, "libSceMouse", 1, 1, sceMouseSetHandType);
LIB_FUNCTION("ghLUU2Z5Lcg", "libSceMouse", 1, "libSceMouse", 1, 1, sceMouseSetPointerSpeed);
LIB_FUNCTION("6aANndpS0Wo", "libSceMouse", 1, "libSceMouse", 1, 1, sceMouseSetProcessPrivilege);
};
} // namespace Libraries::Mouse

View File

@ -1,53 +0,0 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/types.h"
namespace Core::Loader {
class SymbolsResolver;
}
namespace Libraries::Mouse {
struct OrbisMouseOpenParam {
u8 behaviorFlag;
u8 reserve[7];
};
struct OrbisMouseData {
u64 timestamp{};
bool connected{};
u32 buttons{};
s32 xAxis{};
s32 yAxis{};
s32 wheel{};
s32 tilt{};
std::array<u8, 8> reserve{};
};
enum OrbisMouseButtonDataOffset {
ORBIS_MOUSE_BUTTON_PRIMARY = 0x00000001,
ORBIS_MOUSE_BUTTON_SECONDARY = 0x00000002,
ORBIS_MOUSE_BUTTON_OPTIONAL = 0x00000004,
ORBIS_MOUSE_BUTTON_OPTIONAL2 = 0x00000008,
ORBIS_MOUSE_BUTTON_OPTIONAL3 = 0x00000010,
};
int PS4_SYSV_ABI sceMouseClose(s32 handle);
int PS4_SYSV_ABI sceMouseConnectPort();
int PS4_SYSV_ABI sceMouseDebugGetDeviceId();
int PS4_SYSV_ABI sceMouseDeviceOpen();
int PS4_SYSV_ABI sceMouseDisconnectDevice();
int PS4_SYSV_ABI sceMouseDisconnectPort();
int PS4_SYSV_ABI sceMouseGetDeviceInfo();
int PS4_SYSV_ABI sceMouseInit();
int PS4_SYSV_ABI sceMouseMbusInit();
int PS4_SYSV_ABI sceMouseOpen(s32 userId, s32 type, s32 index, OrbisMouseOpenParam* pParam);
int PS4_SYSV_ABI sceMouseRead(s32 handle, OrbisMouseData* pData, s32 num);
int PS4_SYSV_ABI sceMouseSetHandType();
int PS4_SYSV_ABI sceMouseSetPointerSpeed();
int PS4_SYSV_ABI sceMouseSetProcessPrivilege();
void RegisterlibSceMouse(Core::Loader::SymbolsResolver* sym);
} // namespace Libraries::Mouse

View File

@ -16,6 +16,14 @@ struct MouseState {
s32 tilt = 0;
};
enum OrbisMouseButtonDataOffset {
ORBIS_MOUSE_BUTTON_PRIMARY = 0x00000001,
ORBIS_MOUSE_BUTTON_SECONDARY = 0x00000002,
ORBIS_MOUSE_BUTTON_OPTIONAL = 0x00000004,
ORBIS_MOUSE_BUTTON_OPTIONAL2 = 0x00000008,
ORBIS_MOUSE_BUTTON_OPTIONAL3 = 0x00000010,
};
constexpr u32 MAX_MOUSE_STATES = 64;
class GameMouse {

View File

@ -19,7 +19,6 @@
#include <SDL3/SDL_metal.h>
#endif
#include <common/singleton.h>
#include <core/libraries/mouse/mouse.h>
#include <input/mouse.h>
namespace Frontend {
@ -156,19 +155,17 @@ void WindowSDL::onMouseAction(const SDL_Event* event) {
pressed_down = true;
[[fallthrough]];
case SDL_EVENT_MOUSE_BUTTON_UP: {
using Libraries::Mouse::OrbisMouseButtonDataOffset;
auto btn = event->button.button;
if (btn < 1 || btn > 5) { // 1..5 range
return;
}
constexpr static std::array sdl_to_orbis_buttons = {
static_cast<OrbisMouseButtonDataOffset>(0x00),
OrbisMouseButtonDataOffset::ORBIS_MOUSE_BUTTON_PRIMARY,
OrbisMouseButtonDataOffset::ORBIS_MOUSE_BUTTON_OPTIONAL,
OrbisMouseButtonDataOffset::ORBIS_MOUSE_BUTTON_SECONDARY,
OrbisMouseButtonDataOffset::ORBIS_MOUSE_BUTTON_OPTIONAL2,
OrbisMouseButtonDataOffset::ORBIS_MOUSE_BUTTON_OPTIONAL3,
static_cast<Input::OrbisMouseButtonDataOffset>(0x00),
Input::ORBIS_MOUSE_BUTTON_PRIMARY,
Input::ORBIS_MOUSE_BUTTON_OPTIONAL,
Input::ORBIS_MOUSE_BUTTON_SECONDARY,
Input::ORBIS_MOUSE_BUTTON_OPTIONAL2,
Input::ORBIS_MOUSE_BUTTON_OPTIONAL3,
};
mouse.CheckButton(sdl_to_orbis_buttons[btn], pressed_down);
} break;