Merge branch 'XVibrationCheat2' into TemporaryHackishBranch

# Conflicts:
#	Core/CwCheat.cpp
This commit is contained in:
LunaMoo committed 2020-04-13 03:09:06 +02:00
commit a2585b83f7
4 files changed
+48 -35

No files matched your search

+22 -15
View File
@@ -24,7 +24,8 @@
static int CheatEvent = -1;
static CWCheatEngine *cheatEngine;
static bool cheatsEnabled;
SceCtrl vibrationCheat;
using namespace SceCtrl;
void hleCheat(u64 userdata, int cyclesLate);
static inline std::string TrimString(const std::string &s) {
@@ -472,6 +473,12 @@ struct CheatOperation {
int count;
int type;
} pointerCommands;
struct {
uint16_t vibrL;
uint16_t vibrR;
uint8_t vibrLTime;
uint8_t vibrRTime;
} vibrationValues;
};
};
@@ -610,10 +617,10 @@ CheatOperation CWCheatEngine::InterpretNextCwCheat(const CheatCode &cheat, size_
return { CheatOp::VibrationFromMemory, addr };
} else { // 0xA0 sets vibration by cheat parameters
CheatOperation op = { CheatOp::Vibration };
op.vibrL = line1.part1 & 0x0000FFFF;
op.vibrR = line1.part2 & 0x0000FFFF;
op.vibrLTime = (line1.part1 >> 16) & 0x000000FF;
op.vibrRTime = (line1.part2 >> 16) & 0x000000FF;
op.vibrationValues.vibrL = line1.part1 & 0x0000FFFF;
op.vibrationValues.vibrR = line1.part2 & 0x0000FFFF;
op.vibrationValues.vibrLTime = (line1.part1 >> 16) & 0x000000FF;
op.vibrationValues.vibrRTime = (line1.part2 >> 16) & 0x000000FF;
return op;
}
return { CheatOp::Invalid };
@@ -887,13 +894,13 @@ void CWCheatEngine::ExecuteOp(const CheatOperation &op, const CheatCode &cheat,
break;
case CheatOp::Vibration:
if (op.vibrL > 0) {
vibrationCheat.SetLeftVibration(op.vibrL);
vibrationCheat.SetVibrationLeftDropout(op.vibrLTime);
if (op.vibrationValues.vibrL > 0) {
SetLeftVibration(op.vibrationValues.vibrL);
SetVibrationLeftDropout(op.vibrationValues.vibrLTime);
}
if (op.vibrR > 0) {
vibrationCheat.SetRightVibration(op.vibrR);
vibrationCheat.SetVibrationRightDropout(op.vibrRTime);
if (op.vibrationValues.vibrR > 0) {
SetRightVibration(op.vibrationValues.vibrR);
SetVibrationRightDropout(op.vibrationValues.vibrRTime);
}
break;
@@ -902,12 +909,12 @@ void CWCheatEngine::ExecuteOp(const CheatOperation &op, const CheatCode &cheat,
uint16_t checkLeftVibration = Memory::Read_U16(op.addr);
uint16_t checkRightVibration = Memory::Read_U16(op.addr + 0x2);
if (checkLeftVibration > 0) {
vibrationCheat.SetLeftVibration(checkLeftVibration);
vibrationCheat.SetVibrationLeftDropout(Memory::Read_U8(op.addr + 0x4));
SetLeftVibration(checkLeftVibration);
SetVibrationLeftDropout(Memory::Read_U8(op.addr + 0x4));
}
if (checkRightVibration > 0) {
vibrationCheat.SetRightVibration(checkRightVibration);
vibrationCheat.SetVibrationRightDropout(Memory::Read_U8(op.addr + 0x6));
SetRightVibration(checkRightVibration);
SetVibrationRightDropout(Memory::Read_U8(op.addr + 0x6));
}
}
break;
+15 -14
View File
@@ -574,24 +574,25 @@ void Register_sceCtrl_driver()
RegisterModule("sceCtrl_driver", ARRAY_SIZE(sceCtrl), sceCtrl);
}
u16 GetRightVibration() {
u16 sceCtrlGetRightVibration() {
return rightVibration;
}
u16 GetLeftVibration() {
u16 sceCtrlGetLeftVibration() {
return leftVibration;
}
void SceCtrl::SetRightVibration(u16 rVibration) {
rightVibration = rVibration;
}
void SceCtrl::SetLeftVibration(u16 lVibration) {
leftVibration = lVibration;
}
void SceCtrl::SetVibrationRightDropout(u8 vibrationRDropout) {
vibrationRightDropout = vibrationRDropout;
}
void SceCtrl::SetVibrationLeftDropout(u8 vibrationLDropout) {
vibrationLeftDropout = vibrationLDropout;
namespace SceCtrl {
void SetRightVibration(u16 rVibration) {
rightVibration = rVibration;
}
void SetLeftVibration(u16 lVibration) {
leftVibration = lVibration;
}
void SetVibrationRightDropout(u8 vibrationRDropout) {
vibrationRightDropout = vibrationRDropout;
}
void SetVibrationLeftDropout(u8 vibrationLDropout) {
vibrationLeftDropout = vibrationLDropout;
}
}
+3 -4
View File
@@ -88,11 +88,10 @@ u32 __CtrlReadLatch();
void Register_sceCtrl_driver();
u16 GetRightVibration();
u16 GetLeftVibration();
u16 sceCtrlGetRightVibration();
u16 sceCtrlGetLeftVibration();
class SceCtrl {
public:
namespace SceCtrl {
void SetLeftVibration(u16 lVibration);
void SetRightVibration(u16 rVibration);
void SetVibrationLeftDropout(u8 vibrationLDropout);
+8 -2
View File
@@ -361,8 +361,14 @@ void XinputDevice::ApplyButtons(int pad, const XINPUT_STATE &state) {
void XinputDevice::ApplyVibration(int pad, XINPUT_VIBRATION &vibration) {
if (PSP_IsInited()) {
vibration.wLeftMotorSpeed = GetLeftVibration(); // use any value between 0-65535 here
vibration.wRightMotorSpeed = GetRightVibration(); // use any value between 0-65535 here
if (GetUIState() == UISTATE_INGAME) {
vibration.wLeftMotorSpeed = sceCtrlGetLeftVibration(); // use any value between 0-65535 here
vibration.wRightMotorSpeed = sceCtrlGetRightVibration(); // use any value between 0-65535 here
} else {
vibration.wLeftMotorSpeed = 0;
vibration.wRightMotorSpeed = 0;
}
if (prevVibration[pad].wLeftMotorSpeed != vibration.wLeftMotorSpeed || prevVibration[pad].wRightMotorSpeed != vibration.wRightMotorSpeed) {
PPSSPP_XInputSetState(pad, &vibration);
prevVibration[pad] = vibration;