moarvib
This commit is contained in:
@@ -26,7 +26,7 @@ public:
|
|||||||
void FUN_71000b6750();
|
void FUN_71000b6750();
|
||||||
Result FUN_71000b67b0(long* param_2, NpadVibrationHandler* handler);
|
Result FUN_71000b67b0(long* param_2, NpadVibrationHandler* handler);
|
||||||
Result FUN_71000b6898();
|
Result FUN_71000b6898();
|
||||||
Result FUN_71000b6908(undefined4 param_2);
|
Result FUN_71000b6908(u32 param_2);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
u64 xcd_handle;
|
u64 xcd_handle;
|
||||||
|
@@ -9,233 +9,177 @@
|
|||||||
namespace Service::HID {
|
namespace Service::HID {
|
||||||
|
|
||||||
Result NpadVibrationDevice::IncrementRefCounter() {
|
Result NpadVibrationDevice::IncrementRefCounter() {
|
||||||
int iVar1;
|
if (ref_counter == 0) {
|
||||||
char local_4[4];
|
FUN_71000b6a1c();
|
||||||
|
|
||||||
iVar1 = field10_0x14;
|
|
||||||
field10_0x14 = iVar1 + 1;
|
|
||||||
if (iVar1 == 0) {
|
|
||||||
FUN_71000b6a1c(param_1);
|
|
||||||
}
|
}
|
||||||
if (((is_mounted != false) &&
|
|
||||||
(iVar1 = FUN_710011a950(local_4, field9_0x10, field8_0x8), iVar1 == 0)) &&
|
ref_counter++;
|
||||||
(local_4[0] != '\x01')) {
|
if (is_mounted != false && xcd_handle->FUN_710011a950(local_4, device_index) != '\x01') {
|
||||||
FUN_710011a8f0(1, field9_0x10, field8_0x8);
|
xcd_handle->FUN_710011a8f0(true, device_index);
|
||||||
}
|
}
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NpadVibrationDevice::FUN_71000b6a1c() {
|
void NpadVibrationDevice::FUN_71000b6a1c() {
|
||||||
char cVar1;
|
if (ref_counter == 0) {
|
||||||
Result nVar2;
|
return;
|
||||||
float local_30;
|
}
|
||||||
u32 local_2c;
|
if (is_mounted) {
|
||||||
float local_28;
|
f32 volume = 1.0;
|
||||||
u32 local_24;
|
const auto result = vibration_handler->GetVibrationVolume(volume);
|
||||||
float local_4;
|
if (result.IsSuccess()) {
|
||||||
|
xcd_handle->SendVibrationValue(Core::HID::DEFAULT_VIBRATION_VALUE, device_index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cVar1 = is_mounted;
|
if (is_mounted) {
|
||||||
if (0 < (int)field10_0x14 && (bool)cVar1 != false) {
|
f32 volume = 1.0;
|
||||||
local_4 = 1.0;
|
const auto result = vibration_handler->GetVibrationVolume(volume);
|
||||||
nVar2 = VibrationVolume::GetVibrationVolume(npad_vibration, &local_4);
|
if (result.IsError()) {
|
||||||
if (nVar2 == ResultSuccess) {
|
|
||||||
local_2c = 0x43200000;
|
|
||||||
local_24 = 0x43a00000;
|
|
||||||
local_30 = local_4 * 0.0;
|
|
||||||
if (local_4 <= 0.0) {
|
|
||||||
local_30 = 0.0;
|
|
||||||
}
|
|
||||||
local_28 = local_30;
|
|
||||||
FUN_710011a9b0(&local_30, field9_0x10, field8_0x8);
|
|
||||||
}
|
|
||||||
cVar1 = is_mounted;
|
|
||||||
}
|
|
||||||
if (cVar1 != '\0') {
|
|
||||||
local_30 = 1.0;
|
|
||||||
nVar2 = VibrationVolume::GetVibrationVolume(npad_vibration, &local_30);
|
|
||||||
if (nVar2 == ResultSuccess) {
|
|
||||||
FUN_710011ab70(field8_0x8, 0);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
xcd_handle->SendVibrationNotificationPattern(0);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result NpadVibrationDevice::DecrementRefCounter() {
|
Result NpadVibrationDevice::DecrementRefCounter() {
|
||||||
int iVar1;
|
int iVar1;
|
||||||
char local_4[4];
|
char local_4[4];
|
||||||
|
|
||||||
iVar1 = field10_0x14;
|
if (ref_counter == 1) {
|
||||||
if (iVar1 == 1) {
|
FUN_71000b6a1c();
|
||||||
FUN_71000b6a1c(param_1);
|
|
||||||
iVar1 = field10_0x14;
|
|
||||||
}
|
}
|
||||||
field10_0x14 = iVar1 + -1;
|
ref_counter--;
|
||||||
if ((((iVar1 + -1 == 0 || iVar1 < 1) && (field10_0x14 = 0, is_mounted != false)) &&
|
if (ref_counter > 0) {
|
||||||
(iVar1 = FUN_710011a950(local_4, field9_0x10, field8_0x8), iVar1 == 0)) &&
|
return ResultSuccess;
|
||||||
(local_4[0] != '\0')) {
|
|
||||||
FUN_710011a8f0(0, field9_0x10, field8_0x8);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ref_counter = 0;
|
||||||
|
if (is_mounted && FUN_710011a950(local_4, device_index) == 0) {
|
||||||
|
xcd_handle->FUN_710011a8f0(0, device_index);
|
||||||
|
}
|
||||||
|
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result NpadVibrationDevice::SendVibrationValue(const Core::HID::VibrationValue& value) {
|
Result NpadVibrationDevice::SendVibrationValue(const Core::HID::VibrationValue& value) {
|
||||||
Result nVar1;
|
if (ref_counter == 0) {
|
||||||
float local_38;
|
return ResultVibrationNotInitialized;
|
||||||
float local_34;
|
|
||||||
float fStack_30;
|
|
||||||
float local_2c;
|
|
||||||
float local_24;
|
|
||||||
|
|
||||||
if ((int)field10_0x14 < 1) {
|
|
||||||
return Hid_0121_VibrationDisabled;
|
|
||||||
}
|
|
||||||
if (is_mounted != false) {
|
|
||||||
local_24 = 1.0;
|
|
||||||
nVar1 = VibrationVolume::GetVibrationVolume(npad_vibration, &local_24);
|
|
||||||
if (nVar1 != ResultSuccess) {
|
|
||||||
return nVar1;
|
|
||||||
}
|
|
||||||
if (local_24 <= 0.0) {
|
|
||||||
fStack_30 = 0.0;
|
|
||||||
local_38 = 0.0;
|
|
||||||
local_2c = 320.0;
|
|
||||||
local_34 = 160.0;
|
|
||||||
} else {
|
|
||||||
local_34 = param_2[1];
|
|
||||||
local_38 = local_24 * *param_2;
|
|
||||||
local_2c = param_2[3];
|
|
||||||
fStack_30 = local_24 * param_2[2];
|
|
||||||
}
|
|
||||||
nVar1 = FUN_710011a9b0(&local_38, field9_0x10, field8_0x8);
|
|
||||||
return nVar1;
|
|
||||||
}
|
}
|
||||||
|
if (!is_mounted) {
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
f32 volume = 1.0f;
|
||||||
|
const auto result = vibration_handler->GetVibrationVolume(volume);
|
||||||
|
if (result.IsError()) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (volume <= 0.0f) {
|
||||||
|
return xcd_handle->FUN_710011a9b0(Core::HID::DEFAULT_VIBRATION_VALUE, device_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::HID::VibrationValue vibration_value = value;
|
||||||
|
vibration_value.high_amplitude *= volume;
|
||||||
|
vibration_value.low_amplitude *= volume;
|
||||||
|
|
||||||
|
return xcd_handle->FUN_710011a9b0(vibration_value, device_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result NpadVibrationDevice::FUN_71000b6c40(u32 param_2) {
|
Result NpadVibrationDevice::SendVibrationNotificationPattern(u32 param_2) {
|
||||||
Result nVar1;
|
if (!is_mounted) {
|
||||||
float local_24;
|
|
||||||
|
|
||||||
if (is_mounted == false) {
|
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
local_24 = 1.0;
|
|
||||||
nVar1 = VibrationVolume::GetVibrationVolume(npad_vibration, &local_24);
|
f32 volume = 1.0f;
|
||||||
if (nVar1 != ResultSuccess) {
|
const auto result = vibration_handler->GetVibrationVolume(volume);
|
||||||
return nVar1;
|
if (result.IsError()) {
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
if (local_24 <= 0.0) {
|
if (volume <= 0.0) {
|
||||||
param_2 = 0;
|
param_2 = 0;
|
||||||
}
|
}
|
||||||
nVar1 = FUN_710011ab70(field8_0x8, param_2);
|
|
||||||
return nVar1;
|
return xcd_handle->SendVibrationNotificationPattern(param_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result NpadVibrationDevice::FUN_71000b6cc0(long* param_2, int param_3, NpadVibration* param_4) {
|
Result NpadVibrationDevice::FUN_71000b6cc0(IAbstractedPad* abstracted_pad,
|
||||||
int iVar1;
|
Core::HID::VibrationDevicePosition position,
|
||||||
Result nVar2;
|
NpadVibrationHandler* handler) {
|
||||||
u64 uVar3;
|
|
||||||
u32 uVar4;
|
|
||||||
undefined auVar5[16];
|
|
||||||
float local_48;
|
|
||||||
u32 local_44;
|
|
||||||
float local_40;
|
|
||||||
u32 local_3c;
|
|
||||||
float local_34;
|
|
||||||
|
|
||||||
iVar1 = (**(code**)(*param_2 + 0x18))(param_2);
|
Result result = abstracted_pad->driver->UpdateState();
|
||||||
if ((iVar1 == 0) && ((*(byte*)(param_2 + 1) >> 1 & 1) != 0)) {
|
if (result.IsError()) {
|
||||||
auVar5 = GetXcdHandle(param_2);
|
return ResultSuccess;
|
||||||
uVar3 = auVar5._0_8_;
|
|
||||||
field8_0x8 = uVar3;
|
|
||||||
if (param_3 == 1) {
|
|
||||||
uVar4 = 0;
|
|
||||||
} else {
|
|
||||||
if (param_3 != 2) {
|
|
||||||
// WARNING: Subroutine does not return
|
|
||||||
nn::detail::UnexpectedDefaultImpl(uVar3, auVar5._8_8_, uVar3);
|
|
||||||
}
|
}
|
||||||
uVar4 = 1;
|
|
||||||
|
if (!abstracted_pad->internal_flags.is_connected) {
|
||||||
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
field9_0x10 = uVar4;
|
|
||||||
npad_vibration = param_4;
|
xcd_handle = abstracted_pad->xcd_handle;
|
||||||
|
|
||||||
|
switch (position) {
|
||||||
|
case Core::HID::VibrationDevicePosition ::Left:
|
||||||
|
device_index = 0;
|
||||||
|
break;
|
||||||
|
case Core::HID::VibrationDevicePosition ::Right:
|
||||||
|
device_index = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Abort
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
vibration_handler = handler;
|
||||||
is_mounted = true;
|
is_mounted = true;
|
||||||
if (0 < (int)field10_0x14) {
|
|
||||||
iVar1 = FUN_710011a950(&local_48);
|
if (ref_counter == 0) {
|
||||||
if ((iVar1 == 0) && (local_48._0_1_ != '\x01')) {
|
|
||||||
FUN_710011a8f0(1, field9_0x10, field8_0x8);
|
|
||||||
}
|
|
||||||
if ((0 < (int)field10_0x14) && (is_mounted != false)) {
|
|
||||||
local_34 = 1.0;
|
|
||||||
nVar2 = VibrationVolume::GetVibrationVolume(npad_vibration, &local_34);
|
|
||||||
if (nVar2 == ResultSuccess) {
|
|
||||||
local_44 = 0x43200000;
|
|
||||||
local_3c = 0x43a00000;
|
|
||||||
local_48 = local_34 * 0.0;
|
|
||||||
if (local_34 <= 0.0) {
|
|
||||||
local_48 = 0.0;
|
|
||||||
}
|
|
||||||
local_40 = local_48;
|
|
||||||
FUN_710011a9b0(&local_48, field9_0x10, field8_0x8);
|
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = FUN_710011a950(&local_48);
|
||||||
|
if (result.IsSuccess() && (local_48._0_1_ != '\x01')) {
|
||||||
|
xcd_handle->FUN_710011a8f0(1, device_index);
|
||||||
|
}
|
||||||
|
if (ref_counter != 0 && is_mounted) {
|
||||||
|
f32 volume = 1.0f;
|
||||||
|
const auto result = vibration_handler->GetVibrationVolume(volume);
|
||||||
|
if (result.IsSuccess()) {
|
||||||
|
xcd_handle->FUN_710011a9b0(Core::HID::DEFAULT_VIBRATION_VALUE, device_index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return ResultSuccess;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result NpadVibrationDevice::FUN_71000b6e0c() {
|
Result NpadVibrationDevice::FUN_71000b6e0c() {
|
||||||
Result nVar1;
|
if (ref_counter == 0 || !is_mounted) {
|
||||||
float local_30;
|
|
||||||
u32 local_2c;
|
|
||||||
float local_28;
|
|
||||||
u32 local_24;
|
|
||||||
float local_4;
|
|
||||||
|
|
||||||
if (0 < (int)field10_0x14 && is_mounted != false) {
|
|
||||||
local_4 = 1.0;
|
|
||||||
nVar1 = VibrationVolume::GetVibrationVolume(npad_vibration, &local_4);
|
|
||||||
if (nVar1 == ResultSuccess) {
|
|
||||||
local_2c = 0x43200000;
|
|
||||||
local_24 = 0x43a00000;
|
|
||||||
local_30 = local_4 * 0.0;
|
|
||||||
if (local_4 <= 0.0) {
|
|
||||||
local_30 = 0.0;
|
|
||||||
}
|
|
||||||
local_28 = local_30;
|
|
||||||
FUN_710011a9b0(&local_30, field9_0x10, field8_0x8);
|
|
||||||
is_mounted = false;
|
is_mounted = false;
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
f32 volume = 1.0f;
|
||||||
|
const auto result = vibration_handler->GetVibrationVolume(volume);
|
||||||
|
if (result.IsError()) {
|
||||||
is_mounted = false;
|
is_mounted = false;
|
||||||
|
return ResultSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
is_mounted = false;
|
||||||
|
xcd_handle->FUN_710011a9b0(Core::HID::DEFAULT_VIBRATION_VALUE, device_index);
|
||||||
|
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result NpadVibrationDevice::FUN_71000b6eb8(u64* param_2) {
|
Result NpadVibrationDevice::GetActualVibrationValue(Core::HID::VibrationValue& out_value) {
|
||||||
Result nVar1;
|
if (ref_counter < 1) {
|
||||||
u32 local_30;
|
return ResultVibrationNotInitialized;
|
||||||
u64 local_2c;
|
}
|
||||||
u32 local_24;
|
|
||||||
|
|
||||||
if ((int)field10_0x14 < 1) {
|
out_value = Core::HID::DEFAULT_VIBRATION_VALUE;
|
||||||
return Hid_0121_VibrationDisabled;
|
if (!is_mounted) {
|
||||||
}
|
|
||||||
*param_2 = 0x4320000000000000;
|
|
||||||
param_2[1] = 0x43a0000000000000;
|
|
||||||
if (is_mounted != false) {
|
|
||||||
nVar1 = FUN_710011aa90(&local_30, field9_0x10, field8_0x8);
|
|
||||||
if (nVar1 != ResultSuccess) {
|
|
||||||
return nVar1;
|
|
||||||
}
|
|
||||||
*(u32*)param_2 = local_30;
|
|
||||||
*(u64*)((long)param_2 + 4) = local_2c;
|
|
||||||
*(u32*)((long)param_2 + 0xc) = local_24;
|
|
||||||
return nVar1;
|
|
||||||
}
|
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
return xcd_handle->GetActualVibrationValue(out_value, device_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NpadVibrationDevice::IsVibrationMounted() {
|
bool NpadVibrationDevice::IsVibrationMounted() {
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
#include "core/hle/service/hid/controllers/types/npad_types.h"
|
#include "core/hle/service/hid/controllers/types/npad_types.h"
|
||||||
|
|
||||||
namespace Service::HID {
|
namespace Service::HID {
|
||||||
|
class IAbstractedPad;
|
||||||
class NpadVibrationHandler;
|
class NpadVibrationHandler;
|
||||||
|
|
||||||
/// Handles Npad request from HID interfaces
|
/// Handles Npad request from HID interfaces
|
||||||
@@ -26,15 +27,17 @@ public:
|
|||||||
Result DecrementRefCounter();
|
Result DecrementRefCounter();
|
||||||
|
|
||||||
Result SendVibrationValue(const Core::HID::VibrationValue& value);
|
Result SendVibrationValue(const Core::HID::VibrationValue& value);
|
||||||
Result FUN_71000b6c40(u32 param_2);
|
Result SendVibrationNotificationPattern(u32 param_2);
|
||||||
|
|
||||||
Result FUN_71000b6cc0(long* param_2, int param_3, NpadVibration* param_4);
|
Result FUN_71000b6cc0(IAbstractedPad* abstracted_pad, Core::HID::VibrationDevicePosition position,
|
||||||
|
NpadVibrationHandler* handler);
|
||||||
Result FUN_71000b6e0c();
|
Result FUN_71000b6e0c();
|
||||||
Result FUN_71000b6eb8(u64* param_2);
|
Result GetActualVibrationValue(Core::HID::VibrationValue& out_value);
|
||||||
bool IsVibrationMounted();
|
bool IsVibrationMounted();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
u64 xcd_handle;
|
u64 xcd_handle;
|
||||||
|
u32 device_index;
|
||||||
s32 ref_counter;
|
s32 ref_counter;
|
||||||
bool is_mounted;
|
bool is_mounted;
|
||||||
NpadVibrationHandler* vibration_handler;
|
NpadVibrationHandler* vibration_handler;
|
||||||
|
Reference in New Issue
Block a user