mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-08 20:58:41 +00:00
Merge remote-tracking branch 'origin/main' into user_and_settings
This commit is contained in:
@@ -968,6 +968,7 @@ hotkey_toggle_mouse_to_joystick = f7
|
||||
hotkey_toggle_mouse_to_gyro = f6
|
||||
hotkey_add_virtual_user = f5
|
||||
hotkey_remove_virtual_user = f4
|
||||
hotkey_toggle_mouse_to_touchpad = delete
|
||||
hotkey_quit = lctrl, lshift, end
|
||||
)";
|
||||
}
|
||||
|
||||
@@ -4,46 +4,87 @@
|
||||
#include "common/logging/log.h"
|
||||
#include "core/libraries/error_codes.h"
|
||||
#include "core/libraries/libs.h"
|
||||
#include "core/libraries/system/commondialog.h"
|
||||
|
||||
namespace Libraries::Np::NpCommerce {
|
||||
|
||||
using CommonDialog::Error;
|
||||
using CommonDialog::Result;
|
||||
using CommonDialog::Status;
|
||||
|
||||
static Status g_dialog_status = Status::NONE;
|
||||
static Result g_dialog_result = Result::OK;
|
||||
|
||||
s32 PS4_SYSV_ABI sceNpCommerceDialogClose() {
|
||||
LOG_ERROR(Lib_NpCommerce, "(STUBBED) called");
|
||||
LOG_INFO(Lib_NpCommerce, "called");
|
||||
if (g_dialog_status == Status::NONE) {
|
||||
return static_cast<s32>(Error::NOT_INITIALIZED);
|
||||
}
|
||||
if (g_dialog_status != Status::FINISHED) {
|
||||
return static_cast<s32>(Error::NOT_FINISHED);
|
||||
}
|
||||
g_dialog_status = Status::INITIALIZED;
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceNpCommerceDialogGetResult(s32* result) {
|
||||
LOG_ERROR(Lib_NpCommerce, "(STUBBED) called");
|
||||
LOG_INFO(Lib_NpCommerce, "called");
|
||||
if (result == nullptr) {
|
||||
return static_cast<s32>(Error::ARG_NULL);
|
||||
}
|
||||
if (g_dialog_status != Status::FINISHED) {
|
||||
return static_cast<s32>(Error::NOT_FINISHED);
|
||||
}
|
||||
*result = static_cast<s32>(g_dialog_result);
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
s8 PS4_SYSV_ABI sceNpCommerceDialogGetStatus() {
|
||||
LOG_ERROR(Lib_NpCommerce, "(STUBBED) called");
|
||||
return ORBIS_OK;
|
||||
LOG_DEBUG(Lib_NpCommerce, "called, status = {}", static_cast<u32>(g_dialog_status));
|
||||
return static_cast<s8>(g_dialog_status);
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceNpCommerceDialogInitialize() {
|
||||
LOG_ERROR(Lib_NpCommerce, "(STUBBED) called");
|
||||
LOG_INFO(Lib_NpCommerce, "called");
|
||||
if (g_dialog_status != Status::NONE) {
|
||||
return static_cast<s32>(Error::ALREADY_INITIALIZED);
|
||||
}
|
||||
g_dialog_status = Status::INITIALIZED;
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceNpCommerceDialogInitializeInternal() {
|
||||
LOG_ERROR(Lib_NpCommerce, "(STUBBED) called");
|
||||
return ORBIS_OK;
|
||||
LOG_INFO(Lib_NpCommerce, "called");
|
||||
return sceNpCommerceDialogInitialize();
|
||||
}
|
||||
|
||||
s16 PS4_SYSV_ABI sceNpCommerceDialogOpen(s64 check) {
|
||||
LOG_ERROR(Lib_NpCommerce, "(STUBBED) called");
|
||||
LOG_INFO(Lib_NpCommerce, "called, check = {}", check);
|
||||
if (g_dialog_status != Status::INITIALIZED) {
|
||||
LOG_WARNING(Lib_NpCommerce, "Dialog not initialized");
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
g_dialog_status = Status::FINISHED;
|
||||
g_dialog_result = Result::USER_CANCELED;
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceNpCommerceDialogTerminate() {
|
||||
LOG_ERROR(Lib_NpCommerce, "(STUBBED) called");
|
||||
LOG_INFO(Lib_NpCommerce, "called");
|
||||
if (g_dialog_status == Status::NONE) {
|
||||
return static_cast<s32>(Error::NOT_INITIALIZED);
|
||||
}
|
||||
if (g_dialog_status == Status::RUNNING) {
|
||||
return static_cast<s32>(Error::NOT_FINISHED);
|
||||
}
|
||||
g_dialog_status = Status::NONE;
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceNpCommerceDialogUpdateStatus() {
|
||||
LOG_ERROR(Lib_NpCommerce, "(STUBBED) called");
|
||||
return ORBIS_OK;
|
||||
LOG_DEBUG(Lib_NpCommerce, "called, status = {}", static_cast<u32>(g_dialog_status));
|
||||
return static_cast<s32>(g_dialog_status);
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceNpCommerceHidePsStoreIcon() {
|
||||
|
||||
@@ -592,6 +592,9 @@ void ControllerOutput::FinalizeUpdate(u8 gamepad_index) {
|
||||
case HOTKEY_TOGGLE_MOUSE_TO_GYRO:
|
||||
PushSDLEvent(SDL_EVENT_MOUSE_TO_GYRO);
|
||||
break;
|
||||
case HOTKEY_TOGGLE_MOUSE_TO_TOUCHPAD:
|
||||
PushSDLEvent(SDL_EVENT_MOUSE_TO_TOUCHPAD);
|
||||
break;
|
||||
case HOTKEY_RENDERDOC:
|
||||
PushSDLEvent(SDL_EVENT_RDOC_CAPTURE);
|
||||
break;
|
||||
@@ -798,6 +801,9 @@ void ActivateOutputsFromInputs() {
|
||||
it.ResetUpdate();
|
||||
}
|
||||
|
||||
// Check for input blockers
|
||||
ApplyMouseInputBlockers();
|
||||
|
||||
// Iterate over all inputs, and update their respecive outputs accordingly
|
||||
for (auto& it : connections) {
|
||||
// only update this when it's the correct pass
|
||||
|
||||
@@ -35,11 +35,12 @@
|
||||
#define SDL_EVENT_RELOAD_INPUTS SDL_EVENT_USER + 5
|
||||
#define SDL_EVENT_MOUSE_TO_JOYSTICK SDL_EVENT_USER + 6
|
||||
#define SDL_EVENT_MOUSE_TO_GYRO SDL_EVENT_USER + 7
|
||||
#define SDL_EVENT_RDOC_CAPTURE SDL_EVENT_USER + 8
|
||||
#define SDL_EVENT_MOUSE_TO_TOUCHPAD SDL_EVENT_USER + 8
|
||||
#define SDL_EVENT_QUIT_DIALOG SDL_EVENT_USER + 9
|
||||
#define SDL_EVENT_MOUSE_WHEEL_OFF SDL_EVENT_USER + 10
|
||||
#define SDL_EVENT_ADD_VIRTUAL_USER SDL_EVENT_USER + 11
|
||||
#define SDL_EVENT_REMOVE_VIRTUAL_USER SDL_EVENT_USER + 12
|
||||
#define SDL_EVENT_RDOC_CAPTURE SDL_EVENT_USER + 13
|
||||
|
||||
#define LEFTJOYSTICK_HALFMODE 0x00010000
|
||||
#define RIGHTJOYSTICK_HALFMODE 0x00020000
|
||||
@@ -58,6 +59,7 @@
|
||||
#define HOTKEY_RENDERDOC 0xf0000008
|
||||
#define HOTKEY_ADD_VIRTUAL_USER 0xf0000009
|
||||
#define HOTKEY_REMOVE_VIRTUAL_USER 0xf000000a
|
||||
#define HOTKEY_TOGGLE_MOUSE_TO_TOUCHPAD 0xf000000b
|
||||
|
||||
#define SDL_UNMAPPED UINT32_MAX - 1
|
||||
|
||||
@@ -149,6 +151,7 @@ const std::map<std::string, u32> string_to_cbutton_map = {
|
||||
{"hotkey_reload_inputs", HOTKEY_RELOAD_INPUTS},
|
||||
{"hotkey_toggle_mouse_to_joystick", HOTKEY_TOGGLE_MOUSE_TO_JOYSTICK},
|
||||
{"hotkey_toggle_mouse_to_gyro", HOTKEY_TOGGLE_MOUSE_TO_GYRO},
|
||||
{"hotkey_toggle_mouse_to_touchpad", HOTKEY_TOGGLE_MOUSE_TO_TOUCHPAD},
|
||||
{"hotkey_renderdoc_capture", HOTKEY_RENDERDOC},
|
||||
{"hotkey_add_virtual_user", HOTKEY_ADD_VIRTUAL_USER},
|
||||
{"hotkey_remove_virtual_user", HOTKEY_REMOVE_VIRTUAL_USER},
|
||||
@@ -518,7 +521,7 @@ public:
|
||||
|
||||
class ControllerAllOutputs {
|
||||
public:
|
||||
static constexpr u64 output_count = 37;
|
||||
static constexpr u64 output_count = 38;
|
||||
std::array<ControllerOutput, output_count> data = {
|
||||
// Important: these have to be the first, or else they will update in the wrong order
|
||||
ControllerOutput(LEFTJOYSTICK_HALFMODE),
|
||||
@@ -564,6 +567,7 @@ public:
|
||||
ControllerOutput(HOTKEY_RELOAD_INPUTS),
|
||||
ControllerOutput(HOTKEY_TOGGLE_MOUSE_TO_JOYSTICK),
|
||||
ControllerOutput(HOTKEY_TOGGLE_MOUSE_TO_GYRO),
|
||||
ControllerOutput(HOTKEY_TOGGLE_MOUSE_TO_TOUCHPAD),
|
||||
ControllerOutput(HOTKEY_RENDERDOC),
|
||||
ControllerOutput(HOTKEY_ADD_VIRTUAL_USER),
|
||||
ControllerOutput(HOTKEY_REMOVE_VIRTUAL_USER),
|
||||
|
||||
@@ -6,12 +6,19 @@
|
||||
#include "common/assert.h"
|
||||
#include "common/types.h"
|
||||
#include "input/controller.h"
|
||||
#include "input/input_handler.h"
|
||||
#include "input_mouse.h"
|
||||
|
||||
#include <common/singleton.h>
|
||||
#include <emulator.h>
|
||||
#include "SDL3/SDL.h"
|
||||
|
||||
extern Frontend::WindowSDL* g_window;
|
||||
|
||||
namespace Input {
|
||||
|
||||
extern std::list<std::pair<InputEvent, bool>> pressed_keys;
|
||||
|
||||
int mouse_joystick_binding = 0;
|
||||
float mouse_deadzone_offset = 0.5, mouse_speed = 1, mouse_speed_offset = 0.1250;
|
||||
bool mouse_gyro_roll_mode = false;
|
||||
@@ -80,7 +87,6 @@ void EmulateJoystick(GameController* controller, u32 interval) {
|
||||
|
||||
constexpr float constant_down_accel[3] = {0.0f, 10.0f, 0.0f};
|
||||
void EmulateGyro(GameController* controller, u32 interval) {
|
||||
// LOG_INFO(Input, "todo gyro");
|
||||
float d_x = 0, d_y = 0;
|
||||
SDL_GetRelativeMouseState(&d_x, &d_y);
|
||||
controller->Acceleration(1, constant_down_accel);
|
||||
@@ -92,6 +98,31 @@ void EmulateGyro(GameController* controller, u32 interval) {
|
||||
controller->Gyro(1, gyro_from_mouse);
|
||||
}
|
||||
|
||||
void EmulateTouchpad(GameController* controller, u32 interval) {
|
||||
float x, y;
|
||||
SDL_MouseButtonFlags mouse_buttons = SDL_GetMouseState(&x, &y);
|
||||
controller->SetTouchpadState(0, (mouse_buttons & SDL_BUTTON_LMASK) != 0,
|
||||
std::clamp(x / g_window->GetWidth(), 0.0f, 1.0f),
|
||||
std::clamp(y / g_window->GetHeight(), 0.0f, 1.0f));
|
||||
controller->CheckButton(0, Libraries::Pad::OrbisPadButtonDataOffset::TouchPad,
|
||||
(mouse_buttons & SDL_BUTTON_RMASK) != 0);
|
||||
}
|
||||
|
||||
void ApplyMouseInputBlockers() {
|
||||
switch (mouse_mode) {
|
||||
case MouseMode::Touchpad:
|
||||
for (auto& k : pressed_keys) {
|
||||
if (k.first.input.sdl_id == SDL_BUTTON_LEFT ||
|
||||
k.first.input.sdl_id == SDL_BUTTON_RIGHT) {
|
||||
k.second = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Uint32 MousePolling(void* param, Uint32 id, Uint32 interval) {
|
||||
auto* controller = (GameController*)param;
|
||||
switch (mouse_mode) {
|
||||
@@ -101,6 +132,9 @@ Uint32 MousePolling(void* param, Uint32 id, Uint32 interval) {
|
||||
case MouseMode::Gyro:
|
||||
EmulateGyro(controller, interval);
|
||||
break;
|
||||
case MouseMode::Touchpad:
|
||||
EmulateTouchpad(controller, interval);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -12,6 +12,7 @@ enum MouseMode {
|
||||
Off = 0,
|
||||
Joystick,
|
||||
Gyro,
|
||||
Touchpad,
|
||||
};
|
||||
|
||||
bool ToggleMouseModeTo(MouseMode m);
|
||||
@@ -22,6 +23,8 @@ void SetMouseGyroRollMode(bool mode);
|
||||
void EmulateJoystick(GameController* controller, u32 interval);
|
||||
void EmulateGyro(GameController* controller, u32 interval);
|
||||
|
||||
void ApplyMouseInputBlockers();
|
||||
|
||||
// Polls the mouse for changes
|
||||
Uint32 MousePolling(void* param, Uint32 id, Uint32 interval);
|
||||
|
||||
|
||||
@@ -255,6 +255,11 @@ void WindowSDL::WaitEvent() {
|
||||
SDL_SetWindowRelativeMouseMode(this->GetSDLWindow(),
|
||||
Input::ToggleMouseModeTo(Input::MouseMode::Gyro));
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_TO_TOUCHPAD:
|
||||
SDL_SetWindowRelativeMouseMode(this->GetSDLWindow(),
|
||||
Input::ToggleMouseModeTo(Input::MouseMode::Touchpad));
|
||||
SDL_SetWindowRelativeMouseMode(this->GetSDLWindow(), false);
|
||||
break;
|
||||
case SDL_EVENT_ADD_VIRTUAL_USER:
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (controllers[i]->user_id == -1) {
|
||||
@@ -277,7 +282,6 @@ void WindowSDL::WaitEvent() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDL_EVENT_RDOC_CAPTURE:
|
||||
VideoCore::TriggerCapture();
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user