mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-15 02:29:51 +01:00
Improve some code and stop vibration outside of the game.
This commit is contained in:
1 parent
ef4b1488dc
commit
e7f1bf0b2e
4 files changed
+48
-39
No files matched your search
+22
-19
@@ -26,7 +26,8 @@ std::string gameTitle;
|
||||
std::string activeCheatFile;
|
||||
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) {
|
||||
@@ -440,10 +441,6 @@ struct CheatOperation {
|
||||
uint32_t addr;
|
||||
int sz;
|
||||
uint32_t val;
|
||||
uint16_t vibrL;
|
||||
uint16_t vibrR;
|
||||
uint8_t vibrLTime;
|
||||
uint8_t vibrRTime;
|
||||
|
||||
union {
|
||||
struct {
|
||||
@@ -467,6 +464,12 @@ struct CheatOperation {
|
||||
int count;
|
||||
int type;
|
||||
} pointerCommands;
|
||||
struct {
|
||||
uint16_t vibrL;
|
||||
uint16_t vibrR;
|
||||
uint8_t vibrLTime;
|
||||
uint8_t vibrRTime;
|
||||
} vibrationValues;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -605,10 +608,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 };
|
||||
@@ -882,13 +885,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;
|
||||
|
||||
@@ -897,12 +900,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
@@ -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
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user